‎2007 Dec 19 7:49 AM
Hi Experts,
I am facing a peculiar problem. Please go through the code below and it is not giving the aggregate of it_ekbe_642_pgi-menge for the same it_ekbe_642_pgi-ebeln and it_ekbe_642_pgi-ebelp.
LOOP AT it_ekbe_642_pgi.
it_ekbe_642_pgi_tot-ebeln = it_ekbe_642_pgi-ebeln.
it_ekbe_642_pgi_tot-ebelp = it_ekbe_642_pgi-ebelp.
it_ekbe_642_pgi_tot-budat = it_ekbe_642_pgi-budat.
it_ekbe_642_pgi_tot-xblnr = it_ekbe_642_pgi-xblnr.
it_ekbe_642_pgi_tot-menge = it_ekbe_642_pgi-menge.
COLLECT it_ekbe_642_pgi_tot.
ENDLOOP.
Please suggest.
Thanks....
Shibaji.
‎2007 Dec 19 8:57 AM
hi,
Declare internal table fields datatyps should be same as database fields which you are referring.
one more point is if you are not considering xblnr for cumulation of quantites dont put that in loop while using collect stmt.
afterwards you move xblnr with modify stmt into 2nd internal table.
when budat is also same only (not only ebeln ebelp ) qty will be cumulated.
Regds
Sivaparvathi
Please reward points if helpful.
‎2007 Dec 19 8:04 AM
Table EKBE holds the receipt documents for a purchase order. When you have several receipts on a purchase order item but with a different posting date (BUDAT) or reference (XBLNR) the collect statement will create a new record in yoy internal table. Only numeric fields are aggregated.
regards Jack
‎2007 Dec 19 8:37 AM
Hi Jack,
I wanted to aggregate the numeric field (menge) with same ebeln, ebelp, budat and with different xblnr. But, it is overwriting on the previous record.
Please tell me the problem in the code..
Regards,
Shibaji.
‎2007 Dec 19 8:41 AM
Then XBLNR should be left blank otherwise different references (XBLNR) will result in different records in your internal table.
Regards Jack
‎2007 Dec 19 8:43 AM
Hi Jack,
I wanted to aggregate the numeric field (menge) with same ebeln, ebelp, budat and with different xblnr. But, it is overwriting on the previous record.
Please tell me the problem in the code..
Regards,
Shibaji.
‎2007 Dec 19 8:47 AM
Your internal table definition of it_ekbe_642_pgi_tot-menge might not be numeric ?
Regards Jack
‎2007 Dec 19 8:57 AM
hi,
Declare internal table fields datatyps should be same as database fields which you are referring.
one more point is if you are not considering xblnr for cumulation of quantites dont put that in loop while using collect stmt.
afterwards you move xblnr with modify stmt into 2nd internal table.
when budat is also same only (not only ebeln ebelp ) qty will be cumulated.
Regds
Sivaparvathi
Please reward points if helpful.
‎2007 Dec 20 5:43 AM
‎2007 Dec 19 8:59 AM
Hi Shibaji Maitra ,
Since you are aggregating the it_ekbe_642_pgi-menge for the same it_ekbe_642_pgi-ebeln and it_ekbe_642_pgi-ebelp.
For using the Collect statement the order of the fields should be
in proper order i.e. all the char fields come up & then after that
all the numeric fields.Please check the sequence in your internal
table and also the fields type of menge field.
LOOP AT it_ekbe_642_pgi.
it_ekbe_642_pgi_tot-ebeln = it_ekbe_642_pgi-ebeln.
it_ekbe_642_pgi_tot-ebelp = it_ekbe_642_pgi-ebelp.
it_ekbe_642_pgi_tot-xblnr = it_ekbe_642_pgi-xblnr.
it_ekbe_642_pgi_tot-budat = it_ekbe_642_pgi-budat.
it_ekbe_642_pgi_tot-menge = it_ekbe_642_pgi-menge.
COLLECT it_ekbe_642_pgi_tot.
ENDLOOP.
Rewards points if helpful.
Regards
Manoj Kumar
‎2007 Dec 19 9:09 AM
hai Shibaji Maitra,
i think ur problem is to collect the fields only when xblnr is changed.if it is right u must use on change of bcz the collect statement collects the field when a single value of left of ur field (it_ekbe_642_pgi_tot) which u are going to collect(it_ekbe_642_pgi_tot) changes.
i think this might be usefull for u.....