Skip to Content

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

converting rows to horizontal display

Dear all,

I am displaying the values of material usage monthwise.These are being displayed vertically.Could you please tell me how to display this horizontally.

Also i want to sum up the usage.

Also i want to dispaly the count ,where count is the number of times that material has been used in that given period. i am also posting my code.

currently it is as follows:- (eg)

Material Period Quantity

Mat A 02.2007 2.000

Mat A 04.2007 1.000

Mat B 05.2007 3.000

Mat B 08.2007 1.000

Mat B 09.2007 2.000 and so on.....

I want it as follows:-

Material 02.2007 04.2007 05.2007 08.2007 09.2007 Total Count

Mat A 2.000 1.000 0 0 0 3 2

Mat B 0 0 3.000 1.000 2.000 6 3

&----


*& Report ZMM_MATERIAL_USAGE

----


  • MODULE : Material Management *

----


  • Objective - To show Monthly Report for Material Usage * *

  • Program - Updates Tables ( ) Downloads data ( ) *

  • - Outputs List ( ) * *

  • Date Created - 22-11-2007 *

  • Request ID - EC2K913084 *

  • Author - Rahul Bhat *

  • Location - Mumbai *

  • LDB - NA *

----


REPORT ZMM_MATERIAL_USAGE.

----


  • Types Begin with TY_ *

----


  • Internal Table Structure

*TYPES: BEGIN OF TY_MARC , "Plant Data for Material

  • MATNR TYPE MARC-MATNR, "Material Number

  • WERKS TYPE MARC-WERKS, "Plant

  • END OF TY_MARC .

*

*TYPES: BEGIN OF TY_MARA ,

  • MATNR TYPE MARA-MATNR, "Material Number

  • MTART TYPE MARA-MTART, "Material type

  • SPART TYPE MARA-SPART, "Division

  • WERKS TYPE MARC-WERKS, "Plant

  • END OF TY_MARA .

TYPES: BEGIN OF TY_ZV_OLR3_MARACKT , "Plant Material: Search Help with Short Text

MATNR TYPE MARA-MATNR , "Material Number

WERKS TYPE MARC-WERKS , "Plant

MTART TYPE MARA-MTART , "Material Type

MAKTX TYPE MAKT-MAKTX , "Material Description

SPART TYPE MARA-SPART , "Division

END OF TY_ZV_OLR3_MARACKT .

TYPES: BEGIN OF TY_MBEW , "Material Valuation

MATNR TYPE MBEW-MATNR , "Material Number

BWKEY TYPE MBEW-BWKEY , "Valuation area

BWTAR TYPE MBEW-BWTAR , "Valuation type

VERPR TYPE MBEW-VERPR , "Moving Average Price/Periodic Unit Price

END OF TY_MBEW .

*TYPES: BEGIN OF TY_MKPF , "Header: Material Document

  • MBLNR TYPE MKPF-MBLNR , "Number of Material Document

  • MJAHR TYPE MKPF-MJAHR , "Material Document Year

  • BUDAT TYPE MKPF-BUDAT , "Posting Date in the Document

  • END OF TY_MKPF .

*TYPES: BEGIN OF TY_MSEG , "Document Segment: Material

  • MBLNR TYPE MSEG-MBLNR , "Number of Material Document

  • MJAHR TYPE MSEG-MJAHR , "Document Segment: Material

  • ZEILE TYPE MSEG-ZEILE , "Item in Material Document

  • BWART TYPE MSEG-BWART , "Movement Type (Inventory Management)

  • MENGE TYPE MSEG-MENGE , "Quantity

  • MEINS TYPE MSEG-MEINS , "Base Unit of Measure

  • MATNR TYPE MSEG-MATNR , "Material Number

  • END OF TY_MSEG .

TYPES: BEGIN OF TY_WB2_V_MKPF_MSEG2 , "Data Selection from Material Documents

MBLNR TYPE MSEG-MBLNR , "Number of Material Document

MJAHR TYPE MSEG-MJAHR , "Document Segment: Material

BUDAT TYPE MKPF-BUDAT , "Posting Date in the Document

ZEILE_I TYPE MSEG-ZEILE , "Item in Material Document

BWART_I TYPE MSEG-BWART , "Movement Type (Inventory Management)

MENGE_I TYPE MSEG-MENGE , "Quantity

MEINS_I TYPE MSEG-MEINS , "Base Unit of Measure

MATNR_I TYPE MSEG-MATNR , "Material Number

WERKS_I TYPE MSEG-WERKS , "Plant

END OF TY_WB2_V_MKPF_MSEG2 .

TYPES: BEGIN OF TY_WB2_V_MKPF_MSEG2_COPY , "Copy of Data Selection from Material Documents

MATNR_I TYPE MSEG-MATNR , "Material Number

FYEAR(4) TYPE C , "Fiscal Year

MONTH(2) TYPE C , "Month

BWART_I TYPE MSEG-BWART , "Movement Type (Inventory Management)

MBLNR TYPE MSEG-MBLNR , "Number of Material Document

MJAHR TYPE MSEG-MJAHR , "Document Segment: Material

BUDAT TYPE MKPF-BUDAT , "Posting Date in the Document

ZEILE_I TYPE MSEG-ZEILE , "Item in Material Document

MENGE_I TYPE MSEG-MENGE , "Quantity

MEINS_I TYPE MSEG-MEINS , "Base Unit of Measure

WERKS_I TYPE MSEG-WERKS ,

COUNT TYPE I ,

  • USAGE TYPE MSEG-MENGE ,

END OF TY_WB2_V_MKPF_MSEG2_COPY .

----


  • Internal Tables Begin with IT_

  • Work Area Begin with WA_ *

----


*Internal Table Declaration.

*DATA: IT_MARC TYPE STANDARD TABLE OF TY_MARC ,

  • WA_MARC TYPE TY_MARC .

*

*DATA: IT_MARA TYPE STANDARD TABLE OF TY_MARA ,

  • WA_MARA TYPE TY_MARA .

DATA: IT_MATERIAL TYPE STANDARD TABLE OF TY_ZV_OLR3_MARACKT ,

WA_MATERIAL TYPE TY_ZV_OLR3_MARACKT .

DATA: IT_MBEW TYPE STANDARD TABLE OF TY_MBEW ,

WA_MBEW TYPE TY_MBEW .

*DATA: IT_MKPF TYPE STANDARD TABLE OF TY_MKPF ,

  • WA_MKPF TYPE TY_MKPF .

*

*DATA: IT_MSEG TYPE STANDARD TABLE OF TY_MSEG ,

  • WA_MSEG TYPE TY_MSEG .

DATA: IT_VIEW TYPE STANDARD TABLE OF TY_WB2_V_MKPF_MSEG2 ,

WA_VIEW TYPE TY_WB2_V_MKPF_MSEG2 .

DATA: IT_VIEW_COPY TYPE STANDARD TABLE OF TY_WB2_V_MKPF_MSEG2_COPY ,

WA_VIEW_COPY TYPE TY_WB2_V_MKPF_MSEG2_COPY ,

IT_VIEW_TMP TYPE STANDARD TABLE OF TY_WB2_V_MKPF_MSEG2_COPY ,

WA_VIEW_TMP TYPE TY_WB2_V_MKPF_MSEG2_COPY .

----


  • Data(Workfield) Begin with W_ *

----


  • Data Declaration

----


  • Work field declaration - used in program

DATA: W_PERIOD TYPE S031-SPMON.

DATA: W_INDEX TYPE SY-TABIX .

DATA: W_QTY_TOT TYPE MENGE_D .

DATA: TOT_USE_TMP TYPE MENGE_D ,

TOT_USE TYPE MENGE_D ,

W_COUNT TYPE I .

RANGES: RO_DATE FOR SY-DATUM .

----


  • Parameters Begin with PR_ *

----


SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

PARAMETERS: PR_WERKS TYPE MARC-WERKS OBLIGATORY ,

PR_MTART TYPE MARA-MTART OBLIGATORY ,

PR_SPART TYPE MARA-SPART OBLIGATORY ,

PR_MATNR TYPE MARA-MATNR .

----


  • Select Options Begin with SO_ *

----


SELECT-OPTIONS: SO_SPMON FOR W_PERIOD .

SELECTION-SCREEN END OF BLOCK blk1 .

----


  • At selection-screen *

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR SO_SPMON-LOW.

PERFORM F4_HELP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR SO_SPMON-HIGH.

PERFORM F4_HELP.

&----


*& Form F4_HELP

&----


  • Text-F4 Help for Month

  • -Taken from standard SAP program RMCS0F0M.

----


FORM F4_HELP .

DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1 .

INCLUDE STRUCTURE DYNPREAD .

DATA: END OF MF_DYNPFIELDS .

DATA: MF_RETURNCODE LIKE SY-SUBRC ,

MF_MONTH LIKE ISELLIST-MONTH,

MF_HLP_REPID LIKE SY-REPID .

FIELD-SYMBOLS: <MF_FELD> .

*Worth reading screen

GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.

APPEND MF_DYNPFIELDS.

MF_HLP_REPID = SY-REPID.

DO 2 TIMES.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = MF_HLP_REPID

DYNUMB = SY-DYNNR

TABLES

DYNPFIELDS = MF_DYNPFIELDS

EXCEPTIONS

INVALID_ABAPWORKAREA = 01

INVALID_DYNPROFIELD = 02

INVALID_DYNPRONAME = 03

INVALID_DYNPRONUMMER = 04

INVALID_REQUEST = 05

NO_FIELDDESCRIPTION = 06

UNDEFIND_ERROR = 07.

IF SY-SUBRC = 3.

*Current screen is a range image

MF_HLP_REPID = 'SAPLALDB'.

ELSE.

READ TABLE MF_DYNPFIELDS INDEX 1.

*Underscores replaced by Blanks

TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.

EXIT.

ENDIF.

ENDDO.

IF SY-SUBRC = 0.

*The internal format conversion

CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'

EXPORTING

INPUT = MF_DYNPFIELDS-FIELDVALUE

IMPORTING

OUTPUT = MF_MONTH

EXCEPTIONS

ERROR_MESSAGE = 1.

IF MF_MONTH IS INITIAL.

*Initial month => Proposal value of akt. Date deduced

MF_MONTH = SY-DATLO(6).

ENDIF.

CALL FUNCTION 'POPUP_TO_SELECT_MONTH'

EXPORTING

ACTUAL_MONTH = MF_MONTH

IMPORTING

SELECTED_MONTH = MF_MONTH

RETURN_CODE = MF_RETURNCODE

EXCEPTIONS

FACTORY_CALENDAR_NOT_FOUND = 01

HOLIDAY_CALENDAR_NOT_FOUND = 02

MONTH_NOT_FOUND = 03.

IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.

CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'

EXPORTING

INPUT = MF_MONTH

IMPORTING

OUTPUT = MF_DYNPFIELDS-FIELDVALUE.

COLLECT MF_DYNPFIELDS.

CALL FUNCTION 'DYNP_VALUES_UPDATE'

EXPORTING

DYNAME = MF_HLP_REPID

DYNUMB = SY-DYNNR

TABLES

DYNPFIELDS = MF_DYNPFIELDS

EXCEPTIONS

INVALID_ABAPWORKAREA = 01

INVALID_DYNPROFIELD = 02

INVALID_DYNPRONAME = 03

INVALID_DYNPRONUMMER = 04

INVALID_REQUEST = 05

NO_FIELDDESCRIPTION = 06

UNDEFIND_ERROR = 07.

ENDIF.

ENDIF.

ENDFORM. " F4_HELP

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

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

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

START-OF-SELECTION .

PERFORM CONVERT_MMYYYY_TO_DDMMYYY.

PERFORM GET_DATA.

&----


*& Form CONVERT_MMYYYY_TO_DDMMYYY

&----


  • Text-In Selection Screen we give date in MM.YYYY format

  • This cannot be passed to standard table.

  • Hence first convert it to DD.MM.YYYY format.

----


FORM CONVERT_MMYYYY_TO_DDMMYYY .

DATA: LW_VAR TYPE I . "LW-Local Workfield

DATA: LW_DATE1 TYPE SY-DATUM ,

LW_DATE2 TYPE SY-DATUM .

DATA: LW_STR_LOW TYPE STRING,

LW_STR_LOW1 TYPE STRING,

LW_STR_LOW2 TYPE STRING.

DATA: LW_STR_HIGH TYPE STRING,

LW_STR_HIGH1 TYPE STRING,

LW_STR_HIGH2 TYPE STRING.

LW_STR_LOW1 = SO_SPMON-LOW+0(4).

LW_STR_LOW2 = SO_SPMON-LOW+4(2).

CONCATENATE LW_STR_LOW1 LW_STR_LOW2 '01' INTO LW_STR_LOW.

LW_DATE1 = LW_STR_LOW.

*WRITE LW_DATE1.

LW_STR_HIGH1 = SO_SPMON-HIGH+0(4).

LW_STR_HIGH2 = SO_SPMON-HIGH+4(2).

IF LW_STR_HIGH2 = '01' OR

