2016 Jun 14 2:57 PM
Hi Guys,
Is there a single statement to achieve the below?
1) itab1 = itab2
2) Replace value of field1 (of all entries) in itab1 with a constant value 'X'.
I was trying to use Corresponding operator, but only allows mapping values from itab2.
Thanks,
Ajith
2016 Jun 14 3:21 PM
If you are using new ABAP statements, then, I could find the following 'single' statement. But, due to the complexity of this statement, I wouldn't recommend this.
tabl2 = value #( for entry in tabl1
( corresponding #( value ty2( base corresponding #( entry ) field1 = 'X' ) ) ) ).
Rather, split it into 3 statements and the program becomes much more readable.
tabl2 = corresponding #( tabl1 ).
strc2-field1 = 'X'.
modify tabl2 from strc2 transporting field1 where field1 ne strc2-field1.
Thanks,
Juwin
2016 Jun 14 3:21 PM
If you are using new ABAP statements, then, I could find the following 'single' statement. But, due to the complexity of this statement, I wouldn't recommend this.
tabl2 = value #( for entry in tabl1
( corresponding #( value ty2( base corresponding #( entry ) field1 = 'X' ) ) ) ).
Rather, split it into 3 statements and the program becomes much more readable.
tabl2 = corresponding #( tabl1 ).
strc2-field1 = 'X'.
modify tabl2 from strc2 transporting field1 where field1 ne strc2-field1.
Thanks,
Juwin
2016 Jun 14 4:14 PM
Thanks !
Simplified it a bit and seems to work.
itab1 =
VALUE #( FOR wa IN itab1
( VALUE #( BASE CORRESPONDING #( wa )
field1 = 'X' ) ) ).
2016 Jun 14 4:22 PM
Hi Ajith, I tried that in my system and it gives me a syntax error. May be you are on a later version of support pack, which includes the fix for this bug.
Thanks,
Juwin