MMBE 里面的部分数量

*&---------------------------------------------------------------------*
*& Report  ZMM012
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  zmm012.
TABLES: marcv,resb .
DATA: BEGIN OF xtab OCCURS 10,        "未清采购订单数
         werks LIKE ekpo-werks,
         lgort LIKE ekpo-lgort,
         matnr LIKE ekpo-matnr,
         menge LIKE ekpo-menge,
         mengk LIKE ekpo-menge,
       END OF xtab.
DATA: BEGIN OF xtab1 OCCURS 10,        "预留的
         werks LIKE resb-werks,
         lgort LIKE resb-lgort,
         charg LIKE resb-charg,
         matnr LIKE resb-matnr,
         bdmng LIKE resb-bdmng,
         bdmns LIKE resb-bdmng,
         erfme LIKE resb-erfme,
         erfmg LIKE resb-erfmg,
       END OF xtab1.
DATA: BEGIN OF xtab2 OCCURS 10,         "收货冻结的库存
         werks LIKE ekpo-werks,
         matnr LIKE ekpo-matnr,
         ebeln LIKE ekpo-ebeln,
         ebelp LIKE ekpo-ebelp,
         wesbs LIKE ekbe-wesbs,
         wesb2 LIKE ekbe-wesbs,
         meinh LIKE ekpo-meins,
       END OF xtab2.
DATA: BEGIN OF xtab4 OCCURS 100,         "交货计划
         matnr LIKE vbbe-matnr,
         werks LIKE vbbe-werks,
         lgort LIKE vbbe-lgort,
         charg LIKE vbbe-charg,
         vbmna LIKE vbbe-omeng,
         vbmnb LIKE vbbe-omeng,
         vbmnc LIKE vbbe-omeng,
         vbmne LIKE vbbe-omeng,
         vbmng LIKE vbbe-omeng,
         vbmni LIKE vbbe-omeng,
         omeng LIKE vbbe-omeng,
         vrkme LIKE vbep-vrkme,
         wmeng LIKE vbep-wmeng,
       END OF xtab4.
DATA: BEGIN OF xtab5 OCCURS 10.
        INCLUDE STRUCTURE werks_quan.
DATA: END OF xtab5.

SELECT-OPTIONS: s_werks  FOR marcv-werks .
RANGES: xbdart FOR resb-bdart.
 
START-OF-SELECTION.
  CLEAR xtab. REFRESH xtab.
  CALL FUNCTION 'MB_ADD_PURCHASE_ORDER_QUANTITY' "未清采购订单数
    EXPORTING
      x_elikz = ''
      x_loekz = ''
      x_matnr = '002100000000000618'
      x_meins = 'PC'
    TABLES
      xtab    = xtab
      xwerks  = s_werks.
  WRITE / 'XTAB:'.
  LOOP AT xtab.
    PERFORM write_wa USING xtab 'XXXXXXX' 'X' 'X'.
  ENDLOOP.

  REFRESH xbdart.
  CLEAR   xbdart.
  xbdart-sign   = 'I'.
  xbdart-option = 'EQ'.
  xbdart-low    = 'AR'.
  APPEND xbdart.
  xbdart-low    = 'MR'.
  APPEND xbdart.
  CLEAR xtab1. REFRESH xtab1.
  CALL FUNCTION 'MB_ADD_RESERVATION_QUANTITIES' "预留的
    EXPORTING
      x_matnr = '002100000000000618'
      x_xloek = space
      x_kzear = space
      x_kzwso = ''
    TABLES
      xtab1   = xtab1
      xwerks  = s_werks
      xbdart  = xbdart.
  WRITE / 'XTAB1:'.
  LOOP AT xtab1.
    PERFORM write_wa USING xtab1 'XXXXXXX' 'X' 'X'.
  ENDLOOP.

  CLEAR xtab2. REFRESH xtab2.
  CALL FUNCTION 'MB_SELECT_GR_BLOCKED_STOCK' "收货冻结的库存
    EXPORTING
      x_matnr = '002100000000000618'
      x_meins = 'PC'
      x_kzwso = ''
    TABLES
      xtab2   = xtab2
      xwerks  = s_werks.
  WRITE / 'XTAB2:'.
  LOOP AT xtab2.
    PERFORM write_wa USING xtab2 'XXXXXXX' 'X' 'X'.
  ENDLOOP.

  CLEAR xtab4. REFRESH xtab4.
  CALL FUNCTION 'MB_SELECT_SD_SCHEDULED_STOCK' "交货计划
    EXPORTING
      x_matnr = '002100000000000618'
      x_kzwso = ''
    TABLES
      xtab4   = xtab4
      xwerks  = s_werks.
  WRITE / 'XTAB4:'.
  LOOP AT xtab4.
    PERFORM write_wa USING xtab4 'XXXXXXX' 'X' 'X'.
  ENDLOOP.

  CLEAR xtab5. REFRESH xtab5.
  CALL FUNCTION 'MATERIAL_QUANTITIES_FAUF'
    EXPORTING
      matnr     = '002100000000000618'
      kzwso     = ''
    TABLES
      famng_tab = xtab5
      werks_tab = s_werks.
  WRITE / 'XTAB5:'.
  LOOP AT xtab5.
    PERFORM write_wa USING xtab5 'XXXXXXX' 'X' 'X'.
  ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  write_wa
*&---------------------------------------------------------------------*
FORM write_wa USING wa fieldmask newline alllen.
  DATA: str TYPE string ,
        str_idx TYPE string ,
        f_index TYPE i ,
        f_len TYPE i .
  FIELD-SYMBOLS: <f_field> .
  f_len = STRLEN( fieldmask ).
  IF newline = 'X'. WRITE  / ''.ENDIF.
  POSITION 1 .
  DO .
    ASSIGN COMPONENT sy-index OF STRUCTURE wa TO <f_field>.
    IF sy-subrc <> 0 OR sy-index > f_len.
      EXIT.
    ELSE.
      str_idx = sy-index .
      CONDENSE str_idx.
      f_index = sy-index - 1.
      IF fieldmask+f_index(1) = 'X'.
        IF alllen = ''.
          str = <f_field> .
          WRITE str.
        ELSE.
          WRITE <f_field>.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDDO.
ENDFORM.                    "write_wa

你可能感兴趣的:(MMBE 里面的部分数量)