码迷,mamicode.com
首页 > 其他好文 > 详细

SAP PP 批量反查BOM

时间:2021-06-24 18:02:23      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:错误   new   button   订单   art   tls   page   read   stat   

转自链接:https://www.jianshu.com/p/1b61ea6098cd
作者:憨憨憨豆


业务背景介绍

SAP提供BOM反查标准代码为CS15,该CS15可实现物料单层反查BOM和多层反查BOM,以及相应需求数量/结果数量计算;不过SAP未提供批量的反查功能,对此本人大致研究了一下标准程序,开发如下所示的批量反查BOM程序,可满足大部分企业需求;
(备注:程序中应用了大部分CS15标准程序,已实现单层展示和多层展示,单层的需求数量/计划数量的计算)

功能逻辑

1.实现多个物料批量反查BOM-单层(含需求数量和结果数量计算);
2.实现多个物料批量反查BOM-多层(不含需求数量和结果数量计算);
3.具体代码逻辑可参考标准程序:RCS15001;

实现难题

BOM反查多层展示,需要调用函数CS_WHERE_USED_MAT进行递归,较为难以开发;可参考标准程序:RCS15001实现;

模拟案例:

前端业务界面:

技术图片
批量反查BOM界面

ALV报表界面:

技术图片
批量反查BOM结果

相关程序

主程序
REPORT ZPPRP036 MESSAGE-ID 29 LINE-SIZE 132.

INCLUDE ZPPRP036_T.
INCLUDE ZPPRP036_S.
INCLUDE ZPPRP036_F.

INITIALIZATION."屏幕未显示之前执行,对程序设置值以及屏幕元素进行赋值

AT SELECTION-SCREEN.
  IF S_IDNRK-LOW IS INITIAL.
    MESSAGE 物料需填写 TYPE E.
  ENDIF.

  IF PM_WERKS IS INITIAL.
    MESSAGE 工厂需填写 TYPE E.
  ENDIF.

  IF PM_DIRKT IS INITIAL.
    MESSAGE E544 WITH ‘‘.
  ENDIF.
  IF NOT PM_EMENG IS INITIAL
     AND NOT PM_RMENG IS INITIAL.
    MESSAGE E512 WITH ‘‘.
  ENDIF.

AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
    CASE SCREEN-GROUP1.
      WHEN TY1.
        IF PM_MEHRS IS INITIAL.
          SCREEN-ACTIVE = 1."显示
        ELSE.
          SCREEN-ACTIVE = 0."隐藏
        ENDIF.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.

START-OF-SELECTION.
  CLEAR SY-UCOMM.

  PERFORM FRM_GET_DATA.
  PERFORM FRM_OUTPUT_ALV.

END-OF-SELECTION.

 

include ZPPRP036_T相关代码:
*&---------------------------------------------------------------------*
*& 包含               ZPPRP036_T
*&---------------------------------------------------------------------*
TYPE-POOLS: "MBALV
   ICON,                                                    "Acc 2004
   SLIS.

DATA:IS_LAYOUT TYPE LVC_S_LAYO,
     IT_FIELDCAT_LVC TYPE LVC_T_FCAT WITH HEADER LINE.

TABLES: STPO,MARC,STZU,CSDATA.

DATA: BEGIN OF GT_DATA OCCURS 0,
        ZMATNR LIKE MARA-MATNR,
        MAKTX  LIKE MAKT-MAKTX,
        DIMNG  LIKE STPOL_ADD-DIMNG,
        DRMNG  LIKE STPOL_ADD-DRMNG,
        STATUS TYPE STRING, "状态
        MSG    TYPE STRING, "消息
        OBJIC(4)  TYPE C.
    INCLUDE STRUCTURE STPOV.
DATA: END OF GT_DATA.

DATA: BEGIN OF GT_OUT OCCURS 0,
        ZMATNR LIKE MARA-MATNR,
        MAKTX  LIKE MAKT-MAKTX,
        DIMNG  LIKE STPOL_ADD-DIMNG,
        DRMNG  LIKE STPOL_ADD-DRMNG,
        STATUS TYPE STRING, "状态
        MSG    TYPE STRING, "消息
        OBJIC(4)  TYPE C.
    INCLUDE STRUCTURE STPOV.
DATA: END OF GT_OUT.


*     Loop-LTB (mehrstufig)                                   "YHG125492
DATA: BEGIN OF LTB OCCURS 0. "YHG125492
    INCLUDE STRUCTURE STPOV.                                "YHG125492
DATA: END OF LTB.

*     Loop-LTB (mehrstufig)                                   "YHG125492
DATA: BEGIN OF LLTB OCCURS 0. "YHG125492
    INCLUDE STRUCTURE STPOV.                                "YHG125492
DATA: END OF LLTB.

*     Loop-MATCAT (mehrstufig)                                "YHG125492
DATA: BEGIN OF MATCAT OCCURS 0. "YHG125492
    INCLUDE STRUCTURE CSCMAT.                               "YHG125492
DATA: END OF MATCAT .

*     Loop-MATCAT (mehrstufig)                                "YHG125492
DATA: BEGIN OF LMATCAT OCCURS 0. "YHG125492
    INCLUDE STRUCTURE CSCMAT.                               "YHG125492
DATA: END OF LMATCAT .

DATA: BEGIN OF EQUICAT OCCURS 0. "YHG110068
    INCLUDE STRUCTURE CSCEQUI.                              "YHG110068
DATA: END OF EQUICAT . "YHG110068

DATA: BEGIN OF KNDCAT OCCURS 0. "YHG110068
    INCLUDE STRUCTURE CSCKND.                               "YHG110068
DATA: END OF KNDCAT . "YHG110068


DATA: BEGIN OF PRJCAT OCCURS 0. "MBA089075
    INCLUDE STRUCTURE CSCPRJ.                               "MBA089075
DATA: END OF PRJCAT. "MBA089075

DATA: BEGIN OF STDCAT OCCURS 0. "YHG110068
    INCLUDE STRUCTURE CSCSTD.                               "YHG110068
DATA: END OF STDCAT . "YHG110068

DATA: BEGIN OF TPLCAT OCCURS 0. "YHG110068
    INCLUDE STRUCTURE CSCTPL.                               "YHG110068
DATA: END OF TPLCAT .


DATA: BEGIN OF WU_CTAB OCCURS 0, "YHG125492
        MATNR LIKE MARA-MATNR,                              "YHG125492
        WERKS LIKE T001W-WERKS,                             "YHG125492
        STLAN LIKE MAST-STLAN,                              "YHG125492
        WUCHK LIKE CSDATA-XFELD, "Vw zu ermitteln versucht   "YHG125492
        ISUSD LIKE CSDATA-XFELD, "Vw gefunden                "YHG125492
        WUTCK LIKE CSDATA-XFELD, "Vw-Tab geprueft            "YHG125492
      END OF WU_CTAB.

DATA: BEGIN OF WU_CTAB_KEY, "YHG125492
        MATNR LIKE MARA-MATNR,                              "YHG125492
        WERKS LIKE T001W-WERKS,                             "YHG125492
        STLAN LIKE MAST-STLAN,                              "YHG125492
      END OF WU_CTAB_KEY.