LW_STR_HIGH2 = '03' OR

LW_STR_HIGH2 = '05' OR

LW_STR_HIGH2 = '07' OR

LW_STR_HIGH2 = '08' OR

LW_STR_HIGH2 = '10' OR

LW_STR_HIGH2 = '12'.

CONCATENATE LW_STR_HIGH1 LW_STR_HIGH2 '31' INTO LW_STR_HIGH.

LW_DATE2 = LW_STR_HIGH.

  • WRITE LW_DATE2.

ELSEIF LW_STR_HIGH2 = '04' OR

LW_STR_HIGH2 = '06' OR

LW_STR_HIGH2 = '09' OR

LW_STR_HIGH2 = '11'.

CONCATENATE LW_STR_HIGH1 LW_STR_HIGH2 '30' INTO LW_STR_HIGH.

LW_DATE2 = LW_STR_HIGH.

  • WRITE LW_DATE2.

*Logic to check for Leap Year:-

*For all years that are multiples of 100,we need to test if its divisible by 400

*(instead of 4).If yes, then we can be sure that the year is a Leap Year.

ELSEIF LW_STR_HIGH2 = '02'.

*Begin:-To check for Leap Year when February.

LW_VAR = LW_STR_HIGH1 MOD 100.

IF LW_VAR EQ 0.

LW_VAR = LW_STR_HIGH1 MOD 400.

IF LW_VAR EQ 0.

CONCATENATE LW_STR_HIGH1 LW_STR_HIGH2 '29' INTO LW_STR_HIGH.

LW_DATE2 = LW_STR_HIGH.

  • WRITE LW_DATE2.

ELSE.

CONCATENATE LW_STR_HIGH1 LW_STR_HIGH2 '28' INTO LW_STR_HIGH.

LW_DATE2 = LW_STR_HIGH.

  • WRITE LW_DATE2.

ENDIF.

ELSEIF LW_VAR NE 0.

LW_VAR = LW_STR_HIGH1 MOD 4.

IF LW_VAR EQ 0.

CONCATENATE LW_STR_HIGH1 LW_STR_HIGH2 '29' INTO LW_STR_HIGH.

LW_DATE2 = LW_STR_HIGH.

  • WRITE LW_DATE2.

ELSE.

CONCATENATE LW_STR_HIGH1 LW_STR_HIGH2 '28' INTO LW_STR_HIGH.

LW_DATE2 = LW_STR_HIGH.

  • WRITE LW_DATE2.

ENDIF.

ENDIF.

*End:-To check for Leap Year when February.

ENDIF.

*Since we have low and high dates in two different strings,they directly

*cannot be passed to standard table (MSEG).So we first get them into RO_DATE.

RO_DATE-SIGN = 'I'.

RO_DATE-OPTION = 'BT'.

RO_DATE-LOW = LW_DATE1.

RO_DATE-HIGH = LW_DATE2.

APPEND RO_DATE.

ENDFORM. " CONVERT_MMYYYY_TO_DDMMYYY

&----


*& Form GET_DATA

&----


  • Text

----


FORM GET_DATA .

**Select fired on MARC to get only those materials of whose plant has been

**given on Selection Screen.

  • IF PR_MATNR EQ ''.

  • SELECT MATNR WERKS

  • FROM MARC

  • INTO TABLE IT_MARC

  • WHERE WERKS EQ PR_WERKS.

  • ELSE.

  • SELECT MATNR WERKS

  • FROM MARC

  • INTO TABLE IT_MARC

  • WHERE MATNR EQ PR_MATNR AND

  • WERKS EQ PR_WERKS.

  • ENDIF.

*

**If records are found then get material type and division from MARA for

**materials got from MARC.

  • IF SY-SUBRC = 0.

  • SELECT MATNR MTART SPART

  • FROM MARA

  • INTO TABLE IT_MARA

  • FOR ALL ENTRIES IN IT_MARC

  • WHERE MATNR EQ IT_MARC-MATNR.

  • ENDIF.

*

**Filtering out those materials on the basis of material type and division

**that is given on Selection Screen.

  • LOOP AT IT_MARA INTO WA_MARA.

  • W_INDEX = SY-TABIX.

  • IF WA_MARA-MTART NE PR_MTART OR WA_MARA-SPART NE PR_SPART.

  • DELETE IT_MARA INDEX W_INDEX.

  • ELSE.

  • MOVE: PR_WERKS TO WA_MARA-WERKS.

  • MODIFY IT_MARA FROM WA_MARA TRANSPORTING WERKS.

  • CLEAR: WA_MARA.

  • ENDIF.

  • ENDLOOP.

