How To Open Source Code For Badi In Sap

Source code injection is an attack in which the goal is execution of arbitrary code. A successful source code injection can be impossible to detect because an attacker will leave few traces of his presence. The worst case scenario can be the stealing or modification of data, the defacement of web pages and even the complete destruction of all information on a specific website.

For the ultimate in convenient at-home beauty treatments and nail services, look no further than this comprehensive selection of supplies and tools. Whether you’re looking to create polished manicures and pedicures, or stunning makeup looks with a professional eye like a beauty pro, here you’ll find all the best at-home beauty treatments, products and tools to help.

Program to display Exits and BAdI

192014,857

The following program will help you display UserExits and BAdI’s for a particular transaction code or program.

Though this is not my own program and I can’t remember where I found it I thought it will be useful as a ready reference for any one trying to look up the userexits in a more intuitive way.

Go to SE38, enter program name as ZUSEREXIT and click create and enter the program description, choose executable program and test program, assign an ABAP package in the program attributes window.

Now copy paste this source code

REPORT ZUSEREXIT .

TABLES :  TSTC,
          TADIR,
          MODSAPT,
          MODACT,
          TRDIR,
          TFDIR,
          ENLFDIR,
          SXS_ATTRT ,
          TSTCT.

DATA : JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE.
DATA : FIELD1(30).
DATA : V_DEVCLASS LIKE TADIR-DEVCLASS.

PARAMETERS : P_TCODE LIKE TSTC-TCODE,
P_PGMNA LIKE TSTC-PGMNA .

DATA wa_tadir type tadir.

START-OF-SELECTION.

IF NOT P_TCODE IS INITIAL.
SELECT SINGLE * FROM TSTC WHERE TCODE EQ P_TCODE.

ELSEIF NOT P_PGMNA IS INITIAL.
TSTC-PGMNA = P_PGMNA.
ENDIF.

IF SY-SUBRC EQ 0.
SELECT SINGLE * FROM TADIR
WHERE PGMID = ‘R3TR’
AND OBJECT = ‘PROG’
AND OBJ_NAME = TSTC-PGMNA.

MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

IF SY-SUBRC NE 0.
SELECT SINGLE * FROM TRDIR
WHERE NAME = TSTC-PGMNA.
IF TRDIR-SUBC EQ ‘F’.
SELECT SINGLE * FROM TFDIR
WHERE PNAME = TSTC-PGMNA.

SELECT SINGLE * FROM ENLFDIR
WHERE FUNCNAME = TFDIR-FUNCNAME.

SELECT SINGLE * FROM TADIR
WHERE PGMID = ‘R3TR’
AND OBJECT = ‘FUGR’
AND OBJ_NAME EQ ENLFDIR-AREA.

MOVE : TADIR-DEVCLASS TO V_DEVCLASS.
ENDIF.
ENDIF.

SELECT * FROM TADIR INTO TABLE JTAB
WHERE PGMID = ‘R3TR’
AND OBJECT in (‘SMOD’, ‘SXSD’)
AND DEVCLASS = V_DEVCLASS.

SELECT SINGLE * FROM TSTCT
WHERE SPRSL EQ SY-LANGU
AND TCODE EQ P_TCODE.

FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) ‘Transaction Code – ‘,
20(20) P_TCODE,
45(50) TSTCT-TTEXT.
SKIP.
IF NOT JTAB[] IS INITIAL.
WRITE:/(105) SY-ULINE.
FORMAT COLOR COL_HEADING INTENSIFIED ON.

* Sorting the internal Table
sort jtab by OBJECT.
data : wf_txt(60) type c,
wf_smod type i ,
wf_badi type i ,
wf_object2(30) type C.
clear : wf_smod, wf_badi , wf_object2.
* Get the total SMOD.

LOOP AT JTAB into wa_tadir.
at first.
FORMAT COLOR COL_HEADING INTENSIFIED ON.

WRITE:/1 SY-VLINE,
2 ‘Enhancement/ Business Add-in’,
41 SY-VLINE ,
42 ‘Description’,
105 SY-VLINE.
WRITE:/(105) SY-ULINE.
endat.
clear wf_txt.
at new object.
if wa_tadir-object = ‘SMOD’.
wf_object2 = ‘Enhancement’ .
elseif wa_tadir-object = ‘SXSD’.
wf_object2 = ‘ Business Add-in’.

