2009 Mar 17 9:12 AM
Hi Friends,
I have a internal table with 4 fields, all the 3 fiels as records now i have assign value "i" to the 4th fields for all the 3 records. can any one say how to do this with code.
Thanks
Gayathri
2009 Mar 17 9:16 AM
Use this code
loop at itab into wa.
wa-field4 = value. "value which u want to add
modify itab index sy-tabix from wa.
endloop.кu03B1ятu03B9к
Hi Friends,
I have a internal table with 4 fields, all the 3 fiels as records now i have assign value "i" to the 4th fields for all the 3 records. can any one say how to do this with code.
Thanks
Gayathri
2009 Mar 17 9:15 AM
hi,
Your Question is not clear,
Pls explain it properly
Thanks
Suraj
2009 Mar 17 9:16 AM
2009 Mar 17 9:16 AM
Use this code
loop at itab into wa.
wa-field4 = value. "value which u want to add
modify itab index sy-tabix from wa.
endloop.кu03B1ятu03B9к
2009 Mar 17 9:21 AM
Hi,
If you want to add a value to field 4 for all records, then use:-
loop at itab into wa.
wa-field4 = '<value>'.
modify itab from wa index sy-tabix.
endloop.
If you want to add a value to field4 based on a condition, the use:-
loop at itab into wa.
if <condition>. "like field1 = <value> or any thing
wa-field4 = '<value>'.
else.
wa-field4 = '<value>'.
endif.
modify itab from wa index sy-tabix.
endloop.
Hope this helps you.
Regards,
Tarun
2009 Mar 17 9:44 AM
hi , just copy and execute this code .
data : BEGIN OF itab OCCURS 0,
f1 type i,
f2 type i,
f3 type i,
f4 type c,
END OF itab .
itab-f1 = 10.
itab-f2 = 100 .
itab-f3 = 150.
APPEND itab.
itab-f1 = 20.
itab-f2 = 200 .
itab-f3 = 250.
APPEND itab .
itab-f1 = 30.
itab-f2 = 300 .
itab-f3 = 350.
append itab .
LOOP at itab .
MODIFY itab .
itab-f4 = 'i'.
if sy-subrc eq 0 .
write :/ itab-f1,itab-f2,itab-f3,itab-f4.
ENDIF.
endloop.regards
chinnaiya
2009 Mar 17 9:53 AM
hi,
TYPES : BEGIN OF ty_itab,
f1(2),
f2(2),
f3 type i.
END OF ty_itab.
TYPES : BEGIN OF ty_jtab,
f1(2),
f2(2),
f3 TYPE i,
END OF ty_jtab.
DATA : wa_itab TYPE ty_itab,
it_itab TYPE TABLE OF ty_itab,
cnt type i.
wa_itab-f1 = 'US'.
wa_itab-f2 = 'WA'.
APPEND wa_itab TO it_itab.
wa_itab-f1 = 'US'.
wa_itab-f2 = 'WA'.
APPEND wa_itab TO it_itab.
wa_itab-f1 = 'US'.
wa_itab-f2 = 'TX'.
APPEND wa_itab TO it_itab.
wa_itab-f1 = 'US'.
wa_itab-f2 = 'TX'.
APPEND wa_itab TO it_itab.
wa_itab-f1 = 'US'.
wa_itab-f2 = 'PA'.
APPEND wa_itab TO it_itab.
wa_itab-f1 = 'DE'.
wa_itab-f2 = 'AS'.
APPEND wa_itab TO it_itab.
LOOP AT it_itab INTO wa_itab.
cnt = cnt + 1.
wa_itab-f3 = cnt.
modify it_itab from wa_itab index sy-tabix transporting f3.
ENDLOOP.
Thanks & Regards
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |