Application Development 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: 

BAdI ME_PROCESS_PO_CUST only for ME21N

Former Member
0 Kudos

Hello,

I've implemented the method POST_ITEM of BAdI ME_PROCESS_PO_CUST and it works fine so far.

Now, I've the little problem that the coding should only be executed in ME21N and not in ME22N (only for new purchase orders). At the moment I'm doing this with the following coding:

header_obj = im_item->get_header( ).

ls_mepoheader = header_obj->get_data( ).

select single ebeln from ekko where ebeln = ls_mepoheader-ebeln.

If not ( sy-subrc = 0 ).

....custom coding

End If

I tried to use the field SY_TCODE also, but that doesn't work because that field contains value "ME23N" if you call ME23N and then goto change the po.

Is there a better solution for this issue than the ekko-select?

Thanks

Daniel

16 REPLIES 16

Former Member
0 Kudos

hai,

in addition to that sy-tcode pass sy-ucomm = 'METOGG'

also so that while u go from me23n to me22n also it will trigger.

shan.

former_member188685
Active Contributor
0 Kudos

you can use the parameter IM_TRTYP(TRTYP) , and find the Transaction is for Creation or Change or Display. Then accordingly you can code.

0 Kudos

sy-ucomm is empty (no value), so that doesn't help me. Can you explain how I can use IM_TRTYP?

Former Member
0 Kudos

Hi,

put condition only for me21n.

if sy-tcode = 'ME21N'.

then your coding....

....

....

...

endif.

do not put if condition for me22n or me23n .

regd,

0 Kudos

That doesn't help also, because sy-tcode contains "ME23N" if you create an purchase order calling ME23N and then going to menu "Purchase order" -> "Create" (F6).

0 Kudos

if you see the table T160 you can understand it better.

ME21N	H
ME22N	V
ME23N	A

using the TRTYP you can control the logic.

0 Kudos

As I'm not skillful in using BAdI's I don't know how to get this parameter!?

Meanwhile I use method "IS_PERSISTENT" to check if it's a new item or an existing item, so I solved my problem myself. Coding looks like this now:

lc_persi = im_item->is_persistent( ).

if ( lc_persi = mmpur_no ).

....

endif.

However I'd like to know how to get parameter IM_TRTYP?

0 Kudos

this is the parameter of OPEN method, using this you can code it(pass this to another new attribute and use this for checking )

if trtyp = 'H' "create

elseif trtyp = 'V'. "Change

elseif tytyp = 'A'.  "Display

endif.

0 Kudos

You say "pass this to another new attribute". Exactly thats the point I don't know how to do. I saw the attribute in the "Open"-method, but not in the "PROCESS_ITEM"? I know, I can be a pain in the neck !

0 Kudos

you can have extra parameter and proceed, this parameter is a part of implementation class. anyway your problem solved, so you can proceed the way you want.

0 Kudos

Hi Vijay,

I think, your solution with TRTYP won't work also, because the TRTYP is determined with SY-TCODE from table T160 (s. program RM_MEPO_GUI, Include RM_MEPO_GUIF01, Line 19):

select single * from t160 into l_t160 where tcode eq sy-tcode.

check sy-subrc eq 0.

ch_document-trtyp = l_t160-trtyp.

ch_document-doc_type = l_t160-bstyp.

But sy-tcode contains "ME23N", if you create a purchase order calling ME23N and goto menu "Purchase order create". So TRTYP will have value "A" (Display) in that case even though a purchase order is created.

Only for your information.

0 Kudos

yes you are correct. I checked it. Ideally this should start new transaction, But it is not happening in case of ME transaction.

Thanks for sharing .

0 Kudos

The OPEN Method of the BADI has an Import parameter IM_TRTYP.

So if you define an attribute Z_TRTYP for the class, it will be visible in all the methods.

You can use the OPEN method like:


me->Z_trtyp = im_trtyp.

And then in any other method, say PROCESS_HEADER, you can use:


IF me->z_trtyp EQ 'H'.

0 Kudos

Thanks Aparna for the explanation. Now I understand it.

0 Kudos

You can also use this function module for getting the mode (display/ change/ create)

MEPO_DOC_GET_TRANSACTION_STATE

0 Kudos

You can also use this function module for getting the mode (display/ change/ create)

MEPO_DOC_GET_TRANSACTION_STATE