10-15-2008 1:11 PM
Hi all,
i am having a internal IT_LINEITEM
Fields in the table IT_LINEITEM are serialno,linenumber and taxcode
Value for the LINENUMBER field for the first record will be 1, for second record the line number will be 2 , for third record linenumber will be 3, for fourth record value will be 4 and for fifth record value wuii be 5 and so on..............
TAXCODE field is optional in the table
My requirement is that if the TAXCODE field is filled(not initial) only in the 5th and 7th records then the linenumber values should be changed to 2 and 3 for that 5th and 7th records
Actually the linenumber values will be 5 and 7 for the 5th and 7th record but i need to change the linenumber value to 2 and 3 instead of 5 an 7.
Please help me.
Thanks in advance
regards
Ajay
10-15-2008 1:16 PM
Hi,
Use field symbol concept to modify the records in table while looping the internal table IT_LINEITEM.
loop at it_lineitem assigning <FS>.
if <FS>- taxcode is not initial..
count = count + 1.
<FS>-linenumber = count.
endloop.
With Regards,
Dwaraka.S
10-15-2008 1:29 PM
You can use CONTROL BREAK statements.
loop at IT_LINEITEM.
...
... (Your code)
...
at new linenumber.
if IT_LINEITEM-TAXCODE IS NOT INITIAL.
case IT_LINEITEM-LINENUMBER.
when 5.
IT_LINEITEM-LINENUMBER = 2.
when 7.
IT_LINEITEM-LINENUMBER = 5.
endcase.
endif.
...
...
(append / modify WA_LINEITEM to IT_LINEITEM).
...
...
endloop.
10-15-2008 1:32 PM
Hi,
Do u want to change only 5th and 7th record ?
if yes then use this.
sort itab.
read itab with index 5 .
if sy-subrc = 0 and taxcode is not initial.
modify itab ------------.
endif.
same for record 7.
rhea.