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

grouping

Former Member
0 Likes
789

hi friends,

in the below given description what is the meaning of <b>grouping</b> and could u plz suggest the code for this description.

“MTD Qty Shipped”:

Get MENGE from MSEG where BWART(movement type)=”601” where MSEG-EBELNand [ MKPF-BUDAT within first day of the running month until the running date where MKPF-MBLNR=MSEG-MBLNR]. Do grouping based on [“ship-to number-pseudo no. 5” and MSEG-MATNR].

regards,

siri.

5 REPLIES 5
Read only

dani_mn
Active Contributor
0 Likes
748

HI,

Grouping means subtotals.

Addition of related records.

like we have following records,

A     B     C
dd   abc    1000
dd   abc    1000
ee   kkk    1000
ee   kkk    2000

now grouping on field 'A' means result like this

A     B    C
dd   abc  2000
ee   kkk  3000

Regards,

Read only

Former Member
0 Likes
748

hi,

Data should be selected based on ship-to number and mseg-matnr. we should make use of group by.

Check this thread to get information about group by.

Here is a clear explanation of group by with an example

Regards,

Sailaja.

Read only

Former Member
0 Likes
748

check the logic what i given for ur prev.post after that do like this

grouing means Summation @ there level

like

MATNR MENGE

1000 10kgs

1000 20Kgs

and MTD will be like this

1000 30Kgs.

Regards

Prabhu

Read only

Former Member
0 Likes
748

You can try the following code:

DATA: W_FIRSTDAY LIKE SY-DATUM,

W_MENGE LIKE MSEG-MENGE.

CONCATENATE SY-DATUM(6) '01' INTO W_FIRSTDAY.

TABLES: MKPF, MSEG.

SELECT SUM( MENGE ) INTO W_MENGE FROM MKPF INNER JOIN

MSEG ON MKPFMBLNR = MSEGMBLNR

WHERE BWART = '601' AND

BUDAT >= W_FIRSTDAY AND

BUDAT <= SY-DATUM

GROUP BY KUNNR.

*move w_menge to....

ENDSELECT.

Regards.

p.s. this code does not include all the conditions like EBELN etc..but it may give u some idea

Message was edited by: Akriti

Read only

Former Member
0 Likes
748

In the context of your requirement it is basically wanting you to calculate the Month to Date Shipped qty for the ship-to number and material combination.

Regards

Anurag