2007 Jul 26 3:08 PM
Hi all,
I am writing a code in a loop....here i am printing hard code lines"please show..." in the header data based on the line item condition as tax code = 'M3'...here the hard code is printing fine but when ever there are more than one line item having tax code = 'M3' the hard code lines are getting repeated for that i need to get only single line...
i ahve wrote below code but it is not working...pls hlp
MOVE '1' TO GV_TAX_FLAG.
LOOP AT SF_PO-IT_ITEM INTO WA_ITEM.
IF WA_ITEM-TAX_CODE = 'I2'.
*MOVE 'X' TO GV_TAX_FLAG.
GV_TAX_FLAG = GV_TAX_FLAG + 1.
ELSE.
GV_TAX_FLAG = '0'.
ENDIF.
ENDLOOP.
and writing the condition as GV_TAX_FLAG = '1' then print this"...."....
my code is printing the hard code lines repeatedly for line items containing same tax code = "M3" ...
2007 Jul 26 3:19 PM
Hi Srikanth,
herez the solution,
1)first sort your internal table by Tax Code.
2) in the loop use AT NEW.
eg:
data flag type i.
clear flag.
Loop at sf_po into wa_item.
at new wa_item-<your taxcode field>.
flag = 1.
endat.
if flag = 1.
flag = 0.
if taxcodefield = 'l2'.
write:/ "your hard coded statement".
endif.
if taxcodefield = 'm3'.
write:/ "your hard coded statement".
endif.
endif.
Hope this helps you to come up with your solution.
<b>Rewards points if this helps,</b>
Kiran
2007 Jul 26 3:19 PM
Hi Srikanth,
herez the solution,
1)first sort your internal table by Tax Code.
2) in the loop use AT NEW.
eg:
data flag type i.
clear flag.
Loop at sf_po into wa_item.
at new wa_item-<your taxcode field>.
flag = 1.
endat.
if flag = 1.
flag = 0.
if taxcodefield = 'l2'.
write:/ "your hard coded statement".
endif.
if taxcodefield = 'm3'.
write:/ "your hard coded statement".
endif.
endif.
Hope this helps you to come up with your solution.
<b>Rewards points if this helps,</b>
Kiran
2007 Jul 26 4:53 PM
Try this code :::
keep the EXIT command whne ever u have acheived same tax_code
LOOP AT SF_PO-IT_ITEM INTO WA_ITEM.
IF WA_ITEM-TAX_CODE = 'I2'.
*MOVE 'X' TO GV_TAX_FLAG.
GV_TAX_FLAG = GV_TAX_FLAG + 1.
EXIT.
ENDIF.
ENDLOOP.