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: 

how to add complete new column after looping final table.

Former Member
0 Kudos

hi all,

i have looped it_final table.

now after dat i want to add a new column to it_final table ,den how would i add that using another lopp statement.

13 REPLIES 13

Former Member
0 Kudos

Hi,

Delclare all the required columns in IT_FINAL. While processing you can update the data in the columns.

In your case after the loop you can populate the values in the column.

Former Member
0 Kudos

i have looped once it_final ok.

den if i want to add column from a table using another loop statement in it_final den how dat i will doo..??

0 Kudos

If you are talking about adding a new field to your it_final, then you need to add that new field into the Internal Table Structure, and you need to Loop on your it_final once again and inside this loop you need to read the second internal Table from which you want to feed value in the newly added field of internal Table and then Modify the Internal Table it_final inside this loop only.

Former Member
0 Kudos

define your internaltable like this.

data: begin of it occurs 0,

f1(330),

end of it.

note: this is example donot use occurs 0 , types prefered.

Use offset and populate the records as you like.

Regards,

Satish

Former Member
0 Kudos

hi darshan,

loop at it_final into wa_final.
read table it_new into wa_new with key = key 1 .
if sy-subrc = 0.
wa_final-newcol = wa_newcol.
endif.
modify it_final from wa_final.
endloop.

Here you should have a common key field in both it_final table and in it_new table. ( where the it_new table contains the new row that is to be appended to the if_final table ).

Hope your problem solves. if not send in your code. v can help you.

Former Member
0 Kudos

Hi,

From what i have understood.. You want to add field value from another table to your 'IT_FINAL' internal table.. So for that what you have to do is first decalre the field as prt of the final internal table 'IT_FINAl'..


loop at it_final into ls_final.

loop at itab1 into ls_itab1.

ls_final-new_field = itab1-field.

endloop.
modify it_final....

endloop...

But it is better if you use field symbols rather than modify statemnet..

Hope this is what you wanted to know..

Former Member
0 Kudos

Hi

If you are comfortable using field-symbol, go for it. You do not have to use modify in that case.

field-symbols <wa_final> type (table type of it_final).

Loop at it_final assigning <wa_final>.
  read table it_second into wa_second witk key...
  if sy-subrc eq 0.
    <wa_final>-new = wa_second-field.
  endif.
Endloop.

Please let me know if this works.

Sourav.

0 Kudos

any of the above solution not workinggg....

0 Kudos

Hi,

Can you let me know if you are using 'Modify statement'.. If yes the please check if you are using the Transporting addition to it..



modify it_final from ls_final transporting new_field.

0 Kudos

gr8...can you provide brief of your code here....

0 Kudos

thankss all

got the output...with field symbol.

0 Kudos

Hi,

if your problem is solved can you please close the thread, and it would be great if you could appreciate your contributors for there efforts by rewarding...

0 Kudos

Hello Darshan,

<< Whinging removed >>

Edited by: Rob Burbank on Jun 25, 2009 10:28 AM