Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Variables getting initial in BADI.

I have written the code as below in BADI. Even if the condition success for ( if lc_wa_e1maram-mstae eq '04'.) and ( if lc_wa_e1marcm-werks EQ 'UK01' ) but the variables g_var1 and g_var2 getting initial instead of 4 and 2.

Please check below code and let me knw

My code in BADI.

DATA : g_var1 TYPE c,

g_var2 TYPE C.

field-symbolS: <idoc_data> type edidd.

if idoc_control-mestyp eq 'ZMATM'.

loop at idoc_data assigning <idoc_data>.

case <idoc_data>-segnam.

when 'E1MARAM'.

lc_wa_e1maram = <idoc_data>-sdata.

if lc_wa_e1maram-mstae eq '04'.

g_var2 = 2.

endif.

when 'E1MARCM'.

lc_wa_e1marcm = <idoc_data>-sdata.

if lc_wa_e1marcm-werks EQ 'UK01'.

g_var1 = 4.

endif.

endcase.

endloop.

IF g_var2 = 2 and g_var1 ne 4.

clear CREATE_IDOC.

ENDIF.

Regards,

vinay.

Former Member
Former Member replied

Hi,

Why dont you place a break point, debug and see what is happening? My guess is, your code is being called segmentwise. First time variables might have populated. When control comes for other segments, variables will be initialized again.

If above is correct, You can try with EXPORT/IMPORT logic.

When your conditions are satisfied, EXPORT to memory and IMPORT at later point and use it.

Thanks,

Vinod.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question