Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to write the code in BADI

Former Member
0 Likes
993

DATA : IT_SECSTRUCT LIKE ZSEC_STRUCT OCCURS 0 WITH HEADER LINE ,

IT_MESSAGEHEAD LIKE ZSECMESSAGE OCCURS 0 WITH HEADER LINE .

DATA : BEGIN OF ITAB OCCURS 0 ,

MATNR LIKE MSEG-MATNR ,

END OF ITAB .

DATA : ITR(15) .

data : counter1(10),counter(10),counter2(10).

FIELD-SYMBOLS <FS> LIKE I_MSEG.

ASSIGN I_MSEG TO <FS> .

if <FS>-bwart = '201' .

SELECT * FROM ZSECMESSAGE INTO CORRESPONDING FIELDS OF TABLE IT_MESSAGEHEAD WHERE TCODE1 = 'MB1A' .

loop at IT_MESSAGEhead.

split IT_MESSAGEhead-msgid at'-' into counter1 counter2 .

counter2 = counter2 + 1.

condense counter2.

concatenate counter1 '-' counter2 into counter.

IT_MESSAGEhead-msgid = counter.

update zsecmessage from IT_MESSAGEhead.

endloop.

ITR = <FS>-MENGE.

ITAB-MATNR = <FS>-MATNR .

APPEND ITAB .

IT_SECSTRUCT-COLUMNKEY = 'MENGE'.

IT_SECSTRUCT-COLUMNVALUE = ITR .

IT_SECSTRUCT-COLUMNTYPE = 'NUMBER' .

APPEND IT_SECSTRUCT.

LOOP AT ITAB .

IT_SECSTRUCT-COLUMNKEY = 'MATNR'.

IT_SECSTRUCT-COLUMNVALUE = ITAB-MATNR.

IT_SECSTRUCT-COLUMNTYPE = 'STRING' .

APPEND IT_SECSTRUCT.

ENDLOOP .

CALL FUNCTION 'Z_IDOC_OUTBOUND_MTIDOCOUT'

  • EXPORTING

  • CONTROL_RECORD_IN =

  • IMPORTING

  • CONTROL_RECORD_OUT =

TABLES

  • INT_EDIDD =

IT_SECSTRUCT = IT_SECSTRUCT

IT_MESSAGEHEAD = IT_MESSAGEHEAD .

endif .

2 REPLIES 2
Read only

messier31
Active Contributor
0 Likes
469

Hi Neeraj,

Check out following link of SDN. It gives detail explanation on BADI implementation

<b>https://www.sdn.sap.com/irj/sdn/developerareas/abap?rid=/webcontent/uuid/2342e1f3-0b01-0010-a186-fdd... [original link is broken] [original link is broken]</b>

I guess this definitely add a lot to your knowledge repository

Enjoy SAP.

Pankaj Singh

Read only

Former Member
0 Likes
469

hi neeraj,

1. go to transaction se19

2. select the radio button lassic badi' in the 'CREATE IMPLEMENTATION' tab

3. give the name of the corresponding BAdI.

4. Clcik the create implementation button

5. It will ask for the implementation name,provide a 'Z_xXXX' name for your BAdI implementation

6.Choose the tab Interfaces

7. Double click on the required method

8. Enter the code you want to write..

Regards,

Sajan.