2014 Mar 13 7:35 PM
Hi,
I have Variable V2 populated into another Variable V1(not value, directly the variable name).
Now I have to check the value of Variable V2.
In my case the value in V2 can be 'X' or space.
So how to check the value of V2.
Is there anything like IF value(V1) = 'X' comparison.
Data is dynamically populated into V1 i.e., it can have 'V2', 'V3'...etc
Thanks & Regards,
Adithya M
2014 Mar 13 9:08 PM
Hi Adithya,
your problem can be solved by using the assigning statement.
See this link to the help-site:
Assigning Components of Structures to a Field Symbol (SAP Library - ABAP Programming (BC-ABA))
Here is the copy-paste coding from the site:
DATA: BEGIN OF LINE,
COL1 TYPE I VALUE '11',
COL2 TYPE I VALUE '22',
COL3 TYPE I VALUE '33',
END OF LINE.
DATA COMP(5) VALUE 'COL3'.
FIELD-SYMBOLS: <F1>, <F2>, <F3>.
ASSIGN LINE TO <F1>.
ASSIGN COMP TO <F2>.
DO 3 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
WRITE <F3>.
ENDDO.
ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
WRITE / <F3>.
The output is:
11 22 33
33
Have fun
~Florian
2014 Mar 13 9:08 PM
Hi Adithya,
your problem can be solved by using the assigning statement.
See this link to the help-site:
Assigning Components of Structures to a Field Symbol (SAP Library - ABAP Programming (BC-ABA))
Here is the copy-paste coding from the site:
DATA: BEGIN OF LINE,
COL1 TYPE I VALUE '11',
COL2 TYPE I VALUE '22',
COL3 TYPE I VALUE '33',
END OF LINE.
DATA COMP(5) VALUE 'COL3'.
FIELD-SYMBOLS: <F1>, <F2>, <F3>.
ASSIGN LINE TO <F1>.
ASSIGN COMP TO <F2>.
DO 3 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
WRITE <F3>.
ENDDO.
ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
WRITE / <F3>.
The output is:
11 22 33
33
Have fun
~Florian
2014 Mar 15 4:22 AM
Thank you Florian.
It got resolved by the below way,
If V1 & V2 are variables
FIELD-SYMBOLS: <FS> TYPE any.
V2 = 'X'
V1 = 'V2'.
ASSIGN (V1) TO <FS>.
If <FS> is ASSIGNED then <FS> will be having its value as 'X'.