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

getting the quantity

Former Member
0 Likes
847

hi Guru's

i have trouble in getting the menge.


   Select sum(menge)
   into output_tab-menge
   WHERE MKPF.MBLNR = MSEG.MBLNR 
   and MKPF-MJAHR = MSEG-MBLNR
   AND SPMON(MKPF.BUDAT) = SPMON (PA-BUMON)       
   AND SPMON (MKPF.BUDAT) = SPMON (PA-BUMON)      
   AND MKPF-WERKS = PA-WERKS.
   AND MSEG-BWART IN PA-BWART
   AND MSEG-MATNR = INPUT_TAB-MATNR.
 

and it is always prompt "incorrect expression"

thank you in advace.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816

Hi Dranel,

Correct your query.

Select sum(menge)

into output_tab-menge from MKPF

WHERE MKPF.MBLNR = MSEG.MBLNR

and MKPF-MJAHR = MSEG-MBLNR

AND SPMON(MKPF.BUDAT) = SPMON (PA-BUMON)

AND SPMON (MKPF.BUDAT) = SPMON (PA-BUMON)

AND MKPF-WERKS = PA-WERKS.

AND MSEG-BWART IN PA-BWART

AND MSEG-MATNR = INPUT_TAB-MATNR.

Regards,

Vijay

6 REPLIES 6
Read only

Former Member
0 Likes
817

Hi Dranel,

Correct your query.

Select sum(menge)

into output_tab-menge from MKPF

WHERE MKPF.MBLNR = MSEG.MBLNR

and MKPF-MJAHR = MSEG-MBLNR

AND SPMON(MKPF.BUDAT) = SPMON (PA-BUMON)

AND SPMON (MKPF.BUDAT) = SPMON (PA-BUMON)

AND MKPF-WERKS = PA-WERKS.

AND MSEG-BWART IN PA-BWART

AND MSEG-MATNR = INPUT_TAB-MATNR.

Regards,

Vijay

Read only

0 Likes
816

hi Vijay,

the error occurs when i modify the code <unknown column name "MENGE"> i already try to change the table and fields that i used but still the error occurs.

loop at mseg_tab.

AT NEW menge.

SUM.

wkl-qty = mseg-menge.

ENDAT.

ENDLOOP.

select sum( menge )

INTO OUTPUT_TAB-menge

FROM MKPF

WHERE MKPF.MBLNR = MSEG.MBLNR

and MKPF-MJAHR = MSEG-MJAHR

AND SPMON(MKPF.BUDAT) = SPMON (PA-BUMON)

AND SPMON (MKPF.BUDAT) = SPMON (PA-BUMON)

AND MKPF-WERKS = PA-WERKS.

AND MSEG-BWART IN PA-BWART

AND MSEG-MATNR = INPUT_TAB-MATNR.

endselect.

is it OK??.,

Read only

0 Likes
816

Hello

Table MKPF not contain field MENGE. Thif field is present in table MSEG.

Try to change table in your query.

Read only

Former Member
0 Likes
816

Hi,

Add the FROM table clause in the select statement as below


  Select sum(menge)
   into output_tab-menge
  FROM MKPF
  WHERE MKPF.MBLNR = MSEG.MBLNR 
   and MKPF-MJAHR = MSEG-MBLNR
   AND SPMON(MKPF.BUDAT) = SPMON (PA-BUMON)       
   AND SPMON (MKPF.BUDAT) = SPMON (PA-BUMON)      
   AND MKPF-WERKS = PA-WERKS.
   AND MSEG-BWART IN PA-BWART
   AND MSEG-MATNR = INPUT_TAB-MATNR.

Regards,

Vik

Read only

Former Member
0 Likes
816

Hi,

You have missed the FROM clause.

Read only

Former Member
0 Likes
816

MKPF.MBLNR = MSEG.MBLNR is okay

but how can

MKPF-MJAHR be equal to MSEG-MBLNR? You should be having a fiscal year type here, dont you think??

Rgsa

Sameer