2007 Mar 28 11:00 AM
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?
2007 Mar 28 11:01 AM
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?
2007 Mar 28 11:01 AM
Try this..
LOOP AT ITAB1.
AT NEW POPER.
<b>read table itab1 index sy-tabix.</b>
append itab1 to itab2.
ENDAT.
ENDLOOP.
2007 Mar 28 11:02 AM
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
2007 Mar 28 11:05 AM
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.
2007 Mar 28 11:05 AM
data : wtab like itab1.
LOOP AT ITAB1.
move-corresponding itab1 to wtab.
AT NEW POPER.
append wtab to itab2.
ENDAT.
regards
shiba dutta
2007 Mar 28 11:32 AM
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
2007 Mar 28 11:38 AM
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