• 内表数据量过大时,拆分内表,分批次处理。


    *&---------------------------------------------------------------------*
    *& Report  ZDM_ICM_POLICY_WITH_POL
    *&Created  by James on 2018/07/16
    *&---------------------------------------------------------------------*
    *& the report for query the dirty data with policy
    *& 1 policy has been been released but doesn't have POL/PAC
    *& 2 policy haven't be released but have POL/PAC
    *& 3 policy have pol/pac but no policy released.
    *&---------------------------------------------------------------------*
    REPORT ZDM_ICM_POLICY_WITH_POL.
    *&---------------------------------------------------------------------*
    *&  DATA DEFINE
    *&---------------------------------------------------------------------*
    TYPES:
      BEGIN OF TY_RANGE,
        SIGN(1)   type C,
        OPTION(2) type C,
        LOW       type MATNR,
        HIGH      type MATNR,
      END OF TY_RANGE,
    
      BEGIN OF TY_POLNR_RFC,
        POLICYNR_TT TYPE CHAR30,
        TMP_DEL_FG  TYPE CHAR3,
      END OF TY_POLNR_RFC,
    
      BEGIN OF TY_POLNR_RFC_PM,
        POLICYNR_TT  TYPE CHAR17,
        TMP_DEL_FG   TYPE CHAR1,
      END OF TY_POLNR_RFC_PM,
    
      BEGIN OF TY_CAS,
        BUSOBJ_TYPE  TYPE CHAR3,
        BUSOBJ_ID    TYPE CHAR30,
      END OF TY_CAS.
    
    DATA:
      GT_CAS_NO_RE    TYPE TABLE OF TY_CAS,
      GT_CAS_YE_RE    TYPE TABLE OF TY_CAS,
      GT_CAS_HAVE_PO    TYPE TABLE OF TY_CAS,
      GT_FIELDCAT     TYPE lVC_T_FCAT,
      GS_FIELDCAT     TYPE lVC_S_FCAT,
      GS_LAYOUT       TYPE lVC_S_LAYO,
    
    * temporary storage
      GT_POLNR_YE_RFC TYPE TABLE OF TY_POLNR_RFC,
      GT_POLNR_NO_RFC TYPE TABLE OF TY_POLNR_RFC.
    
    *&---------------------------------------------------------------------*
    *&  PARAMETERS DEFINITION
    *&---------------------------------------------------------------------*
    SELECTION-SCREEN BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-B01.
    PARAMETERS:
      P_RELE RADIOBUTTON GROUP RD1 TYPE CHAR1,
      P_NULL RADIOBUTTON GROUP RD1 TYPE CHAR1 DEFAULT 'X',
      P_POL  RADIOBUTTON GROUP RD1 TYPE CHAR1,
      P_DEST  TYPE RFCDES-RFCDEST.
    SELECTION-SCREEN END OF BLOCK B01.
    
    *&---------------------------------------------------------------------*
    *&  INITIALIZATION
    *&---------------------------------------------------------------------*
    INITIALIZATION.
    CLEAR:
      GT_CAS_NO_RE,
      GT_CAS_YE_RE,
      GT_CAS_HAVE_PO,
      GT_FIELDCAT,
      GS_FIELDCAT,
      GS_LAYOUT.
    
    *&---------------------------------------------------------------------*
    *&  START-OF-SELECTION
    *&---------------------------------------------------------------------*
    START-OF-SELECTION.
    
    PERFORM CALL_RFC.
    PERFORM EDIT_POLNR.
    
    IF GT_CAS_NO_RE    IS INITIAL AND
       GT_CAS_YE_RE    IS INITIAL AND
       GT_CAS_HAVE_PO  IS INITIAL.
      EXIT.
    ENDIF.
    PERFORM ALV_SHOW.
    *&---------------------------------------------------------------------*
    *&      Form  CALL_RFC
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  <--  GT_POLNR_YE_RFC        Released yes
    *  <--  GT_POLNR_NO_RFC        Released no
    *----------------------------------------------------------------------*
    FORM CALL_RFC .
      DATA:
        LT_RFC          TYPE TABLE OF TY_POLNR_RFC_PM,
        LT_POLNR_YE_RFC TYPE TABLE OF TY_POLNR_RFC,
        LT_POLNR_NO_RFC TYPE TABLE OF TY_POLNR_RFC,
        LS_POLNR_YE_RFC TYPE TY_POLNR_RFC,
        LS_POLNR_NO_RFC TYPE TY_POLNR_RFC.
    
      FIELD-SYMBOLS:
        <FS_RFC>        TYPE TY_POLNR_RFC_PM.
    
      CLEAR:
        LT_RFC,
        LT_POLNR_YE_RFC,
        LT_POLNR_NO_RFC,
        LS_POLNR_YE_RFC,
        LS_POLNR_NO_RFC.
    
      UNASSIGN:
        <FS_RFC>.
    
    *   Call RFC
        CALL FUNCTION 'ZDM_ICM_GET_POLICY'
        DESTINATION P_DEST
        TABLES
           TT_POLNR_RCF = LT_RFC.
    
    * divide policy as released and not yet
      IF LT_RFC IS NOT INITIAL.
    
    *   has been released
        IF P_RELE = ABAP_TRUE.
          SORT LT_RFC BY TMP_DEL_FG DESCENDING.
          LOOP AT LT_RFC ASSIGNING <FS_RFC>
            WHERE TMP_DEL_FG   = ABAP_TRUE.
            LS_POLNR_YE_RFC-POLICYNR_TT = <FS_RFC>-POLICYNR_TT.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT         = LS_POLNR_YE_RFC-POLICYNR_TT
             IMPORTING
               OUTPUT         = LS_POLNR_YE_RFC-POLICYNR_TT.
              LS_POLNR_YE_RFC-TMP_DEL_FG  = <FS_RFC>-TMP_DEL_FG.
              APPEND LS_POLNR_YE_RFC TO LT_POLNR_YE_RFC.
              CLEAR LS_POLNR_YE_RFC.
          ENDLOOP.
          MOVE-CORRESPONDING LT_POLNR_YE_RFC TO GT_POLNR_YE_RFC.
    
          IF GT_POLNR_YE_RFC IS INITIAL.
            MESSAGE 'Can not find Policy which already be released from /PM0/ABDQMIGJOUR ' TYPE 'E'.
            EXIT.
          ENDIF.
    
    *   hasn't be released
        ELSEIF P_NULL = ABAP_TRUE OR P_POL = ABAP_TRUE.
          SORT LT_RFC BY TMP_DEL_FG ASCENDING.
          LOOP AT LT_RFC ASSIGNING <FS_RFC>
            WHERE  TMP_DEL_FG   = ABAP_FALSE.
            LS_POLNR_NO_RFC-POLICYNR_TT = <FS_RFC>-POLICYNR_TT.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT         = LS_POLNR_NO_RFC-POLICYNR_TT
             IMPORTING
               OUTPUT         = LS_POLNR_NO_RFC-POLICYNR_TT.
    
            LS_POLNR_NO_RFC-TMP_DEL_FG  = <FS_RFC>-TMP_DEL_FG.
            APPEND LS_POLNR_NO_RFC TO LT_POLNR_NO_RFC.
            CLEAR LS_POLNR_NO_RFC.
          ENDLOOP.
    
          MOVE-CORRESPONDING LT_POLNR_NO_RFC TO GT_POLNR_NO_RFC.
          IF GT_POLNR_NO_RFC IS INITIAL.
            MESSAGE 'Can not find Policy which has not be released from /PM0/ABDQMIGJOUR ' TYPE 'E'.
            EXIT.
          ENDIF.
        ENDIF.
    
      ELSE.
        MESSAGE 'Can not get any Polict from /PM0/ABDQMIGJOUR ' TYPE 'E'.
        EXIT.
      ENDIF.
    
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  EDIT_POLNR
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  GT_POLNR_YE_RFC        Released yes
    *  -->  GT_POLNR_NO_RFC        Released no
    *  <--  GT_CAS_YE_RE           policy has been been released but doesn't have POL/PAC
    *  <--  GT_CAS_NO_RE           policy haven't be released but have POL/PAC
    *  <--  GT_CAS_HAVE_PO         policy have pol/pac but no policy released.
    *----------------------------------------------------------------------*
    FORM EDIT_POLNR .
      DATA:
        LT_CAS_NO_RE      TYPE TABLE OF TY_CAS,
        LT_CAS_YE_RE      TYPE TABLE OF TY_CAS,
        LT_CAS_HAVE_PO    TYPE TABLE OF TY_CAS,
        LT_RANGE          TYPE TABLE OF TY_RANGE,
        LS_RANGE          TYPE TY_RANGE,
        LT_POLNR_NO_RE    TYPE TABLE OF TY_POLNR_RFC,  " Released yes
        LT_POLNR_YE_RE    TYPE TABLE OF TY_POLNR_RFC,  " Released no
        LS_POLNR_YE_RE    TYPE  TY_CAS,
    *----------start add by james in 2018/08/02 DE1K9A028J-----------
        LV_PACKGE         TYPE I VALUE '500000',
        LV_COUNT          TYPE i,
        LV_START          TYPE i VALUE '1',
        LV_END            TYPE I.
    *----------end   add by james in 2018/08/02 DE1K9A028J-----------
      FIELD-SYMBOLS:
        <FS_POLNR_YE_RE>  TYPE TY_POLNR_RFC,
        <FS_CAS_YE_RE>    TYPE TY_CAS.
    
      CLEAR:
        LT_CAS_NO_RE,
        LT_CAS_YE_RE,
        LT_CAS_HAVE_PO,
        LT_RANGE,
        LS_RANGE,
        LT_POLNR_NO_RE,
        LT_POLNR_YE_RE.
    
      UNASSIGN:
       <FS_POLNR_YE_RE>,
       <FS_CAS_YE_RE>.
    
    * define range
      LS_RANGE-sign    = 'I'.
      LS_RANGE-option  = 'EQ'.
      LS_RANGE-low     = 'POL'.
      APPEND LS_RANGE TO LT_RANGE.
      CLEAR LS_RANGE.
    
      LS_RANGE-sign    = 'I'.
      LS_RANGE-option  = 'EQ'.
      LS_RANGE-low     = 'PAC'.
      APPEND LS_RANGE TO LT_RANGE.
    
    * case1 for released
      IF P_RELE = ABAP_TRUE.
    *----------start add by james in 2018/08/02 DE1K9A028J-----------
        DESCRIBE TABLE GT_POLNR_YE_RFC LINES LV_COUNT.
        WHILE LV_START <= LV_COUNT.
          LV_END = LV_START + LV_PACKGE - 1 .
          APPEND LINES OF GT_POLNR_YE_RFC FROM LV_START TO LV_END TO LT_POLNR_YE_RE .
          LV_START = LV_END + 1.
    *      IF SY-TABIX MOD LV_PACKGE = 0 OR SY-TABIX = LV_COUNT.
          IF LT_POLNR_YE_RE IS NOT INITIAL.
            SELECT BUSOBJ_TYPE
                   BUSOBJ_ID
              INTO CORRESPONDING FIELDS OF TABLE LT_CAS_YE_RE
              FROM ZICNSL_CAS
              FOR ALL ENTRIES IN LT_POLNR_YE_RE
              WHERE BUSOBJ_ID    = LT_POLNR_YE_RE-POLICYNR_TT
              AND   BUSOBJ_TYPE  IN LT_RANGE.
    
    *       policy has been been released but doesn't have POL/PAC
            IF LT_CAS_YE_RE IS NOT INITIAL.
              SORT LT_CAS_YE_RE BY BUSOBJ_ID.
              DELETE ADJACENT DUPLICATES FROM LT_CAS_YE_RE COMPARING BUSOBJ_ID.
              SORT LT_POLNR_YE_RE BY POLICYNR_TT.
              SORT LT_CAS_YE_RE   BY BUSOBJ_ID .
    
              LOOP AT LT_POLNR_YE_RE ASSIGNING <FS_POLNR_YE_RE>.
                READ TABLE LT_CAS_YE_RE ASSIGNING <FS_CAS_YE_RE>
                  WITH KEY BUSOBJ_ID = <FS_POLNR_YE_RE>-POLICYNR_TT BINARY SEARCH.
                IF SY-SUBRC <> 0.
                  LS_POLNR_YE_RE-BUSOBJ_ID    = <FS_POLNR_YE_RE>-POLICYNR_TT.
                  LS_POLNR_YE_RE-BUSOBJ_TYPE  = 'No'.
                  APPEND LS_POLNR_YE_RE  TO GT_CAS_YE_RE.
                  CLEAR:LS_POLNR_YE_RE.
                ENDIF.
              ENDLOOP.
            ENDIF.
          ENDIF.
          CLEAR:
            LT_POLNR_YE_RE,
            LT_CAS_YE_RE.
        ENDWHILE.
    
        IF GT_CAS_YE_RE IS INITIAL .
          MESSAGE 'according to released policy, haven not find pol/pac' TYPE 'E'.
          EXIT.
        ENDIF.
    *----------end   add by james in 2018/08/02 DE1K9A028J-----------
      ENDIF.
    
    * case2 for haven't be released
      IF P_NULL = ABAP_TRUE.
    *----------start add by james in 2018/08/02 DE1K9A028J-----------
        DESCRIBE TABLE GT_POLNR_NO_RFC LINES LV_COUNT.
        WHILE LV_START <= LV_COUNT.
          LV_END = LV_START + LV_PACKGE - 1 .
          APPEND LINES OF GT_POLNR_NO_RFC FROM LV_START TO LV_END TO LT_POLNR_NO_RE .
          LV_START = LV_END + 1.
    *      IF SY-TABIX MOD LV_PACKGE = 0 OR SY-TABIX = LV_COUNT.
          IF LT_POLNR_NO_RE IS NOT INITIAL.
            SELECT BUSOBJ_TYPE
                   BUSOBJ_ID
               INTO CORRESPONDING FIELDS OF TABLE LT_CAS_NO_RE
              FROM ZICNSL_CAS
              FOR ALL ENTRIES IN LT_POLNR_NO_RE
              WHERE BUSOBJ_ID    = LT_POLNR_NO_RE-POLICYNR_TT
              AND   BUSOBJ_TYPE  IN LT_RANGE.
    
    *       policy haven't be released but have POL/PAC
            IF LT_CAS_NO_RE IS NOT INITIAL.
              SORT LT_CAS_NO_RE BY BUSOBJ_TYPE BUSOBJ_ID.
              DELETE ADJACENT DUPLICATES FROM LT_CAS_NO_RE COMPARING BUSOBJ_TYPE BUSOBJ_ID.
              APPEND LINES OF LT_CAS_NO_RE TO GT_CAS_NO_RE .
            ENDIF.
          ENDIF.
          CLEAR:
            LT_POLNR_NO_RE,
            LT_CAS_NO_RE.
        ENDWHILE.
        IF GT_CAS_NO_RE IS INITIAL.
          MESSAGE ' do not have the policy already be released but still have POL/PAC' TYPE 'S'.
          EXIT.
        ENDIF.
    *----------end   add by james in 2018/08/02 DE1K9A028J-----------
      ENDIF.
    
    * case3 for have pol/pac but no policy released.
      IF P_POL = ABAP_TRUE.
        LT_POLNR_NO_RE = GT_POLNR_NO_RFC.
        FREE:GT_POLNR_NO_RFC.
    
        SELECT BUSOBJ_TYPE
               BUSOBJ_ID INTO CORRESPONDING FIELDS OF TABLE LT_CAS_HAVE_PO
          FROM ZICNSL_CAS
          FOR ALL ENTRIES IN LT_POLNR_NO_RE
          WHERE BUSOBJ_ID    = LT_POLNR_NO_RE-POLICYNR_TT
          AND   BUSOBJ_TYPE  IN LT_RANGE.
    
        IF LT_CAS_HAVE_PO IS NOT INITIAL.
          SORT LT_CAS_HAVE_PO BY BUSOBJ_TYPE BUSOBJ_ID.
          DELETE ADJACENT DUPLICATES FROM LT_CAS_HAVE_PO COMPARING BUSOBJ_TYPE BUSOBJ_ID.
          GT_CAS_HAVE_PO  = LT_CAS_NO_RE.
        ENDIF.
      ENDIF.
    
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  ALV_SHOW
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  GT_CAS_YE_RE           policy has been been released but doesn't have POL/PAC
    *  -->  GT_CAS_NO_RE           policy haven't be released but have POL/PAC
    *  -->  GT_CAS_HAVE_PO         policy have pol/pac but no policy released.
    *----------------------------------------------------------------------*
    FORM ALV_SHOW .
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-ZEBRA      = 'X'.
      GS_LAYOUT-SEL_MODE   = 'D'.
    
      gs_fieldcat-fieldname = 'BUSOBJ_TYPE'.
      gs_fieldcat-coltext   = 'BUSOBJ_TYPE'.
      gs_fieldcat-outputlen = '20'.
      APPEND gs_fieldcat TO gt_fieldcat.
      CLEAR gs_fieldcat.
    
      gs_fieldcat-fieldname = 'BUSOBJ_ID'.
      gs_fieldcat-coltext   = 'BUSOBJ_ID'.
      gs_fieldcat-outputlen = '20'.
      APPEND gs_fieldcat TO gt_fieldcat.
      CLEAR gs_fieldcat.
    
      IF P_RELE = ABAP_TRUE .
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
          EXPORTING
            i_callback_program = sy-repid
            is_layout_lvc      = gs_layout
            it_fieldcat_lvc    = gt_fieldcat
            I_SAVE             = 'A'
          TABLES
            t_outtab           = GT_CAS_YE_RE
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ELSEIF P_NULL = ABAP_TRUE.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
          EXPORTING
            i_callback_program = sy-repid
            is_layout_lvc      = gs_layout
            it_fieldcat_lvc    = gt_fieldcat
            I_SAVE             = 'A'
          TABLES
            t_outtab           = GT_CAS_NO_RE
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ELSEIF P_POL = ABAP_TRUE.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
          EXPORTING
            i_callback_program = sy-repid
            is_layout_lvc      = gs_layout
            it_fieldcat_lvc    = gt_fieldcat
            I_SAVE             = 'A'
          TABLES
            t_outtab           = GT_CAS_HAVE_PO
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ENDIF.
    
    ENDFORM.
  • 相关阅读:
    1、电源管理概念
    37、mipg-streamer的使用讲解
    ARM+linux学习过程(3)mini2440的USB驱动无法在win7下识别
    ARM+linux学习过程(2)安装vmware-tool过程与错误解决
    ARM+linux学习过程(1)虚拟机下ubuntu上网
    35、在编译Linux内核中增加程序需要完成以下3项工作
    36、ALSA声卡驱动和应用
    35、在JZ2440上使用3G上网卡
    POJ
    CF453-A Visiting a Friend (dfs)
  • 原文地址:https://www.cnblogs.com/HARU/p/9407051.html
Copyright © 2020-2023  润新知