*Select fired on view ZV_OLR3_MARACKT which results in above 3 steps together

IF PR_MATNR EQ ''.

SELECT MATNR WERKS MTART MAKTX SPART

FROM ZV_OLR3_MARACKT

INTO TABLE IT_MATERIAL

WHERE WERKS EQ PR_WERKS AND

MTART EQ PR_MTART AND

SPART EQ PR_SPART.

ELSE.

SELECT MATNR WERKS MTART MAKTX SPART

FROM ZV_OLR3_MARACKT

INTO TABLE IT_MATERIAL

WHERE MATNR EQ PR_MATNR AND

WERKS EQ PR_WERKS AND

MTART EQ PR_MTART AND

SPART EQ PR_SPART.

ENDIF.

  • SORT IT_MARA BY MATNR.

SORT IT_MATERIAL BY MATNR.

*Select fired on MBEW to get Rate (VERPR) on basis of material and plant

*in IT_MARA.

  • SELECT MATNR BWKEY BWTAR VERPR

  • FROM MBEW

  • INTO TABLE IT_MBEW

  • FOR ALL ENTRIES IN IT_MARA

  • WHERE MATNR EQ IT_MARA-MATNR AND

  • BWKEY EQ IT_MARA-WERKS.

  • SELECT MATNR BWKEY BWTAR VERPR

  • FROM MBEW

  • INTO TABLE IT_MBEW

  • FOR ALL ENTRIES IN IT_MATERIAL

  • WHERE MATNR EQ IT_MATERIAL-MATNR AND

  • BWKEY EQ IT_MATERIAL-WERKS.

*

  • IF SY-SUBRC = 0.

    • Do Nothing.

  • ENDIF.

**Select fired on MKPF to get Document Number on basis of period given on

**selection screen.

  • SELECT MBLNR MJAHR BUDAT

  • FROM MKPF

  • INTO TABLE IT_MKPF

  • WHERE BUDAT IN RO_DATE.

*

**If records are found then pass Document Number (MBLNR) to MSEG Table.

  • IF SY-SUBRC = 0.

  • SELECT MBLNR MJAHR ZEILE BWART MENGE MEINS MATNR

  • FROM MSEG

  • INTO TABLE IT_MSEG

  • FOR ALL ENTRIES IN IT_MKPF

  • WHERE MBLNR EQ IT_MKPF-MBLNR AND

  • BWART IN ('261','262','601','602').

  • SORT IT_MSEG BY BWART MATNR.

  • ENDIF.

*Select fired on View WB2_V_MKPF_MSEG2 to get required common fields of

*Table MKPF and MSEG.Also above commented coded is thus avoided.

SELECT MBLNR

MJAHR

BUDAT

ZEILE_I

BWART_I

MENGE_I

MEINS_I

MATNR_I

WERKS_I

FROM WB2_V_MKPF_MSEG2

INTO TABLE IT_VIEW

WHERE BUDAT IN RO_DATE AND

BWART_I IN ('261','262','601','602') AND

WERKS_I EQ PR_WERKS.

*If records are found then read table MARA for which existing records

*are moved to copy table.

IF SY-SUBRC EQ 0.

SORT IT_VIEW BY MATNR_I.

LOOP AT IT_VIEW INTO WA_VIEW.

W_INDEX = SY-TABIX.

  • READ TABLE IT_MARA INTO WA_MARA WITH KEY MATNR = WA_VIEW-MATNR_I.

READ TABLE IT_MATERIAL INTO WA_MATERIAL WITH KEY MATNR = WA_VIEW-MATNR_I.

IF SY-SUBRC NE 0.

DELETE IT_VIEW INDEX W_INDEX.

ELSE.

MOVE-CORRESPONDING: WA_VIEW TO WA_VIEW_COPY.

MOVE: WA_VIEW-BUDAT+0(4) TO WA_VIEW_COPY-FYEAR,

WA_VIEW-BUDAT+4(2) TO WA_VIEW_COPY-MONTH.

APPEND WA_VIEW_COPY TO IT_VIEW_COPY.

CLEAR WA_VIEW_COPY.

ENDIF.

  • CLEAR: WA_VIEW,WA_MARA.

CLEAR: WA_VIEW,WA_MATERIAL.

ENDLOOP.