endif.
FORMAT COLOR COL_GROUP INTENSIFIED ON.

WRITE:/1 SY-VLINE,

2 wf_object2,
105 SY-VLINE.
endat.

case wa_tadir-object.
when ‘SMOD’.
wf_smod = wf_smod + 1.
SELECT SINGLE MODTEXT into wf_txt
FROM MODSAPT
WHERE SPRSL = SY-LANGU
AND NAME = wa_tadir-OBJ_NAME.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

when ‘SXSD’.
* For BADis
wf_badi = wf_badi + 1 .
select single TEXT into wf_txt
from SXS_ATTRT
where sprsl = sy-langu
and EXIT_NAME = wa_tadir-OBJ_NAME.
FORMAT COLOR COL_NORMAL INTENSIFIED ON.

endcase.

WRITE:/1 SY-VLINE,
2 wa_tadir-OBJ_NAME hotspot on,
41 SY-VLINE ,
42 wf_txt,
105 SY-VLINE.
AT END OF object.
write : /(105) sy-ULINE.
ENDAT.

ENDLOOP.

WRITE:/(105) SY-ULINE.

SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ ‘No.of Exits:’ , wf_smod.
WRITE:/ ‘No.of BADis:’ , wf_badi.

ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) ‘No userexits or BADis exist’.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) ‘Transaction does not exist’.
ENDIF.

AT LINE-SELECTION.

data : wf_object type tadir-object.
clear wf_object.

GET CURSOR FIELD FIELD1.
CHECK FIELD1(8) EQ ‘WA_TADIR’.
read table jtab with key obj_name = sy-lisel+1(20).
move jtab-object to wf_object.

case wf_object.
when ‘SMOD’.
SET PARAMETER ID ‘MON’ FIELD SY-LISEL+1(10).

CALL TRANSACTION ‘SMOD’ AND SKIP FIRST SCREEN.
when ‘SXSD’.
SET PARAMETER ID ‘EXN’ FIELD SY-LISEL+1(20).
CALL TRANSACTION ‘SE18’ AND SKIP FIRST SCREEN.

endcase.

Save activate the program and transport it.

Now go to SE93, create a transaction code ZEXIT of type report and assign the program ZUSEREXIT to it.

Now when you execute tcode ZEXIT any time you will the screen which looks like below.

3-22-2012 1-45-41 PM.png

When you execute you will have a report of available exits/enhancements and BAdI’s

3-22-2012 1-46-38 PM.png

If you click on any of one of them on the left column you can directly go the relevant exit as shown in screenshot below.

3-22-2012 1-53-09 PM.png

From here on you can select Attribute or Components or Documentation.

If you click on a BAdI the program will take you to SE18 as shown below.

3-22-2012 1-55-39 PM.png

Just select the BAdI Name radio button, it will automatically populate the BAdI you selected.

3-22-2012 1-57-15 PM.png

What is BADI?

A BADI (business add-in) customer-specific source code provided by SAP that is used to modify the existing ABAP code. It allows a diverse landscape ie customer-specific, country-specific, etc so that it can accommodate a wider range of solutions without affecting the original source code of the object.

To see the implementation use the transaction SE18, put the name of badi, so click on display, it’ll open new screen, click on definition and implementation.

All implementation it will be show.

De: Shankar Sanke via sap-abap [mailto:sap-abap@Groups.ITtoolbox.com]
Enviada em: ter?a-feira, 28 de setembro de 2010 14:41
Para: mauriciosilva
Assunto: Re: [sap-abap] How to see all implementations of one specific badi

Posted by Shankar Sanke (Senior Software Engineer)
on Sep 28 at 1:41 PM Mark as helpful

In that case, You can have multiple implementations for the badi but only
one single implementation active at one given time.So in this case the Z
implementation will be active as the other one is a SAP implementation.So
you need to choose the Z implementation.It will show you the methods in
it.Choose your method and edit the method.Do not try to edit anywhere else.
1.Choose the Z implementations.
2.Choose a method (By double clicking on the method).
3.In the method go in edit mode and add your logic.

