2015 Feb 24 5:30 AM
Hi Experts,
I have small confusion with Field symbols while using the statement ASSIGN COMPONENT Statement...
Check this Sample code ...as below ...
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EX:
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>.
DATA: FIELDNAME(20) TYPE C.
DATA: FIELDVALUE(5) TYPE C.
DATA: INDEX(3) TYPE C.
FIELD-SYMBOLS: <FS1>.
DO 5 TIMES.
INDEX = SY-INDEX.
CONCATENATE 'FLD' INDEX INTO FIELDVALUE.
CONDENSE FIELDVALUE NO-GAPS.
ASSIGN COMPONENT INDEX OF STRUCTURE <DYN_WA> TO <FS1>.
<FS1> = FIELDVALUE.
ENDDO.
* Append to the dynamic internal table
APPEND <DYN_WA> TO <DYN_TABLE>.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
In the above code we assign index wise component to <FS1> Field symbol from the structure <DYN_WA>.
Next line we assign FIELDVALUE (already concatenate with the 'FLD'index) to <FS1> then only the <DYN_WA> will be filled with content of Concatenated value...
How.. this procedure will be done..
Could any one please give me clarity on that.....
Program is working fine but i am not getting the Exact execution way that internally takes...
Thanks,
vamsi.
2015 Feb 24 5:46 AM
Hi..
Here we are referring the dynamic structure fields <DYN_WA>.
consider <DYN_WA> contains 5 fields as shown below.
<DYN_WA>-field1 = 5.
<DYN_WA>-field2 = 6.
<DYN_WA>-field3 = 7.
<DYN_WA>-field4 = 8.
<DYN_WA>-field5 = 9.
We are running the loop 5 times, it shows we are fetching the first five field value
DO 5 TIMES.
"Index variable gets the loop index
INDEX = SY-INDEX.
"Concatenating the value based on index like (FLD1,FLD2, FLD3, FLD4, FLD5)
CONCATENATE 'FLD' INDEX INTO FIELDVALUE.
"Removing space here
CONDENSE FIELDVALUE NO-GAPS.
"Assigning the dynamic structure field value to Field symbol based on index, During first loop run, <FS1> assign to field Field1 and it will contain the value 5, for second run <FS1> will contain value 6
ASSIGN COMPONENT INDEX OF STRUCTURE <DYN_WA> TO <FS1>.
"Update the Field symbol value with new value
<FS1> = FIELDVALUE.
ENDDO.
2015 Feb 24 5:50 AM
Hi Vamsi,
ASSIGN COMPONENT INDEX OF STRUCTURE <DYN_WA> TO <FS1>. "Pointing "INDEX" th field in <DYN_WA> by <FS1>.
<FS1> = FIELDVALUE. "Assigning vale to the pointer, so that the same value will get populated in <DYN_WA>.
INDEX can be position of filed in structure or name(in caps) of the filed in structure.
Regards
Sreekanth
2015 Feb 24 6:00 AM
You've three options that will help you to help yourself.
1) Run the program in the debugger and examine the contents of the variables at each step
2) Write "WRITE" statements after each step, which WRITE the values of the variables at each step.
3) If this is a homework type question and you have to answer without running the program then dry run the program. Dry runsThis
This is not ABAP specific. This applies to any programming language. It's also a basic part of being a programmer.
Thread locked