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: 

Variables getting initial in BADI.

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

vinod_vemuru2
Active Contributor
0 Kudos

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.

1 REPLY 1

vinod_vemuru2
Active Contributor
0 Kudos

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.