Skip to Content
0
Former Member
Jun 04, 2009 at 05:25 AM

Problem with inner joinning mseg and mkpf

386 Views

Hi Experts,

I am developing a report and I am facing a problem in fetching details from joining mseg and mkpf.

As per my requirment I need to fetch data from MBEWH table where the month and year

is fiscal and I have converted to material year.

Now my problem is I need to fetch menge for several movement types from mseg by linking

mkpf budat. I need to split the mkpf~budat into month and year ....

for this I have applied the below code and I am getting dump error in the querry please

advice where I went wrong , else advice is there any other way

note : if I use into corresponding fields its taking huge time for few records

and dump for huge records so I went for into table

DATA: T_MSEG type table of TYP_MSEG.
FIELD-SYMBOLS: <FS_MSEG> type TYP_MSEG

SELECT MSEG~MATNR MSEG~WERKS MSEG~MBLNR MSEG~MJAHR MSEG~BWART
         MSEG~BUKRS MSEG~MENGE MKPF~BUDAT MSEG~SHKZG
   FROM MSEG INNER JOIN MKPF ON MSEG~MBLNR = MKPF~MBLNR
    AND MSEG~MJAHR = MKPF~MJAHR   INTO TABLE T_MSEG
    FOR ALL ENTRIES IN T_TAB
  WHERE MSEG~MATNR EQ T_TAB-MATNR AND MSEG~WERKS EQ T_TAB-BWKEY
    AND MSEG~BWART IN ('301','302','311','312','601','602','641','642').

LOOP AT T_MSEG ASSIGNING <FS_MSEG>.
    MOVE: <FS_MSEG>-BUDAT+0(6) TO IT_MSEG-SPMON,
          <FS_MSEG>-MENGE      TO IT_MSEG-MENGE,
          <FS_MSEG>-BWART      TO IT_MSEG-BWART,
          <FS_MSEG>-WERKS      TO IT_MSEG-WERKS,
          <FS_MSEG>-MATNR      TO IT_MSEG-MATNR,
          <FS_MSEG>-SHKZG      TO IT_MSEG-SHKZG.
    COLLECT IT_MSEG.
  ENDLOOP.

Please advice

Karthik