2008 Dec 10 1:17 PM
Hi,
How i can Add a value to internal table e.g.
i have table like that :
f_name field1
aaa 001
aaa 002
aaa 003
bbb 001
bbb 002
bbb 003
ccc 001
ccc 002
ccc 003i want to add to table new row with name and number 000
field_name field1
aaa 000
aaa 001
aaa 002
aaa 003
bbb 000
bbb 001
bbb 002
bbb 003
ccc 000
ccc 001
ccc 002
ccc 003Regards
2008 Dec 10 1:22 PM
hi,
take one more internal table itab2.
Loop at itab1.
at end of f_name.
itab2-fname = f_name.
itab2-number = '000'.
append itab2.
endat.
endloop.
append itab2 from itab2.
sort itab2 by f_name number,
hi,
take one more internal table itab2.
Loop at itab1.
at end of f_name.
itab2-fname = f_name.
itab2-number = '000'.
append itab2.
endat.
endloop.
append itab2 from itab2.
sort itab2 by f_name number,
2008 Dec 10 1:19 PM
Hi,
internal table => Append or Collect itab
DB-table => Modify table
Regards
Nicole
2008 Dec 10 1:22 PM
hi,
take one more internal table itab2.
Loop at itab1.
at end of f_name.
itab2-fname = f_name.
itab2-number = '000'.
append itab2.
endat.
endloop.
append itab2 from itab2.
sort itab2 by f_name number,
2008 Dec 10 1:22 PM
Hi,
Populate the data in Itab header.Write an INSERT with index = 1. You will get the data as the first record in Itab.
Thanks,
Vivekanand
2008 Dec 10 1:22 PM
you need to populate the wa_itab with values you want and use append statment.
append tvbdpl to z_tvbdpl.~~ append wa_itab to itab
2008 Dec 10 1:23 PM
loop at itab into wa.
if wa-field_name ne temp.
wa-field1 = 000.
insert wa into itab index sy-tabix.
endif.
wa-field_name = temp.
endloop.
2008 Dec 10 1:24 PM
data: begin of itab occurs 0,
field1 type char10 ,
field2 type i,
end of itab .
itab-field1 = 'test1'.
itab-field2 = '01'.
append itab .
itab-field1 = 'test2'.
itab-field2 = '02'.
append itab .
loop at itab .
write:/ itab-field1 ,
itab-field2 .
endloop .
2008 Dec 10 1:25 PM
Hi,
try doing like this:
data: g_field1 type field1,
i_tab_temp type table of................. "declare one more internal table like i_tab
wa_itab_temp like line of i_tab_temp. "declare one more WA for the internal table.
loop at i_tab into wa_itab.
if g_field1 is initial.
g_field1 = wa_itab-field1.
wa_itab_temp-field1 = wa_itab-field1.
wa_itab_temp-field2 = '000'.
append wa_tab_temp to i_tab_temp.
endif.
if wa_tab-field1 = g_field.
wa_itab_temp-field1 = wa_itab-field1.
wa_itab_temp-field2 = wa_itab-field1.
append wa_tab_temp to i_tab_temp.
else.
g_field1 = wa_itab-field1.
wa_itab_temp-field1 = wa_itab-field1.
wa_itab_temp-field2 = '000'.
append wa_tab_temp to i_tab_temp.
endif.
endloop.So i_tab_temp will be your final table if you want you can refresh i_tab.
Regards,
Neha
2008 Dec 10 1:49 PM
Hi,
You should consider using a table type SORTED table. Then if you use the INSERT statement, The line will be inserted into the table according to the table key.
Or you can think of appending all the lines and then later sorting the table by the 2 fields of the internal table will give you the expected result.
regards,
Advait
2008 Dec 10 2:40 PM
Hi Vijay,
Simple way is, append the records to internal table as normal way & sort on the first field.
You will get the entries in the desired format.
-Sujatha
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |