2017년 3월 2일 목요일

Excel Template Download 및 Upload 예제 프로그램

*&---------------------------------------------------------------------*
*& 프로그램 ID   : ZTRR1220
*& 프로그램 명   : [TR] Batch Create Bank key
*& 생성일        : 2017.02.24
*& 생성자        :  
*& 구  분        : 신규 생성(O), 기존 프로그램 이관(X)
*& 프로그램 설명 : [TR] Batch Create Bank key
*&---------------------------------------------------------------------*
*& 변경번호 : #1   변경자 : XXX     변경일자 : YYYY..MM.DD
*& 변경내용 : 가급적 자세한 설명을 기술한다.
*&            변경사항이 발생 할 때마다 변경사유를 기록한다.
*&            최근 변경내역을 위쪽에 기술한다.
*&---------------------------------------------------------------------*
REPORT ZTRR1220 MESSAGE-ID ZTRM.

INCLUDE ZTRR1220TOP.
INCLUDE ZTR_CONSTANTS.
INCLUDE ZTR_COMMON.
INCLUDE ZTRR1220F01.

*----------------------------------------------------------------------*
* INITIALIZATION                                                       *
*----------------------------------------------------------------------*
INITIALIZATION.
  PERFORM INIT_PGM.
  PERFORM SET_DYNP.
  PERFORM FC01_ACTIVE.

*----------------------------------------------------------------------*
* SELECTION-SCREEN.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*  PERFORM CONTROL_FCXX.
  PERFORM SELECTION_SCREEN.

AT SELECTION-SCREEN OUTPUT.
  PERFORM LOOP_AT_SCREEN.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
  PERFORM F4_FNAME USING P_FNAME.

*----------------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM INIT_DATA.        " Initiaiton, Master data
****  PERFORM ENQUEUE_???? USING GV_LOCK.
****  PERFORM SELECT_DATA.      " Data select

*----------------------------------------------------------------------*
* END-OF-SELECTION.
*----------------------------------------------------------------------*
END-OF-SELECTION.
  PERFORM DATA_PROCESSING.  " Data modify

**  IF SY-BATCH NE 'X'.
**    IF GT_LIST[] IS INITIAL.
**      MESSAGE S000 WITH 'No data found'.
**    ENDIF.
**    CALL SCREEN 100.
**  ENDIF.



INCLUDE ZTRR1220TOP.

TABLES ICONSSCRFIELDS.

*************************************************
* Program Table/Structure DEFINITION
*************************************************
TABLES :  BKPF
  ,       ACDOCA
  ,       BSIK
  ,       BSAK
  ,       LFBK
  ,       BNKA
  ,       BUT0BK    "BP: Bank Details
  ,       T51R5
  .