DATA: BEGIN OF WU_ML_STACK OCCURS 0, "YHG125492
        STUFE LIKE STPOV-LEVEL,                             "YHG125492
        LOOPX LIKE SY-INDEX,                                "YHG125492
        MATNR LIKE MARA-MATNR,                              "YHG125492
        WERKS LIKE T001W-WERKS,                             "YHG125492
        STLAN LIKE MAST-STLAN,                              "YHG125492
      END OF WU_ML_STACK.                                   "YHG125492

DATA: BEGIN OF MNG_STACK OCCURS 0, "YHG125492
        STUFE LIKE STPOV-LEVEL,                             "YHG125492
        EMENG LIKE STPOV-EMENG,                             "YHG125492
        RMENG LIKE STPOV-EMENG,                             "YHG125492
        EMFAC TYPE F,                                       "HGA115915
        LDSGN LIKE CSDATA-XFELD,                            "HGA118294
        EXTRM LIKE CSDATA-XFELD,                            "HGA118294
      END OF MNG_STACK.                                     "YHG125492

*---------------------------------------------------------------------*
*        interne Feldleisten                                          *
*---------------------------------------------------------------------*
*     Materialdaten zum Einstiegsmaterial
DATA: BEGIN OF SELPOOL.
    INCLUDE STRUCTURE MC29S.
DATA: END OF SELPOOL.

*     Materialdaten zum Einstiegsmaterial merken (mehrstufig)
DATA: BEGIN OF SAV_SELPOOL. "YHG125492
    INCLUDE STRUCTURE MC29S.                                "YHG125492
DATA: END OF SAV_SELPOOL. "YHG125492

DATA: BEGIN OF WU_MEMID, "YHG125492
        TABID(2) TYPE C,                                    "YHG125492
        MATNR    LIKE MARA-MATNR,                           "YHG125492
        WERKS    LIKE T001W-WERKS,                          "YHG125492
        STLAN    LIKE MAST-STLAN,                           "YHG125492
      END OF WU_MEMID.                                      "YHG125492

DATA: DSP_IMENG(7) TYPE P DECIMALS 3,
      DSP_RMENG(7) TYPE P DECIMALS 3,
      OPO_MEINH    LIKE STPO-MEINS,
      OPO_MENGE    LIKE STPO-MENGE.                         "HGA115686
DATA: SAV_FRMNG TYPE F. "HGA131954
DATA: TMAT_REVLV LIKE AEOI-REVLV. "YHG083168
DATA: REVL_SDATU LIKE SY-DATUM. "YHG083168
DATA: WU_CTAB_LOOPX LIKE SY-TABIX. "YHG125492
DATA: STACK_PREVX LIKE SY-TABIX. "YHG125492
DATA: LTB_LOOPX LIKE SY-TABIX. "YHG125492
DATA: LTB_STRTX LIKE SY-TABIX. "YHG125492
DATA: ACT_LEVEL LIKE STPOV-LEVEL. "YHG125492
DATA: STACK_FLAG LIKE CSDATA-XFELD. "YHG125492
DATA: POP_FLAG LIKE CSDATA-XFELD. "YHG125492
DATA: END_FLAG LIKE CSDATA-XFELD. "YHG125492

DATA: "HGA118294
  MAX_FNUM  TYPE F VALUE 9.999999999999000E+09,           "HGA118294
  PNULL(13) TYPE P         VALUE 0,                         "HGA118294
  FNULL     TYPE F VALUE 0.000000000000000E+00.           "HGA118294
include ZPPRP036_S相关代码:
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_IDNRK FOR STPO-IDNRK  NO INTERVALS."OBLIGATORY

PARAMETERS: PM_WERKS LIKE MARC-WERKS MEMORY ID WRK, "OBLIGATORY
            PM_STLAN LIKE STZU-STLAN,
            PM_DATUV LIKE STPO-DATUV DEFAULT SY-DATUM,
            PM_DATUB LIKE STPO-DATUV DEFAULT 99991231,
            PM_DIRKT LIKE CSDATA-XFELD DEFAULT X.
PARAMETERS:
            PM_MEHRS AS CHECKBOX USER-COMMAND FLAG
*            PM_MEHRS RADIOBUTTON GROUP G1
            .

SELECTION-SCREEN END OF BLOCK B1.


*&---------------------------------------------------------------------*
* DEFINE SELECTION SCREEN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS: PM_EMENG LIKE STPO-MENGE MODIF ID TY1,
            PM_RMENG LIKE STPO-MENGE MODIF ID TY1.
SELECTION-SCREEN END OF BLOCK B2.
include ZPPRP036_F相关代码:
*&---------------------------------------------------------------------*
*& 包含               ZPPRP036_F
*&---------------------------------------------------------------------*

FORM GET_WU_RECS "YHG125492
   USING LCL_MATNR
         LCL_WERKS
         LCL_STLAN.

*     alle direkten Verwendungen nach LTB holen
  CALL FUNCTION CS_WHERE_USED_MAT
    EXPORTING
      DATUB                      = PM_DATUB
      DATUV                      = PM_DATUV
      MATNR                      = LCL_MATNR                             "YHG125492
      STLAN                      = LCL_STLAN                             "YHG125492
      WERKS                      = LCL_WERKS                             "YHG125492
      STLTP                      = M                           "note 308150
    IMPORTING
      TOPMAT                     = SELPOOL
    TABLES
      WULTB                      = LTB
      EQUICAT                    = EQUICAT
      KNDCAT                     = KNDCAT
      MATCAT                     = MATCAT
      STDCAT                     = STDCAT
      TPLCAT                     = TPLCAT
      PRJCAT                     = PRJCAT
    EXCEPTIONS
*     CALL_INVALID               = 01
      MATERIAL_NOT_FOUND         = 02
      NO_WHERE_USED_REC_FOUND    = 03
      NO_WHERE_USED_REC_SELECTED = 04
      NO_WHERE_USED_REC_VALID    = 05.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*

FORM FRM_GET_DATA .
  SORT S_IDNRK BY LOW.
  DELETE ADJACENT DUPLICATES FROM S_IDNRK.

  LOOP AT S_IDNRK.
    CLEAR:LTB[],SAV_SELPOOL,WU_MEMID,WU_CTAB_KEY,WU_CTAB[].
    CLEAR:WU_CTAB_LOOPX,LLTB[],LMATCAT,MATCAT,LMATCAT,WU_ML_STACK[],END_FLAG,LTB_LOOPX,POP_FLAG,STACK_FLAG,ACT_LEVEL,LTB_STRTX.

    PERFORM GET_WU_RECS                                     "YHG125492
       USING S_IDNRK-LOW                                    "YHG125492
             PM_WERKS                                       "YHG125492
             PM_STLAN.                                      "YHG125492

    CASE SY-SUBRC.
      WHEN 0.
        READ TABLE LTB INDEX 1.
        IF SY-SUBRC = 0 ."若存在数据
          IF NOT PM_MEHRS IS INITIAL.
