zoukankan      html  css  js  c++  java
  • CRM 价格批导2<上一个太多冗余>

    INCLUDE:LCRM_MKTPL_COND_IFF39

    *----------------------------------------------------------------------*
    ***INCLUDE LCRM_MKTPL_COND_IFF39 .
    *----------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *&      Form  add_cond_messages_to_return
    *&---------------------------------------------------------------------*
    *       Get messages from condition maintenance and append them
    *       to the return table
    *----------------------------------------------------------------------*
    FORM add_cond_messages_to_return
           TABLES  px_t_return STRUCTURE bapiret2
           USING   pi_hlog     TYPE      balloghndl.
    
      DATA:
             ls_hlog             TYPE bal_s_lfil, " filter for log header
             lr_log_handle       TYPE bal_s_logh, " range for handle
             lt_msg_handle       TYPE bal_t_msgh,
             ls_msg_handle       TYPE balmsghndl,
             ls_msg              TYPE bal_s_msg,
             ls_return           TYPE bapiret2.
    
    * filter for log handle
      lr_log_handle-sign   = 'I'.
      lr_log_handle-option = 'EQ'.
      lr_log_handle-low    = pi_hlog.
      INSERT lr_log_handle INTO TABLE ls_hlog-log_handle.
    
    * search the log for messages
      CALL FUNCTION 'BAL_GLB_SEARCH_MSG'
        EXPORTING
          i_s_log_filter = ls_hlog
        IMPORTING
          e_t_msg_handle = lt_msg_handle
        EXCEPTIONS
          msg_not_found  = 1
          OTHERS         = 2.
      IF sy-subrc = 1.
    *   no message found
      ELSEIF sy-subrc <> 0.
        PERFORM append_return TABLES px_t_return.
      ELSE.
        LOOP AT lt_msg_handle INTO ls_msg_handle.
    *     Retrieve messages from the condition log
          CALL FUNCTION 'BAL_LOG_MSG_READ'
            EXPORTING
              i_s_msg_handle = ls_msg_handle
            IMPORTING
              e_s_msg        = ls_msg
            EXCEPTIONS
              log_not_found  = 1
              msg_not_found  = 2
              OTHERS         = 3.
          IF sy-subrc <> 0.
            PERFORM append_return TABLES px_t_return.
          ELSE.
    *      Abort messages should not be sent back in the application log
    *      Condition Technique returns A messages for Error messages...
    *      Abort message should really abort and not bring back messages...
            IF ls_msg-msgty = 'A'.
              ls_msg-msgty = 'E'.
            ENDIF.
    
    *       Add message to the return table
            ls_return-type       = ls_msg-msgty.
            ls_return-id         = ls_msg-msgid.
            ls_return-number     = ls_msg-msgno.
            ls_return-message_v1 = ls_msg-msgv1.
            ls_return-message_v2 = ls_msg-msgv2.
            ls_return-message_v3 = ls_msg-msgv3.
            ls_return-message_v4 = ls_msg-msgv4.
            MESSAGE ID     ls_msg-msgid
                    TYPE   'I'
                    NUMBER ls_msg-msgno
                    WITH   ls_msg-msgv1
                           ls_msg-msgv1
                           ls_msg-msgv1
                           ls_msg-msgv1
                    INTO   ls_return-message.
            APPEND ls_return TO px_t_return.
          ENDIF.
        ENDLOOP.
      ENDIF.
    
    ENDFORM.                    " add_cond_messages_to_return

    INCLUDE LCRM_MKTPL_COND_IFF62.

    *----------------------------------------------------------------------*
    ***INCLUDE LCRM_MKTPL_COND_IFF62 .
    *----------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *&      Form  append_return
    *&---------------------------------------------------------------------*
    *       Append message to the table PX_T_RETURN
    *----------------------------------------------------------------------*
    FORM append_return TABLES  px_t_return STRUCTURE bapiret2.
    
      DATA: l_s_return TYPE bapiret2,
            lv_msgty   TYPE SYMSGTY.
    
    * Abort messages should not be sent back in the application log
    * Condition Technique returns A messages for Error messages...
    
      IF sy-msgty = 'A'.
        lv_msgty = 'E'.
      ELSE.
        lv_msgty = sy-msgty.
      ENDIF.
    
      CALL FUNCTION 'BALW_BAPIRETURN_GET2'
        EXPORTING
          type   = lv_msgty
          cl     = sy-msgid
          number = sy-msgno
          par1   = sy-msgv1
          par2   = sy-msgv2
          par3   = sy-msgv3
          par4   = sy-msgv4
        IMPORTING
          return = l_s_return.
    
      APPEND l_s_return TO px_t_return.
    
    ENDFORM.                    " append_return

    MAIN PROGRAM :YLYTEST05

    *&---------------------------------------------------------------------*
    *& Report  YCOND_INBOUND
    *&
    *&---------------------------------------------------------------------*
    *&Service Pricing: Org/ZZZMODENO/PRICE_GRP/ZREPCODE/PRODUCT/用户量贩店DIS服务商服务定价批导
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  YLYTEST05 LINE-SIZE 400.
    
    
    *----------------------------------------------------------------------*
    * Constants
    *----------------------------------------------------------------------*
     CONSTANTS:
    ** Condition technique: applications
       C_KAPPL_CRM           TYPE /SAPCND/APPLICATION VALUE 'CRM'.",
    
    
    
    TYPES: BEGIN OF TY_DOC,
             P_SORG       TYPE  CRMT_SALES_ORG,
             P_DISCHL     TYPE  CRMT_DISTRIBUTION_CHANNEL,
             P_ZZZMODENO  TYPE ZMODENO,
             P_ZREPCODE   TYPE ZRPCODE,
             P_BP         TYPE  BU_PARTNER,
             P_PROD       TYPE  COMT_PRODUCT_ID,
             P_PGRP       TYPE  CRMT_PRICE_GRP,
             P_KBETR      TYPE  KBETR,
             P_KMEIN      TYPE  KMEIN,
             P_KPEIN      TYPE KPEIN,
             P_KONWA      TYPE  KONWA,
             P_BDATE      TYPE  D,
             P_EDATE      TYPE  D,
             HIERARCHY_ID TYPE  COMT_HIERARCHY_ID,
             CATEGORY_ID  TYPE COMT_CATEGORY_ID,
           END OF TY_DOC.
    
    DATA: WA_DOC TYPE TY_DOC,
          IT_DOC TYPE STANDARD TABLE OF TY_DOC.
    
    CLEAR: WA_DOC, IT_DOC.
    
    DATA:TIMESTAMP_TO      TYPE /SAPCND/TIMESTAMP_TO,
         TIMESTAMP_TO_A TYPE TIMESTAMP,
         TIMESTAMP_TO_B TYPE TIMESTAMP,
         TO_DAY         TYPE D.
    CLEAR: TIMESTAMP_TO, TO_DAY, TIMESTAMP_TO_A, TIMESTAMP_TO_B.
    
    TYPES: BEGIN OF TY_ERR,
             INX     TYPE I,
             ERR_LOG TYPE STRING,
           END OF TY_ERR.
    
    DATA: IT_ERR TYPE STANDARD TABLE OF TY_ERR,
          WA_ERR TYPE TY_ERR.
    CLEAR:IT_ERR, WA_ERR.
    
    DATA:
      TIM TYPE T,
      TZ  TYPE TTZZ-TZONE.
    “TZ = SY-ZONLO.
    TZ 'UTC'.
    *******************************************************************
    *   User-defined Include-files (if necessary).                    *
    *******************************************************************
    
    *
    INCLUDE LCRM_MKTPL_COND_IFF39.
    
    INCLUDE LCRM_MKTPL_COND_IFF62.
    
    
    TYPES:BEGIN OF ZCRM_MKTPL_COND_IF_CUST_DATAX,
            KAPPL          TYPE  CRM_MKTPL_KAPPL_CDET,
            KVEWE          TYPE  CRM_MKTPL_KVEWE_CDET,
            KSCHL          TYPE  CRM_MKTPL_KSCHL_CDET,
            KOTABNR        TYPE /SAPCND/COND_TABLE_ID,
            PRODUCT_GUID   TYPE COMT_PRODUCT_GUID,
            SALES_ORG         TYPE CRMT_SALES_ORG,
            CHANNEL           TYPE CRMT_DISTRIBUTION_CHANNEL,
            ZZZMODENO      TYPE ZMODENO,
            ZREPCODE       TYPE ZRPCODE,
            PARTNER           TYPE BU_PARTNER_GUID,
            BILL_TO_PARTY     TYPE CRMT_BILL_TO_PARTY,
            PRICE_GRP      TYPE CRMT_PRICE_GRP,
            KMEIN          TYPE KMEIN,
            KPEIN             TYPE PRCT_COND_PRICING_UNIT,
            KONWA          TYPE KONWA,
            TIMESTAMP_FROM TYPE TIMESTAMP,
            TIMESTAMP_TO   TYPE TIMESTAMP,
            KBETR_PRT      TYPE KBETR,
            RELEASE_STATUS TYPE /SAPCND/RELEASE_STATUS,
            HIERARCHY_GUID TYPE COMT_HIERARCHY_GUID,
            HIER_CAT_GUID     TYPE COMT_CATEGORY_GUID,
          END OF ZCRM_MKTPL_COND_IF_CUST_DATAX.
    DATA:ZCRM_MKTPL_COND_IF_CUST_DATAX  TYPE ZCRM_MKTPL_COND_IF_CUST_DATAX.
    
    DATA:
      L_T_CUST_DATAX TYPE TABLE OF ZCRM_MKTPL_COND_IF_CUST_DATAX,
      L_S_CUST_DATAX TYPE ZCRM_MKTPL_COND_IF_CUST_DATAX,
      L_START        TYPE TIMESTAMP,
      L_END          TYPE TIMESTAMP,
      L_CGEN_TYPE    TYPE CRM_MKTPL_CGEN_TYPE.
    
    
    DATA:L_T_COND_SESSION  TYPE TABLE OF CRM_MKTPL_COND_IF_CONDSESSION.
    DATA:L_S_COND_SESSION  TYPE CRM_MKTPL_COND_IF_CONDSESSION.
    DATA: LS_BAL_LOG         TYPE       BAL_S_LOG.
    DATA:L_HLOG            TYPE BALLOGHNDL.
    DATA:LV_RESULT  TYPE  SYSUBRC.
    DATA:LS_T_RETURN TYPE  STANDARD TABLE OF BAPIRET2.
    DATA:PE_SUBRC TYPE SY-SUBRC.
    DATA:TMP_COND_SESSION TYPE /SAPCND/MAINT_SESSION_ID.
    
    
    PARAMETERS:
      P_FILE LIKE RLGRAP-FILENAME.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      PERFORM SELECT_FILE.
    
    START-OF-SELECTION.
      PERFORM IMPORT_DATA.
    
      IF IT_ERR IS INITIAL.
    
        CALL FUNCTION 'BAL_LOG_CREATE'
          EXPORTING
            I_S_LOG      = LS_BAL_LOG
          IMPORTING
            E_LOG_HANDLE = L_HLOG
          EXCEPTIONS
            OTHERS       = 1.
    * initialize condition session
        CALL FUNCTION '/SAPCND/MNT_INIT_OW'
          EXPORTING
            I_APPLICATION   = C_KAPPL_CRM
            I_HLOG          = L_HLOG
            I_MAINT_CONTEXT = 'GCM'
            I_GROUPNAME     = 'ZHSI001' "/SAPCND/GROUPT_I表里找得
          IMPORTING
            E_HSESSION      = TMP_COND_SESSION
            E_RESULT        = LV_RESULT
          EXCEPTIONS
            EXC_STOP_WORK   = 1
            EXC_RFC         = 2
            OTHERS          = 3.
    
        L_S_COND_SESSION-SESSION = TMP_COND_SESSION.
        L_S_COND_SESSION-KAPPL = 'CRM'.
        L_S_COND_SESSION-GROUP = 'GCM'.
        APPEND L_S_COND_SESSION TO L_T_COND_SESSION.
    
        LOOP AT IT_DOC INTO WA_DOC.
    
          CLEAR L_S_CUST_DATAX.
          L_S_CUST_DATAX-KAPPL = 'CRM'.
          L_S_CUST_DATAX-KVEWE = 'PR'.
          L_S_CUST_DATAX-KSCHL = 'ZJP1'."/SAPCND/GROUPT_I表里找得
    
          L_S_CUST_DATAX-SALES_ORG = WA_DOC-P_SORG.
          L_S_CUST_DATAX-CHANNEL = WA_DOC-P_DISCHL.
    
          DATA:LS_PRODGUID  TYPE COMT_PRODUCT_GUID.
          SELECT SINGLE PRODUCT_GUID
            INTO LS_PRODGUID
            FROM COMM_PRODUCT
           WHERE PRODUCT_ID = WA_DOC-P_PROD.
          L_S_CUST_DATAX-PRODUCT_GUID = LS_PRODGUID.
    
          SELECT SINGLE CATEGORY_GUID
                 INTO L_S_CUST_DATAX-HIER_CAT_GUID
                 FROM COMM_CATEGORY
                 WHERE CATEGORY_ID = WA_DOC-CATEGORY_ID.
    
          SELECT SINGLE UNIT
                 INTO WA_DOC-P_KMEIN
                 FROM COMM_PR_UNIT
                 WHERE PRODUCT_GUID = LS_PRODGUID
                 AND IS_BASE_UNIT = 'X'.
          IF SY-SUBRC <> 0.
            SELECT SINGLE UNIT
                  INTO WA_DOC-P_KMEIN
                  FROM COMM_PR_UNIT
                  WHERE PRODUCT_GUID = LS_PRODGUID
                  AND IS_BASE_UNIT = ''.
          ENDIF.
    
          L_S_CUST_DATAX-PRICE_GRP = WA_DOC-P_PGRP.
    
          L_S_CUST_DATAX-KOTABNR = 'CUS00011'.
          L_S_CUST_DATAX-KPEIN = 1.
          L_S_CUST_DATAX-KMEIN = WA_DOC-P_KMEIN.
          L_S_CUST_DATAX-ZZZMODENO = WA_DOC-P_ZZZMODENO.
          L_S_CUST_DATAX-ZREPCODE = WA_DOC-P_ZREPCODE.
          L_S_CUST_DATAX-KONWA = WA_DOC-P_KONWA.
          L_S_CUST_DATAX-KBETR_PRT = WA_DOC-P_KBETR.
          L_S_CUST_DATAX-RELEASE_STATUS = SPACE.
    
          CLEAR TIM.
    
          CONVERT DATE WA_DOC-P_BDATE TIME TIM
              INTO TIME STAMP L_S_CUST_DATAX-TIMESTAMP_FROM TIME ZONE TZ.
    
          TIM = '235959'.
    
          CONVERT DATE WA_DOC-P_EDATE TIME TIM
                  INTO TIME STAMP L_S_CUST_DATAX-TIMESTAMP_TO TIME ZONE TZ.
    
          APPEND L_S_CUST_DATAX TO L_T_CUST_DATAX.
          CLEAR L_S_CUST_DATAX.
    
        ENDLOOP.
    
    
        PERFORM ZMNT_COND_RECORDS_CD TABLES  L_T_CUST_DATAX
                                             LS_T_RETURN
                                             L_T_COND_SESSION
                                    USING
                                             L_START
                                             L_END
                                             L_HLOG
                                    CHANGING PE_SUBRC.
        CHECK PE_SUBRC IS INITIAL.
    
    
    
        DATA:LV_SESSION LIKE LINE OF L_T_COND_SESSION.
        DATA:I_SESSION TYPE  /SAPCND/MAINT_SESSION_ID.
        READ TABLE L_T_COND_SESSION INTO LV_SESSION INDEX 1.
        I_SESSION = LV_SESSION-SESSION.
    *   VIII. save the changes
        CALL FUNCTION '/SAPCND/MNT_SAVE_OW'
          EXPORTING
            I_HSESSION                   = I_SESSION
            I_HLOG                       = L_HLOG
    *       i_with_commit                = 'X'
          IMPORTING
            E_RESULT                     = LV_RESULT
          EXCEPTIONS
            EXC_STOP_WORK                = 1
            EXC_RFC                      = 2
            EXC_UPDATING_DATABASE        = 3
            EXC_CREATING_SCALE_FIELDNAME = 4
            EXC_UNEXPECTED_ERROR         = 5
            OTHERS                       = 6.
        IF SY-SUBRC <> 0  OR LV_RESULT > 4.
        ENDIF.
    
        COMMIT WORK.
    
    
        PERFORM OUTPUT_RESULT.
    
      ELSE.
    
        LOOP AT IT_ERR INTO WA_ERR.
          WRITE :/ '行:', WA_ERR-INX, WA_ERR-ERR_LOG.
        ENDLOOP.
    
      ENDIF.
    
    
    *----------------------------------------------------------------------*
    ***INCLUDE LCRM_MKTPL_COND_IFF93 .
    *----------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *&      Form  zmnt_cond_records_cd
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM ZMNT_COND_RECORDS_CD
        TABLES   PI_T_CUST_DATAX   STRUCTURE ZCRM_MKTPL_COND_IF_CUST_DATAX
                 PX_T_RETURN       STRUCTURE BAPIRET2
                 L_T_COND_SESSION  STRUCTURE CRM_MKTPL_COND_IF_CONDSESSION
        USING
                 PI_START          TYPE      TIMESTAMP
                 PI_END            TYPE      TIMESTAMP
                 L_HLOG            TYPE      BALLOGHNDL
        CHANGING PE_SUBRC          TYPE      SY-SUBRC.
    
      DATA: L_SUBRC             TYPE SY-SUBRC,
            L_RESULT            TYPE SY-SUBRC,
            L_OVERLAP           TYPE C,
            L_LOCKING           TYPE C,
            L_T_WORKING_SET     TYPE REF TO DATA,
            L_T_WORKING_SET_OLD TYPE REF TO DATA,
            L_T_VARNUMH_OVERLAP TYPE TABLE OF CRM_MKTPL_COND_IF_VARNUMH,
            L_T_RETURN          TYPE TABLE OF BAPIRET2.
    
    * loop at application
      LOOP AT L_T_COND_SESSION.
    * ----- get old data from the condition buffer
        PERFORM GET_WORKING_SET TABLES   PX_T_RETURN
                                   USING    L_T_COND_SESSION
                                            SPACE
                                            L_HLOG
                                   CHANGING L_T_WORKING_SET_OLD
                                            L_SUBRC.
        CHECK L_SUBRC IS INITIAL.
    
    * ----- build working set
        PERFORM BUILD_WORKING_SET TABLES   PI_T_CUST_DATAX
                                     USING    L_T_COND_SESSION
                                              PI_START
                                              PI_END
                                              L_HLOG
                                              L_T_WORKING_SET_OLD
                                     CHANGING L_T_WORKING_SET
                                              L_SUBRC.
        CHECK L_SUBRC IS INITIAL.
    
        IF NOT L_SUBRC IS INITIAL.
          PE_SUBRC = 1.
          EXIT.
        ENDIF.
    
    * ----- pass new working set to the condition buffer
        PERFORM MAINTAIN_CONDITION_RECORDS TABLES   PX_T_RETURN
                                           USING    L_T_COND_SESSION
                                                    L_T_WORKING_SET
                                                    L_HLOG
                                           CHANGING L_RESULT
                                                    L_SUBRC.
        IF NOT L_SUBRC IS INITIAL.
    *     error in the condition maintenance
          PE_SUBRC = 1.
          EXIT.
        ELSE.
          IF L_RESULT LE 4.
    *       everything o.k. -> notify changes and continue
    
            CONTINUE.          " -> next application
          ENDIF.
        ENDIF.
    
        IF L_RESULT GT 4.
    *     problems have occured, possibly due to overlap conflicts
    *------ do overlap conflict resolution
    
        ENDIF.
    
      ENDLOOP.
    
    
    
    
    * add messages from condition log to return table
      PERFORM ADD_COND_MESSAGES_TO_RETURN TABLES PX_T_RETURN
                                          USING  L_HLOG.
    
    ENDFORM.                    " zmnt_cond_records_cd
    
    
    *&---------------------------------------------------------------------*
    *&      Form  get_working_set
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->PX_T_RETURN          text
    *      -->PI_S_COND_SESSION    text
    *      -->PI_INCL_DEL_RECORDS  text
    *      -->PI_HLOG              text
    *      -->PE_T_WORKING_SET     text
    *----------------------------------------------------------------------*
    FORM GET_WORKING_SET
        TABLES   PX_T_RETURN         STRUCTURE BAPIRET2
        USING    PI_S_COND_SESSION   TYPE      CRM_MKTPL_COND_IF_CONDSESSION
                 PI_INCL_DEL_RECORDS TYPE      XFELD
                 PI_HLOG             TYPE      BALLOGHNDL
        CHANGING PE_T_WORKING_SET    TYPE      REF TO DATA
                 PE_SUBRC            TYPE      SY-SUBRC.
    
      DATA: LS_ATTRIB_VALUE     TYPE  /SAPCND/ATTRIB_VALUE_INT,
            LT_ATTRIB_VALUE     TYPE  /SAPCND/T_ATTRIB_VALUE_INT,
            L_RESULT            TYPE  SY-SUBRC,
            L_SUPPR_DEL_RECORDS TYPE  /SAPCND/BOOLEAN,
            L_MSGTEXT(72).
    
      CLEAR PE_T_WORKING_SET.
    
    * Build range for selection
      LS_ATTRIB_VALUE-FIELDNAME = 'KAPPL'.
      LS_ATTRIB_VALUE-VALUE = PI_S_COND_SESSION-KAPPL.
      APPEND LS_ATTRIB_VALUE TO LT_ATTRIB_VALUE.
      LS_ATTRIB_VALUE-FIELDNAME = 'KVEWE'.
      LS_ATTRIB_VALUE-VALUE = 'PR'.
      APPEND LS_ATTRIB_VALUE TO LT_ATTRIB_VALUE.
    
    
    * include/suppress the deleted records
      IF PI_INCL_DEL_RECORDS IS INITIAL.
        L_SUPPR_DEL_RECORDS = 'X'.
      ENDIF.
    
      CALL FUNCTION '/SAPCND/MNT_GET_WORKING_SET_OW'
        EXPORTING
          I_HSESSION                 = PI_S_COND_SESSION-SESSION
          I_HLOG                     = PI_HLOG
    *     I_CALL_FIELD_CHECK         = ' '
          I_SUPPRESS_DELETED_RECORDS = L_SUPPR_DEL_RECORDS
    *     IT_ATTRIB_SELECTION_EXT    =
          IT_ATTRIB_VALUE_INT        = LT_ATTRIB_VALUE
        IMPORTING
          ET_WORKING_SET_INT         = PE_T_WORKING_SET
    *     ET_WORKING_SET_EXT         =
          E_RESULT                   = L_RESULT
        EXCEPTIONS
          EXC_STOP_WORK              = 1
          EXC_RFC                    = 2
          EXC_CONV_JAVA              = 3
          EXC_ATTR_CONV              = 4
          EXC_FIELD_CHECK            = 5
          EXC_UPDATING_WORKING_SET   = 6
          EXC_NOT_INT_AND_EXT        = 7
          EXC_EXTERNAL_ONLY          = 8
          EXC_CONVERT_RANGES         = 9
          EXC_CREATING_OBJECT_NAMES  = 10
          EXC_STOP_WORK_BADI         = 11
          EXC_IMPLEMENTATION_MISSING = 12
          EXC_ADDING_DEBUG_TRACE_MSG = 13
          EXC_BAL_LOG                = 14
          OTHERS                     = 15.
      IF SY-SUBRC <> 0.
        PE_SUBRC = SY-SUBRC.
    *   Collect message from /SAPCND/MNT_GET_WORKING_SET_OW
        PERFORM APPEND_RETURN TABLES PX_T_RETURN.
    *   Send message: System has stopped the processing
        MESSAGE E025(CRM_MKTPL_COND_IF)
          WITH '/SAPCND/MNT_GET_WORKING_SET_OW'
          INTO L_MSGTEXT.
        PERFORM APPEND_RETURN TABLES PX_T_RETURN.
      ENDIF.
    
    ENDFORM.                    " get_working_set_cd
    
    *&---------------------------------------------------------------------*
    *&      Form  build_working_set
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->PI_T_CUST_DATAX       text
    *      -->PI_S_COND_SESSION     text
    *      -->PI_START              text
    *      -->PI_END                text
    *      -->PI_HLOG               text
    *      -->PI_T_WORKING_SET_OLD  text
    *      -->PE_T_WORKING_SET      text
    *----------------------------------------------------------------------*
    FORM BUILD_WORKING_SET
       TABLES   PI_T_CUST_DATAX      STRUCTURE ZCRM_MKTPL_COND_IF_CUST_DATAX
       USING    PI_S_COND_SESSION    TYPE      CRM_MKTPL_COND_IF_CONDSESSION
                PI_START             TYPE      TIMESTAMP
                PI_END               TYPE      TIMESTAMP
                PI_HLOG              TYPE      BALLOGHNDL
                PI_T_WORKING_SET_OLD TYPE REF TO DATA
       CHANGING PE_T_WORKING_SET     TYPE REF TO DATA
                PE_SUBRC             TYPE      SY-SUBRC.
    
    
      DATA: L_WS_NAME_BROAD  TYPE /SAPCND/WORKING_SET_NAME.
    
      DATA: L_WORKING_SET_ITEM       TYPE REF TO DATA,
            L_WORKING_SET_ITEM_BROAD TYPE REF TO DATA.
    
      FIELD-SYMBOLS: <LT_WORKING_SET>            TYPE TABLE,
                     <LT_WORKING_SET_OLD>        TYPE TABLE,
                     <LS_WORKING_SET_ITEM>       TYPE ANY,
                     <LS_WORKING_SET_ITEM_BROAD> TYPE ANY.
    
    * get names of working set (broad working set):
      CALL FUNCTION '/SAPCND/GEN_WORKING_SET_NAME'
        EXPORTING
          I_APPLICATION          = PI_S_COND_SESSION-KAPPL
        IMPORTING
          E_WORKING_SET_NAME_INT = L_WS_NAME_BROAD.
    
    * get pointer to the imported working set
      ASSIGN PI_T_WORKING_SET_OLD->* TO <LT_WORKING_SET_OLD>.
    * get pointers to the exporting working sets
      CREATE DATA PE_T_WORKING_SET LIKE <LT_WORKING_SET_OLD>.
      ASSIGN PE_T_WORKING_SET->* TO <LT_WORKING_SET>.
    
      CREATE DATA L_WORKING_SET_ITEM LIKE LINE OF <LT_WORKING_SET_OLD>.
      ASSIGN L_WORKING_SET_ITEM->* TO <LS_WORKING_SET_ITEM>.
    
      CREATE DATA L_WORKING_SET_ITEM_BROAD TYPE (L_WS_NAME_BROAD).
    
    * loop at products/sales_org/distribution_channel/partner_function
      LOOP AT PI_T_CUST_DATAX.
    
    *   fill working set for one item
        PERFORM BUILD_WORKING_SET_ITEM USING PI_S_COND_SESSION
                                                PI_T_CUST_DATAX
                                                PI_START
                                                PI_END
                                                PI_HLOG
                                                L_WS_NAME_BROAD
                                       CHANGING L_WORKING_SET_ITEM_BROAD
                                                PE_SUBRC.
    
        ASSIGN L_WORKING_SET_ITEM_BROAD->*
            TO <LS_WORKING_SET_ITEM_BROAD>.
        MOVE-CORRESPONDING <LS_WORKING_SET_ITEM_BROAD>
                        TO <LS_WORKING_SET_ITEM>.
        APPEND <LS_WORKING_SET_ITEM> TO <LT_WORKING_SET>.
    
      ENDLOOP.                        " at pi_t_cust_datax
    
    ENDFORM.                    " build_working_set_cd
    
    *&---------------------------------------------------------------------*
    *&      Form  build_working_set_item
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->PI_S_COND_SESSION    text
    *      -->PI_S_CUST_DATAX      text
    *      -->PI_START             text
    *      -->PI_END               text
    *      -->PI_HLOG              text
    *      -->PI_WS_NAME           text
    *      -->PE_WORKING_SET_ITEM  text
    *----------------------------------------------------------------------*
    FORM BUILD_WORKING_SET_ITEM
       USING     PI_S_COND_SESSION   TYPE CRM_MKTPL_COND_IF_CONDSESSION
                 PI_S_CUST_DATAX     TYPE ZCRM_MKTPL_COND_IF_CUST_DATAX
                 PI_START            TYPE TIMESTAMP
                 PI_END              TYPE TIMESTAMP
                 PI_HLOG             TYPE BALLOGHNDL
                 PI_WS_NAME          TYPE /SAPCND/WORKING_SET_NAME
       CHANGING  PE_WORKING_SET_ITEM TYPE REF TO  DATA
                 PE_SUBRC            TYPE SY-SUBRC.
    
    * internal working sets
      FIELD-SYMBOLS: <LS_WORKING_SET_ITEM> TYPE ANY.
    
    * field values (in alphabetic order)
      FIELD-SYMBOLS:
        <BILL_TO_PARTY>  TYPE CRMT_BILL_TO_PARTY,
        <CLIENT>         TYPE MANDT,
        <DIS_CHANNEL>    TYPE CRMT_DISTRIBUTION_CHANNEL,
        <DIVISION>       TYPE CRMT_DIVISION,
        <HIER_NO_GUID>   TYPE BU_HIERNR_GUID,
        <HIER_NODE_GUID> TYPE BU_NODE_GUID,
        <KAPPL>          TYPE /SAPCND/APPLICATION,
        <KOTABNR>        TYPE /SAPCND/COND_TABLE_ID,
        <KSCHL>          TYPE /SAPCND/COND_TYPE,
        <KVEWE>          TYPE /SAPCND/USAGE,
        <PARTNER_GUID>   TYPE BU_PARTNER_GUID,
        <PAYER>          TYPE CRMT_PAYER,
        <ZZZMODENO>      TYPE ZMODENO,
        <ZREPCODE>       TYPE ZRPCODE,
        <KMEIN>          TYPE KMEIN,
        <KPEIN>          TYPE KPEIN,
        <KONWA>          TYPE KONWA,
        <RELEASE_STATUS> TYPE /SAPCND/RELEASE_STATUS,
        <KBETR_PRT>      TYPE PRCT_COND_RATE,
        <PRICE_GRP>      TYPE CRMT_PRICE_GRP,
        <PRODUCT>        TYPE COMT_PRODUCT_GUID,
        <SALES_ORG>      TYPE CRMT_SALES_ORG,
        <SHIP_TO_PARTY>  TYPE CRMT_SHIP_TO_PARTY,
        <SOLD_TO_PARTY>  TYPE CRMT_SOLD_TO_PARTY,
        <TIMESTAMP_FROM> TYPE /SAPCND/TIMESTAMP_FROM,
        <TIMESTAMP_TO>   TYPE /SAPCND/TIMESTAMP_TO,
        <HIER_CAT_GUID>  TYPE COMT_CATEGORY_GUID,
        <VARNUMH>        TYPE /SAPCND/COND_TABLE_ENTRY_ID.
    
    * create internal working sets
      CREATE DATA PE_WORKING_SET_ITEM TYPE (PI_WS_NAME).
      ASSIGN PE_WORKING_SET_ITEM->* TO <LS_WORKING_SET_ITEM>.
    
    
    * assignments (in alphabetic order)
      ASSIGN COMPONENT 'ZZZMODENO' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <ZZZMODENO>.
      ASSIGN COMPONENT 'CLIENT' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <CLIENT>.
      ASSIGN COMPONENT 'ZREPCODE' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <ZREPCODE>.
      ASSIGN COMPONENT 'DIVISION' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <DIVISION>.
      ASSIGN COMPONENT 'HIER_NO_GUID' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <HIER_NO_GUID>.
      ASSIGN COMPONENT 'HIER_NODE_GUID' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <HIER_NODE_GUID>.
      ASSIGN COMPONENT 'KAPPL'   OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KAPPL>.
      ASSIGN COMPONENT 'KOTABNR' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KOTABNR>.
      ASSIGN COMPONENT 'KSCHL'   OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KSCHL>.
      ASSIGN COMPONENT 'KVEWE'   OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KVEWE>.
      ASSIGN COMPONENT 'PARTNER_GUID' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <PARTNER_GUID>.
      ASSIGN COMPONENT 'PAYER' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <PAYER>.
      ASSIGN COMPONENT 'KMEIN' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KMEIN>.
      ASSIGN COMPONENT 'KPEIN' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KPEIN>.
      ASSIGN COMPONENT 'KONWA' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KONWA>.
      ASSIGN COMPONENT 'PRODUCT' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <PRODUCT>.
      ASSIGN COMPONENT 'SALES_ORG' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <SALES_ORG>.
      ASSIGN COMPONENT 'SHIP_TO_PARTY' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <SHIP_TO_PARTY>.
      ASSIGN COMPONENT 'SOLD_TO_PARTY' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <SOLD_TO_PARTY>.
      ASSIGN COMPONENT 'KBETR' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <KBETR_PRT>.
      ASSIGN COMPONENT 'PRICE_GRP' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <PRICE_GRP>.
    
      ASSIGN COMPONENT 'TIMESTAMP_FROM' OF STRUCTURE
                        <LS_WORKING_SET_ITEM> TO <TIMESTAMP_FROM>.
      ASSIGN COMPONENT 'TIMESTAMP_TO' OF STRUCTURE
                        <LS_WORKING_SET_ITEM> TO <TIMESTAMP_TO>.
      ASSIGN COMPONENT 'VARNUMH' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <VARNUMH>.
      ASSIGN COMPONENT 'RELEASE_STATUS' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <RELEASE_STATUS>.
      ASSIGN COMPONENT 'HIER_CAT_GUID' OF STRUCTURE <LS_WORKING_SET_ITEM>
                                 TO <HIER_CAT_GUID>.
    
    * assign condition record fields
    * create new varnumh
      CALL FUNCTION 'GUID_CREATE'
        IMPORTING
          EV_GUID_16 = <VARNUMH>.
    * other fields
      <CLIENT>         = SY-MANDT.
    *  <TIMESTAMP_FROM> = PI_START.
    *  <TIMESTAMP_TO>   = PI_END.
      <KAPPL>          = PI_S_CUST_DATAX-KAPPL.
      <KVEWE>          = PI_S_CUST_DATAX-KVEWE.
      <KOTABNR>        = PI_S_CUST_DATAX-KOTABNR.
      <KSCHL>          = PI_S_CUST_DATAX-KSCHL.
      <SALES_ORG>      = PI_S_CUST_DATAX-SALES_ORG.
    *  <DIS_CHANNEL>    = PI_S_CUST_DATAX-CHANNEL.
    *  <division>       = pi_s_cust_datax-division.
      <PRODUCT>        = PI_S_CUST_DATAX-PRODUCT_GUID.
      <ZZZMODENO>        = PI_S_CUST_DATAX-ZZZMODENO.
      <ZREPCODE>        = PI_S_CUST_DATAX-ZREPCODE.
    *  <PARTNER_GUID>   = PI_S_CUST_DATAX-PARTNER.
    *  <sold_to_party>  = pi_s_cust_datax-sold_to_party.
      <KMEIN> = PI_S_CUST_DATAX-KMEIN.
      <KPEIN> = PI_S_CUST_DATAX-KPEIN.
      <KONWA> = PI_S_CUST_DATAX-KONWA.
      <PRICE_GRP> = PI_S_CUST_DATAX-PRICE_GRP.
      <KBETR_PRT> = PI_S_CUST_DATAX-KBETR_PRT.
      <TIMESTAMP_FROM> = PI_S_CUST_DATAX-TIMESTAMP_FROM.
      <TIMESTAMP_TO> = PI_S_CUST_DATAX-TIMESTAMP_TO.
      <RELEASE_STATUS> = PI_S_CUST_DATAX-RELEASE_STATUS.
    *  <HIER_CAT_GUID> = PI_S_CUST_DATAX-HIER_CAT_GUID.
    *  <ship_to_party>  = pi_s_cust_datax-ship_to_party.
    *  <BILL_TO_PARTY>  = PI_S_CUST_DATAX-BILL_TO_PARTY.
    *  <payer>          = pi_s_cust_datax-payer.
    * customer hierarchy
    *  <HIER_NO_GUID>   = PI_S_CUST_DATAX-HIERARCHY_GUID.
    *  <hier_node_guid> = pi_s_cust_datax-HIER_CAT_GUID.
    
    ENDFORM.                    " build_working_set_item_cd
    
    
    *&---------------------------------------------------------------------*
    *&      Form  maintain_condition_records
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->PX_T_RETURN        text
    *      -->PI_S_COND_SESSION  text
    *      -->PI_T_WORKING_SET   text
    *      -->PE_RESULT          text
    *      -->PE_SUBRC           text
    *----------------------------------------------------------------------*
    FORM MAINTAIN_CONDITION_RECORDS
            TABLES   PX_T_RETURN         STRUCTURE  BAPIRET2
            USING    PI_S_COND_SESSION   TYPE CRM_MKTPL_COND_IF_CONDSESSION
                     PI_T_WORKING_SET    TYPE REF TO DATA
                     PI_HLOG             TYPE BALLOGHNDL
            CHANGING PE_RESULT           TYPE SY-SUBRC
                     PE_SUBRC            TYPE SY-SUBRC.
    
      DATA: L_MSGTEXT(72).
    
    * By default: everything is okay
      CLEAR: PE_RESULT,
             PE_SUBRC.
    
      CALL FUNCTION '/SAPCND/MNT_MAINTAIN_OW'
        EXPORTING
          I_HSESSION                 = PI_S_COND_SESSION-SESSION
          I_HLOG                     = PI_HLOG
    *     IT_WORKING_SET_EXT         =
          IT_WORKING_SET_INT         = PI_T_WORKING_SET
        IMPORTING
          E_RESULT                   = PE_RESULT
        EXCEPTIONS
          EXC_STOP_WORK              = 1
          EXC_DEFAULT_VALUE          = 2
          EXC_DEFAULT_CHECK          = 3
          EXC_CONV_JAVA              = 4
          EXC_RFC                    = 5
          EXC_UPDATING_WORKING_SET   = 6
          EXC_STOP_WORK_BADI         = 7
          EXC_IMPLEMENTATION_MISSING = 8
          EXC_DELETING_MSG_LOG       = 9
          EXC_ADDING_DEBUG_TRACE_MSG = 10
          EXC_PUT_CONSTANTS          = 11
          OTHERS                     = 12.
      IF SY-SUBRC <> 0.
        PE_SUBRC = SY-SUBRC.
    *   Collect message from /SAPCND/MNT_MAINTAIN_OW
        PERFORM APPEND_RETURN TABLES PX_T_RETURN.
    *   Send message: System has stopped processing
        MESSAGE E025(CRM_MKTPL_COND_IF)
          WITH '/SAPCND/MNT_MAINTAIN_OW'
          INTO L_MSGTEXT.
        PERFORM APPEND_RETURN TABLES PX_T_RETURN.
      ENDIF.
    
    ENDFORM.                    " maintain_condition_records
    
    
    *&---------------------------------------------------------------------*
    *&      Form  IMPORT_DATA
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM IMPORT_DATA .
      DATA : ITAB_FILE  LIKE ZALSMEX_TABLINE OCCURS 100 WITH HEADER LINE.
      REFRESH ITAB_FILE.
    
      DATA: LV_DATFM    LIKE USR01-DATFM,
            LV_YEAR(4)  TYPE C,
            LV_MONTH(2) TYPE C,
            LV_DAY(2)   TYPE C.
      DATA: ZINX TYPE I.
      CLEAR ZINX.
    
      CALL FUNCTION 'ZEXCEL_UPLOAD'
        EXPORTING
          FILENAME                = P_FILE
          I_BEGIN_COL             = '1'
          I_BEGIN_ROW             = '1'
          I_END_COL               = '12'
          I_END_ROW               = '5000'
        TABLES
          INTERN                  = ITAB_FILE
        EXCEPTIONS
          INCONSISTENT_PARAMETERS = 1
          UPLOAD_OLE              = 2
          OTHERS                  = 3.
    
      LOOP AT ITAB_FILE FROM 10.
    
        CASE ITAB_FILE-COL.
    
          WHEN 1.
            IF ITAB_FILE-VALUE <> ''.
              CONDENSE ITAB_FILE-VALUE.
              SELECT COUNT( * )
              FROM COMM_PR_FRG_ROD
              WHERE SALES_ORG = ITAB_FILE-VALUE.
              IF SY-SUBRC = 0.
                WA_DOC-P_SORG = ITAB_FILE-VALUE.
              ELSE.
                CONCATENATE WA_ERR-ERR_LOG
                 'Sales organization not exist !'
                 INTO WA_ERR-ERR_LOG SEPARATED BY ''.
              ENDIF.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
               'Sales organization can not be initial !'
               INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
    
          WHEN 2.
            IF ITAB_FILE-VALUE <> ''.
              WA_DOC-P_ZZZMODENO = ITAB_FILE-VALUE.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
              'custom model can not be initial !'
              INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
    
          WHEN 3."price group
            IF ITAB_FILE-VALUE <> ''.
              CONDENSE ITAB_FILE-VALUE.
              SELECT COUNT( * )
              FROM CRMC_PRICEGRP
              WHERE PRICE_GROUP = ITAB_FILE-VALUE.
              IF SY-SUBRC = 0.
                WA_DOC-P_PGRP = ITAB_FILE-VALUE.
              ELSE.
                CONCATENATE WA_ERR-ERR_LOG
                 'Price group not exist !'
                 INTO WA_ERR-ERR_LOG SEPARATED BY ''.
              ENDIF.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
               'Price group can not be initial !'
               INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
    
          WHEN 4."Repair Code
            IF ITAB_FILE-VALUE <> ''.
              WA_DOC-P_ZREPCODE = ITAB_FILE-VALUE.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
               'Repair Code can not be initial !'
               INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
    
          WHEN 5."product id
            IF ITAB_FILE-VALUE <> ''.
              CONDENSE ITAB_FILE-VALUE.
              CALL FUNCTION 'CONVERSION_EXIT_PRID1_INPUT'
                EXPORTING
                  INPUT             = ITAB_FILE-VALUE
                IMPORTING
                  OUTPUT            = WA_DOC-P_PROD
                EXCEPTIONS
                  LENGHT_ERROR      = 1
                  CUSTOMIZING_ERROR = 2
                  OTHERS            = 3.
              SELECT COUNT( * )
              FROM COMM_PRODUCT
              WHERE PRODUCT_ID = WA_DOC-P_PROD.
              IF SY-SUBRC <> 0.
                CONCATENATE WA_ERR-ERR_LOG
               'product not exist !'
               INTO WA_ERR-ERR_LOG SEPARATED BY ''.
              ENDIF.
    
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
              'product can not be initial !'
              INTO WA_ERR-ERR_LOG SEPARATED BY ''.
    
            ENDIF.
    
          WHEN 6.
            IF ITAB_FILE-VALUE <> '' AND ITAB_FILE-VALUE > '0.00'.
              CONDENSE ITAB_FILE-VALUE.
              WA_DOC-P_KBETR = ITAB_FILE-VALUE.
    *          wa_doc-p_KPEIN = itab_file-value.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
              'amount is not valid !'
              INTO WA_ERR-ERR_LOG SEPARATED BY ''.
    
            ENDIF.
          WHEN 7.
            IF ITAB_FILE-VALUE <> ''.
              CONDENSE ITAB_FILE-VALUE.
              WA_DOC-P_KONWA = ITAB_FILE-VALUE.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
              'Condition currency can not be initial !'
              INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
          WHEN 8.
            IF ITAB_FILE-VALUE <> ''.
              CONDENSE ITAB_FILE-VALUE.
              IF ITAB_FILE-VALUE CA '-/.'.
                SEARCH ITAB_FILE-VALUE FOR '-'.
                IF SY-SUBRC = 0.
                  SPLIT ITAB_FILE-VALUE AT '-' INTO LV_YEAR LV_MONTH LV_DAY.
                ELSE.
                  SEARCH ITAB_FILE-VALUE FOR '/'.
                  IF SY-SUBRC = 0.
                    SPLIT ITAB_FILE-VALUE AT '-' INTO LV_YEAR LV_MONTH LV_DAY.
                  ELSE.
                    SEARCH ITAB_FILE-VALUE FOR '.'.
                    IF SY-SUBRC = 0.
                      SPLIT ITAB_FILE-VALUE AT '-' INTO LV_YEAR LV_MONTH LV_DAY.
                    ENDIF.
                  ENDIF.
                ENDIF.
                IF STRLEN( LV_MONTH ) = 1.
                  CONCATENATE '0' LV_MONTH INTO LV_MONTH.
                ENDIF.
                IF STRLEN( LV_DAY ) = 1.
                  CONCATENATE '0' LV_DAY INTO LV_DAY.
                ENDIF.
                CONCATENATE LV_YEAR LV_MONTH LV_DAY INTO WA_DOC-P_BDATE.
              ELSE.
                WA_DOC-P_BDATE = ITAB_FILE-VALUE.
              ENDIF.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
              'Valid From can not be initial !'
              INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
    
          WHEN 9.
            IF ITAB_FILE-VALUE <> ''.
              CONDENSE ITAB_FILE-VALUE.
              IF ITAB_FILE-VALUE CA '-/.'.
                SEARCH ITAB_FILE-VALUE FOR '-'.
                IF SY-SUBRC = 0.
                  SPLIT ITAB_FILE-VALUE AT '-' INTO LV_YEAR LV_MONTH LV_DAY.
                ELSE.
                  SEARCH ITAB_FILE-VALUE FOR '/'.
                  IF SY-SUBRC = 0.
                    SPLIT ITAB_FILE-VALUE AT '-' INTO LV_YEAR LV_MONTH LV_DAY.
                  ELSE.
                    SEARCH ITAB_FILE-VALUE FOR '.'.
                    IF SY-SUBRC = 0.
                      SPLIT ITAB_FILE-VALUE AT '-' INTO LV_YEAR LV_MONTH LV_DAY.
                    ENDIF.
                  ENDIF.
                ENDIF.
                IF STRLEN( LV_MONTH ) = 1.
                  CONCATENATE '0' LV_MONTH INTO LV_MONTH.
                ENDIF.
                IF STRLEN( LV_DAY ) = 1.
                  CONCATENATE '0' LV_DAY INTO LV_DAY.
                ENDIF.
                CONCATENATE LV_YEAR LV_MONTH LV_DAY INTO WA_DOC-P_EDATE.
              ELSE.
                WA_DOC-P_EDATE = ITAB_FILE-VALUE.
              ENDIF.
            ELSE.
              CONCATENATE WA_ERR-ERR_LOG
              'Valid To can not be initial !'
              INTO WA_ERR-ERR_LOG SEPARATED BY ''.
            ENDIF.
    
          WHEN OTHERS.
    
        ENDCASE.
        AT  END  OF  ROW.
          APPEND WA_DOC TO IT_DOC.
          CLEAR WA_DOC.
          ZINX = ZINX + 1.
          IF WA_ERR-ERR_LOG IS NOT INITIAL.
            WA_ERR-INX = ZINX.
            APPEND WA_ERR TO IT_ERR.
            CLEAR WA_ERR.
          ENDIF.
        ENDAT.
      ENDLOOP.
    
    
    ENDFORM.                    "IMPORT_DATA
    *&---------------------------------------------------------------------*
    *&      Form  SELECT_FILE
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM SELECT_FILE .
    
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          MASK             = ',Excel Files,*.xls,All Files,*.*.'(101)
          TITLE            = '####'(100)
        IMPORTING
          FILENAME         = P_FILE
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      IF SY-SUBRC <> 0 AND SY-SUBRC <> 3.
        MESSAGE E100(ZDEV) WITH '#######'(007).
      ENDIF.
    
    
    
    
    ENDFORM.                    " SELECT_FILE
    *&---------------------------------------------------------------------*
    *&      Form  OUTPUT_RESULT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM OUTPUT_RESULT .
    
      LOOP AT IT_DOC INTO WA_DOC.
    
        WRITE:/ '販売組織:', WA_DOC-P_SORG NO-GAP, 'お客様モデル:', WA_DOC-P_ZZZMODENO NO-GAP
        ,'顧客の区分:',WA_DOC-P_PGRP,'保守コード',WA_DOC-P_ZREPCODE NO-GAP, '製品ID', WA_DOC-P_PROD NO-GROUPING,
        '価格', WA_DOC-P_KBETR, '有効開始日', WA_DOC-P_BDATE, '有効終日', WA_DOC-P_EDATE.
    
      ENDLOOP.
    
    
    ENDFORM.                    " OUTPUT_RESULT
  • 相关阅读:
    手机领域的各种角色介绍
    windows配置教程
    windows7安装教程(vmware)
    /etc/profile、~/.bash_profile、~/.bashrc和/etc/bashrc
    vmware自定义网段
    wps去除首字母自动大写
    Windows和Linux创建软链接和硬链接
    计算机的组成部件及其厂商
    windows开机锁定小键盘
    PL/SQL Developer安装教程
  • 原文地址:https://www.cnblogs.com/sapSB/p/6609693.html
Copyright © 2011-2022 走看看