ENDIF.

*Sorting on basis of material year and month,processing event will be triggered

*at end of month.

SORT IT_VIEW_COPY BY MATNR_I FYEAR MONTH.

*On basis of movement type (BWART),calculation of exact quantity of material

*used in a particular month.(Processing Event used here)

LOOP AT IT_VIEW_COPY INTO WA_VIEW_COPY.

MOVE WA_VIEW_COPY TO WA_VIEW_TMP.

IF WA_VIEW_COPY-BWART_I = '261' OR WA_VIEW_COPY-BWART_I = '601'.

W_QTY_TOT = W_QTY_TOT + WA_VIEW_COPY-MENGE_I.

ENDIF.

IF WA_VIEW_COPY-BWART_I = '262' OR WA_VIEW_COPY-BWART_I = '602'.

W_QTY_TOT = W_QTY_TOT - WA_VIEW_COPY-MENGE_I.

ENDIF.

AT END OF MONTH.

W_COUNT = W_COUNT + 1.

  • TOT_USE = TOT_USE + W_QTY_TOT.

MOVE: W_QTY_TOT TO WA_VIEW_TMP-MENGE_I,

W_COUNT TO WA_VIEW_TMP-COUNT .

  • TOT_USE TO WA_VIEW_TMP-USAGE .

APPEND WA_VIEW_TMP TO IT_VIEW_TMP.

CLEAR: WA_VIEW_TMP,W_QTY_TOT,W_COUNT."TOT_USE.

ENDAT.

CLEAR: WA_VIEW_COPY,WA_VIEW_TMP.

ENDLOOP.

SORT IT_VIEW_TMP BY MATNR_I.

IF PR_MTART EQ 'FERT'.

SELECT MATNR BWKEY BWTAR VERPR

FROM MBEW

INTO TABLE IT_MBEW

FOR ALL ENTRIES IN IT_VIEW_TMP

WHERE MATNR EQ IT_VIEW_TMP-MATNR_I AND

BWTAR EQ 'NEW VEH' AND

BWKEY EQ IT_VIEW_TMP-WERKS_I.

ELSEIF PR_MTART EQ 'HALB'.

SELECT MATNR BWKEY BWTAR VERPR

FROM MBEW

INTO TABLE IT_MBEW

FOR ALL ENTRIES IN IT_VIEW_TMP

WHERE MATNR EQ IT_VIEW_TMP-MATNR_I AND

BWTAR EQ 'M&M' AND

BWKEY EQ IT_VIEW_TMP-WERKS_I.

ELSEIF PR_MTART EQ 'ZHLB'.

SELECT MATNR BWKEY BWTAR VERPR

FROM MBEW

INTO TABLE IT_MBEW

FOR ALL ENTRIES IN IT_VIEW_TMP

WHERE MATNR EQ IT_VIEW_TMP-MATNR_I AND

BWTAR EQ 'LOCAL' AND

BWKEY EQ IT_VIEW_TMP-WERKS_I.

ENDIF.

DATA: STRING TYPE STRING.

IF SY-SUBRC = 0.

SORT IT_MBEW BY MATNR.

WRITE: 20 SY-VLINE,49 SY-VLINE,70 SY-VLINE COLOR 4.

WRITE: 05'MATNR' ,40'PERIOD',60'QUANTITY'.

WRITE:SY-ULINE.

LOOP AT IT_VIEW_TMP INTO WA_VIEW_TMP.

WRITE: 20 SY-VLINE, 49 SY-VLINE,70 SY-VLINE.

CONCATENATE WA_VIEW_TMP-MONTH '.' WA_VIEW_TMP-FYEAR INTO STRING.

TOT_USE_TMP = WA_VIEW_TMP-MENGE_I.

AT END OF MONTH.

TOT_USE = TOT_USE + TOT_USE_TMP.

W_COUNT = W_COUNT + 1.

WRITE: / WA_VIEW_TMP-MATNR_I,STRING,TOT_USE_TMP,W_COUNT.

CLEAR W_COUNT.

ENDAT.

AT END OF MATNR_I.

WRITE: SY-ULINE.

  • W_COUNT = W_COUNT + 1.

  • WRITE: / WA_VIEW_TMP-MATNR_I,STRING,TOT_USE,W_COUNT.

CLEAR TOT_USE.

ENDAT.

ENDLOOP.

ENDIF.

ENDFORM. " GET_DATA

Tags:
Not what you were looking for? View more on this topic or Ask a question