cancel
Showing results for 
Search instead for 
Did you mean: 

How to move a variable value to all the rows of a specific column?

0 Kudos

Hello Guys,

Hope you all are doing great.

I have a requirement to write a variable value to all rows of a specific column. Yes both the fields are of same type.

For Example.

Variable 1 = SAP

Internal Table before

column 1 Column 2

Name 1 (empty)

Name 2 (empty)

Name 3 (empty)

After

column 1 Column 2

Name 1 SAP

Name 2 SAP

Name 3 SAP

Currently am able to achieve this by looping on to the internal table assigning field symbol and moving the variable value.

But, am already in a loop and inside a perform, so I wanted to avoid loop inside the loop.

Is there any way I can achieve this, without loop?

Is there any 7.4 syntax to achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

joltdx
Active Contributor

You can use the MODIFY itab statement like so:

variable_1 = 'SAP'.
MODIFY internal_table
  FROM VALUE #( column_2 = variable_1 )
  TRANSPORTING column_2
  WHERE column_2 <> variable_1.

Here is a link to the SAP documentation for reference

0 Kudos

Thank you so much jorgen_lindqvist41.

Really appreciate in taking your valuable time to help.

That was a good one, its working as expected.

I hope it works for heavy load like 20K data min too (yet to test).

only correction was column 1 instead of column 2 in where clause. 

Answers (0)