SAP MRP MD04运行结果展示

内容是MD04中需求和库存的内容。MD04将一个物料显示了一张表,我们现在需要的是一个物料一行的表。

        你可以使用function:MD_STOCK_REQUIREMENTS_LIST_API。输入物料号工厂号,他下面所有的表头和行项目信息全部都会取出来。你只需要把function返回给你的信息组织一下,选取一部分放到报表就可以了。

        选择屏幕输入:

        物料号 单值

        工厂        单值 默认0080

        MRP area 单值 默认0080

 

        报表展示的信息有:

1.        MD04中所有信息,除此之外还包括:

2.        表头内容:

        Material Number

Plant

Deletion Indicator

Material Description (Short Text)

Material Type

Material Group

Base Unit of Measure

Plant-Specific Material Status

MRP Type

Procurement Type

Special procurement type

Mixed MRP indicator

3.        表行内内容,要求,一个需求一行,MD04内所有有的内容需要在报表里,除此之外,另加入:

需求产生日期,需求产生,需求计划单日期,计划单需求释放日期,采购订单生成日期或生产订单生成日期,发货日期等。总之流程每一个步骤的日期都加上。这些在function返回的内容里都有,你可以拿测试数据取出来看,然后添加到报表中。

报表要求生成ALV,并且双击点击物料的时候,可以链接到物料主数据查看页面(MM03);点击工单号的时候,可以链接到该工单浏览页面(CO03),点击采购申请或采购订单时,可以链接到采购申请或采购单浏览界面(ME23N)。

*&---------------------------------------------------------------------*
*& Report  XXXXXXXX
*&---------------------------------------------------------------------*
*&PROGRAM NAME : 
*---------------------------------------------------------------------*
* VERSION:            V1.0
* DATE CREATED :      2016/07/26
* CREATED BY   :      Ma Haifeng
* TRANSPORT REQUEST:  XXXXXXXXXX
* DESCRIPTION  :      Stock Requirements List
* request raised by:  Li honghua

REPORT zpp003.

********************************
* INNITIALIZATION
********************************

TABLES : marc,mdlv.

TYPES : BEGIN OF ltype_marc,
        matnr TYPE marc-matnr,
        werks TYPE marc-werks,
        END OF ltype_marc.

TYPES : BEGIN OF ltype_malv,
        berid TYPE mdlv-berid,
        END OF ltype_malv.

DATA : lt_display TYPE TABLE OF zspp_require_list,
       ls_display LIKE LINE OF lt_display.

********************************
* SELECTION-SCREEN
********************************

SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME.

PARAMETER m_matnr LIKE  marc-matnr.
PARAMETER m_werks LIKE  marc-werks DEFAULT '0080'.

SELECTION-SCREEN END OF BLOCK blk01.

PERFORM frm_get_data.

PERFORM frm_alv_display.

********************************
* START OF SELECTION
********************************
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_get_data .

  DATA : lt_innerinfo TYPE TABLE OF mdez,
         ls_innerinfo LIKE LINE OF lt_innerinfo.

  DATA : lt_headinfo TYPE TABLE OF mt61d,
         ls_headinfo LIKE LINE OF lt_headinfo.

  DATA : lt_innerinfo2 TYPE TABLE OF mdps,
         ls_innerinfo2 LIKE LINE OF lt_innerinfo2.

  CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
    EXPORTING
      matnr                    = m_matnr
      werks                    = m_werks
    IMPORTING
      e_mt61d                  = ls_headinfo
*     E_MDKP                   =
*     E_CM61M                  =
*     E_MDSTA                  =
*     E_ERGBZ                  =
    TABLES
      mdpsx                    = lt_innerinfo2
      mdezx                    = lt_innerinfo
*     MDSUX                    =
    EXCEPTIONS
      material_plant_not_found = 1
      plant_not_found          = 2
      OTHERS                   = 3.


  LOOP AT lt_innerinfo INTO ls_innerinfo.

    ls_display-dat00 = ls_innerinfo-dat00.
    ls_display-delb0 = ls_innerinfo-delb0.
    ls_display-extra = ls_innerinfo-extra.
    ls_display-umdat = ls_innerinfo-umdat.
    ls_display-auskt = ls_innerinfo-auskt.
    ls_display-mng01 = ls_innerinfo-mng01.
    ls_display-mng02 = ls_innerinfo-mng02.
    ls_display-lgort = ls_innerinfo-lgort.
    ls_display-dat01 = ls_innerinfo-dat01.
    ls_display-dat02 = ls_innerinfo-dat02.
    ls_display-dat03 = ls_innerinfo-dat03.

    APPEND ls_display TO lt_display.

  ENDLOOP.

  LOOP AT lt_display INTO ls_display WHERE extra NE 'Safety Stock' .

    READ TABLE lt_innerinfo2 INTO ls_innerinfo2 INDEX sy-tabix - 1.
    IF ls_innerinfo2-delkz = 'LA'.  "//采购订单
      ls_display-delnr = ls_innerinfo2-delnr.
    ELSEIF ls_innerinfo2-delkz = 'VC'.  "//销售订单
      ls_display-zdelnr = ls_innerinfo2-delnr.
    ELSEIF ls_innerinfo2-delkz = 'AR'.  "//工单
      ls_display-del12 = ls_innerinfo2-del12.
    ENDIF.

    MODIFY lt_display FROM ls_display. "//index sy-tabix.

  ENDLOOP.

  LOOP AT lt_display INTO ls_display.

    ls_display-matnr = ls_headinfo-matnr.
    ls_display-werks = ls_headinfo-werks.
    ls_display-lvorm = ls_headinfo-lvorm.
    ls_display-maktx = ls_headinfo-maktx.
    ls_display-mtart = ls_headinfo-mtart.
    ls_display-matkl = ls_headinfo-matkl.
    ls_display-meins = ls_headinfo-meins.
    ls_display-mmsta = ls_headinfo-mmsta.
    ls_display-dismm = ls_headinfo-dismm.
    ls_display-beskz = ls_headinfo-dismm.
    ls_display-sobsl = ls_headinfo-sobsl.
    ls_display-miskz = ls_headinfo-miskz.

    MODIFY lt_display FROM ls_display.
  ENDLOOP.