*        Daten zum Einstiegsmaterial sichern
            SAV_SELPOOL = SELPOOL.

*        LTB und MATCAT exportieren;
            PERFORM EXP_WUTAB
               USING S_IDNRK-LOW
                     PM_WERKS
                     PM_STLAN.
*
**        Verwendungsergebnis registrieren
            PERFORM REG_WURES
               USING S_IDNRK-LOW
                     PM_WERKS
                     PM_STLAN
                     X X  .

            LOOP AT WU_CTAB.
              WU_CTAB_LOOPX = SY-TABIX.
*              ... hat Verwendung
              CHECK NOT WU_CTAB-ISUSD IS INITIAL.
*              ... zugeh. Verw.-Tab. noch nicht ueberprueft
              CHECK WU_CTAB-WUTCK IS INITIAL.

              WU_MEMID-TABID = LT.
              WU_MEMID-MATNR = WU_CTAB-MATNR.
              WU_MEMID-WERKS = WU_CTAB-WERKS.
*d          WU_MEMID-STLAN = WU_CTAB-STLAN.                   "HGA114476
              WU_MEMID-STLAN = PM_STLAN.                    "HGA114476

              CLEAR: LLTB. REFRESH: LLTB.
              IMPORT LTB TO LLTB
                 FROM MEMORY ID WU_MEMID.

              WU_MEMID-TABID = MT.
              CLEAR: LMATCAT. REFRESH: LMATCAT.
              IMPORT MATCAT TO LMATCAT
                 FROM MEMORY ID WU_MEMID.

*d          LOOP AT LLTB.                                     "HGC154389
*d             CHECK LLTB-BMTYP = TYP_MAT.                    "HGC154389

*d             CHECK LLTB-REKRI IS INITIAL                    "HGC154389
*d                   AND LLTB-REKRS IS INITIAL.               "HGC154389
              LOOP AT LLTB                                  "HGC154389
                 WHERE     BMTYP EQ M                     "HGC154389
                       AND REKRI IS INITIAL                 "HGC154389
*d                   AND rekrs IS INITIAL.          "HGC154389 MBA148624
                       AND REKRS IS INITIAL           "HGC154389 MBA148624
                       AND KZKUP IS INITIAL                 "MBC167558
                       AND EXCPT NE CONV.                 "MBA148624

                READ TABLE LMATCAT INDEX LLTB-TTIDX.

                WU_CTAB_KEY-MATNR = LMATCAT-MATNR.
                WU_CTAB_KEY-WERKS = LLTB-WERKS.
*d             WU_CTAB_KEY-STLAN = LLTB-STLAN.                "HGA114476
                WU_CTAB_KEY-STLAN = PM_STLAN.               "HGA114476
                READ TABLE WU_CTAB WITH KEY WU_CTAB_KEY.
                CHECK SY-SUBRC <> 0.

                PERFORM GET_WU_RECS
                   USING LMATCAT-MATNR
                         LLTB-WERKS
*d                      LLTB-STLAN.                           "HGA114476
                         PM_STLAN.                          "HGA114476

                IF SY-SUBRC = 0.
*                 LTB und MATCAT exportieren;
                  PERFORM EXP_WUTAB
                     USING LMATCAT-MATNR
                           LLTB-WERKS
*d                         LLTB-STLAN.                        "HGA114476
                           PM_STLAN.                        "HGA114476

*                 Verwendungsergebnis registrieren
                  PERFORM REG_WURES
                     USING LMATCAT-MATNR
                           LLTB-WERKS
*d                         LLTB-STLAN                         "HGA114476
                           PM_STLAN                         "HGA114476
                           X X  .
                ELSE.
*                 Verwendungsergebnis registrieren
                  PERFORM REG_WURES
                     USING LMATCAT-MATNR
                           LLTB-WERKS
*d                         LLTB-STLAN                         "HGA114476
                           PM_STLAN                         "HGA114476
                           X    .
                ENDIF.
              ENDLOOP.

              READ TABLE WU_CTAB INDEX WU_CTAB_LOOPX.
              WU_CTAB-WUTCK = X.
              MODIFY WU_CTAB.
            ENDLOOP.

            SELPOOL = SAV_SELPOOL.
            CLEAR: LTB. REFRESH: LTB.
            CLEAR: MATCAT. REFRESH: MATCAT.

            READ TABLE WU_CTAB INDEX 1.
            WU_MEMID-TABID = LT.
            WU_MEMID-MATNR = WU_CTAB-MATNR.
            WU_MEMID-WERKS = WU_CTAB-WERKS.
            WU_MEMID-STLAN = WU_CTAB-STLAN.

            CLEAR: LLTB. REFRESH: LLTB.
            IMPORT LTB TO LLTB
               FROM MEMORY ID WU_MEMID.

            WU_MEMID-TABID = MT.
            CLEAR: LMATCAT. REFRESH: LMATCAT.
            IMPORT MATCAT TO LMATCAT
               FROM MEMORY ID WU_MEMID.

            ACT_LEVEL = 1 .
            WU_ML_STACK-STUFE = ACT_LEVEL.
            WU_ML_STACK-LOOPX = 1 .
            WU_ML_STACK-MATNR = WU_CTAB-MATNR.
            WU_ML_STACK-WERKS = WU_CTAB-WERKS.
            WU_ML_STACK-STLAN = WU_CTAB-STLAN.
            APPEND WU_ML_STACK.
            LTB_STRTX = 1 .

            WHILE END_FLAG IS INITIAL.
*d          LOOP AT LLTB FROM LTB_STRTX.                      "HGC154389
*d             CHECK LLTB-BMTYP = TYP_MAT.                    "HGC154389
              LOOP AT LLTB FROM LTB_STRTX                   "HGC154389
                 WHERE BMTYP EQ M.                        "HGC154389

                LTB_LOOPX = SY-TABIX.

                IF     POP_FLAG IS INITIAL
                   OR  LLTB-SUMFG EQ x.

                  READ TABLE LMATCAT INDEX LLTB-TTIDX.
                  MATCAT = LMATCAT. APPEND MATCAT.

                  LLTB-TTIDX = SY-TABIX.
                  LLTB-LEVEL = ACT_LEVEL.
                  LTB = LLTB.
                  APPEND LTB.

                  CHECK LLTB-SUMFG NE X.
                  CHECK LLTB-REKRI IS INITIAL
                     AND LLTB-EXCPT NE CONV               "MBB167558
                     AND LLTB-KZKUP IS INITIAL              "note 593874
                     AND LLTB-REKRS IS INITIAL.


                  WU_CTAB_KEY-MATNR = LMATCAT-MATNR.
                  WU_CTAB_KEY-WERKS = LLTB-WERKS.
*d                WU_CTAB_KEY-STLAN = LLTB-STLAN.             "HGA114476
                  WU_CTAB_KEY-STLAN = PM_STLAN.             "HGA114476
                  READ TABLE WU_CTAB WITH KEY WU_CTAB_KEY.

                  IF NOT WU_CTAB-ISUSD IS INITIAL.
                    WU_ML_STACK-STUFE = ACT_LEVEL + 1 .
                    WU_ML_STACK-LOOPX = 1 .
                    WU_ML_STACK-MATNR = LMATCAT-MATNR.
                    WU_ML_STACK-WERKS = LLTB-WERKS.
*d                   WU_ML_STACK-STLAN = LLTB-STLAN.          "HGA114476
                    WU_ML_STACK-STLAN = PM_STLAN.           "HGA114476
                    APPEND WU_ML_STACK.
                    STACK_PREVX = SY-TABIX - 1 .

                    POP_FLAG = X.
                  ENDIF.
                ELSE.
                  READ TABLE WU_ML_STACK
                     WITH KEY ACT_LEVEL.
                  WU_ML_STACK-LOOPX = LTB_LOOPX.
                  MODIFY WU_ML_STACK INDEX SY-TABIX.

                  STACK_FLAG = X.

                  EXIT.
                ENDIF.
              ENDLOOP.

              IF NOT POP_FLAG IS INITIAL.
                CLEAR: POP_FLAG.

*              ?war LLTB-Loop zuende
*              ja
                IF STACK_FLAG IS INITIAL.
*                 vorletzten Stack-Satz einlesen
                  READ TABLE WU_ML_STACK INDEX STACK_PREVX.
*                 Anzahl Saetze der LLTB ermitteln
                  DESCRIBE TABLE LLTB LINES SY-TABIX.
*                 Index um 1 hoeher setzen, damit kein weiterer
*                 Satz dieser LLTB mehr gelesen werden kann
                  WU_ML_STACK-LOOPX = SY-TABIX + 1 .
