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

Populating internal table field with same value

Former Member
0 Likes
4,389

Is there syntax that will fill a field value in every record in an internal table without looping?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,968

use MODIFY with the TRANSPORTING option. Check the online help

something like...


name1 = 'ABHI'
MODIFY TABLE ITab FROM WA TRANSPORTING name1where name2 = 'THAPAR' .

8 REPLIES 8
Read only

Former Member
0 Likes
2,967

Hi ,

Check MODIFY statement for table with where clause.

Press F1 on Modify.

Hope this helps you.

Read only

Former Member
0 Likes
2,969

use MODIFY with the TRANSPORTING option. Check the online help

something like...


name1 = 'ABHI'
MODIFY TABLE ITab FROM WA TRANSPORTING name1where name2 = 'THAPAR' .

Read only

Former Member
0 Likes
2,967

Without looping or without using the LOOP statement??

Rob

Read only

0 Likes
2,967

Hi Rob,

I didn't know this, after studying online help on MODIFY itab, ABAP Statement

MODIFY itab - itab_lines

Syntax

... itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.

I tried

DATA:
    ls_t100 TYPE t100,
    lt_t100 TYPE TABLE OF t100.

  SELECT * INTO TABLE lt_t100 FROM t100 UP TO 20 ROWS.
  MODIFY lt_t100 FROM ls_t100 TRANSPORTING text where text <> ls_t100-text .

clears field text in all rows of lt_t100.

after many years of field-symbols finally a reason to use MODIFY again

Regards,

Clemens

Read only

0 Likes
2,967

But ABAP must do an internal loop through the table to find and replace the values.

Rob

Read only

0 Likes
2,967

whatever an internal loop in the KERNEL may be.

Clemens

Read only

Former Member
0 Likes
2,967

Try this out: (Here looping is used only to fille the itab and display the records)


types: begin of ty_name,
         first_name(20),
         last_name(20),
       end of ty_name.

data: t_name type standard table of ty_name,
      wa_name like line of t_name.


do 5 times.
  wa_name-first_name = 'John'.
  wa_name-last_name = 'Myers'.
  append wa_name to t_name.
enddo.


wa_name-last_name = 'Mathew'.
MODIFY t_name FROM WA_NAME TRANSPORTING last_name
  where first_name = 'John'.

clear WA_NAME.
loop at t_name into wa_name.
  write:/ wa_name-first_name, ', ', wa_name-last_name.
endloop.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,967

APPEND LINES OF itab1 TO itab2.

INSERT <line> INTO TABLE <itab>.

Check f1 help for this statements