Application Development and Automation 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: 
Read only

Set value to the interna table

Former Member
0 Likes
883

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
858

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к

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к

6 REPLIES 6
Read only

Former Member
0 Likes
858

hi,

Your Question is not clear,

Pls explain it properly

Thanks

Suraj

Read only

Former Member
0 Likes
858

Hi,

Could you be bit clear.

thanks ,

kat

Read only

Former Member
0 Likes
859

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к

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
858

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

Read only

Former Member
0 Likes
858

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

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
858

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