Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt regd Field Symbols

Former Member
0 Kudos

Hi SDN's

I have createad dynamic internal table using the method cl_alv_table_create=>create_dynamic_table from the blog

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

i am struck at the last point. what i wanted to know is the the internal table is in the form of a Field Symbol <FS> . But i have an internal table which already contains the data.. how do i move the data from internal tables to the Dynamic internal table.. I had already posted previously, but not able to understand .. can some body help me in understanding to get the data from Internal table to the dynamic internal table

<b>My internal table</b> is in the below format

Alloc no|ChargeCode	|Amount	|
---------------------------------
A119	|301		|100	|
A119	|301		|200	|
A119	|302		|150	|
A119	|302		|250	|
A119	|303		|100	|
A229	|301		|100	|
A229	|321		|100	|
A239	|301		|100	|
A239	|303		|50	|

and i have the <b>dynaic internal table</b> format as below

Alloc No|301	|302	|303	|321	|
-----------------------------------------
A119	|300	|400	|100	|NIL	|
A229	|100	|NIL	|NIL	|100	|
A239	|100	|NIL	|50	|NIL	|

Please help me in understanding to move the data in to the above format

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Pratyu Usha,

I started dealing with it recently, so I'll try to help...

I built the dynamic table row after row.

To do this efficiently, the static (non-dynamic) table must be sorted by "Alloc No".

Then you need a field-symbol for the work-area line of the dynamic table:

ASSIGN LOCAL COPY OF INITIAL LINE OF <dynamic-table> TO <line>.

where <dynamic-table> is the field-symbol representing your dynamic table.

then you loop at your static table, and for each line of the static table you assign the right column of the dynamic table's line to other field-symbol:

ASSIGN COMPONENT StaticTable-ChargeCode OF STRUCTURE <line> TO <field>.

where <field> is another field-symbol and StaticTable is your static table...

For example, suppose that you're currently in the first row of your static table - <field> will point to the column named "301" of the work-area of your dynamic table.

now you just put the value inside that column:

<field> = StaticTable-Amount.

OR if you want to sum the value:

 ADD StaticTable-Amount to <field>.

Now, at end of "Alloc no", you need to add your dynamic work-area to the dynamic table:

APPEND <line> TO <dynamic-table>.
CLEAR: <line>.

There.

That should work.

Please let me know!

Alon

1 REPLY 1

Former Member
0 Kudos

Hi Pratyu Usha,

I started dealing with it recently, so I'll try to help...

I built the dynamic table row after row.

To do this efficiently, the static (non-dynamic) table must be sorted by "Alloc No".

Then you need a field-symbol for the work-area line of the dynamic table:

ASSIGN LOCAL COPY OF INITIAL LINE OF <dynamic-table> TO <line>.

where <dynamic-table> is the field-symbol representing your dynamic table.

then you loop at your static table, and for each line of the static table you assign the right column of the dynamic table's line to other field-symbol:

ASSIGN COMPONENT StaticTable-ChargeCode OF STRUCTURE <line> TO <field>.

where <field> is another field-symbol and StaticTable is your static table...

For example, suppose that you're currently in the first row of your static table - <field> will point to the column named "301" of the work-area of your dynamic table.

now you just put the value inside that column:

<field> = StaticTable-Amount.

OR if you want to sum the value:

 ADD StaticTable-Amount to <field>.

Now, at end of "Alloc no", you need to add your dynamic work-area to the dynamic table:

APPEND <line> TO <dynamic-table>.
CLEAR: <line>.

There.

That should work.

Please let me know!

Alon