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

BADI implementation

Former Member
0 Likes
786

Hi all,

I have implemented BADI for the MIGO.

Now I want to use that BADI when the transaction runs.

I want help in that or help with steps.

-- Umesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
713

Hi,

I assume that you have created the BADI definition for MIGO. After creation, you need to decide during which event your logic must get triggered.

For eq there is a method called as POST_DOCUMENT. Inside this method you can check some data before the document gets posted. If the check is false you can issue some error message.

So we had a issue in MIGO transaction that, during the posting of a material document no, the vendor no/ Delivery challan no / Material Doc Year must be a unique combination. Since this was not happening, the vendor used to give the same Delivery challan No and create more no of material documents in the same year. In order to prevent this the following code was written:

    • To check if the Vendor/ DC No / Year is unique for

    • every Material Document.

IF w_bwart1 = '101'.

SELECT SINGLE reljr INTO w_reljr FROM t009b

WHERE bumon = sy-datum+4(2).

w_year = sy-datum+0(4) - w_reljr.

SELECT lifnr xblnr bldat

INTO CORRESPONDING FIELDS OF TABLE it_mkpf1

FROM mkpf

JOIN mseg

ON mkpfmblnr = msegmblnr

AND mkpfmjahr = msegmjahr

WHERE mseg~lifnr = wa_mseg-lifnr

AND mkpf~xblnr = is_mkpf-xblnr

AND mkpf~mjahr = w_year.

IF sy-subrc = 0.

MESSAGE e000(zsfl) WITH 'Duplicate Vendor/Delivery

Note/Material Doc.Year'.

ENDIF.

ENDIF.

Lakshminarayanan

PLease mark all helpful answers for points.

5 REPLIES 5
Read only

Former Member
0 Likes
714

Hi,

I assume that you have created the BADI definition for MIGO. After creation, you need to decide during which event your logic must get triggered.

For eq there is a method called as POST_DOCUMENT. Inside this method you can check some data before the document gets posted. If the check is false you can issue some error message.

So we had a issue in MIGO transaction that, during the posting of a material document no, the vendor no/ Delivery challan no / Material Doc Year must be a unique combination. Since this was not happening, the vendor used to give the same Delivery challan No and create more no of material documents in the same year. In order to prevent this the following code was written:

    • To check if the Vendor/ DC No / Year is unique for

    • every Material Document.

IF w_bwart1 = '101'.

SELECT SINGLE reljr INTO w_reljr FROM t009b

WHERE bumon = sy-datum+4(2).

w_year = sy-datum+0(4) - w_reljr.

SELECT lifnr xblnr bldat

INTO CORRESPONDING FIELDS OF TABLE it_mkpf1

FROM mkpf

JOIN mseg

ON mkpfmblnr = msegmblnr

AND mkpfmjahr = msegmjahr

WHERE mseg~lifnr = wa_mseg-lifnr

AND mkpf~xblnr = is_mkpf-xblnr

AND mkpf~mjahr = w_year.

IF sy-subrc = 0.

MESSAGE e000(zsfl) WITH 'Duplicate Vendor/Delivery

Note/Material Doc.Year'.

ENDIF.

ENDIF.

Lakshminarayanan

PLease mark all helpful answers for points.

Read only

0 Likes
713

Hi,

Thanks for reply.

I have written code in the POST_DOCUMENT.

I have acitved that, but my problem is that when that BAPI gets called. Or after doing this whether we have to do any setting so that this code gets executed.

that means after se19 is there any setting so that this code gets executed.

- umesh

Read only

0 Likes
713

Hi,

After you have written the code, activate the code. Then come out of the editor.

Aftet his you need to activate the BADI, because only active BADI'd gets triggered in runtime.

You can keep a break-point inside your code. Then run the transaction MIGO and try to post the document. The runtime environment immediately goes to your break-point before doing any further processing. This ensures that whatever checks you have done in your coding will get triggered.

You don't need to do anything else.

At any point of time, if you do not require the BADI, go to SE19 and just de-activate it. That's it. You do not even need to comment your coding.

Lakshminarayanan

<b>P.S. Mark all helpful answers for points</b>

Read only

0 Likes
713

Hi Laxminarayan,

I have successfully implemented that BADI.

Thanks for your reply.

--Umesh

Read only

Former Member
0 Likes
713

Hi,

The call to the BADI is already made in the standard code..

You need to implement the BADI and make sure that it is activated...

Your implementation will be called after the standard implementation..

You can also deactivate other custom implementations...

Regards,

Tanveer.

<b>Please mark helpful answers</b>