Wednesday, September 30, 2020

BP transection tax Classified Upload Program In SAP ABAP.

BP transection BDC Program In SAP ABAP.

BDC Program for BP transection.

REPORT ZTCS_TAXCLASSIFIED_UPLOAD.

INCLUDE ZTCS_TAXCLASSIFIED_UPLOAD_TOP2.
INCLUDE ZTCS_TAXCLASSIFIED_UPLOAD2.
INCLUDE ZTCS_TAXCLASSIFIED_UPLOAD_SUB2.

INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

  CALL FUNCTION 'F4_FILENAME'
*   EXPORTING
*     PROGRAM_NAME        = SYST-CPROG
*     DYNPRO_NUMBER       = SYST-DYNNR
*     FIELD_NAME          = ' '
    IMPORTING
      file_name p_path.

START-OF-SELECTION.
  PERFORM get_excel_data.
  PERFORM call_bdc.
====================================================================================
*&---------------------------------------------------------------------*
*& INCLUDE          ZTCS_TAXCLASSIFIED_UPLOAD_TOP2
*&---------------------------------------------------------------------*
DATA SERIAL TYPE I.
TYPES BEGIN OF TYP_FINAL,
        OPEN_NUMBER(10),
        PARTNER_ROLE(7),
        TAXKD(1),
        END OF TYP_FINAL.
FIELD-SYMBOLS<FS_FINAL> TYPE TYP_FINAL.
FIELD-SYMBOLS <FS>.

DATA IT_FINAL TYPE STANDARD TABLE OF TYP_FINAL,
       WA_FINAL TYPE                   TYP_FINAL,
       IT_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE,
       WA_EXCEL TYPE                   ALSMEX_TABLINE,
       BDCDATA  LIKE BDCDATA OCCURS WITH HEADER LINE,
       MESSTAB  LIKE BDCMSGCOLL OCCURS WITH HEADER LINE,
       INDEX    TYPE I,
       MSG      TYPE STRING.
================================================================================
*&---------------------------------------------------------------------*
*& INCLUDE          ZTCS_TAXCLASSIFIED_UPLOAD2
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS P_PATH LIKE RLGRAP-FILENAME OBLIGATORY,
             P_STROW TYPE OBLIGATORY,
             P_EDROW TYPE OBLIGATORY.
SELECTION-SCREEN SKIP 1.
PARAMETERS P_MODE LIKE CTU_PARAMS-DISMODE OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
===============================================================================
*&---------------------------------------------------------------------*
*& INCLUDE          ZTCS_TAXCLASSIFIED_UPLOAD_SUB2
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& FORM GET_EXCEL_DATA
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& -->  P1        TEXT
*& <--  P2        TEXT
*&---------------------------------------------------------------------*
FORM GET_EXCEL_DATA .
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                P_PATH
      I_BEGIN_COL             1
      I_BEGIN_ROW             P_STROW
      I_END_COL               100
      I_END_ROW               P_EDROW
    TABLES
      INTERN                  IT_EXCEL
    EXCEPTIONS
      INCONSISTENT_PARAMETERS 1
      UPLOAD_OLE              2
      OTHERS                  3.
  IF SY-SUBRC <> 0.
    MESSAGE 'ERROR OCCUR IN READING THE EXCEL FILE' TYPE 'I'.
    STOP.
  ENDIF.

  LOOP AT IT_EXCEL INTO WA_EXCEL.
    INDEX WA_EXCEL-COL.
    ASSIGN COMPONENT INDEX OF STRUCTURE WA_FINAL TO <FS>.
    <FS> WA_EXCEL-VALUE.
    AT END OF ROW.
      APPEND WA_FINAL TO IT_FINAL.
      CLEAR WA_FINAL.
    ENDAT.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& FORM CALL_BDC
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& -->  P1        TEXT
*& <--  P2        TEXT
*&---------------------------------------------------------------------*
FORM CALL_BDC .
LOOP AT IT_FINAL INTO WA_FINAL.
    REFRESH BDCDATA.
    REFRESH MESSTAB.
    CLEAR   BDCDATA.
    CLEAR   MESSTAB.

perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SCREEN_1000_SETTINGS'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BDC_CURSOR'
                              'BUS_JOEL_MAIN-CHANGE_NUMBER'.
perform bdc_dynpro      using 'SAPLBUPA_DIALOG_SETTINGS' '4000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BUS_MAIN_ENTER'.
perform bdc_field       using 'BDC_CURSOR'
                              'BUS_JOEL_SET-BUPR_CHANGE_MODE'.
perform bdc_field       using 'BUS_JOEL_SET-BUPA_DISPLAY_MODE'
                              ''.
perform bdc_field       using 'BUS_JOEL_SET-BUPA_CHANGE_MODE'
                              'X'.
perform bdc_field       using 'BUS_JOEL_SET-BUPR_DISPLAY_MODE'
                              ''.
perform bdc_field       using 'BUS_JOEL_SET-BUPR_CHANGE_MODE'
                              'X'.
perform bdc_field       using 'BUS_JOEL_SET-BUPA_CREATE_ROLE'
                              'X'.
perform bdc_field       using 'BUS_JOEL_SET-USE_ALV'
                              'X'.
perform bdc_field       using 'BUS_LOCATOR_SET-NARROW'
                              'X'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SCREEN_1000_OPEN'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BDC_CURSOR'
                              'BUS_JOEL_MAIN-CHANGE_NUMBER'.
perform bdc_dynpro      using 'SAPLBUPA_DIALOG_JOEL' '1600'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BUS_MAIN_ENTER'.
perform bdc_field       using 'BDC_CURSOR'
                              'BUS_JOEL_MAIN-OPEN_NUMBER'.
perform bdc_field       using 'BUS_JOEL_MAIN-OPEN_NUMBER' WA_FINAL-OPEN_NUMBER.
                                                                                      " '100000011'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SCREEN_1110_CHG_ROLE'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BDC_CURSOR'
                              'BUS_JOEL_MAIN-PARTNER_ROLE'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_ROLE'  WA_FINAL-PARTNER_ROLE.
                                                                          "'FLCU01'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_TIMEDEP'
                              '000001'.
*perform bdc_field       using 'BUS000FLDS-TITLE_MEDI'
*                              '3000'.
**perform bdc_field       using 'BUT000-NAME_ORG1'
**                              'S. DHAWAN & SONS.'.
**perform bdc_field       using 'BUS000FLDS-BU_SORT1_TXT'
**                              'SD3'.
**perform bdc_field       using 'ADDR1_DATA-STR_SUPPL1'
**                              '118 CHAMPAKLAL INDUSTRIAL ESTATE'.
**perform bdc_field       using 'ADDR1_DATA-STR_SUPPL2'
**                              'MUMBAI'.
**perform bdc_field       using 'ADDR1_DATA-CITY2'
**                              'MUMBAI'.
**perform bdc_field       using 'ADDR1_DATA-POST_CODE1'
**                              '400022'.
**perform bdc_field       using 'ADDR1_DATA-CITY1'
**                              'MUMBAI'.
**perform bdc_field       using 'ADDR1_DATA-COUNTRY'
**                              'IN'.
**perform bdc_field       using 'ADDR1_DATA-REGION'
**                              '27'.
**perform bdc_field       using 'ADDR1_DATA-TIME_ZONE'
**                              'INDIA'.
**perform bdc_field       using 'ADDR1_DATA-LANGU'
**                              'EN'.
**perform bdc_field       using 'SZA1_D0100-TEL_NUMBER'
**                              '23344451'.
**perform bdc_field       using 'SZA1_D0100-MOB_NUMBER'
**                              '98475626731'.
**perform bdc_field       using 'SZA1_D0100-FAX_NUMBER'
**                              '36464751'.
**perform bdc_field       using 'SZA1_D0100-SMTP_ADDR'
**                              'siddharth.banerjee@gmail.com'.
**perform bdc_field       using 'BUS000FLDS-ADDR_VALID_FROM'
**                              '23.04.2019'.
**perform bdc_field       using 'BUS000FLDS-ADDR_VALID_TO'
**                              '31.12.9999'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SCREEN_1000_MAIN_P02'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_ROLE' WA_FINAL-PARTNER_ROLE.
                                                                                 " 'FLCU01'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_TIMEDEP'
                              '000001'.
