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

LOOP on a field symbol

Former Member
0 Likes
1,384

Hi everybody.

Here is the program I trie to compile but i got a problem as <fs> is without header.

in seltab I have all table I want to modify records.

data: xtablename(30) type c.

LOOP AT seltab.

IF seltab-low NE 'PA0000' AND seltab-low NE 'PA0001' AND seltab-low NE 'PA0002'.

concatenate 'I_' SELTAB-LOW into xtablename.

assign (xtablename) to <fs>.

LOOP AT <fs> WHERE pernr = hiring-pernr

AND begda LE I_PA0001-BEGDA

AND endda GE I_PA0001-BEGDA.

<fs>-begda = I_PA0001-BEGDA.

MODIFY <fs>.

ENDLOOP.

ENDIF.

ENDLOOP.

Thanks for your help

Message was edited by:

Raynald Hauduc

Message was edited by:

Raynald Hauduc

Hi everybody.

Here is the program I trie to compile but i got a problem as <fs> is without header.

in seltab I have all table I want to modify records.

data: xtablename(30) type c.

LOOP AT seltab.

IF seltab-low NE 'PA0000' AND seltab-low NE 'PA0001' AND seltab-low NE 'PA0002'.

concatenate 'I_' SELTAB-LOW into xtablename.

assign (xtablename) to <fs>.

LOOP AT <fs> WHERE pernr = hiring-pernr

AND begda LE I_PA0001-BEGDA

AND endda GE I_PA0001-BEGDA.

<fs>-begda = I_PA0001-BEGDA.

MODIFY <fs>.

ENDLOOP.

ENDIF.

ENDLOOP.

Thanks for your help

Message was edited by:

Raynald Hauduc

Message was edited by:

Raynald Hauduc

13 REPLIES 13
Read only

Former Member
0 Likes
1,354

try like this...

modify <fs> from wa...

and wa-begda = I_PA0001-BEGDA.

Regars,

Satya

Read only

Former Member
0 Likes
1,354

Hi Raynald,

I've done something like that a few times ago :

DATA : w_tab(10) type c,

w_temp(10) type c.

W_TAB = 'MARA'.

CONCATENATE w_tab '[]' INTO w_temp.

UNASSIGN <NEW_TAB>.

ASSIGN (w_temp) TO <NEW_TAB>.

ASSIGN LOCAL COPY OF (w_tab) TO <NEW_WA>.

LOOP AT <NEW_TAB> INTO <NEW_WA>.

..........

ENDLOOP.

Hope it helps,

Mathieu

Read only

0 Likes
1,354

ASSIGN LOCAL COPY OF (w_tab) TO <NEW_WA> is not working

I can compile but <NEW_WA> is not assign

Read only

0 Likes
1,354

The SAP help on LOCAL COPY is :

<i>ASSIGN LOCAL COPY OF f TO <fs>.

Effect

Has largely the same effect as a normal ASSIGN statement.

However, this variant of ASSIGN can only be used within a subroutine. The system creates a local copy of the field f, to which the field symbol points.

</i>

As you are using local table, it won't work... And without the LOCAL COPY OF? Is it working?

Read only

0 Likes
1,354

Not as I need a header with the same structure as my filed symbol.

Read only

0 Likes
1,354

HI

Why dont you declare

<fs_wa> type any.

loop at <fs> assigning <fs_wa>.

  • logic for your loop

endloop.

Hope this helps

Read only

0 Likes
1,354

How do you define your field symbol <fs> ??

When you do such a thing :

<i>LOOP AT <fs> WHERE pernr = hiring-pernr

AND begda LE I_PA0001-BEGDA

AND endda GE I_PA0001-BEGDA.</i>

He replies <i>The line types of the table must be statically defined</i>... O_o

Read only

0 Likes
1,354

My field symbol is without header so I can work on it

Read only

Former Member
0 Likes
1,354

Try like this

REPORT zkb_test.

DATA: dref TYPE REF TO data.

FIELD-SYMBOLS: <fs_i_scarr> TYPE table,

<fs_w_scarr> TYPE ANY,

<fs_field> TYPE ANY.

CREATE DATA dref TYPE TABLE OF scarr.

ASSIGN dref->* TO <fs_i_scarr>.

SELECT * FROM scarr INTO TABLE <fs_i_scarr>.

LOOP AT <fs_i_scarr> ASSIGNING <fs_w_scarr>.

ASSIGN COMPONENT 2 OF STRUCTURE <fs_w_scarr> TO <fs_field>.

WRITE / <fs_field>.

IF <fs_field> EQ 'AA'.

ASSIGN COMPONENT 5 OF STRUCTURE <fs_w_scarr> TO <fs_field>.

<fs_field> = 'www.a-airlines.com'.

ENDIF.

ENDLOOP.

Regards

Kathirvel

Read only

Former Member
0 Likes
1,354

hi Raynald.

The table xtablename does not have the workarea.

1. Either define the table xtablename with work area.

DATA : I_PA1234 TYPE TABLE OF xxx WITH HEADER LINE.

2. Or define an explicit work area and loop the table into that work area.

LOOP AT <fs> INTO <fsw> WHERE pernr = hiring-pernr
                                              AND begda LE I_PA0001-BEGDA
                                              AND endda GE I_PA0001-BEGDA.
         <fsw>-begda = I_PA0001-BEGDA.
         MODIFY <fs>.
ENDLOOP.

Hope this helps.

Regards,

Richa

Read only

0 Likes
1,354

1)How can I declare xtablename with work area as it's a field symbol?

for the 2) how fsw had to be declare?

Thanks for yourhelp

Read only

0 Likes
1,354

I trie to do somthing like this

LOOP AT I_PAxxx0 WHERE pernr = hiring-pernr

AND begda LE I_PA0001-BEGDA

AND endda GE I_PA0001-BEGDA.

I_PAxxx0-begda = I_PA0001-BEGDA.

MODIFY I_PAxxx0.

ENDLOOP.

DELETE I_PA9xxx0 WHERE pernr = hiring-pernr

AND endda LT I_PA0001-BEGDA.

LOOP AT I_PAxxx1 WHERE pernr = hiring-pernr

AND begda LE I_PA0001-BEGDA

AND endda GE I_PA0001-BEGDA.

I_PAxxx1-begda = I_PA0001-BEGDA.

MODIFY I_PAxxx1.

ENDLOOP.

DELETE I_PAxxx1 WHERE pernr = hiring-pernr

AND endda LT I_PA0001-BEGDA.

but without a duplicate code

Read only

0 Likes
1,354

No idea?