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

ME_PROCESS_PO_CUST - Method PROCESS_HEADER running twice

Former Member
0 Likes
3,132

Hello everybody,

I've implemented method PROCESS_HEADER of BADI ME_PROCESS_PO_CUST for changing the field SUBMI with the SET_DATA method. The strange thing is, that the method is called twice. The problem seems to be the following row in IF_FLUSH_TRANSPORT_MM~START:


* Step 3: Recheck if the extension changed any business object
  IF NOT my_recheck_queue IS INITIAL.

In my case, the internal table my_recheck_queue isn't INITIAL and that's the reason why the PROCESS_HEADER method is called again.

Does someone have an idea how I can avoid the PROCESS_HEADER method running twice?

Thanks

Daniel

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,135

Hi,

If the only issue is that you need your code to be executed only once, you can make use of IMPORT & EXPORT techniques.

For Example:

1] In the call, try to get ID from Memory like

IMPORT TEXT01 FROM MEMORY ID 'SOMEID'.

IF SY-SUBRC EQ 0 AND TEXT01 IS NOT INITIAL.

" Clear the contents from Memory specifying Memory ID

RETURN. "Exit further processing

ELSE.

"Process your required logic.

EXPORT TEXT01 FROM 'BADI_ALREADY_PROCESSED_ID' TO MEMORY ID 'SOMEID'.

ENDIF.

Take some more help of IMPORT/EXPORT usage if necessary.

BR

Neelesh

Hello everybody,

I've implemented method PROCESS_HEADER of BADI ME_PROCESS_PO_CUST for changing the field SUBMI with the SET_DATA method. The strange thing is, that the method is called twice. The problem seems to be the following row in IF_FLUSH_TRANSPORT_MM~START:


* Step 3: Recheck if the extension changed any business object
  IF NOT my_recheck_queue IS INITIAL.

In my case, the internal table my_recheck_queue isn't INITIAL and that's the reason why the PROCESS_HEADER method is called again.

Does someone have an idea how I can avoid the PROCESS_HEADER method running twice?

Thanks

Daniel

6 REPLIES 6
Read only

Former Member
0 Likes
2,135

Hi,

BADI can be called many times while accessing transaction.

If it is affecting your logic means, put a check in the beginning of the method whether the field has been changed already.

If yes, do not go inside the logic again.

Cheers,

Raja.D

Read only

Former Member
0 Likes
2,135

HI,

Can u elaborate what is the logic/Requirement ?

if u are wanting to validate on some data then u can enable the logic based on user command (of SAVE,CHECK button).

if it satisfies then execute ur logic.

Regards,

Madhukar Shetty

Read only

0 Likes
2,135

My logic is to check the countries of the delivery addresses on item level and then updating the collective number under certain conditions (all countries are identical and the country is maintained in an user table).

First I wanted to do this in CHECK method, but updating the collective number didn't work there. Then I tried the POST method, but updating the collective number didn't work there also, so I tried it in the PROCESS_HEADER and this is the first method where updating the collective number works.

Read only

0 Likes
2,135

HI,

So now ur logic is working, and the only issue is logic is running twice CORRECT then just add a if condition before ur logic i.e

If sy-ucomm eq 'MECHECKDOC' or sy-ucomm eq 'PB'. "This is for Check button

ur logic

endif

Thanks,

Madhukar Shetty

Read only

Former Member
0 Likes
2,136

Hi,

If the only issue is that you need your code to be executed only once, you can make use of IMPORT & EXPORT techniques.

For Example:

1] In the call, try to get ID from Memory like

IMPORT TEXT01 FROM MEMORY ID 'SOMEID'.

IF SY-SUBRC EQ 0 AND TEXT01 IS NOT INITIAL.

" Clear the contents from Memory specifying Memory ID

RETURN. "Exit further processing

ELSE.

"Process your required logic.

EXPORT TEXT01 FROM 'BADI_ALREADY_PROCESSED_ID' TO MEMORY ID 'SOMEID'.

ENDIF.

Take some more help of IMPORT/EXPORT usage if necessary.

BR

Neelesh

Read only

0 Likes
2,135

I guess, I solved it with the import/export suggestion of neelpad7. I have to test it in detail, but so far it looks good.

Thanks everybody.

Daniel