05-06-2013 10:55 AM
I have an internal table (refer Table 1 below) from which I need to pass certain values to a dynamic Internal table.
I have managed to build the dynamic internal table required, but the issue I face is how to transfer the values in the format as seen in Table 2 below.
When I do the below I am able to get the specific values required, but then I am not sure how I should proceed after this.
LOOP AT it_table1 ASSIGNING <fs_it1>.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_it1> TO <fs1>.
ASSIGN COMPONENT 4 OF STRUCTURE <fs_it1> TO <fs2>.
ENDLOOP.
I did quite an extensive search in this & other forums, but couldn't manage to find a clue.
If this query has been addressed before please help to point me to the right thread or if further clarification is needed let me know.
Table 1:
Category | Type | Subject | Value - 1 | Value - 2 | Value - 3 | Value - 4 | Value - 5 | Total |
AA | XX01 | A | 10 | 10 | 20 | |||
AB | XY02 | B | 5 | 15 | 5 | 25 | ||
AC | XX03 | C | 15 | 5 | 20 | |||
AA | XX01 | D | 20 | 15 | 35 |
Table 2:
Dynamic Table for Value - 1 (dynamic table created based on column - Type of main internal table) | |||||
Category | XX01 | XY02 | XX03 | XX01 | Total |
AA | 10 | 10 | |||
AB | 0 | ||||
AC | 15 | 15 | |||
AA | 20 | 20 |
05-06-2013 11:23 AM
This is what your code should look like
LOOP AT gt_static INTO wa_static.
APPEND INITIAL LINE TO <gt_dyn> ASSIGNING <gwa_dyn>.
* Category
ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <gwa_dyn> TO <gv_cat>.
<gv_cat> = wa_static-category.
* Type - XX01, XY02, XX03 etc
ASSIGN COMPONENT wa_static-type OF STRUCTURE <gwa_dyn> TO <gv_type>.
<gv_type> = wa_static-value1.
ENDLOOP.
A couple of points to note:
BR,
Suhas
05-06-2013 11:23 AM
This is what your code should look like
LOOP AT gt_static INTO wa_static.
APPEND INITIAL LINE TO <gt_dyn> ASSIGNING <gwa_dyn>.
* Category
ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <gwa_dyn> TO <gv_cat>.
<gv_cat> = wa_static-category.
* Type - XX01, XY02, XX03 etc
ASSIGN COMPONENT wa_static-type OF STRUCTURE <gwa_dyn> TO <gv_type>.
<gv_type> = wa_static-value1.
ENDLOOP.
A couple of points to note:
BR,
Suhas
05-07-2013 11:58 PM
Suhas appreciate your quick help. That definitely addressed the issue faced by me.
Keep the good work going.