*                 LeseIndex merken
                  MODIFY WU_ML_STACK INDEX STACK_PREVX.
                ELSE.
                  CLEAR: STACK_FLAG.
                ENDIF.

                ACT_LEVEL = ACT_LEVEL + 1 .
                READ TABLE WU_ML_STACK
                   WITH KEY ACT_LEVEL.
              ELSE.
                IF ACT_LEVEL = 1 .
                  EXIT.
                  END_FLAG = X.
                ENDIF.

                DESCRIBE TABLE WU_ML_STACK LINES SY-TABIX.
                DELETE WU_ML_STACK INDEX SY-TABIX.
                SY-TABIX = SY-TABIX - 1.
                READ TABLE WU_ML_STACK INDEX SY-TABIX.
              ENDIF.

              WU_MEMID-TABID = LT.
              WU_MEMID-MATNR = WU_ML_STACK-MATNR.
              WU_MEMID-WERKS = WU_ML_STACK-WERKS.
              WU_MEMID-STLAN = WU_ML_STACK-STLAN.

              CLEAR: LLTB. REFRESH: LLTB.
              IMPORT LTB TO LLTB
                FROM MEMORY ID WU_MEMID.

              WU_MEMID-TABID = MT.
              CLEAR: LMATCAT. REFRESH: LMATCAT.
              IMPORT MATCAT TO LMATCAT
                 FROM MEMORY ID WU_MEMID.

              ACT_LEVEL = WU_ML_STACK-STUFE.
              LTB_STRTX = WU_ML_STACK-LOOPX.
            ENDWHILE.
          ENDIF.

          "单层展示,并调整布局;-》需求数量和变动数量
          MOVE-CORRESPONDING LTB[] TO GT_DATA[]. "相似结构体赋值
          LOOP AT GT_DATA.
            PERFORM MNG_DSP_NEW.
            GT_DATA-MAKTX = SELPOOL-MAKTX.
            GT_DATA-DIMNG = DSP_IMENG.
            GT_DATA-DRMNG = DSP_RMENG.
            GT_DATA-ZMATNR = S_IDNRK-LOW.
            GT_DATA-STATUS = @5B@.
            GT_DATA-OBJIC = @A6@.
            MODIFY GT_DATA.
            CLEAR:DSP_IMENG,DSP_RMENG,SAV_FRMNG.
          ENDLOOP.

          APPEND LINES OF GT_DATA[] FROM 1 TO LINES( GT_DATA[] ) TO GT_OUT[].

        ENDIF.
      WHEN 2."记录错误信息
        CONCATENATE GT_OUT-MSG 物料未找到 INTO GT_OUT-MSG.
        GT_OUT-STATUS = @5C@.
        GT_OUT-ZMATNR = S_IDNRK-LOW.

        APPEND GT_OUT .
      WHEN 3.
        CONCATENATE GT_OUT-MSG 物料在该工厂BOM中未找到 INTO GT_OUT-MSG.
        GT_OUT-STATUS = @5C@.
        GT_OUT-ZMATNR = S_IDNRK-LOW.
        APPEND GT_OUT .
      WHEN 4.
        CONCATENATE GT_OUT-MSG 对于物料的使用,没有做出选择 INTO GT_OUT-MSG.
        GT_OUT-ZMATNR = S_IDNRK-LOW.
        APPEND GT_OUT .
      WHEN 5.
        CONCATENATE GT_OUT-MSG & 有效值输入, & 未被使用 INTO GT_OUT-MSG.
        GT_OUT-ZMATNR = S_IDNRK-LOW.
        APPEND GT_OUT .
    ENDCASE.
    CLEAR:GT_OUT-MSG.
  ENDLOOP.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form FRM_OUTPUT_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM FRM_OUTPUT_ALV .

  DEFINE SET_FCAT.
    IT_FIELDCAT_LVC-FIELDNAME = &1.
    IT_FIELDCAT_LVC-SCRTEXT_L = &2.
    IT_FIELDCAT_LVC-NO_ZERO = &3.
    IT_FIELDCAT_LVC-LZERO = &4.
    IT_FIELDCAT_LVC-REF_TABLE = &5.
    IT_FIELDCAT_LVC-REF_FIELD = &6.
    APPEND IT_FIELDCAT_LVC.
  END-OF-DEFINITION.

  IS_LAYOUT-ZEBRA = X.
  IS_LAYOUT-CWIDTH_OPT = X.
  IS_LAYOUT-SEL_MODE = D.
  IS_LAYOUT-CTAB_FNAME = FLDNAME.

  SET_FCAT  ZMATNR TEXT-F01  ‘‘ ‘‘ MARA MATNR. "主组件
  SET_FCAT  DIMNG  TEXT-E21  ‘‘ ‘‘ STPOL_ADD DIMNG. "所需数量(显示的)
  SET_FCAT  DRMNG  TEXT-E22  ‘‘ ‘‘ STPOL_ADD DRMNG. "结果数量
  SET_FCAT  STATUS TEXT-E23  ‘‘ ‘‘ ICON ICON_D. "错误状态
  SET_FCAT  MSG    TEXT-E24  ‘‘ ‘‘ ‘‘ ‘‘. "错误信息
  SET_FCAT  MAKTX  TEXT-E25  ‘‘ ‘‘ MAKT MAKT. "错误信息
  SET_FCAT  OBJIC  TEXT-E26  ‘‘ ‘‘ ICON ICON_D. "对象状态
  SET_FCAT  LEVEL TEXT-F02  ‘‘ ‘‘ STPOV LEVEL. "层次(在多层 BOM 展开中)
  SET_FCAT  MATNR TEXT-F03  ‘‘ ‘‘ STPOV MATNR. "物料编号
  SET_FCAT  EQUNR TEXT-F04  ‘‘ ‘‘ STPOV EQUNR. "设备号
  SET_FCAT  BMTYP TEXT-F05  ‘‘ ‘‘ STPOV BMTYP. "物料清单类别
  SET_FCAT  TTIDX TEXT-F06  ‘‘ ‘‘ STPOV TTIDX. "在类别表内的索引
  SET_FCAT  OJTXB TEXT-F07  ‘‘ ‘‘ STPOV OJTXB. "对象描述(部件)
  SET_FCAT  REVLV TEXT-F08  ‘‘ ‘‘ STPOV REVLV. "版次
  SET_FCAT  CSLTY TEXT-F09  ‘‘ ‘‘ STPOV CSLTY. "标志: 配置物料(物料变式)
  SET_FCAT  LSTFG TEXT-F10  ‘‘ ‘‘ STPOV LSTFG. "复选框
  SET_FCAT  WERKS TEXT-F11  ‘‘ ‘‘ STPOV WERKS. "工厂
  SET_FCAT  IWERK TEXT-F12  ‘‘ ‘‘ STPOV IWERK. "工厂
  SET_FCAT  STLAN TEXT-F13  ‘‘ ‘‘ STPOV STLAN. "BOM 用途
  SET_FCAT  STKOZ TEXT-F14  ‘‘ ‘‘ STPOV STKOZ. "内部计数器
  SET_FCAT  LOEKZ TEXT-F15  ‘‘ ‘‘ STPOV LOEKZ. "BOM 删除标志
  SET_FCAT  BMENG TEXT-F16  ‘‘ ‘‘ STPOV BMENG. "基本数量
  SET_FCAT  STLST TEXT-F17  ‘‘ ‘‘ STPOV STLST. "BOM 状态
  SET_FCAT  BMEIN TEXT-F18  ‘‘ ‘‘ STPOV BMEIN. "BOM 基本单位
  SET_FCAT  EMENG TEXT-F19  ‘‘ ‘‘ STPOV EMENG. "CS 浮点字段 (数量帮助...)
  SET_FCAT  FXMNG TEXT-F20  ‘‘ ‘‘ STPOV FXMNG. "CS 浮点字段 (数量帮助...)
  SET_FCAT  MSIGN TEXT-F21  ‘‘ ‘‘ STPOV MSIGN. "复选框
  SET_FCAT  EMEIH TEXT-F22  ‘‘ ‘‘ STPOV EMEIH. "组件计量单位
  SET_FCAT  CRTFG TEXT-F23  ‘‘ ‘‘ STPOV CRTFG. "复选框
  SET_FCAT  SUMFG TEXT-F24  ‘‘ ‘‘ STPOV SUMFG. "总计记录指示符
  SET_FCAT  EXCPT TEXT-F25  ‘‘ ‘‘ STPOV EXCPT. "例外
  SET_FCAT  STLTY TEXT-F26  ‘‘ ‘‘ STPOV STLTY. "物料清单类别
  SET_FCAT  STLNR TEXT-F27  ‘‘ ‘‘ STPOV STLNR. "物料单
  SET_FCAT  STLKN TEXT-F28  ‘‘ ‘‘ STPOV STLKN. "BOM 项目节点号
  SET_FCAT  STPOZ TEXT-F29  ‘‘ ‘‘ STPOV STPOZ. "内部计数器
  SET_FCAT  DATUV TEXT-F30  ‘‘ ‘‘ STPOV DATUV. "有效起始日期
  SET_FCAT  AENNR TEXT-F31  ‘‘ ‘‘ STPOV AENNR. "更改编号
  SET_FCAT  ANDAT TEXT-F32  ‘‘ ‘‘ STPOV ANDAT. "日期记录创建于
  SET_FCAT  ANNAM TEXT-F33  ‘‘ ‘‘ STPOV ANNAM. "创建记录的用户
  SET_FCAT  AEDAT TEXT-F34  ‘‘ ‘‘ STPOV AEDAT. "最后更改的日期
  SET_FCAT  AENAM TEXT-F35  ‘‘ ‘‘ STPOV AENAM. "更改对象用户的名称
  SET_FCAT  IDNRK TEXT-F36  ‘‘ ‘‘ STPOV IDNRK. "BOM 组件
  SET_FCAT  PSWRK TEXT-F37  ‘‘ ‘‘ STPOV PSWRK. "发放工厂
  SET_FCAT  POSTP TEXT-F38  ‘‘ ‘‘ STPOV POSTP. "项目类别(物料单)
  SET_FCAT  POSNR TEXT-F39  ‘‘ ‘‘ STPOV POSNR. "BOM 项目号
  SET_FCAT  SORTF TEXT-F40  ‘‘ ‘‘ STPOV SORTF. "排序字符串
  SET_FCAT  MEINS TEXT-F41  ‘‘ ‘‘ STPOV MEINS. "组件计量单位
  SET_FCAT  MENGE TEXT-F42  ‘‘ ‘‘ STPOV MENGE. "组件数量
  SET_FCAT  FMENG TEXT-F43  ‘‘ ‘‘ STPOV FMENG. "固定数量
  SET_FCAT  AUSCH TEXT-F44  ‘‘ ‘‘ STPOV AUSCH. "组件报废百分比
  SET_FCAT  AVOAU TEXT-F45  ‘‘ ‘‘ STPOV AVOAU. "工序报废
  SET_FCAT  NETAU TEXT-F46  ‘‘ ‘‘ STPOV NETAU. "标志:净废品
  SET_FCAT  SCHGT TEXT-F47  ‘‘ ‘‘ STPOV SCHGT. "指示符:散装物料
  SET_FCAT  BEIKZ TEXT-F48  ‘‘ ‘‘ STPOV BEIKZ. "物料供应标识符
  SET_FCAT  ERSKZ TEXT-F49  ‘‘ ‘‘ STPOV ERSKZ. "标识:备件
  SET_FCAT  RVREL TEXT-F50  ‘‘ ‘‘ STPOV RVREL. "标识:与销售相关的项目
  SET_FCAT  SANFE TEXT-F51  ‘‘ ‘‘ STPOV SANFE. "标识:与生产相关项目
  SET_FCAT  SANIN TEXT-F52  ‘‘ ‘‘ STPOV SANIN. "指示器:与工厂维护相关的项目
  SET_FCAT  SANKA TEXT-F53  ‘‘ ‘‘ STPOV SANKA. "与成本核算相关标志
  SET_FCAT  SANKO TEXT-F54  ‘‘ ‘‘ STPOV SANKO. "标识:与工程相关项目
  SET_FCAT  SANVS TEXT-F55  ‘‘ ‘‘ STPOV SANVS. "指示器:高级配置
  SET_FCAT  STKKZ TEXT-F56  ‘‘ ‘‘ STPOV STKKZ. "PM 装配指示符
  SET_FCAT  REKRI TEXT-F57  ‘‘ ‘‘ STPOV REKRI. "标志: BOM 是递归的
  SET_FCAT  REKRS TEXT-F58  ‘‘ ‘‘ STPOV REKRS. "标志: 递归性允许
  SET_FCAT  CADPO TEXT-F59  ‘‘ ‘‘ STPOV CADPO. "CAD 标识
  SET_FCAT  NLFZT TEXT-F60  ‘‘ ‘‘ STPOV NLFZT. "提前期偏置量
  SET_FCAT  VERTI TEXT-F61  ‘‘ ‘‘ STPOV VERTI. "组件消耗的分配键值
  SET_FCAT  ALPOS TEXT-F62  ‘‘ ‘‘ STPOV ALPOS. "指示符:替代项目
  SET_FCAT  EWAHR TEXT-F63  ‘‘ ‘‘ STPOV EWAHR. "使用可能性按 % (可选项目)
  SET_FCAT  EKGRP TEXT-F64  ‘‘ ‘‘ STPOV EKGRP. "采购组
  SET_FCAT  LIFZT TEXT-F65  ‘‘ ‘‘ STPOV LIFZT. "以天计算的交货时间
  SET_FCAT  LIFNR TEXT-F66  ‘‘ ‘‘ STPOV LIFNR. "供应商或债权人的帐号
  SET_FCAT  PREIS TEXT-F67  ‘‘ ‘‘ STPOV PREIS. "价格
  SET_FCAT  PEINH TEXT-F68  ‘‘ ‘‘ STPOV PEINH. "价格单位
  SET_FCAT  WAERS TEXT-F69  ‘‘ ‘‘ STPOV WAERS. "货币码
  SET_FCAT  SAKTO TEXT-F70  ‘‘ ‘‘ STPOV SAKTO. "成本要素
  SET_FCAT  ROANZ TEXT-F71  ‘‘ ‘‘ STPOV ROANZ. "可变大小项目号
  SET_FCAT  ROMS1 TEXT-F72  ‘‘ ‘‘ STPOV ROMS1. "尺寸1
  SET_FCAT  ROMS2 TEXT-F73  ‘‘ ‘‘ STPOV ROMS2. "尺寸2
  SET_FCAT  ROMS3 TEXT-F74  ‘‘ ‘‘ STPOV ROMS3. "大小 3
  SET_FCAT  ROMEI TEXT-F75  ‘‘ ‘‘ STPOV ROMEI. "大小 1 到 3 的计量单位
  SET_FCAT  ROMEN TEXT-F76  ‘‘ ‘‘ STPOV ROMEN. "可变尺寸项目数量
  SET_FCAT  RFORM TEXT-F77  ‘‘ ‘‘ STPOV RFORM. "公式码
  SET_FCAT  UPSKZ TEXT-F78  ‘‘ ‘‘ STPOV UPSKZ. "指示符 : 子项目存在
  SET_FCAT  LTXSP TEXT-F79  ‘‘ ‘‘ STPOV LTXSP. "语言:用此语言存储长文本
  SET_FCAT  POTX1 TEXT-F80  ‘‘ ‘‘ STPOV POTX1. "BOM 项目文本(行1)
  SET_FCAT  POTX2 TEXT-F81  ‘‘ ‘‘ STPOV POTX2. "BOM 项目文本 (行 2)
  SET_FCAT  OBJTY TEXT-F82  ‘‘ ‘‘ STPOV OBJTY. "对象类型(BOM 项目)
  SET_FCAT  MATKL TEXT-F83  ‘‘ ‘‘ STPOV MATKL. "物料组
  SET_FCAT  WEBAZ TEXT-F84  ‘‘ ‘‘ STPOV WEBAZ. "以天计的收货处理时间
  SET_FCAT  DOKAR TEXT-F85  ‘‘ ‘‘ STPOV DOKAR. "文档类型
  SET_FCAT  DOKNR TEXT-F86  ‘‘ ‘‘ STPOV DOKNR. "凭证编号
  SET_FCAT  DOKVR TEXT-F87  ‘‘ ‘‘ STPOV DOKVR. "文档版本
  SET_FCAT  DOKTL TEXT-F88  ‘‘ ‘‘ STPOV DOKTL. "凭证部分
  SET_FCAT  CSSTR TEXT-F89  ‘‘ ‘‘ STPOV CSSTR. "平均物料纯度按 %
  SET_FCAT  CLASS TEXT-F90  ‘‘ ‘‘ STPOV CLASS. "类号
  SET_FCAT  KLART TEXT-F91  ‘‘ ‘‘ STPOV KLART. "类别种类
  SET_FCAT  POTPR TEXT-F92  ‘‘ ‘‘ STPOV POTPR. "项目类别(物料单)
  SET_FCAT  EKORG TEXT-F93  ‘‘ ‘‘ STPOV EKORG. "采购组织
  SET_FCAT  CLOBK TEXT-F94  ‘‘ ‘‘ STPOV CLOBK. "所需组件
  SET_FCAT  CLMUL TEXT-F95  ‘‘ ‘‘ STPOV CLMUL. "允许的多重选择
  SET_FCAT  KNOBJ TEXT-F96  ‘‘ ‘‘ STPOV KNOBJ. "具有分配相关性的对象编号
  SET_FCAT  LGORT TEXT-F97  ‘‘ ‘‘ STPOV LGORT. "生产订单的发货地点
  SET_FCAT  KZKUP TEXT-F98  ‘‘ ‘‘ STPOV KZKUP. "指示符:联合产品
  SET_FCAT  INTRM TEXT-F99  ‘‘ ‘‘ STPOV INTRM. "中间物料
  SET_FCAT  DVDAT TEXT-E01  ‘‘ ‘‘ STPOV DVDAT. "最后日期班次的日期
  SET_FCAT  DVNAM TEXT-E02  ‘‘ ‘‘ STPOV DVNAM. "进行日期变更的用户的名称
  SET_FCAT  DSPST TEXT-E03  ‘‘ ‘‘ STPOV DSPST. "展开类型
  SET_FCAT  ALPST TEXT-E04  ‘‘ ‘‘ STPOV ALPST. "替代项目:策略
  SET_FCAT  ALPRF TEXT-E05  ‘‘ ‘‘ STPOV ALPRF. "替代项目:评比定单
  SET_FCAT  ALPGR TEXT-E06  ‘‘ ‘‘ STPOV ALPGR. "替代项目:组
  SET_FCAT  DATUB TEXT-E07  ‘‘ ‘‘ STPOV DATUB. "有效截止日期
  SET_FCAT  VWALT TEXT-E08  ‘‘ ‘‘ STPOV VWALT. "可选的 BOM
  SET_FCAT  AENRA TEXT-E09  ‘‘ ‘‘ STPOV AENRA. "更改号到
  SET_FCAT  AENKZ TEXT-E10  ‘‘ ‘‘ STPOV AENKZ. "修改标识
  SET_FCAT  MTBME TEXT-E11  ‘‘ ‘‘ STPOV MTBME. "基本计量单位
  SET_FCAT  MTAME TEXT-E12  ‘‘ ‘‘ STPOV MTAME.  "发货单位
  SET_FCAT  UMREZ TEXT-E13  ‘‘ ‘‘ STPOV UMREZ. "基本计量单位转换分子
  SET_FCAT  UMREN TEXT-E14  ‘‘ ‘‘ STPOV UMREN. "转换为基本计量单位的分母
  SET_FCAT  NLFZV TEXT-E15  ‘‘ ‘‘ STPOV NLFZV. "工序的提前期偏移量
  SET_FCAT  NLFMV TEXT-E16  ‘‘ ‘‘ STPOV NLFMV. "工序提前期偏移量的单位
  SET_FCAT  VBELN TEXT-E17  ‘‘ ‘‘ STPOV VBELN. "销售订单
  SET_FCAT  VBPOS TEXT-E18  ‘‘ ‘‘ STPOV VBPOS. "销售订单行项
  SET_FCAT  PSPNR TEXT-E19  ‘‘ ‘‘ STPOV PSPNR. "WBS 要素
  SET_FCAT  RFPNT TEXT-E20  ‘‘ ‘‘ STPOV RFPNT. "BOM 传输的参考点


  CALL FUNCTION REUSE_ALV_GRID_DISPLAY_LVC
    EXPORTING
