对CU50的修改(未使用)

目的是把CU50中的选择配置拿出来,再把最后BOM的结果拿出来。2023.10.13

一、CU50里面2个标准函数有修改:

----------LCUKOF01----函数----------------

        CALL FUNCTION 'CU01_DISPLAY_BOM'
          EXPORTING
            masterdata           = rcuko-ukomp
            RESULT               = rcuko-uaktk
            level_by_level       = rcuko-dmstu
            all_components       = rcuko-ucmpf
            no_masterdata        = g_nomd
            no_result            = g_nore
            include_header       = incl1
          IMPORTING
            return_with_function = list_okcode
          TABLES
            bom_list_index       = indx_clst
            bom_list             = lt_clst.

*{   INSERT         S4DK913063                                        1
DATA gs_ZCU50_LIST  like ZCU50_LIST.

DELETE FROM ZCU50_LIST.
COMMIT WORK .

LOOP AT gt_clst_for_list INTO DATA(gs400) WHERE INTENSIV = 'X' AND INSTP = '1'.

  gs_ZCU50_LIST-UUID = cl_uuid_factory=>create_system_uuid( )->create_uuid_c22( ).
  gs_ZCU50_LIST-TEXT =  gs400-ZEILE.

  INSERT into ZCU50_LIST VALUES gs_ZCU50_LIST.
  CLEAR gs_ZCU50_LIST.

ENDLOOP.

*}   INSERT



-----------LCEI0F90函数--------------

   CALL FUNCTION 'CUTC_GET_SETTINGS'
    IMPORTING
      active = lv_ddb_trace.

  IF lv_ddb_trace IS INITIAL.
    ls_fcode-fcode = 'TRCD'.
    APPEND ls_fcode TO lt_fcode.
  ELSE.
    ls_fcode-fcode = 'TRCA'.
    APPEND ls_fcode TO lt_fcode.
  ENDIF.
*{   INSERT         S4DK913063                                        1


  DATA gs_ZVCOND_SD like ZVCOND_SD.

  DELETE FROM ZVCOND_SD.
  COMMIT WORK .


  gs_ZVCOND_SD-UUID = cl_uuid_factory=>create_system_uuid( )->create_uuid_c22( ).
  gs_ZVCOND_SD-VARCOND = GV_MATNR.
  INSERT into ZVCOND_SD VALUES gs_ZVCOND_SD.
  CLEAR gs_ZVCOND_SD.

  gs_ZVCOND_SD-UUID = cl_uuid_factory=>create_system_uuid( )->create_uuid_c22( ).
  gs_ZVCOND_SD-VARCOND = GV_WERKS.
  INSERT into ZVCOND_SD VALUES gs_ZVCOND_SD.
  CLEAR gs_ZVCOND_SD.

  gs_ZVCOND_SD-UUID = cl_uuid_factory=>create_system_uuid( )->create_uuid_c22( ).
  gs_ZVCOND_SD-VARCOND = GV_DATE.
  INSERT into ZVCOND_SD VALUES gs_ZVCOND_SD.
  CLEAR gs_ZVCOND_SD.

LOOP AT GT_VCOND_SD INTO DATA(gs400).

  gs_ZVCOND_SD-UUID = cl_uuid_factory=>create_system_uuid( )->create_uuid_c22( ).
  gs_ZVCOND_SD-VARCOND =  gs400-VARCOND.

  INSERT into ZVCOND_SD VALUES gs_ZVCOND_SD.
  CLEAR gs_ZVCOND_SD.

ENDLOOP.


*}   INSERT

二、存数据的透明表:

对CU50的修改(未使用)_第1张图片

对CU50的修改(未使用)_第2张图片

三、处理程序:






*&---------------------------------------------------------------------*
*& Report ZPPR0016B
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZPPR0016B.



TABLES:vbap,stko,ZCU50_LIST.


  DATA ls_write     TYPE zspp_bominfo.
  DATA ls_head      TYPE zspp_bominfo.
  DATA lt_head      TYPE TABLE OF zspp_bominfo.
  DATA lv_rfcdest   TYPE rfcdest.
  DATA lt_esb_com   TYPE zsca_esb_com_tab.
  DATA lt_bomlist   TYPE TABLE OF zspp_bomlist.


DATA gt_stpo TYPE TABLE OF stpox.
DATA:gs_layout   TYPE lvc_s_layo,                           "#EC NEEDED
     gs_glay     TYPE lvc_s_glay,                           "#EC NEEDED
     gt_fieldcat TYPE lvc_t_fcat.                           "#EC NEEDED



TYPES: BEGIN OF ty_table,
         matnr(40)       TYPE C,
       END OF ty_table.

DATA gt_SAP TYPE  TABLE OF ty_table.
DATA gt_APS TYPE  TABLE OF ty_table.

DATA gs_gsgs TYPE ty_table.




SELECTION-SCREEN BEGIN OF BLOCK a0 WITH FRAME TITLE TEXT-001.


PARAMETERS:p_datuv TYPE stko-datuv DEFAULT sy-datum.     "有效起始日期

SELECTION-SCREEN END OF BLOCK a0.


START-OF-SELECTION.


PERFORM frm_SAP_data.

PERFORM frm_APS_data.

PERFORM frm_xxx.



FORM frm_SAP_data.

  DATA GT_ZCU50_LIST TYPE TABLE OF ZCU50_LIST.

  SELECT * FROM ZCU50_LIST INTO TABLE GT_ZCU50_LIST.

  LOOP AT GT_ZCU50_LIST ASSIGNING FIELD-SYMBOL().

    gs_gsgs-MATNR = -TEXT+8(40) .

    IF gs_gsgs-MATNR EQ 'F2'.   CONTINUE.  ENDIF.
    IF gs_gsgs-MATNR EQ 'F2PD'. CONTINUE.  ENDIF.
    IF gs_gsgs-MATNR EQ 'F2BD'. CONTINUE.  ENDIF.

    APPEND gs_gsgs to gt_SAP.
    CLEAR gs_gsgs.

  ENDLOOP.

ENDFORM.



FORM frm_APS_data.

  DATA GT_VCOND_SD TYPE TABLE OF ZVCOND_SD.

  SELECT * FROM ZVCOND_SD INTO TABLE GT_VCOND_SD.

    LOOP AT GT_VCOND_SD INTO DATA(line).

      "------PM--------------
      if cl_abap_list_utilities=>dynamic_output_length( line-VARCOND ) > 10.  ls_head-ATWRT1 = line-VARCOND.         ENDIF.

      "------CC--------------
        IF line-VARCOND+0(2)  EQ 'CC' .

             ls_head-ATWRT2 = line-VARCOND.

        ENDIF.

      "------PA--------------
       IF line-VARCOND+0(2)  EQ 'PA' .

             ls_head-ATWRT3 = line-VARCOND.

        ENDIF.

      "------P0--------------
      IF line-VARCOND+0(2)  EQ 'P0' .


             IF ls_head-ATWRT4 is INITIAL.

               ls_head-ATWRT4 = line-VARCOND.
               ELSE.
                 ls_head-ATWRT4 = ls_head-ATWRT4 && ';'  &&  line-VARCOND.

             ENDIF.
      ENDIF.
      "------1003--------------
       IF line-VARCOND+0(3)  EQ '100' .

            ls_head-werks = line-VARCOND.

        ENDIF.

        "------F2--------------
       IF line-VARCOND+0(2)  EQ 'F2' .

            ls_head-matnr = line-VARCOND.

        ENDIF.

      "------20231013--------------
       IF line-VARCOND+0(3)  EQ '202' .

            ls_head-badat = line-VARCOND.

        ENDIF.

    ENDLOOP.




    IF ls_head-matnr EQ 'F2'.    ls_head-z_st   = 'V'.    ENDIF.
    IF ls_head-matnr EQ 'F2PD'.  ls_head-z_st   = 'P'.    ENDIF.
    IF ls_head-matnr EQ 'F2BD'.  ls_head-z_st   = 'A'.    ENDIF.


    APPEND ls_head TO lt_head .

  ls_write =  ls_head.
    CLEAR ls_head.

   lv_rfcdest = zcl_ca_tools=>get_rfcdest( ).

    CALL FUNCTION 'ZSAP_PP_APS_BOMINFO_OUT' DESTINATION lv_rfcdest
      TABLES
        et_po_header = lt_head
        tt_esb_com   = lt_esb_com
        tt_bomlist   = lt_bomlist.



ENDFORM.








FORM frm_xxx.



"----###############-----------

WRITE:/  p_datuv   &&  ':'   && ls_head-ATWRT1 && ',' && ls_head-ATWRT2 && ',' &&  ls_head-ATWRT3 && ',' &&  ls_head-ATWRT4.