perform bdc_field       using 'BDC_CURSOR'
                              'BUS000FLDS-TITLE_MEDI'.
*perform bdc_field       using 'BUS000FLDS-TITLE_MEDI'
*                              '3000'.
*perform bdc_field       using 'BUT000-NAME_ORG1'
*                              'S. DHAWAN & SONS.'.
*perform bdc_field       using 'BUS000FLDS-BU_SORT1_TXT'
*                              'SD3'.
*perform bdc_field       using 'ADDR1_DATA-STR_SUPPL1'
*                              '118 CHAMPAKLAL INDUSTRIAL ESTATE'.
*perform bdc_field       using 'ADDR1_DATA-STR_SUPPL2'
*                              'MUMBAI'.
*perform bdc_field       using 'ADDR1_DATA-CITY2'
*                              'MUMBAI'.
*perform bdc_field       using 'ADDR1_DATA-POST_CODE1'
*                              '400022'.
*perform bdc_field       using 'ADDR1_DATA-CITY1'
*                              'MUMBAI'.
*perform bdc_field       using 'ADDR1_DATA-COUNTRY'
*                              'IN'.
*perform bdc_field       using 'ADDR1_DATA-REGION'
*                              '27'.
*perform bdc_field       using 'ADDR1_DATA-TIME_ZONE'
*                              'INDIA'.
*perform bdc_field       using 'ADDR1_DATA-LANGU'
*                              'EN'.
*perform bdc_field       using 'SZA1_D0100-TEL_NUMBER'
*                              '23344451'.
*perform bdc_field       using 'SZA1_D0100-MOB_NUMBER'
*                              '98475626731'.
*perform bdc_field       using 'SZA1_D0100-FAX_NUMBER'
*                              '36464751'.
*perform bdc_field       using 'SZA1_D0100-SMTP_ADDR'
*                              'siddharth.banerjee@gmail.com'.
*perform bdc_field       using 'BUS000FLDS-ADDR_VALID_FROM'
*                              '23.04.2019'.
*perform bdc_field       using 'BUS000FLDS-ADDR_VALID_TO'
*                              '31.12.9999'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=CVIC_SA_DETAIL'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_ROLE'  WA_FINAL-PARTNER_ROLE.
                                                                     " 'FLCU01'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_TIMEDEP'
                              '000001'.
perform bdc_field       using 'BDC_CURSOR'
                              'RF02D-VKORG'.
perform bdc_dynpro      using 'SAPLBUSS' '0040'.
perform bdc_field       using 'BDC_OKCODE'
                              '=CVIC_SA_OKAY'.
perform bdc_field       using 'BDC_CURSOR'
                              'CVIS_SALES_AREA_DYNPRO-SALES_ORG(01)'.
perform bdc_field       using 'CVIS_SALES_AREA_DYNPRO-XMARK(01)'
                              'X'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SCREEN_1100_TAB_03'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_ROLE'  WA_FINAL-PARTNER_ROLE.
                                                                   "  'FLCU01'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_TIMEDEP'
                              '000001'.
perform bdc_field       using 'BDC_CURSOR'
                              'RF02D-VKORG'.