*************************************************
* 프로그램 상태 체크
*************************************************
DATA GV_LOCK(1)         TYPE C" Locking
DATA GV_UPLOAD_ERROR(1TYPE C" 업로드 오류
DATA GV_ALREADY_POST(1TYPE C" 실행 여부
DATA GV_POST_ERROR(1)   TYPE C" 전기 오류
DATA GV_CHANGE(1)       TYPE C" 변경이력

DATA GV_SAVE_COMPLETE(1TYPE C.

DATA GV_T_CNT TYPE I.
DATA GV_S_CNT TYPE I.
DATA GV_F_CNT TYPE I.

DATA GV_ALREADY_SAVED  TYPE C.
DATA GV_ALREADY_POSTED TYPE C.

*************************************************
* COMMON DEFINITION
*************************************************
DATA GV_OK_CODE LIKE SY-UCOMM.
DATA GV_MODE TYPE UI_FUNC.
DATA GT_UCOMM TYPE TABLE OF SY-UCOMM.
DATA GS_UCOMM TYPE SY-UCOMM.
DATA GV_KOKRS LIKE TKA02-KOKRS.

* 메인 인터널 테이블 구조(ALV)
DATA GT_MAIN_FIELDCAT TYPE LVC_T_FCAT.

*************************************************
* 엑셀 업로드
*************************************************
FIELD-SYMBOLS <GF_UPLOADT> TYPE STANDARD TABLE.
FIELD-SYMBOLS <GF_UPLOADS> TYPE ANY.

DATA GF_UPLOADT      TYPE REF TO DATA.
DATA GF_UPLOADS      TYPE REF TO DATA.

DATA GT_UPLD_FCAT TYPE LVC_T_FCAT.
DATA GS_UPLD_FCAT TYPE LVC_S_FCAT.

*************************************************
* CONSTANTS DEFINITION
*************************************************
CONSTANTS GC_UPLOAD_STRUCT  TYPE DD03L-TABNAME
            VALUE 'ZTRS_ZTRR1220_UPLOAD'.
CONSTANTS GC_SMW0           TYPE W3_QVALUE      VALUE ''.

*************************************************
* Internal Table
*************************************************
TYPES GTY_DATA TYPE ZTRS_ZTRR1220_UPLOAD.

DATA GT_DATA TYPE STANDARD TABLE OF GTY_DATA,  " ALV Display Internal Table
       GS_DATA LIKE LINE OF GT_DATA.             " Work area

DATA BEGIN OF GT_LIST OCCURS 0.
    INCLUDE STRUCTURE ZTRS_ZTRR1220_UPLOAD.
DATA :
  F_COL TYPE LVC_T_SCOL,
  ERR   TYPE C.
DATA END OF GT_LIST.

DATA GS_LIST LIKE LINE OF GT_LIST.
FIELD-SYMBOLS <GS_LIST> LIKE GS_LIST.

*
TYPES BEGIN OF GTY_HOUSE_BANK_INFO,
          BUKRS LIKE T001-BUKRS,
          BUTXT LIKE T001-BUTXT,
          HBKID LIKE T012-HBKID,  "Short key for a house bank
          HKTID LIKE T012K-HKTID"ID for account details
          BANKS LIKE BNKA-BANKS,  "Bank country key
          BANKL LIKE BNKA-BANKL,  "Bank Keys
          BANKA LIKE BNKA-BANKA,  "Name of bank
          TEXT1 LIKE T012T-TEXT1"Description
          BANKN LIKE T012K-BANKN"Bank account number
          WAERS LIKE T012K-WAERS"Currency Key
          HKONT LIKE T012K-HKONT"General Ledger Account
          TXT50 LIKE SKAT-TXT50,
*          "Suspense GL Account (미결계정, SUSPENSE )
*          SUSPE_HKONT TYPE ZE_TR_SUSPENSE_HKONT,
        END OF GTY_HOUSE_BANK_INFO.

DATA GT_HOUSE_BANK_INFO TYPE TABLE OF GTY_HOUSE_BANK_INFO.
DATA GS_HOUSE_BANK_INFO TYPE          GTY_HOUSE_BANK_INFO.
*

DATA GT_T001  LIKE T001  OCCURS WITH HEADER LINE"Company Codes
DATA GT_T003T LIKE T003T OCCURS WITH HEADER LINE"Document Type Texts
DATA GT_T005T LIKE T005T OCCURS WITH HEADER LINE"Country Names
DATA GT_T012  LIKE T012  OCCURS WITH HEADER LINE"House Banks
DATA GT_T012K LIKE T012K OCCURS WITH HEADER LINE"House Bank Accounts
DATA GT_SKB1  LIKE SKB1  OCCURS WITH HEADER LINE"G/L account master (company code)
DATA GT_TGSB  LIKE TGSB  OCCURS WITH HEADER LINE"Business Areas
DATA GT_TCURC LIKE TCURC OCCURS WITH HEADER LINE"Currency Codes
DATA GT_TCURX LIKE TCURX OCCURS WITH HEADER LINE"Currency Codes
*

DATA GV_ERROR       TYPE CHAR1.
DATA GT_RETURN      TYPE TABLE OF BAPIRET2.
DATA GV_CNT_SUCCESS TYPE I.
DATA GV_CNT_FAILURE TYPE I.

*************************************************
* SELECTION-SCREEN
*************************************************
SELECTION-SCREEN BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-BL1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20TEXT-S01 FOR FIELD P_BUKRS.
SELECTION-SCREEN POSITION  33.
PARAMETERS P_BUKRS LIKE T001-BUKRS OBLIGATORY " DEFAULT C_BUKRS
  MODIF ID BUK.
SELECTION-SCREEN POSITION  40.
SELECTION-SCREEN COMMENT  40(30P_BUTXT.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END   OF BLOCK BLK01.

SELECTION-SCREEN BEGIN OF BLOCK BLK03 WITH FRAME TITLE TEXT-BL3.
PARAMETERS P_FNAME TYPE RLGRAP-FILENAME
 MODIF ID FLE MEMORY ID ZTRR1220.
SELECTION-SCREEN END OF BLOCK BLK03.
*
SELECTION-SCREENFUNCTION KEY 1.

SELECTION-SCREEN BEGIN OF BLOCK DSMOD WITH FRAME TITLE TEXT-BLB.
*PARAMETER : P_DSMOD TYPE DISPMODE DEFAULT 'N' MODIF ID DSM.
PARAMETER P_DSMOD TYPE CTU_MODE DEFAULT 'N' MODIF ID DSM NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK DSMOD.




INCLUDE ZTR_CONSTANTS.

CONSTANTS C_BUKRS LIKE BKPF-BUKRS       VALUE 'B477'"회사코드
            C_WAERS LIKE BKPF-WAERS       VALUE 'VND',  "Currency Key
            C_LAND1 LIKE T001-LAND1       VALUE 'VN',   "Country Key
            C_KTOPL LIKE SKAT-KTOPL       VALUE '1000'"Chart of Accounts
            C_KOKRS LIKE CSKT-KOKRS       VALUE '1000'"관리회계영역
            C_KALSM LIKE T007S-KALSM      VALUE 'TAX??',"Procedure
            C_KURST LIKE TCURR-KURST      VALUE 'M'.    "Exchange Rate Type


CONSTANTS C_0(1)                        VALUE '0',
            C_1(1)                        VALUE '1',
            C_2(1)                        VALUE '2',
            C_3(1)                        VALUE '3',
            C_4(1)                        VALUE '4',
            C_5(1)                        VALUE '5',
            C_6(1)                        VALUE '6',
            C_7(1)                        VALUE '7',
            C_8(1)                        VALUE '8',
            C_9(1)                        VALUE '9',
            C_10(2)                       VALUE '10',
            C_20(2)                       VALUE '20',
            C_30(2)                       VALUE '30',
            C_40(2)                       VALUE '40',
            C_50(2)                       VALUE '50',
            C_60(2)                       VALUE '60',
            C_70(2)                       VALUE '70',
            C_80(2)                       VALUE '80',
            C_90(2)                       VALUE '90',
            C_100(3)                      VALUE '100',
            C_00(2)                       VALUE '00',
            C_000(3)                      VALUE '000',
            C_A(1)                        VALUE 'A',
            C_B(1)                        VALUE 'B',
            C_C(1)                        VALUE 'C',
            C_D(1)                        VALUE 'D',
            C_E(1)                        VALUE 'E',
            C_F(1)                        VALUE 'F',
            C_G(1)                        VALUE 'G',
            C_H(1)                        VALUE 'H',
            C_I(1)                        VALUE 'I',
            C_J(1)                        VALUE 'J',
            C_K(1)                        VALUE 'K',
            C_L(1)                        VALUE 'L',
            C_M(1)                        VALUE 'M',
            C_N(1)                        VALUE 'N',
            C_O(1)                        VALUE 'O',
            C_P(1)                        VALUE 'P',
            C_Q(1)                        VALUE 'Q',
            C_R(1)                        VALUE 'R',
            C_S(1)                        VALUE 'S',
            C_T(1)                        VALUE 'T',
            C_U(1)                        VALUE 'U',
            C_V(1)                        VALUE 'V',
            C_W(1)                        VALUE 'W',
            C_X(1)                        VALUE 'X',
            C_Y(1)                        VALUE 'Y',
            C_Z(1)                        VALUE 'Z',
            C_0123456789S(11)             VALUE '0123456789 ',
            C_0123456789(10)              VALUE '0123456789',
            C_ESP(3)                      VALUE 'ESP',
            C_IDR(3)                      VALUE 'IDR',
            C_ITL(3)                      VALUE 'ITL',
            C_JPY(3)                      VALUE 'JPY',
            C_USD(3)                      VALUE 'USD',
            C_KRW(3)                      VALUE 'KRW',
            C_VND(3)                      VALUE 'VND',
            C_PTE(3)                      VALUE 'PTE',
            C_TTB(3)                      VALUE 'TTB',
            C_CB(2)                       VALUE 'CB',
            C_TTS(3)                      VALUE 'TTS',
            C_CS(2)                       VALUE 'CS',
            C_CR(2)                       VALUE 'CR',
            C_ZTTB(4)                     VALUE 'ZTTB',
            C_ZCB(3)                      VALUE 'ZCB',
            C_ZTTS(4)                     VALUE 'ZTTS',
            C_ZCS(3)                      VALUE 'ZCS',
            C_ZCR(3)                      VALUE 'ZCR',
            C_ZM(2)                       VALUE 'ZM',
            C_AR(2)                       VALUE 'AR',
            C_SEND        TYPE UI_FUNC    VALUE 'SEND',
            C_BLOCK       TYPE UI_FUNC    VALUE 'BLOC',
            C_CHANGE      TYPE UI_FUNC    VALUE 'CHANGE',
            C_DISPLAY     TYPE UI_FUNC    VALUE 'DISPLAY',
            C_ICON        TYPE ICONNAME   VALUE '@0Z@',
            C_INFO        TYPE ICONQUICK  VALUE 'CHANGE DATA',
            C_ADD         TYPE UI_FUNC    VALUE 'ADD',
            C_ICON_ADD    TYPE ICONNAME   VALUE '@17@',
            C_INFO_ADD    TYPE ICONQUICK  VALUE 'ADD DATA',
            C_DEL         TYPE UI_FUNC    VALUE 'DELETE',
            C_ICON_DEL    TYPE ICONNAME   VALUE '@18@',
            C_INFO_DEL    TYPE ICONQUICK  VALUE 'DELETE DATA',
            C_KOART_D     TYPE KOART      VALUE 'D'"고객
            C_KOART_K     TYPE KOART      VALUE 'K'"거래처
*            C_USE_Y       TYPE ZTRE_USE  VALUE 'Y',
*            C_USE_N       TYPE ZTRE_USE  VALUE 'N',
*            C_STATE_A     TYPE ZTRE_SEND_STATE VALUE 'A',
*            C_STATE_B     TYPE ZTRE_SEND_STATE VALUE 'B',
*            C_STATE_C     TYPE ZTRE_SEND_STATE VALUE 'C',
            C_ZTRKEY(2)                   VALUE '30',
            C_LAND_KR     TYPE LAND1      VALUE 'KR',
            C_SUC(1)                      VALUE 'S',
            C_ERR(1)                      VALUE 'E',
            C_55A200CL TYPE TPM_AA_REF  VALUE '55A200CL',
            C_55A200CF TYPE TPM_AA_REF  VALUE '55A200CF',
            C_55A200DL TYPE TPM_AA_REF  VALUE '55A200DL',
            C_55A200DF TYPE TPM_AA_REF  VALUE '55A200DF'.

CONSTANTS C_1M  TYPE CHAR10 VALUE 'January'.
CONSTANTS C_2M  TYPE CHAR10 VALUE 'Febuary'.
CONSTANTS C_3M  TYPE CHAR10 VALUE 'March'.
CONSTANTS C_4M  TYPE CHAR10 VALUE 'April'.
CONSTANTS C_5M  TYPE CHAR10 VALUE 'May'.
CONSTANTS C_6M  TYPE CHAR10 VALUE 'June'.
CONSTANTS C_7M  TYPE CHAR10 VALUE 'July'.
CONSTANTS C_8M  TYPE CHAR10 VALUE 'August'.
CONSTANTS C_9M  TYPE CHAR10 VALUE 'September'.
CONSTANTS C_10M TYPE CHAR10 VALUE 'October'.
CONSTANTS C_11M TYPE CHAR10 VALUE 'November'.
CONSTANTS C_12M TYPE CHAR10 VALUE 'December'.

DATA GV_EXECUTE_MODE    TYPE UI_FUNC.
CONSTANTS GC_CREATE     TYPE UI_FUNC VALUE 'CREATE'.
CONSTANTS GC_CHANGE     TYPE UI_FUNC VALUE 'CHANGE'.
CONSTANTS GC_DISPLAY    TYPE UI_FUNC VALUE 'DISPLAY'.
CONSTANTS GC_DELETE     TYPE UI_FUNC VALUE 'DELETE'.
CONSTANTS GC_MODIFY     TYPE UI_FUNC VALUE 'MODIFY'.
CONSTANTS GC_INSERT     TYPE UI_FUNC VALUE 'INSERT'.
CONSTANTS GC_APPEND     TYPE UI_FUNC VALUE 'APPEND'.
CONSTANTS GC_UPLOAD     TYPE UI_FUNC VALUE 'UPLOAD'.
CONSTANTS GC_DOWNLOAD   TYPE UI_FUNC VALUE 'DOWNLOAD'.



INCLUDE ZTRR1220F01.
*&---------------------------------------------------------------------*
*&      Form  INIT_PGM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM INIT_PGM .

*** 사용자 ID에 따른 회사코드 지정
**  PERFORM _AUTH01_GET_USER_BUKRS.
**  P_BUKRS = G_AUTH_BUKRS.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SET_DYNP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_DYNP .

  PERFORM SET_COMPANY_BASE USING P_BUKRS.
  P_BUTXT GV_BUTXT_CM.

*  SELECT SINGLE KOKRS FROM TKA02
*    INTO GV_KOKRS
*    WHERE BUKRS = P_BUKRS.
*  PERFORM SET_KOKRS_BASE USING GV_KOKRS.
*  SET PARAMETER ID 'CAC' FIELD GV_KOKRS.

*  P_GJAHR = SY-DATUM+0(4).

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FC01_ACTIVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FC01_ACTIVE .

  PERFORM SET_BTN_1000
      USING '01' ICON_XXL 'Excel Form Download'(F01).

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  CONTROL_FCXX
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CONTROL_FCXX .
*  DATA : LV_UCOMM LIKE SY-UCOMM.
*
*  LV_UCOMM = SSCRFIELDS-UCOMM.
*  CASE LV_UCOMM.
*    WHEN 'FC01'.
*      CALL FUNCTION 'ZCO_OPEN_SMW0'
*        EXPORTING
*          P_DOCNAM = GC_SMW0
*          P_TITLE  = 'Upload Cost Center budget'(F02).
*  ENDCASE.
*  CLEAR : LV_UCOMM.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SELECTION_SCREEN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SELECTION_SCREEN .

  CASE SY-UCOMM.

*- excel sheet download

    WHEN 'FC01'.
      PERFORM EXCUTE_DOWNLOAD.
      EXIT.

  ENDCASE.

  CHECK SY-UCOMM 'ONLI'.

*** 현재 월 시작일/종료일
**  CONCATENATE SY-DATUM(6) '01' INTO GV_SDATE.
**  PERFORM GET_LAST_DAY USING GV_SDATE GV_EDATE.

  PERFORM SET_COMPANY_BASE USING P_BUKRS.
  P_BUTXT GV_BUTXT_CM.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  EXCUTE_DOWNLOAD
*&---------------------------------------------------------------------*
FORM EXCUTE_DOWNLOAD .
  CLEAR GV_INDEX.

*- 양식 파일 Open

  CREATE OBJECT GS_EXCEL 'EXCEL.APPLICATION'.
  CALL METHOD OF
    GS_EXCEL
      'WORKBOOKS' GS_BOOKS.
  CALL METHOD OF
    GS_BOOKS
      'ADD' GS_BOOK.

  CALL METHOD OF
    GS_EXCEL
      'APPLICATION' GS_CELL.

  SET PROPERTY OF GS_EXCEL 'VISIBLE'     1.
  GET PROPERTY OF GS_EXCEL 'ActiveSheet' GS_SHEET.

  CALL METHOD OF
      GS_EXCEL
      'Worksheets' GS_SHEET
    EXPORTING
      #1           'Sheet1'.

  CALL METHOD OF
    GS_SHEET
    'Activate'.

*- 엑셀 셀값 채우기
  PERFORM FILL_CELL USING:
               '1'  'Bank Country'(C01),
               '1'  'Bank Key'(C02),
               '1'  'Bank Name'(C03),
               '1'  'Bank Region'(C04),
               '1'  'Bank Street'(C05),
               '1'  'Bank City'(C06),
               '1'  'Bank Branch'(C07),
               '1'  'Bank group'(C08).
*  "샘플 예제 데이터 채우기
*  CLEAR GV_INDEX.
*  PERFORM FILL_CELL_SAMPLE USING:
*               '2'  '0.12345'(C08).

  FREE OBJECTGS_CELLGS_EXCELGS_SHEETGS_BOOKSGS_FONT.

ENDFORM" EXCUTE_DOWNLOAD
*&---------------------------------------------------------------------*
*&      Form  FILL_CELL
*&---------------------------------------------------------------------*
FORM FILL_CELL USING P_ROW P_FIELDNAME.
  GV_INDEX GV_INDEX + 1.

  CALL METHOD OF
      GS_EXCEL
      'CELLS'  GS_CELL
    EXPORTING
      #1       P_ROW             "행
      #2       GV_INDEX.         "칼럼

  SET PROPERTY OF GS_CELL 'VALUE' P_FIELDNAME.

  CALL METHOD OF
    GS_CELL
      'FONT' GS_FONT.

  SET PROPERTY OF GS_FONT     'SIZE'                '10'.
  SET PROPERTY OF GS_FONT     'Name'                'Arial'.
  SET PROPERTY OF GS_FONT     'FONTSTYLE'           'BOLD'.
  SET PROPERTY OF GS_FONT     'Bold'                1.
  SET PROPERTY OF GS_CELL     'HorizontalAlignment' -4131.
  GET PROPERTY OF GS_CELL     'Interior'            GS_INTERIOR.
  SET PROPERTY OF GS_INTERIOR 'Color'               '10092543'.

  CALL METHOD OF
    GS_CELL
      'COLUMNS' GS_COLUMNS.
  CALL METHOD OF
    GS_COLUMNS
    'AutoFit'.

*- 선 그리기
  CALL METHOD OF
    GS_CELL
    'BorderAround'
    EXPORTING
      #1 1                 "continuous line
      #2 2.                "점선

ENDFORM" FILL_CELL
*&---------------------------------------------------------------------*
*&      Form  FILL_CELL_SAMPLE
*&---------------------------------------------------------------------*
FORM FILL_CELL_SAMPLE USING P_ROW P_FIELDNAME.
  GV_INDEX GV_INDEX + 1.

  CALL METHOD OF
      GS_EXCEL
      'CELLS'  GS_CELL
    EXPORTING
      #1       P_ROW             "행
      #2       GV_INDEX.         "칼럼

  SET PROPERTY OF GS_CELL 'VALUE' P_FIELDNAME.

  CALL METHOD OF
    GS_CELL
      'FONT' GS_FONT.

  SET PROPERTY OF GS_FONT     'SIZE'                '10'.
  SET PROPERTY OF GS_FONT     'Name'                'Arial'.
  SET PROPERTY OF GS_FONT     'FONTSTYLE'           'NORMAL'.
  SET PROPERTY OF GS_FONT     'Bold'                0.
  SET PROPERTY OF GS_CELL     'HorizontalAlignment' -4131.
  GET PROPERTY OF GS_CELL     'Interior'            GS_INTERIOR.
*  SET PROPERTY OF gs_interior 'Color'               = '10092543'.

  CALL METHOD OF
    GS_CELL
      'COLUMNS' GS_COLUMNS.
  CALL METHOD OF
    GS_COLUMNS
    'AutoFit'.

*- 선 그리기
  CALL METHOD OF
    GS_CELL
    'BorderAround'
    EXPORTING
      #1 1                 "continuous line
      #2 2.                "점선

ENDFORM" FILL_CELL_SAMPLE
*&---------------------------------------------------------------------*
*&      Form  LOOP_AT_SCREEN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM LOOP_AT_SCREEN .

  LOOP AT SCREEN.

    IF SCREEN-GROUP1 EQ 'ACT'.
      SCREEN-INPUT 0.
      SCREEN-DISPLAY_3D 0.
      SCREEN-INVISIBLE 1.

      MODIFY SCREEN.
    ENDIF.

  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  INIT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM INIT_DATA .

  CLEAR GV_ALREADY_SAVED.

  PERFORM GET_MASTER_DATA.

*  PERFORM GET_DOM_TEXT_LIST USING 'XFELD'.

  CLEAR GV_SAVE_COMPLETE.
  CLEAR GV_ALREADY_POST.
  CLEAR GV_CNT_SUCCESSGV_CNT_FAILURE.
  CLEAR GV_LOCK.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  GET_MASTER_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_MASTER_DATA .
*
  CLEAR GT_T001GT_T001[].
  SELECT  INTO TABLE GT_T001
    FROM  T001
*    WHERE BUKRS = P_BUKRS
    .
  SORT GT_T001 BY   BUKRS
                    .
*
  CLEAR GT_T003TGT_T003T[].
  SELECT  INTO TABLE GT_T003T
    FROM  T003T
    WHERE SPRAS SY-LANGU
    .
  SORT GT_T003T BY  SPRAS
                    BLART
                    .
*
  CLEAR GT_T005TGT_T005T[].
  SELECT  INTO TABLE GT_T005T
    FROM  T005T
    WHERE SPRAS SY-LANGU
    .
  SORT GT_T005T BY  SPRAS
                    LAND1
                    .
*
  CLEAR GT_T012GT_T012[].
  SELECT  INTO TABLE GT_T012
    FROM  T012
    WHERE BUKRS P_BUKRS
    .
  SORT GT_T012 BY   BUKRS
                    HBKID
                    .
*
  CLEAR GT_T012KGT_T012K[].
  SELECT  INTO TABLE GT_T012K
    FROM  T012K
    WHERE BUKRS P_BUKRS
    .
  SORT GT_T012K BY  BUKRS
                    HBKID
                    .
*
  CLEAR GT_TGSBGT_TGSB[].
  SELECT  INTO TABLE GT_TGSB
    FROM  TGSB
*    WHERE GSBER = P_GSBER
    .
  SORT GT_TGSB  BY  GSBER
                    .
*
  CLEAR GT_TCURCGT_TCURC[].
  SELECT  INTO TABLE GT_TCURC
    FROM  TCURC
*    WHERE WAERS = P_WAERS
    .
  SORT GT_TCURC BY  WAERS
                    .

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SELECT_DATA .
  CLEAR GT_DATAGT_DATA[].

**  SELECT
**          PF~BUKRS
**    ,     IK~GJAHR
**    ,     IK~GSBER
**    ,     IK~PRCTR
**    ,     IK~ZLSCH
**    ,     IK~ZLSPR
**    ,     IK~BELNR
**    ,     IK~BUZEI
**    ,     IK~LIFNR
**    ,     F1~NAME1
**    ,     IK~BSCHL
**    ,     IK~WAERS
**    ,     IK~WRBTR
**    ,     IK~DMBTR
**    ,     PF~BUDAT
**    ,     PF~BLDAT
**    ,     IK~ZFBDT
**    ,     IK~ZBD1T
**    "     DUEDT
**    ,     PF~USNAM
**    "     NAME_TEXT
**    ,     PF~CPUDT
**    ,     IK~HBKID
**    ,     IK~BVTYP
**    ,     BK~BANKS
**    ,     BK~BANKL
**    ,     KA~BANKA
**    ,     BK~BANKN
**    ,     BK~KOINH
**    ,     IK~SGTXT
**    INTO CORRESPONDING FIELDS OF TABLE @GT_DATA
**    FROM  BKPF AS PF
**          INNER JOIN BSIK AS IK
**                                  ON  PF~BUKRS  =   IK~BUKRS
**                                  AND PF~BELNR  =   IK~BELNR
**                                  AND PF~GJAHR  =   IK~GJAHR
**          LEFT OUTER JOIN LFA1 AS F1
**                                  ON  IK~LIFNR  =   F1~LIFNR
**          LEFT OUTER JOIN BUT0BK AS BK
**                                  ON  IK~LIFNR  =   BK~PARTNER
**                                  AND IK~BVTYP  =   BK~BKVID
**          LEFT OUTER JOIN BNKA AS KA
**                                  ON  BK~BANKS  =   KA~BANKS
**                                  AND BK~BANKL  =   KA~BANKL
**    WHERE PF~BUKRS  =   @P_BUKRS
**    AND   PF~BELNR  IN  @S_BELNR
**    AND   PF~GJAHR  IN  @S_GJAHR
**    AND   IK~GSBER  IN  @S_GSBER
**    AND   IK~PRCTR  IN  @S_PRCTR
**    AND   IK~ZLSCH  IN  @S_ZLSCH
**    AND   IK~ZLSPR  IN  @S_ZLSPR
**    AND   IK~BUDAT  IN  @S_BUDAT
**    AND   IK~BLDAT  IN  @S_BLDAT
**    AND   IK~WAERS  IN  @S_WAERS
**    .
*
*  DATA : LS_USER_ADDRESS LIKE ADDR3_VAL.
*
*  LOOP AT GT_DATA ASSIGNING FIELD-SYMBOL(<DATA>).
**    <DATA>-DUEDT = <DATA>-ZFBDT + <DATA>-ZBD1T.
**
**    CLEAR: LS_USER_ADDRESS.
**    CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
**      EXPORTING
**        USER_NAME    = <DATA>-USNAM
**      IMPORTING
**        USER_ADDRESS = LS_USER_ADDRESS.
**    <DATA>-NAME_TEXT = LS_USER_ADDRESS-NAME_TEXT.
*
*  ENDLOOP.
*
**
*  DATA : LT_TMP_DATA LIKE GT_DATA.
*
*  CLEAR : LT_TMP_DATA, LT_TMP_DATA[].
*  LT_TMP_DATA[] = GT_DATA[].
*  CLEAR : GT_DATA, GT_DATA[].
*
**  LOOP AT LT_TMP_DATA ASSIGNING FIELD-SYMBOL(<TMP>).
**    IF <TMP>-DUEDT IN S_DUEDT.
**      APPEND <TMP> TO GT_DATA.
**    ENDIF.
**  ENDLOOP.
**
*
**  SORT GT_DATA BY   BUKRS
**                    GSBER
**                    PRCTR
**                    ZLSCH
**                    ZLSPR
**                    BELNR
**                    BUZEI
**                    .
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  DATA_PROCESSING
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DATA_PROCESSING .

  CHECK GV_LOCK EQ ''.
  PERFORM CHECK_PREVIOUS.
  PERFORM BAR_MSG USING 60 'Read From Excel...'(F09).
  PERFORM READ_DATA.
  PERFORM CREATE_BANK_KEY.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  CHECK_PREVIOUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CHECK_PREVIOUS .

  DATA LV_ANSWER TYPE C.
*
*  IF GT_ZCOT0010[] IS NOT INITIAL.
*
*    DATA(LS_ZCOT0010) = GT_ZCOT0010[ 1 ].
*
*    IF LS_ZCOT0010-POSTED NE  'X'.
*
*      PERFORM POPUP_TO_CONFIRM_02 USING 'CONFIRM'
*                                   'Already planned this year. Do you want to reaarange?'(F22) ''
*                          CHANGING LV_ANSWER.
*      IF LV_ANSWER <> 'J'.
*        LEAVE LIST-PROCESSING.
*      ENDIF.
*
*    ELSE.
*      MESSAGE I000 WITH 'Already posted plan data this year. reverse first.'(F23).
*      LEAVE LIST-PROCESSING.
*    ENDIF.
*  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  ARRANGE_POSTABLE_FIELD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ARRANGE_POSTABLE_FIELD .

**  LOOP AT GT_LIST ASSIGNING FIELD-SYMBOL(<FS>).
**
**    <FS>-BLART  =   GV_BLART_TR_MANUAL_INCOMING.  "TR-Manual_Incoming
**
**    <FS>-BUKRS  =   P_BUKRS.
**    <FS>-WAERS  =   GV_WAERS_CM.
**
**  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  READ_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM READ_DATA .

* 1. 업로드 스트럭처 생성
  PERFORM CREATE_UPLOAD_TABLE USING GC_UPLOAD_STRUCT.
* 2. 업로드 파일 취득
  PERFORM UPLOAD_XLS_STRUCT TABLES <GF_UPLOADT>
                 USING  P_FNAME     " 파일명
                              "S_COL-LOW
                              "S_ROW-LOW
                              256 "S_COL-HIGH
                              65536"S_ROW-HIGH
  CHECK <GF_UPLOADT>[] IS NOT INITIAL.
*3. 인터널 테이블로 이전
  PERFORM TRANSFER_GT_DATA.

**  CHECK GT_LIST[] IS NOT INITIAL.
**
**  PERFORM ARRANGE_POSTABLE_FIELD.
**
**  "4. Validation
**  PERFORM VALIDATION_CHECK.
**
***5. 인터널 테이블 데이터
**  PERFORM EDIT_DATA.

ENDFORM.

FORM CREATE_UPLOAD_TABLE USING P_STRUCT.

  DATA LV_STRNM  LIKE DD02L-TABNAME.
  DATA LT_UPLD_FCAT LIKE TABLE OF GS_UPLD_FCAT.

  LV_STRNM P_STRUCT.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME       LV_STRNM
      I_BYPASSING_BUFFER     'X'
    CHANGING
      CT_FIELDCAT            GT_UPLD_FCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE 1
      PROGRAM_ERROR          2
      OTHERS                 3.

  LOOP AT GT_UPLD_FCAT INTO GS_UPLD_FCAT.
    CLEAR GS_UPLD_FCAT-REF_TABLEGS_UPLD_FCAT-REF_FIELD.

    IF GS_UPLD_FCAT-DECIMALS IS NOT INITIAL.
      GS_UPLD_FCAT-INTLEN GS_UPLD_FCAT-INTLEN + 1.
    ENDIF.

    IF GS_UPLD_FCAT-DATATYPE EQ 'DATS'.
      GS_UPLD_FCAT-INTLEN '10'.
    ENDIF.

    " 올린 그대로 받기 위해 CHAR로 변환.
    GS_UPLD_FCAT-DATATYPE 'CHAR'.
    GS_UPLD_FCAT-INTTYPE  'C'.

    APPEND GS_UPLD_FCAT TO LT_UPLD_FCAT.
  ENDLOOP.

  CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
      IT_FIELDCATALOG LT_UPLD_FCAT
    IMPORTING
      EP_TABLE        GF_UPLOADT.

  ASSIGN GF_UPLOADT->TO <GF_UPLOADT>.

  CREATE DATA GF_UPLOADS LIKE LINE OF <GF_UPLOADT>.
  ASSIGN GF_UPLOADS->TO <GF_UPLOADS>.

ENDFORM.                    " CREATE_DYNAMIC_TABLE
*
*
*
FORM TRANSFER_GT_DATA.

  DATA BEGIN OF LT_LOWERCASE OCCURS 0,
           DOMNAME   LIKE DD01L-DOMNAME,
           LOWERCASE LIKE DD01L-LOWERCASE,
         END OF LT_LOWERCASE.

  FIELD-SYMBOLS <FS_UPLD_FIELD> TYPE ANY,
                  <FS_DATA_FIELD> TYPE ANY.
  DATA LV_CONVFUNC TYPE STRING.
  DATA LF_OREF   TYPE REF TO CX_ROOT.
  DATA LV_TEXT TYPE STRING.

  DATA LT_COL TYPE STANDARD TABLE OF ZTRS_ZTRR1070.
  DATA LS_COL LIKE LINE OF LT_COL.

  CLEAR GT_DATAGT_DATA[]GS_DATA.

  CHECK GT_UPLD_FCAT[] IS NOT INITIAL.

  SELECT DOMNAME LOWERCASE
    INTO TABLE LT_LOWERCASE
    FROM DD01L
    FOR ALL ENTRIES IN GT_UPLD_FCAT
    WHERE DOMNAME GT_UPLD_FCAT-DOMNAME
    AND AS4LOCAL 'A'.

  SORT LT_LOWERCASE.

  LOOP AT <GF_UPLOADT> INTO <GF_UPLOADS>.
    LOOP AT GT_UPLD_FCAT INTO GS_UPLD_FCAT.
      ASSIGN COMPONENT GS_UPLD_FCAT-COL_POS OF STRUCTURE <GF_UPLOADS>
               TO <FS_UPLD_FIELD>.

      IF SY-SUBRC NE 0.
        MESSAGE S000 WITH 'Field assign Fail.'(F10).
        LEAVE LIST-PROCESSING.
      ENDIF.

      READ TABLE LT_LOWERCASE WITH KEY DOMNAME GS_UPLD_FCAT-DOMNAME
        BINARY SEARCH.

      IF LT_LOWERCASE-LOWERCASE NE 'X'.
        TRANSLATE <FS_UPLD_FIELD> TO UPPER CASE.
      ENDIF.

      IF GS_UPLD_FCAT-CONVEXIT IS NOT INITIAL.
        CONCATENATE 'CONVERSION_EXIT_' GS_UPLD_FCAT-CONVEXIT '_INPUT'
               INTO LV_CONVFUNC.

        CALL FUNCTION LV_CONVFUNC
          EXPORTING
            INPUT  <FS_UPLD_FIELD>
          IMPORTING
            OUTPUT <FS_UPLD_FIELD>
          EXCEPTIONS
            OTHERS 1.
      ENDIF.

      CASE GS_UPLD_FCAT-DATATYPE.
        WHEN 'INT1' OR 'INT2' OR 'INT4' OR 'NUMC' OR 'QUAN' OR
              'DEC' OR 'CURR'.
          PERFORM BDC_CURR USING <FS_UPLD_FIELD>.
        WHEN 'DATS'.
          PERFORM BDC_DATE USING <FS_UPLD_FIELD>.
      ENDCASE.
      "체크 박스 대문자 변경
      IF GS_UPLD_FCAT-VALEXI 'X' AND GS_UPLD_FCAT-INTLEN '000001'.
        TRANSLATE <FS_UPLD_FIELD> TO UPPER CASE.
      ENDIF.

      ASSIGN COMPONENT GS_UPLD_FCAT-COL_POS OF STRUCTURE GS_DATA
         TO <FS_DATA_FIELD>.

      IF SY-SUBRC NE 0.
        MESSAGE S000 WITH 'Field assign Fail.'(F10).
        LEAVE LIST-PROCESSING.
      ENDIF.

      TRY .
          <FS_DATA_FIELD> <FS_UPLD_FIELD>.

        CATCH CX_ROOT INTO LF_OREF.
          LV_TEXT LF_OREF->GET_TEXT).
          CONCATENATE GS_UPLD_FCAT-FIELDNAME ` ` LV_TEXT
          INTO LV_TEXT.
          MESSAGE S000 DISPLAY LIKE 'E' WITH LV_TEXT.
          LEAVE LIST-PROCESSING.
      ENDTRY.
    ENDLOOP.

    APPEND GS_DATA TO GT_DATA.
    CLEAR GS_DATA.

    CLEAR LT_LOWERCASE.

  ENDLOOP.

  " 데이터 캐릭터 별로 COLLECT 한다.
  LOOP AT GT_DATA ASSIGNING FIELD-SYMBOL(<FS>).
    MOVE-CORRESPONDING <FS> TO GS_LIST.
    APPEND GS_LIST TO GT_LIST.

****    PERFORM CONVERSION_EXIT_IN  USING 'INVDT' <FS>-GDATU LS_COL-GDATU.
*    LS_COL-WAERS = GV_WAERS_CM.

*    COLLECT  LS_COL INTO LT_COL.
    APPEND  LS_COL TO LT_COL.
  ENDLOOP.

**  LOOP AT LT_COL INTO LS_COL.
**    MOVE-CORRESPONDING LS_COL TO GS_LIST.
**
**    APPEND GS_LIST TO GT_LIST.
**  ENDLOOP.

ENDFORM.                    " TRANSFER_GT_DATA
*
*
*
FORM EDIT_DATA .

  FIELD-SYMBOLS <FS_VAL> TYPE ANY.
  DATA LV_FIELD(50TYPE C.


  CHECK GT_DATA[] IS NOT INITIAL.

  DATA(LV_DATUMSY-DATUM.
  DATA(LV_UZEITSY-UZEIT.

**  LOOP AT GT_LIST ASSIGNING <GS_LIST>.
**
**    IF <GS_LIST>-STATUS IS INITIAL.
**      <GS_LIST>-STATUS = ICON_LIGHT_OUT.
**    ENDIF.
**
**    <GS_LIST>-UPLOAD_DATE = LV_DATUM.
**    <GS_LIST>-UPLOAD_TIME = LV_UZEIT.
**    <GS_LIST>-UPLOAD_SEQ  = SY-TABIX.
**
**    SET_CREATE_TIMESTAMP '<GS_LIST>'.
**    SET_CHANGE_TIMESTAMP '<GS_LIST>'.
***    PERFORM SET_CREATE_TIMESTAMP USING '<GS_LIST>'.
***    PERFORM SET_CHANGE_TIMESTAMP USING '<GS_LIST>'.
**
**  ENDLOOP.

ENDFORM.                    " EDIT_DATA
*&---------------------------------------------------------------------*
*&      Form  DB_TO_LIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DB_TO_LIST.
*
*  CLEAR : GT_LIST, GT_LIST[].
*
*  LOOP AT GT_DATA ASSIGNING FIELD-SYMBOL(<DATA>).
*    MOVE-CORRESPONDING <DATA> TO GS_LIST.
*
*    GS_LIST-STATUS = ICON_YELLOW_LIGHT.
*    APPEND GS_LIST TO GT_LIST.
*  ENDLOOP.
*
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  VALIDATION_CHECK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM VALIDATION_CHECK .

  DATA LT_LIST LIKE GT_LIST OCCURS WITH HEADER LINE.
  DATA LV_CNT TYPE I.


  CHECK GT_LIST[] IS NOT INITIAL.

  LT_LIST[] GT_LIST[].

  CLEAR GV_UPLOAD_ERROR.
  CLEAR GV_S_CNT.
  CLEAR GV_F_CNT.

  GV_T_CNT LINESGT_LIST ).

  LOOP AT GT_LIST ASSIGNING FIELD-SYMBOL(<FS>).

**    READ TABLE GT_T012  TRANSPORTING NO FIELDS
**                        WITH KEY HBKID = <FS>-HBKID
**                        .
**    IF SY-SUBRC <> 0.
**      <FS>-MESSAGE = 'Invalid House bank'(F61).
**      <FS>-STATUS = ICON_RED_LIGHT.
**      GV_UPLOAD_ERROR = 'X'.
**      PERFORM SET_ERROR_FIELD_RED  USING <FS> 'HBKID'.
**      <FS>-ERR = 'X'.
**    ENDIF.

    IF <FS>-ERR 'X'.
      GV_F_CNT GV_F_CNT + 1.
    ELSE.
      GV_S_CNT GV_S_CNT + 1.
    ENDIF.

  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0632   text
*----------------------------------------------------------------------*
FORM SET_ERROR_FIELD_RED  USING P_DATA STRUCTURE GT_LIST
       P_FIELD.
  DATA LS_COLOR TYPE LVC_S_SCOL.
  CLEAR LS_COLOR.
*-- 필드 강조
  LS_COLOR-FNAME P_FIELD.
  LS_COLOR-COLOR-COL 6.
  INSERT LS_COLOR INTO TABLE P_DATA-F_COL.
ENDFORM.                    " SET_ERROR_FIELD
*&---------------------------------------------------------------------*
*&      Form  BDC_OPTION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PV_DSMOD   text
*----------------------------------------------------------------------*
FORM BDC_OPTION  USING    PV_DSMOD.
  PERFORM SET_BDC_OPTION  USING     'X'       "DEFSIZE
                                    'S'       "UPDMODE
                                    ''        "CATTMODE
                                    PV_DSMOD  "DISMODE
                                    ''        "RACCOMMIT
                                    ''        "NOBINPI
                           CHANGING GS_BDC_OPTION.
ENDFORM.                    " BDC_OPTION
*&---------------------------------------------------------------------*
*&      Form  CREATE_BANK_KEY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CREATE_BANK_KEY .

  DATA LS_BANK_ADDRESS LIKE BAPI1011_ADDRESS.
  DATA LS_BAPIRET2 TYPE BAPIRET2.
  DATA LV_BANKCOUNTRY LIKE BAPI1011_KEY-BANK_CTRY.
  DATA LV_BANKKEY     LIKE BAPI1011_KEY-BANK_KEY.
  DATA LV_CODE.
  DATA LV_MESSAGE(100).


* reset
  CALL FUNCTION 'MESSAGES_INITIALIZE'.

  LOOP AT GT_LIST ASSIGNING <GS_LIST>.

    CLEAR LS_BANK_ADDRESS.
    CLEAR LV_BANKCOUNTRYLV_BANKKEY.

    MOVE <GS_LIST>-BANK_CTRY  TO LS_BANK_ADDRESS-BANK_NAME.
    MOVE <GS_LIST>-REGION     TO LS_BANK_ADDRESS-REGION.
    MOVE <GS_LIST>-STREET     TO LS_BANK_ADDRESS-STREET.
    MOVE <GS_LIST>-CITY       TO LS_BANK_ADDRESS-CITY.
    MOVE <GS_LIST>-SWIFT_CODE TO LS_BANK_ADDRESS-SWIFT_CODE.
    MOVE <GS_LIST>-BANK_GROUP TO LS_BANK_ADDRESS-BANK_GROUP.

    CALL FUNCTION 'BAPI_BANK_CREATE'
      EXPORTING
        BANK_CTRY                          <GS_LIST>-BANK_CTRY
        BANK_KEY                           <GS_LIST>-BANK_KEY
        BANK_ADDRESS                       LS_BANK_ADDRESS
*       BANK_METHOD                        =
*       BANK_FORMATTING                    =
*       BANK_ADDRESS1                      =
*       I_XUPDATE                          = 'X'
*       I_CHECK_BEFORE_SAVE                =
*       BANK_IBAN_RULE                     =
*       BANK_B2B_SUPPORTED                 =
*       BANK_COR1_SUPPORTED                =
*       BANK_R_TRANSACTION_SUPPORTED       =
*       BANK_INTERNAL_BANK                 =
      IMPORTING
        RETURN                             LS_BAPIRET2
        BANKCOUNTRY                        LV_BANKCOUNTRY
        BANKKEY                            LV_BANKKEY.

    CALL FUNCTION 'MESSAGE_STORE'
      EXPORTING
        ARBGB LS_BAPIRET2-ID
**        EXCEPTION_IF_NOT_ACTIVE = ' '
        MSGTY LS_BAPIRET2-TYPE
        MSGV1 LS_BAPIRET2-MESSAGE
        MSGV2 LS_BAPIRET2-MESSAGE_V2
        MSGV3 LS_BAPIRET2-MESSAGE_V3
        MSGV4 LS_BAPIRET2-MESSAGE_V4
        TXTNR LS_BAPIRET2-NUMBER
        ZEILE SY-TABIX
      EXCEPTIONS
        MESSAGE_TYPE_NOT_VALID  1
        NOT_ACTIVE              2
        OTHERS                  3.

  ENDLOOP.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  CALL FUNCTION 'MESSAGES_SHOW'
    EXCEPTIONS
      INCONSISTENT_RANGE    1
      NO_MESSAGES           2
      OTHERS                3.


ENDFORM.


STRUCTURE - ZTRS_ZTRR1220_UPLOAD

BANK_CTRY Types BANKS CHAR 3 0 Bank country key
BANK_KEY Types BANKK CHAR 15 0 Bank Keys
BANK_NAME Types BANKA CHAR 60 0 Name of bank
REGION Types REGIO CHAR 3 0 Region (State, Province, County)
STREET Types STRAS_GP CHAR 35 0 Street and House Number
CITY Types ORT01_GP CHAR 35 0 City
BANK_BRANCH Types BRNCH CHAR 40 0 Bank Branch
SWIFT_CODE Types SWIFT CHAR 11 0 SWIFT/BIC for International Payments
BANK_GROUP Types BGRUP CHAR 2 0 Bank group (bank network)