Application Development and Automation 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: 
Read only

Append a record in dynamic internal table after loop statement

Former Member
0 Likes
724

Hi All,

I have a dynamic internal table <DYN_TAB> with work area <WA_DYTAB>.

I have populated the table with records from a standard table.

Post that I wanted to modify some columns in that so have written

LOOP AT <DYN_TAB> ASSIGNING <WA_DYTAB>.

ASSIGN COMPONENT "WHATEVER" OF STRUCTURE <WA_DYTAB> TO <FS>.

<FS> = 'WHATEVER".

ENDLOOP.

The problem is after the loop I have to append 1 more record to this dynamic internal table.

If a use a CLEAR <WA_DYTAB>. and then append my record, the last record in my table is cleared and I have 2 records with appended values.

If I use UNASSIGN <WA_DYTAB> when i append my record it gives a dump saying <WA_DYTAB> not yet assigned.

If I do not do anything (either CLEAR or UNASSIGN) again the last record is modified based on new values I assign and also another record is appended with the same values.

What do I do to retain already existing values in the table and append 1 more record to it.

Regards,

Mrunal

2 REPLIES 2
Read only

Former Member
0 Likes
476

Hi Mrunal,

In this case, after the loop, the field symbol is pointing to the last record in the internal table. Hence whatever change is made to the field symbol, it is directly reflected in the last record of internal table. We can use normal workarea (not a field symbol) to append the required record to the internal table. Not sure if it works for dynamic internal tale. Please try to move the required values to the workarea (defined as 'like line of' internal table) and append the workarea to internal table.

You may fing some help in the attached link.

http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html

Regards

Radhika

Read only

Former Member
0 Likes
476

Thanks Radhika, But already done what's mentioned in the blog..

Did some manipulations with the work area to get the desired output - based on own logic (may not be perfect so not posting Code here ).

Mrunal

Edited by: Mrunal Shyamkant Patki on Nov 25, 2009 10:43 AM