Skip to Content
0
Former Member
Feb 27, 2007 at 08:39 AM

Error in Report

29 Views

Hello All,

Can Any body explain what went wrong with my code, which i have given below.

if i enter material no and plant in input i am able to get the corect out put. But i f enter only plant no (eg1000) i am not getting all the correct details. Similarly if i enter both storage location, mrp controls in input i am getting the correct results.

if iommitted MRP Control and endtered all the details i am not getting the correct results.

thanks and regards

Madhavi

REPORT Y_MATERIAL_EXTRACTION_2 LINE-SIZE 172

LINE-COUNT 37(5)

NO STANDARD PAGE HEADING.

***********************************************************************

  • T A B L E S *******************

***********************************************************************

TABLES: mara, "GENERAL MASTER DATA

marc, "PLANT DATA FOR MATERIAL

mard, "STORAGE LOCATION DATA FOR MATERIAL

mvke, "SALES DATA FOR MATERIAL

makt. "MATERIAL DESCRIPTION

DATA: r_labst_total LIKE mard-labst VALUE '0'.

***********************************************************************

  • I N T E R N A L T A B L E S *******************

***********************************************************************

DATA:BEGIN OF i_marc OCCURS 0,

matnr LIKE marc-matnr,

werks LIKE marc-werks,

dispo LIKE marc-dispo,

END OF i_marc.

DATA:BEGIN OF i_mard OCCURS 0,

matnr LIKE mard-matnr,

lgort LIKE mard-lgort,

labst LIKE mard-labst,

END OF i_mard.

DATA: BEGIN OF i_mvke OCCURS 0,

matnr LIKE mvke-matnr,

vkorg LIKE mvke-vkorg,

vtweg LIKE mvke-vtweg,

END OF i_mvke.

DATA: BEGIN OF i_out occurs 0,

matnr LIKE marc-matnr,

werks LIKE marc-werks,

dispo LIKE marc-dispo,

mbrsh LIKE mara-mbrsh,

meins LIKE mara-meins,

matkl LIKE mara-matkl,

vkorg LIKE mvke-vkorg,

vtweg LIKE mvke-vtweg,

spras LIKE makt-spras,

maktx LIKE makt-maktx,

lgort LIKE mard-lgort,

labst LIKE mard-labst,

labst_total LIKE mard-labst,

END OF i_out.

***********************************************************************

  • S T A R T - O F - S E L EC T I O N *******************

***********************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-100.

SELECT-OPTIONS: s_matnr FOR marc-matnr, "OBLIGATORY,

s_lgort FOR mard-lgort,

s_dispo FOR marc-dispo.

PARAMETERS: p_werks LIKE marc-werks. "OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

***********************************************************************

  • S T A R T - O F - S E L EC T I O N *******************

***********************************************************************

START-OF-SELECTION.

SELECT matnr werks dispo

FROM marc

INTO TABLE i_marc

WHERE matnr IN s_matnr

AND werks EQ p_werks

AND dispo IN s_dispo.

IF i_marc[] IS INITIAL.

WRITE:/'NO MATCHING DATA IS FOUND FROM TABLE MARC'.

EXIT.

ENDIF.

SELECT matnr lgort labst

FROM mard

INTO TABLE i_mard

FOR ALL ENTRIES IN i_marc

WHERE matnr = i_marc-matnr

AND werks EQ p_werks

AND lgort IN s_lgort.

IF i_mard[] IS INITIAL.

WRITE:/ 'NO MATCHING DATA IS SELECTED FROM TABLE MARD'.

EXIT.

ENDIF.

SELECT matnr vkorg vtweg

FROM mvke

INTO TABLE i_mvke

FOR ALL ENTRIES IN i_marc

WHERE matnr = i_marc-matnr.

IF i_mvke[] IS INITIAL.

WRITE:/ 'NO MATCHING DATA IS SELECTED FROM TABLE MVKE'.

EXIT.

ENDIF.

LOOP AT i_marc.

MOVE-CORRESPONDING i_marc TO i_out.

CLEAR marc.

SELECT SINGLE matnr mbrsh meins matkl

FROM mara

INTO CORRESPONDING FIELDS OF mara

WHERE matnr = i_out-matnr.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING mara TO i_out.

ELSE.

CONTINUE.

ENDIF.

SELECT SINGLE matnr spras maktx

FROM makt

INTO CORRESPONDING FIELDS OF makt

WHERE matnr = i_out-matnr

AND spras = SY-LANGU.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING makt TO i_out.

ENDIF.

LOOP AT i_mard WHERE matnr = i_marc-matnr.

MOVE:i_mard-lgort TO i_out-lgort,

i_mard-labst TO i_out-labst.

  • APPEND i_out.

  • ENDLOOP.

LOOP AT i_mvke WHERE matnr = i_marc-matnr.

MOVE:i_mvke-vkorg TO i_out-vkorg,

i_mvke-vtweg TO i_out-vtweg.

APPEND i_out.

ENDLOOP.

CLEAR i_out.

ENDLOOP.

ENDLOOP.

************************************************************************

  • DISPLAYIING FROM I-OUT ********************************

************************************************************************

SORT i_out BY matnr.

LOOP AT i_out.

WRITE: SY-VLINE, 5 i_out-matnr,SY-VLINE,

25 i_out-werks,SY-VLINE,

31 i_out-dispo,SY-VLINE,

36 i_out-mbrsh,SY-VLINE,

40 i_out-meins,SY-VLINE,

45 i_out-matkl,SY-VLINE,

60 i_out-vkorg,SY-VLINE,

70 i_out-vtweg,SY-VLINE,

80 i_out-maktx,SY-VLINE,

125 i_out-lgort,SY-VLINE,

132 i_out-labst,SY-VLINE.

r_labst_total = r_labst_total + i_out-labst.

AT END OF labst.

WRITE: r_labst_total COLOR 6,

SY-VLINE.

WRITE:/ SY-ULINE.

ENDAT.

AT LAST.

SKIP 2.

WRITE: /50 'Total Stock = ' COLOR 3,r_labst_total COLOR 4.

ENDAT.

ENDLOOP.

***********************************************************************

  • E N D - O F - S E L EC T I O N ***********************

***********************************************************************

END-OF-SELECTION.

***********************************************************************

  • T O P - O F - P A G E ************************

***********************************************************************

TOP-OF-PAGE.

WRITE: 60 'MATERIAL MASTER EXTRACTION REPORT' COLOR COL_GROUP,

SY-ULINE.

WRITE: /6 'MATERIAL_NO',

25 'PLANT',

31 'MRP',

35 'IND',

39 'BUOM',

46 'GROUP',

56 'SALES_ORG',

67 'D_CHNL',

82 'DESCRIPTION',

124 'S_LOC',

137 'STOCK',

153 'CUMULATIVE STOCK'.

WRITE SY-ULINE.

***********************************************************************

  • E N D - O F - P A G E ************************

***********************************************************************

END-OF-PAGE.

WRITE: /85 'PAGNO: ',SY-PAGNO,

SY-ULINE.