*     I_INTERFACE_CHECK        = ‘ ‘
*     I_BYPASSING_BUFFER       =
*     I_BUFFER_ACTIVE          =
      I_CALLBACK_PROGRAM       = SY-REPID
      I_CALLBACK_PF_STATUS_SET = FRM_SET_PF_STATUS
*     I_CALLBACK_USER_COMMAND  = ‘FRM_ALV_USER_COMMAND‘
*     I_CALLBACK_TOP_OF_PAGE   = ‘ ‘
*     I_CALLBACK_HTML_TOP_OF_PAGE       = ‘ ‘
*     I_CALLBACK_HTML_END_OF_LIST       = ‘ ‘
*     I_STRUCTURE_NAME         =
*     I_BACKGROUND_ID          = ‘ ‘
*     I_GRID_TITLE             =
*     I_GRID_SETTINGS          =
      IS_LAYOUT_LVC            = IS_LAYOUT
      IT_FIELDCAT_LVC          = IT_FIELDCAT_LVC[]
*     IT_EXCLUDING             =
*     IT_SPECIAL_GROUPS_LVC    =
*     IT_SORT_LVC              =
*     IT_FILTER_LVC            =
*     IT_HYPERLINK             =
*     IS_SEL_HIDE              =
*     I_DEFAULT                = ‘X‘
*     I_SAVE                   = ‘ ‘
*     IS_VARIANT               =
*     IT_EVENTS                =
*     IT_EVENT_EXIT            =
*     IS_PRINT_LVC             =
*     IS_REPREP_ID_LVC         =
*     I_SCREEN_START_COLUMN    = 0
*     I_SCREEN_START_LINE      = 0
*     I_SCREEN_END_COLUMN      = 0
*     I_SCREEN_END_LINE        = 0
*     I_HTML_HEIGHT_TOP        =
*     I_HTML_HEIGHT_END        =
*     IT_ALV_GRAPHICS          =
*     IT_EXCEPT_QINFO_LVC      =
*     IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER  =
*     ES_EXIT_CAUSED_BY_USER   =
    TABLES
      T_OUTTAB                 = GT_OUT[]
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.
  IF SY-SUBRC <> 0.

  ENDIF.