How to Find Badi for Standard Transaction Code?

Please follow the steps below to find the badi for a standard t-code:

Execute t-code SE24 in SAP command feild

SE24

Next enter the object type as CL_EXITHANDLER and click the Display button.

Object Type

Now navigate to the Methods tab and double click on GET_INSTANCE method to open it.

Method

Next, insert a debugger at the line as follows:

CALL METHOD cl_exithandler=>get_class_name_by_interface
Insert Code

And then execute the standard t-code VA01 for BADI & you will get all Badi one by one.

Once you get the correct BADI, execute t-code SE18

SE18

Next, enter the BADI name and click Display

execute Badi

How to Use Filters

Recalling from the previous step (How to Implement a BAdI), you need a way to select between different BAdI implementations. This is where you need the BAdI filter.

What you need is to change the BAdI definition. You can define one or many filters for a BAdI. For the purpose of this example, you create only one filter. Therefore, in this step you define the filter in the BAdI definition, determine filter values for the respective BAdI implementation, and use the filter in the instantiation of the BAdI handle.Note

When modifying your example you do not take into account the differentiation between the BAdI provider and the implementer. In real life it is the BAdI provider who defines a BAdI with a filter or adds a filter to an existing BAdI. It is also part of this role to use the filter condition to select the respective BAdI implementation in the ABAP code. It is the implementer who determines the filter value(s) or an interval for one or many BAdI implementations.

  1. Navigate to your enhancement spot and open the Enh. Spot Element Definition tab that shows a list of all the enhancement elements of the spot.
  2. Switch to a change mode, select your BAdI in the list, and in the small toolbar above choose Create BAdI Subobject icon and then Filter.
  3. The following dialog appears, where you fill in the corresponding fields:
  4. Confirm the entries.The filter is now visible as a property below the BAdI.
  5. Activate the enhancement spot, double-click on the implementation and navigate to the respective BAdI implementation by double-clicking the respective row in the table of BAdI implementations.
  6. Switch to change mode, double-click the triangle in front of the BAdI implementation in the tree and then double-click on the filter icon below.
  7. On the Filter Values screen, choose the Create Filter Combination pushbutton.
  8. Select Country as the filter and confirm
  9. Double-click on the row below Combination 1.A new dialog opens:
  1. Activate the (simple) enhancement implementation and navigate back to the spot.The other implementation, that is the one for USA, also needs the respective filter value. So you go to the respective (simple) enhancement implementation and change the BAdI implementation in the same way as you just did above. The respective filter value for this country is ‘US’.
  2. Return to your program and adapt it to the modified BAdI. Running the syntax check shows you that you need to have a filter parameter in the GET BADI command if the BAdI you try to instantiate is defined with a filter. The required addition to the GET BADI command is FILTERS. It is after this keyword that you insert the name of the BAdI filter and a value the filter is compared to. You also have to take care that an appropriate value can be passed to the GET BADI routine:REPORT  Z_DEMO_ENH.parameters: ctry(2) type c.DATA: handle TYPE REF TO z_badi_calc_vat,sum TYPE p,vat TYPE p,percent TYPE p.sum = 50.GET BADI handle FILTERS Country = ctry.CALL BADI handle->get_vatEXPORTING im_amount = sumIMPORTING ex_amount_vat = vatex_percent_vat = percent.WRITE: 'percentage:', percent, 'VAT:' ,vat.If you pass GB to the parameter ctry, you get a VAT rate of 17.5 percent. If the value of the parameter ctry is US, the VAT rate is 4 percent. When the parameter ctry has any other value, you still get a calculated value for the data field percent. This is because you have defined a fallback class for your BAdI. The fallback class is not only selected if no BAdI implementation is available, but also if none of the existing BAdI implementations meets the filter conditions in the GET BADI command. Accordingly, you get a VAT rate of 20 percent, which is the VAT rate you have implemented in the method get_vat in the fallback class.

Conclusion

The Enterprise Extension Builder (EEB) enables you to implement your own business logic in the form of business add-ins (BAdIs) and application functions, and incorporate them in standard applications.

0 Comments

No Comment.