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: 

Changing the values in the internal table .

Former Member
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

vamshi_mohan
Participant
0 Kudos

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.

Former Member
0 Kudos

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.