Make your own free website on Tripod.com

Units of Measure

* Extract the Unit of Conversion from Material Master
REPORT ZUNT MESSAGE-ID Z1
        LINE-SIZE 195 NO STANDARD PAGE HEADING LINE-COUNT 060(001).

TABLES: MARM,         " Units of Measure
        MARC,         " Material Master: C Segment
        MARA,         " Material Master: General Data
        EINE,         " Purchasing Info Record - Purchasing Organization
        EINA.         " Purchasing Info Record - General Data

SELECT-OPTIONS X_WERKS FOR MARC-WERKS.
SELECT-OPTIONS X_MTART FOR MARA-MTART.
SELECT-OPTIONS X_MEINS FOR MARA-MEINS.
SELECT-OPTIONS X_MATNR FOR MARM-MATNR.
SELECT-OPTIONS X_ESOKZ FOR EINE-ESOKZ.

DATA: BEGIN OF INT_MARC OCCURS 0,
      WERKS LIKE MARC-WERKS,
      MTART LIKE MARA-MTART,
      MATNR LIKE MARC-MATNR,
      MEINS LIKE MARA-MEINS,
      UMREN LIKE MARM-UMREN,
      UMREZ LIKE MARM-UMREZ,
      MEINH LIKE MARM-MEINH,
      ESOKZ LIKE EINE-ESOKZ,
      END OF INT_MARC.

SELECT * FROM MARC.
  CHECK X_WERKS.

  CLEAR MARM.
  SELECT SINGLE * FROM MARM WHERE MATNR = MARC-MATNR.
  CHECK SY-SUBRC = 0.

  CLEAR MARA.
  SELECT SINGLE * FROM MARA WHERE MATNR = MARC-MATNR.
  CHECK X_MTART.
  CHECK X_MEINS.
  CHECK MARA-LVORM = SPACE.

  CLEAR EINA.
  SELECT SINGLE * FROM EINA WHERE MATNR = MARC-MATNR
                              AND LOEKZ = SPACE.

  CLEAR EINE.
  SELECT SINGLE * FROM EINE WHERE INFNR = EINA-INFNR
                              AND LOEKZ = SPACE.
  CHECK X_ESOKZ.

  INT_MARC-WERKS = MARC-WERKS.
  INT_MARC-MTART = MARA-MTART.
  INT_MARC-MATNR = MARC-MATNR.
  INT_MARC-MEINS = MARA-MEINS.
  INT_MARC-UMREN = MARM-UMREN.
  INT_MARC-UMREZ = MARM-UMREZ.
  INT_MARC-MEINH = MARM-MEINH.
  INT_MARC-ESOKZ = EINE-ESOKZ.
  APPEND INT_MARC.
  CLEAR  INT_MARC.

ENDSELECT.

SORT INT_MARC BY WERKS ESOKZ MTART MATNR.
MESSAGE I086 WITH 'loop at int_marc'.
LOOP AT INT_MARC.
  FORMAT COLOR COL_GROUP.
  WRITE: / INT_MARC-WERKS UNDER 'Plt',
           INT_MARC-MTART UNDER 'M.Type',
           INT_MARC-MATNR UNDER 'Material',
           INT_MARC-MEINS UNDER 'Unit',
           INT_MARC-UMREN UNDER 'Denom',
           INT_MARC-UMREZ UNDER 'Numer',
           INT_MARC-MEINH UNDER 'Alt',
           INT_MARC-ESOKZ UNDER 'Cat'.
ENDLOOP.

TOP-OF-PAGE.
 FORMAT COLOR COL_TOTAL.
 WRITE: / SY-DATUM, SY-UZEIT, SY-REPID, SY-UNAME,
         'Material Unit Conversion',
         SY-PAGNO.
  SKIP.
  WRITE: /1 'Plt',
          5 'M.Type',
         12 'Material',
         32 'Unit',
         37 'Denom',
         47 'Numer',
         57 'Alt',
         61 'Cat'.
  SKIP.

Return to SAP Hints and Tips on Configuration and ABAP/4 Programming