ENDFORM.

FORM FRM_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.

  DATA:RS_EXTAB TYPE LINE OF SLIS_T_EXTAB.

*   CLEAR:rs_extab,rt_extab.
*   IF rb1 = ‘X‘.
*     rs_extab-fcode = ‘EXECUTE‘.
*     APPEND rs_extab TO rt_extab.
*     rs_extab-fcode = ‘REVERSE‘.
*     APPEND rs_extab TO rt_extab.
*   ENDIF.

*  SET PF-STATUS ‘ZMAIN‘ EXCLUDING RT_EXTAB.
  SET PF-STATUS ZMAIN.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form MNG_DSP_NEW
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM MNG_DSP_NEW .
  DATA: TMP_FLT1 TYPE F,
        TMP_FLT2 TYPE F.

*  abs. Btrg.
  IF LTB-MSIGN = -.
    GT_DATA-MENGE = GT_DATA-MENGE * -1 .
    GT_DATA-EMENG = GT_DATA-EMENG * -1 .
    GT_DATA-FXMNG = GT_DATA-FXMNG * -1 .
  ENDIF.

*  einstufig
  IF GT_DATA-LEVEL = 1 . "单层
    CASE GT_DATA-SUMFG.
      WHEN SPACE.
        GT_DATA-EMENG = GT_DATA-MENGE.
*d          GT_DATA-EMEIH = GT_DATA-MEINS.                            "HGA013934

        IF NOT PM_EMENG IS INITIAL.
          IF GT_DATA-FMENG IS INITIAL.
            DSP_IMENG = PM_EMENG.

            TMP_FLT1 =   GT_DATA-BMENG
                       * (   PM_EMENG
                           / GT_DATA-MENGE ) .
            IF TMP_FLT1 < MAX_FNUM.
              DSP_RMENG = TMP_FLT1.
              SAV_FRMNG = TMP_FLT1.                         "HGA131954
            ELSE.
              DSP_RMENG = MAX_FNUM.
              SAV_FRMNG = MAX_FNUM.                         "HGA131954
            ENDIF.
          ELSE.
            DSP_IMENG = GT_DATA-MENGE.

            DSP_RMENG = PNULL.
            SAV_FRMNG = FNULL.                              "HGA131954

          ENDIF.
        ENDIF.

        IF NOT PM_RMENG IS INITIAL.
          IF GT_DATA-FMENG IS INITIAL.
            TMP_FLT1 =   GT_DATA-MENGE
                       * (   PM_RMENG
                           / GT_DATA-BMENG ) .
            IF TMP_FLT1 < MAX_FNUM.
              DSP_IMENG = TMP_FLT1.
            ELSE.
              DSP_IMENG = MAX_FNUM.
            ENDIF.

            DSP_RMENG = PM_RMENG.
            SAV_FRMNG = PM_RMENG.                           "HGA131954
          ELSE.
            DSP_IMENG = GT_DATA-MENGE.
            DSP_RMENG = PNULL.
            SAV_FRMNG = FNULL.                              "HGA131954
          ENDIF.
        ENDIF.

        IF     PM_EMENG IS INITIAL
           AND PM_RMENG IS INITIAL.

          IF GT_DATA-FMENG IS INITIAL.
            DSP_IMENG = GT_DATA-MENGE.
            DSP_RMENG = GT_DATA-BMENG.
            SAV_FRMNG = GT_DATA-BMENG.                      "HGA131954
          ELSE.
            DSP_IMENG = GT_DATA-MENGE.
            DSP_RMENG = PNULL.
            SAV_FRMNG = FNULL.                              "HGA131954
          ENDIF.
        ENDIF.

    ENDCASE.
