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: 

looping at a dynamic table .

former_member125661
Contributor
0 Kudos

I am trying to modify contents of an internal table (certain calculations). This table is dynamic internal table.

This is what I ideally want to do.



loop at <gt_tabletotal> assigning <l_linetotal>.


if  <l_linetotal>-PERIOD = 'Prior'.

read table <gt_tabletotal> with key pmnux = <l_linetotal>-pmnux  wenux = <l_linetotal>-wenux period = <l_linetotal>-period = 'Current' .

if sy-subrc eq 0.
 <l_linetotal>-PCNT = <l_linetotal>-TOTAL / <gt_tabletotal>-total * 100 .
endif.

endif.


endloop.

But this results in a syntax error - saying <l_linetotal> has no structure. How can i fix it ? .In the debug more, I do see the struture and am able to modify it in debugger.

Edited by: Shareen Hegde on Apr 9, 2008 12:56 AM

2 REPLIES 2

Former Member
0 Kudos

Try this


field-symbols : <wa> type any.
data: new_line type ref to data. 

CREATE DATA new_line LIKE LINE OF <gt_tabletotal>. 
ASSIGN new_line->* TO <wa>. 

loop at <gt_tabletotal> assigning <wa>.
 
if <wa>-PERIOD = 'Prior'.
 
read table <gt_tabletotal> with key pmnux = <l_linetotal>-pmnux  wenux = <l_linetotal>-wenux period = <l_linetotal>-period = 'Current' .
 
if sy-subrc eq 0.
<wa>-PCNT = <wa>-TOTAL / <gt_tabletotal>-total * 100 .
endif.
 
endif.
endloop.

0 Kudos

Ramiro,

still same error <workarea> has no structure and therefore no component called period.


field-symbols : <wa> type any.
data: new_line type ref to data.

CREATE DATA new_line LIKE LINE OF <gt_tabletotal>.
ASSIGN new_line->* TO <wa>.

loop at <gt_tabletotal> assigning <wa>.

if <wa>-PERIOD = 'Prior'.

read table <gt_tabletotal> with key pmnux = <l_linetotal>-pmnux  wenux = <l_linetotal>-wenux period = <l_linetotal>-period = 'Current' .

if sy-subrc eq 0.
<wa>-PCNT = <wa>-TOTAL / <gt_tabletotal>-total * 100 .
endif.

endif.
endloop.