05-27-2008 8:02 PM
Hi All,
I'm have a big internal table like this
data: begin of data occurs 0,
Field01,
Field02,
Field03,
*bucket 1
Field04,
Field05,
Field06,
*bucket 2
Field04,
Field05,
Field06,
*bucket 3
Field04,
Field05,
Field06,
Field 1, 2 3 will be the same for pernr, first last name.
Field 4, 5, 6 are the same format but different numbers (or values ) in different buckets.
Each bucket can be shown (or not) based on the condition of a person, for example if that person live in 2 states, it will show 2 bucket with 2 address info inside each.
I will run this under get pernr to sort out each person who have many address or not.
Can I use dynamic work area and field symbol here? if I can, how?
Really appreciate your help with points...
05-27-2008 8:14 PM
Yes, you can use the Dynamics using the Field symbols.
Pseudo code is like:
If the condition is true
.. assign the field to the field symbol
...like L_FIELD = 'ITAB-FIELD01' .... (You can use concatenate here)
... ASSIGN (L_FIELD) TO <FS>.
... <FS> = 'TEST1'.
... this will se 'TEST1' to the ITAB-FIELD01.
Regards,
Naimesh Patel
05-27-2008 8:20 PM
Naimesh, but later on, how do I move the <fs> to the big internal table? use "move correspond" and work area?? Can you be more specific so I can see that light here, thanks!
Edited by: Ben Boman on May 27, 2008 9:35 PM
05-27-2008 8:36 PM
You can use the ASSIGN COMPONENT ... and than APPEND the work area to the table.
Check out this sample program:
REPORT ZTEST_NP.
DATA: BEGIN OF ITAB OCCURS 0,
F1 TYPE I,
F2 TYPE I,
F3 TYPE I,
END OF ITAB.
DATA: WA_ITAB LIKE ITAB.
DATA: L_CNT TYPE I.
FIELD-SYMBOLS: <F_FLD> TYPE ANY.
DO 10 TIMES. " I want 10 reocrds
CLEAR L_CNT.
DO 3 TIMES. " I have 3 fields
L_CNT = L_CNT + 1.
ASSIGN COMPONENT L_CNT OF STRUCTURE WA_ITAB TO <F_FLD>.
<F_FLD> = L_CNT.
ENDDO.
APPEND WA_ITAB TO ITAB.
CLEAR ITAB.
ENDDO.
LOOP AT ITAB INTO WA_ITAB.
WRITE: / WA_ITAB-F1,
WA_ITAB-F2,
WA_ITAB-F3.
ENDLOOP.
Regards,
Naimesh Patel