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: 

If Condition Not working.

Former Member
0 Kudos

Hello All,

in my Below code this if condition is not working properly. Here i want data like when BLART = RV this time amount move in one field and if BLART = DZ this time amount move in different filed. so i got right data in my ALV but now this distribution is not done by me. So can you please help me out..........

loop at itab.

move itab-kunnr to itab1-kunnr.

move itab-belnr to itab1-belnr.

MOVE itab-zuonr to itab1-zuonr.

MOVE itab-budat to itab1-budat.

MOVE itab-blart to itab1-blart.

if itab-blart = 'RV'.

MOVE itab-dmbtr to itab1-dmbtr.

endif.

if itab-blart = 'DZ'.

MOVE itab-dmbtr to dmbtr1.

endif.

append itab1.

endloop.

Thanks in Advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Your code is correct.

I think you need to Clear the data after Append.

Please check Document type BLART is correct.

Try the below code....



loop at itab.
itab1-kunnr  =  itab-kunnr.
itab1-belnr  = itab-belnr.
itab1-zuonr = itab-zuonr.
itab1-budat   = itab-budat.
itab1-blart =  itab-blart.
if itab-blart = 'RV'.
 itab1-dmbtr = itab-dmbtr.
elseif  itab-blart = 'DZ'.
itab1-dmbtr = itab-dmbtr1.
endif.
append itab1.

clear : itab,itab1.
endloop.

.

Regards

Arbind

3 REPLIES 3

former_member404244
Active Contributor
0 Kudos

Hi,

make sure BLART field is having either 'DZ' or 'RV' VALUE. Try like this...



loop at itab.



move itab-kunnr to itab1-kunnr.
move itab-belnr to itab1-belnr.
MOVE itab-zuonr to itab1-zuonr.
MOVE itab-budat to itab1-budat.
MOVE itab-blart to itab1-blart.
if itab-blart = 'RV'.
MOVE itab-dmbtr to itab1-dmbtr.
elseif itab-blart = 'DZ'.
MOVE itab-dmbtr to itab1-dmbtr1.
endif.

append itab1.

endloop.

Regards,

Nagaraj

Former Member
0 Kudos

Hi,

Your code is correct.

I think you need to Clear the data after Append.

Please check Document type BLART is correct.

Try the below code....



loop at itab.
itab1-kunnr  =  itab-kunnr.
itab1-belnr  = itab-belnr.
itab1-zuonr = itab-zuonr.
itab1-budat   = itab-budat.
itab1-blart =  itab-blart.
if itab-blart = 'RV'.
 itab1-dmbtr = itab-dmbtr.
elseif  itab-blart = 'DZ'.
itab1-dmbtr = itab-dmbtr1.
endif.
append itab1.

clear : itab,itab1.
endloop.

.

Regards

Arbind

Former Member
0 Kudos

what data type declare for your internal table fields (blart) , u have to decalre exact data type exactly what is in table data type to that field otherwise some times it will going wrong like data type mismatching and etc...

first check data type of the field in your internal table.

then u will get solution.