Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

collect with inner join

hi all,

I m using below code to get sum according to matnr.

tables : mseg , mkpf.

select msegmatnr msegmenge msegbwart mkpfmblnr

into corresponding fields of table itab

from mseg

inner join mkpf on mkpfmblnr = msegmblnr

and mseg~matnr in matnr

and mseg~bwart in bwart

and mkpf~budat in dat.

collect itab.

but I am not able to get sum for it.

plz help me

Tags:
Former Member
replied

Hi Ankita..

If u want to Use COLLECT then follow this code.

<b>Step 1: Declare itabs like this:</b>

DATA : BEGIN OF ITAB,

MATNR TYPE MSEG-MATNR,

MENGE TYPE MSEG-MENGE,

BWART TYPE MSEG-BWART,

MBLNR TYPE MKPF-MBLNR,

BUDAT TYPE MKPF-BUDAT,

END OF ITAB.

DATA : BEGIN OF ITAB_TOTAL,

MATNR TYPE MSEG-MATNR,

MENGE TYPE MSEG-MENGE,

END OF ITAB_TOTAL.

<b>Step 2: Join like this</b>

select msegmatnr msegmenge msegbwart mkpfmblnr mkpf~budat

into table itab

from mseg

inner join mkpf on mkpfmblnr = msegmblnr

and mseg~matnr in matnr

and mseg~bwart in bwart

and mkpf~budat in dat.

Step 3: Summarize using COLLECT like this

LOOP AT ITAB .

MOVE-CORRESPONDING ITAB TO ITAB_TOTAL.

COLLECT ITAB_TOTAL.

ENDLOOP.

<b>Reward points if helpful</b>

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question