*  mehrstufig
  ELSE.
    "多层需求数量和应用数量计算
*    CHECK GT_DATA-EXCPT NE ‘CONV‘.                          "MBA148624
*    IF MNG_STACK-EXTRM IS INITIAL.
*      CASE GT_DATA-SUMFG.
*        WHEN SPACE.
*
*          IF NOT PM_EMENG IS INITIAL.
*            IF GT_DATA-FMENG IS INITIAL.
*              DSP_IMENG = OPO_MENGE.
*
*              TMP_FLT1 =   GT_DATA-BMENG
*                         * (   MNG_STACK-EMENG
*                             / GT_DATA-EMENG ).
*              IF TMP_FLT1 < MAX_FNUM.
*                DSP_RMENG = TMP_FLT1.
*                SAV_FRMNG = TMP_FLT1.                       "HGA131954
*              ELSE.
*                DSP_RMENG = MAX_FNUM.
*                SAV_FRMNG = MAX_FNUM.                       "HGA131954
*              ENDIF.
*            ELSE.
*              TMP_FLT1 =   (   GT_DATA-EMENG
*                              * OPO_MENGE )
*                         / MNG_STACK-EMENG .
*              IF TMP_FLT1 < MAX_FNUM.
*                DSP_IMENG = TMP_FLT1.
*              ELSE.
*                DSP_IMENG = MAX_FNUM.
*              ENDIF.
*
*              DSP_RMENG = PNULL.
*              SAV_FRMNG = FNULL.                            "HGA131954
*            ENDIF.
*          ENDIF.
*
*          IF NOT PM_RMENG IS INITIAL.
*            IF GT_DATA-FMENG IS INITIAL.
*              TMP_FLT1 =   (   (   GT_DATA-EMENG
*                                 * PM_RMENG )
*                             / GT_DATA-BMENG )
*                         * MNG_STACK-EMFAC.
*              IF TMP_FLT1 < MAX_FNUM.
*                DSP_IMENG = TMP_FLT1.
*              ELSE.
*                DSP_IMENG = MAX_FNUM.
*              ENDIF.
*
*              DSP_RMENG = PM_RMENG.
*              SAV_FRMNG = PM_RMENG.                         "HGA131954
*            ELSE.
*              DSP_IMENG = GT_DATA-EMENG * MNG_STACK-EMFAC.
*              DSP_RMENG = PNULL.
*              SAV_FRMNG = FNULL.                            "HGA131954
*            ENDIF.
*          ENDIF.
*
*          IF     PM_EMENG IS INITIAL
*             AND PM_RMENG IS INITIAL.
*
*            IF GT_DATA-FMENG IS INITIAL.
*              DSP_IMENG = OPO_MENGE.
*
*              TMP_FLT1 =   GT_DATA-BMENG
*                         * (   MNG_STACK-EMENG
*                             / GT_DATA-EMENG ).
*              IF TMP_FLT1 < MAX_FNUM.
*                DSP_RMENG = TMP_FLT1.
*                SAV_FRMNG = TMP_FLT1.                       "HGA131954
*
*              ELSE.
*                DSP_RMENG = MAX_FNUM.
*                SAV_FRMNG = MAX_FNUM.                       "HGA131954
*              ENDIF.
*            ELSE.
*              TMP_FLT1 =   (   GT_DATA-EMENG
*                              * OPO_MENGE )
*                         / MNG_STACK-EMENG .
*              IF TMP_FLT1 < MAX_FNUM.
*                DSP_IMENG = TMP_FLT1.
*              ELSE.
*                DSP_IMENG = MAX_FNUM.
*              ENDIF.
*
*              DSP_RMENG = PNULL.
*              SAV_FRMNG = FNULL.                            "HGA131954
*
*            ENDIF.
*          ENDIF.
*
*      ENDCASE.
*
**d    IF act_ldsgn = ‘-‘.                                    "note 57953
*      IF MNG_STACK-LDSGN = ‘-‘.                              "note 57953
*        DSP_IMENG = DSP_IMENG * -1 .
*      ENDIF.
*    ELSE.
*      DSP_IMENG = PNULL.
*      DSP_RMENG = PNULL.
*      SAV_FRMNG = FNULL.                                    "HGA131954
*    ENDIF.
  ENDIF.

*  abs. Btrg. rück
  IF     GT_DATA-MSIGN = -.
    GT_DATA-MENGE = GT_DATA-MENGE * -1 .
    GT_DATA-EMENG = GT_DATA-EMENG * -1 .
    GT_DATA-FXMNG = GT_DATA-FXMNG * -1 .
    DSP_IMENG = DSP_IMENG * -1 .
  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form EXP_WUTAB
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_S_IDNRK_LOW  text
*      -->P_PM_WERKS  text
*      -->P_PM_STLAN  text
*&---------------------------------------------------------------------*
FORM EXP_WUTAB
   USING LCL_MATNR
         LCL_WERKS
         LCL_STLAN.

  WU_MEMID-TABID = LT.
  WU_MEMID-MATNR = LCL_MATNR.
  WU_MEMID-WERKS = LCL_WERKS.
  WU_MEMID-STLAN = LCL_STLAN.
  EXPORT LTB TO MEMORY ID WU_MEMID.

  WU_MEMID-TABID = MT.
  EXPORT MATCAT TO MEMORY ID WU_MEMID.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form REG_WURES
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_S_IDNRK_LOW  text
*      -->P_PM_WERKS  text
*      -->P_PM_STLAN  text
*      -->P_       text
*      -->P_       text
*      -->P_       text
*&---------------------------------------------------------------------*

FORM REG_WURES
   USING LCL_MATNR
         LCL_WERKS
         LCL_STLAN
         LCL_WUCHK
         LCL_ISUSD
         LCL_WUTCK.

  WU_CTAB_KEY-MATNR = LCL_MATNR.
  WU_CTAB_KEY-WERKS = LCL_WERKS.
  WU_CTAB_KEY-STLAN = LCL_STLAN.
  READ TABLE WU_CTAB WITH KEY WU_CTAB_KEY.

  IF SY-SUBRC <> 0.
    MOVE-CORRESPONDING WU_CTAB_KEY TO WU_CTAB.
    WU_CTAB-WUCHK = LCL_WUCHK.
    WU_CTAB-ISUSD = LCL_ISUSD.
    WU_CTAB-WUTCK = LCL_WUTCK.
    APPEND WU_CTAB.
  ELSE.
    IF NOT LCL_WUCHK IS INITIAL.
      WU_CTAB-WUCHK = LCL_WUCHK.
    ENDIF.

    IF NOT LCL_ISUSD IS INITIAL.
      WU_CTAB-ISUSD = LCL_ISUSD.
    ENDIF.

    IF NOT LCL_WUTCK IS INITIAL.
      WU_CTAB-WUTCK = LCL_WUTCK.
    ENDIF.

    MODIFY WU_CTAB.
  ENDIF.
ENDFORM.

 

 




SAP PP 批量反查BOM

标签:错误   new   button   订单   art   tls   page   read   stat   

原文地址:https://www.cnblogs.com/rainysblog/p/14925362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!