**perform bdc_field       using 'GS_KNVV-BZIRK'
**                              'T22004'.
**perform bdc_field       using 'GS_KNVV-VKBUR'
**                              '15'.
**perform bdc_field       using 'GS_KNVV-VKGRP'
**                              '22'.
**perform bdc_field       using 'GS_KNVV_DYNP-AWAHR'
**                              '100'.
**perform bdc_field       using 'GS_KNVV-WAERS'
**                              'INR'.
**perform bdc_field       using 'GS_KNVV-KURST'
**                              ''.
**perform bdc_field       using 'GS_KNVV-KALKS'
**                              '1'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BUS_MAIN_ENTER'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_ROLE'  WA_FINAL-PARTNER_ROLE.
                                                                               " 'FLCU01'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_TIMEDEP'
                              '000001'.
*perform bdc_field       using 'GS_KNVV-INCO1'
*                              'FOB'.
*perform bdc_field       using 'GS_KNVV-INCO2_L'
*                              'Free on Board'.
*perform bdc_field       using 'GS_KNVV-ZTERM'
*                              'Z006'.
*perform bdc_field       using 'GS_KNVV-KKBER'
*                              '1100'.
*perform bdc_field       using 'GS_KNVV-KTGRD'
*                              '01'.
perform bdc_field       using 'BDC_CURSOR'
                              'GT_KNVI_TC-TAXKD(05)'.
perform bdc_field       using 'GT_KNVI_TC-TAXKD(05)' WA_FINAL-TAXKD.
                                                                       "   '1'.
perform bdc_dynpro      using 'SAPLBUS_LOCATOR' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BUS_MAIN_SAVE'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_TYPE'
                              '3'.
perform bdc_field       using 'BUS_LOCA_SRCH01-SEARCH_ID'
                              '8'.
perform bdc_field       using 'BUS_LOCA_SRCH01-MAXHIT'
                              '100'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_ROLE'  WA_FINAL-PARTNER_ROLE.
                                                                      "  ' FLCU01'.
perform bdc_field       using 'BUS_JOEL_MAIN-PARTNER_TIMEDEP'
                              '000001'.
*perform bdc_field       using 'GS_KNVV-INCO1'
*                              'FOB'.
*perform bdc_field       using 'GS_KNVV-INCO2_L'
*                              'Free on Board'.
*perform bdc_field       using 'GS_KNVV-ZTERM'
*                              'Z006'.
*perform bdc_field       using 'GS_KNVV-KKBER'
*                              '1100'.
*perform bdc_field       using 'GS_KNVV-KTGRD'
*                              '01'.
perform bdc_field       using 'BDC_CURSOR'
                              'GT_KNVI_TC-TAXKD(05)'.

CALL TRANSACTION 'BP' USING BDCDATA
                        MODE  P_MODE
                        MESSAGES INTO MESSTAB.

    LOOP AT MESSTAB.
      IF MESSTAB-MSGTYP 'E' OR MESSTAB-MSGTYP 'S'.

        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            ID        SY-MSGID
            LANG      '-D'
            NO        SY-MSGNO
            V1        SY-MSGV1
            V2        SY-MSGV2
            V3        SY-MSGV3
            V4        SY-MSGV4
          IMPORTING
            MSG       MSG
          EXCEPTIONS
            NOT_FOUND 1
            OTHERS    2.
        IF SY-SUBRC <> 0.

        ENDIF.
        SERIAL SERIAL + 1.
        WRITE :/9 SERIAL COLOR 7MSG.
      ENDIF.
    ENDLOOP.

ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
*        START NEW SCREEN                                              *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR BDCDATA.
  BDCDATA-PROGRAM  PROGRAM.
  BDCDATA-DYNPRO   DYNPRO.
  BDCDATA-DYNBEGIN 'X'.
  APPEND BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
*        INSERT FIELD                                                  *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
*  IF FVAL <> NODATA.
  CLEAR BDCDATA.
  BDCDATA-FNAM FNAM.
  BDCDATA-FVAL FVAL.
  SHIFT BDCDATA-FVAL LEFT DELETING LEADING SPACE.
  APPEND BDCDATA.
*  ENDIF.
ENDFORM.

No comments:

Post a Comment