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

AT NEW

Former Member
0 Likes
1,493

I have :

select *

from Z99BW69

INTO CORRESPONDING FIELDS OF TABLE ITAB1

where POPER = '002'

AND MATNR IN ('WS0218' , 'WS0217', 'WS0203')

AND BELNR IN ('0070000020','0070000023','0070000021','0070000022',

'0070000024').

sort itab1 by MANDT BUKRS MATNR POPER BLDAT BELNR.

LOOP AT ITAB1.

AT NEW POPER.

append itab1 to itab2.

ENDAT.

But the result is :

007 |S35 |WS0203 |002 |*******|********|*** |*****|***|

007 |S35 |WS0217 |002 |*******|********|*** |*****|***|

007 |S35 |WS0218 |002 |*******|********|*** |*****|***|

How can I insert the initial values of the fields?

I want to insert the values of the ITAB1, but using AT NEW POPER. Example:

007 |S35 |WS0218 |002 |123123|123123|123123|11111|2222|

is a way to do it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,374

Try this..

LOOP AT ITAB1.

AT NEW POPER.

<b>read table itab1 index sy-tabix.</b>

append itab1 to itab2.

ENDAT.

ENDLOOP.

I have :

select *

from Z99BW69

INTO CORRESPONDING FIELDS OF TABLE ITAB1

where POPER = '002'

AND MATNR IN ('WS0218' , 'WS0217', 'WS0203')

AND BELNR IN ('0070000020','0070000023','0070000021','0070000022',

'0070000024').

sort itab1 by MANDT BUKRS MATNR POPER BLDAT BELNR.

LOOP AT ITAB1.

AT NEW POPER.

append itab1 to itab2.

ENDAT.

But the result is :

007 |S35 |WS0203 |002 |*******|********|*** |*****|***|

007 |S35 |WS0217 |002 |*******|********|*** |*****|***|

007 |S35 |WS0218 |002 |*******|********|*** |*****|***|

How can I insert the initial values of the fields?

I want to insert the values of the ITAB1, but using AT NEW POPER. Example:

007 |S35 |WS0218 |002 |123123|123123|123123|11111|2222|

is a way to do it?

6 REPLIES 6
Read only

Former Member
0 Likes
1,375

Try this..

LOOP AT ITAB1.

AT NEW POPER.

<b>read table itab1 index sy-tabix.</b>

append itab1 to itab2.

ENDAT.

ENDLOOP.

Read only

Former Member
0 Likes
1,374

Hi..,

<b>use ON CHANGE OF ..</b>

Here u r using AT NEW .. AT events are group based functions...

i mean before POPER if any fields value gets changed then this block will get processed..

so u use

<b>

loop at itab.

On change of itab-poper.

append itab to itab1.

endon.

endloop.

</b>

This will work properly...

regards,

sai ramesh

Read only

Former Member
0 Likes
1,374

declare a flag.

ex:

data: g_fl type c.

sort itab1 by MANDT BUKRS MATNR POPER BLDAT BELNR.

LOOP AT ITAB1.

AT NEW POPER.

g_fl = 'X'.

ENDAT.

if g_fl = 'X'.

append itab1 to itab2.

clear g_fl.

endif.

Read only

Former Member
0 Likes
1,374

data : wtab like itab1.

LOOP AT ITAB1.

move-corresponding itab1 to wtab.

AT NEW POPER.

append wtab to itab2.

ENDAT.

regards

shiba dutta

Read only

Former Member
0 Likes
1,374

hi there

"If you are working with a work area <wa>, it does not contain the current line in the AT... ENDAT statement block. All character fields to the right of the current group key are filled with asterisks (*). All other fields to the right of the current group key contain their initial value".

this is the documentation from library...so, to avoid this you could always use a read statement within your loop are move it into a work area and then move the data from work area...pl make sure that the field on which a control break statement is operated upon in an internal table is the first field to avoid ambiguous results...thanks

if helpful, reward

Sathish. R

Read only

0 Likes
1,374

yes satish you are correct only but it is true for

loop at itab into wa.

it will contain the * and 0 values ..

just check my prev reply i think you can get the correct data by that.

regards

shiba dutta