ENDFORM.                    " FRM_GET_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_alv_display .


  DATA : ls_layout   TYPE slis_layout_alv.
  DATA : lt_fieldcat TYPE slis_t_fieldcat_alv.
  DATA : l_repid     TYPE sy-repid.
  PERFORM frm_build_fieldcat CHANGING lt_fieldcat.
  PERFORM frm_build_layout CHANGING ls_layout.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-repid
      it_fieldcat              = lt_fieldcat
      is_layout                = ls_layout
      i_callback_user_command  = 'FRM_USER_COMMAND'
*     i_callback_pf_status_set = 'FRM_PF_STATUS_SET'
    TABLES
      t_outtab                 = lt_display.

ENDFORM.                    " FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  frm_build_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->CT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM frm_build_fieldcat  CHANGING ct_fieldcat TYPE slis_t_fieldcat_alv.

    DATA : ls_fieldcat LIKE LINE OF ct_fieldcat.
    REFRESH ct_fieldcat.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZSPP_REQUIRE_LIST'
    CHANGING
      ct_fieldcat      = ct_fieldcat.

   LOOP AT ct_fieldcat INTO ls_fieldcat.

    CASE ls_fieldcat-fieldname.
      WHEN 'ZDELNR'.
        IF sy-langu = '1'.
          ls_fieldcat-seltext_l = '销售订单'.
        ELSE.
          ls_fieldcat-seltext_l = 'Sales Order'.
          ls_fieldcat-seltext_m = 'Sales Order'.
          ls_fieldcat-seltext_s = 'Sales Order'.
        ENDIF.

      WHEN 'DELNR'.
        IF sy-langu = '1'.
          ls_fieldcat-seltext_l = '采购订单'.
        ELSE.
          ls_fieldcat-seltext_l = 'Purchase Order'.
          ls_fieldcat-seltext_m = 'Purchase Order'.
          ls_fieldcat-seltext_s = 'Purchase Order'.
        ENDIF.

       WHEN 'DEL12'.
        IF sy-langu = '1'.
          ls_fieldcat-seltext_l = '工单'.
        ELSE.
          ls_fieldcat-seltext_l = 'Work Order'.
          ls_fieldcat-seltext_m = 'Work Order'.
          ls_fieldcat-seltext_s = 'Work Order'.
        ENDIF.
    ENDCASE.

    MODIFY ct_fieldcat FROM ls_fieldcat TRANSPORTING seltext_l seltext_m seltext_s.

  ENDLOOP.
ENDFORM.                    "frm_build_fieldcat
*&---------------------------------------------------------------------*
*&      Form  frm_build_layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->CS_LAYOUT  text
*----------------------------------------------------------------------*
FORM frm_build_layout  CHANGING cs_layout TYPE slis_layout_alv.

  CLEAR cs_layout.
  MOVE 'X' TO cs_layout-detail_popup.
  MOVE 'X' TO cs_layout-colwidth_optimize.
  MOVE 'COLOR' TO cs_layout-info_fieldname.
*  MOVE 'SELECTED' TO cs_layout-box_fieldname.

ENDFORM.                    " FRM_BUILD_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  sub_user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM           text
*      -->US_SELECTE_FIELD  text
*----------------------------------------------------------------------*
FORM frm_user_command USING r_ucomm LIKE sy-ucomm
                      us_selecte_field TYPE slis_selfield.
  CASE r_ucomm.
    WHEN '&IC1'.                 "双击事件的功能码
      READ TABLE lt_display INTO ls_display INDEX us_selecte_field-tabindex.

      IF us_selecte_field-fieldname = 'MATNR'.

        SET PARAMETER ID 'MAT' FIELD ls_display-matnr.
        CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

      ELSEIF us_selecte_field-fieldname = 'DEL12'.

        SET PARAMETER ID 'ANR' FIELD ls_display-del12.
        CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.

      ELSEIF us_selecte_field-fieldname = 'DELNR'.

        SET PARAMETER ID 'BES' FIELD ls_display-delnr.
        CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

      ELSEIF us_selecte_field-fieldname = 'ZDELNR'.

        SET PARAMETER ID 'AUN' FIELD ls_display-zdelnr.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

      ENDIF.

  ENDCASE.
ENDFORM.                    " SUB_USER_COMMAND



你可能感兴趣的:(ABAP程序开发)