DATA lv_l1 TYPE i VALUE 0.
DATA lv_l2 TYPE i VALUE 0.

lv_l1 = lines( lt_bomlist ).
lv_l2 = lines( gt_SAP ).

WRITE:/ 'APS: '  &&  lv_l1.
WRITE:/ 'SAP: '  &&  lv_l2 .



"----####?##?#-----------



LOOP AT lt_bomlist INTO DATA(gs_2).

  gs_gsgs-MATNR = gs_2-MATNR.

  APPEND gs_gsgs to gt_APS.
  CLEAR gs_gsgs.

ENDLOOP.



SORT gt_SAP.
SORT gt_APS.


IF gt_SAP[] = gt_APS[].
  WRITE:/ 'every item same'.
ELSE.
  WRITE:/ 'some item different'.
ENDIF.




CLEAR:gt_SAP[],gt_APS[],lt_bomlist[],gt_stpo[].






ENDFORM.







FORM frm_ALV.





  "#####?##
TYPES: BEGIN OF ty_flight,
         TXT1(40)  TYPE C,
         id         TYPE i ,
         TXT2(40)  TYPE C,
         TXT3(40)  TYPE C,
       END OF ty_flight.

"#####?#
DATA gt_20 TYPE  TABLE OF ty_flight.
DATA gs_20 TYPE   ty_flight.


*
*
*  LOOP AT gt_SAP INTO DATA(gs_s).
*
*
*     gs_20-TXT2 = gs_s-MATNR.
*     APPEND gs_20 to gt_20.
*     CLEAR gs_20.
*
*
*  ENDLOOP.
*
*
*
*  LOOP AT gt_APS INTO DATA(gs_s).
*
*
*     gs_20-TXT3 = gs_s-MATNR.
*     APPEND gs_20 to gt_20.
*     CLEAR gs_20.
*
*  ENDLOOP.
*






  DATA: WS_FIELDCAT        TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
        WS_FIELDGROUPS_TAB TYPE SLIS_T_SP_GROUP_ALV,
        WS_LAYOUT          TYPE SLIS_LAYOUT_ALV,
        WS_SORTFIELDS_TAB  TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
        WS_EVENTS          TYPE SLIS_T_EVENT.
  DATA: NN TYPE I VALUE 0.
  DATA: TITLE TYPE LVC_TITLE.
  DATA: COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.
*
  DEFINE HOUT.
    NN = NN + 1.
    WS_FIELDCAT-COL_POS       =  NN.
    WS_FIELDCAT-TABNAME       = 'GT_20'.
    WS_FIELDCAT-KEY           = &1.
    WS_FIELDCAT-FIELDNAME     = &2.
    WS_FIELDCAT-SELTEXT_M     = &3.
    WS_FIELDCAT-CFIELDNAME    = &4.
    WS_FIELDCAT-DATATYPE      = &5.
    WS_FIELDCAT-REF_TABNAME   = &6.
    WS_FIELDCAT-REF_FIELDNAME = &7.
    WS_FIELDCAT-DO_SUM        = &8.
    WS_FIELDCAT-HOTSPOT       = &9.
    APPEND WS_FIELDCAT.
    CLEAR WS_FIELDCAT.
  END-OF-DEFINITION.

  HOUT:


''  'TXT1' '##   ##   ##     ##'  ''  ''  ''  ''  ''  '',
''  'TXT2' '  SAP '  ''  ''  ''  ''  ''  '',
''  'TXT3' '  APS  '  ''  ''  ''  ''  ''  ''.



  WS_LAYOUT-ZEBRA             = 'X'.
  WS_LAYOUT-GET_SELINFOS      = 'X'.
  WS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  WS_LAYOUT-DETAIL_POPUP      = 'X'.



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM      = SY-REPID
      IS_LAYOUT               = WS_LAYOUT
      IT_FIELDCAT             = WS_FIELDCAT[]
      IT_SPECIAL_GROUPS       = WS_FIELDGROUPS_TAB[]
      IT_SORT                 = WS_SORTFIELDS_TAB[]
      IT_EVENTS               = WS_EVENTS[]
      I_GRID_TITLE            = TITLE
      I_DEFAULT               = 'X'
      I_SAVE                  = 'A'
    TABLES
      T_OUTTAB                = GT_20[]
    EXCEPTIONS
      PROGRAM_ERROR           = 1
      OTHERS                  = 2.





ENDFORM.

你可能感兴趣的:(SAP,ABAP,SAP,CU50)