ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 프로그램 소스 직접 수행
    SAP/ABAP 2013. 3. 11. 15:37

    *&---------------------------------------------------------------------*
    *& Report  Z_EXCUTE_SOURCE                                             *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *& 소스 텍스트파일을 읽어 직접 수행한다.                               *
    *&                                                                     *
    *&---------------------------------------------------------------------*

    REPORT  Z_EXCUTE_SOURCE                                             .

    DATAPGNAME(08VALUE 'Z_EXCUTE_SOURCE'.

    DATABEGIN OF ITAB_SOURCE OCCURS 100,
          TEXT(90),
          END OF ITAB_SOURCE.

    DATAF(240)TYPE IH(72).

    DATA FNAME2 TYPE STRING.

    DATA FILE_TABLE TYPE FILETABLE,
           FILE_ENCODING TYPE ABAP_ENCOD,
           RC TYPE I.

    START-OF-SELECTION.

      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
        EXPORTING
          WINDOW_TITLE            '파일 읽기 선택'
          DEFAULT_FILENAME        ' '
          WITH_ENCODING           'X'
        CHANGING
          FILE_TABLE              FILE_TABLE
          RC                      RC
          FILE_ENCODING           FILE_ENCODING
        EXCEPTIONS
          FILE_OPEN_DIALOG_FAILED 1
          CNTL_ERROR              2
          ERROR_NO_GUI            3
          NOT_SUPPORTED_BY_GUI    4
          OTHERS                  5.

      IF SY-SUBRC <> OR RC <= 0.
        STOP.
      ELSE.
        READ TABLE FILE_TABLE INTO FNAME2 INDEX 1.
      ENDIF.

      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME            FNAME2
          FILETYPE            'ASC'
          HAS_FIELD_SEPARATOR 'X'
          DAT_MODE            'X'
        TABLES
          DATA_TAB            ITAB_SOURCE.



      SYNTAX-CHECK FOR ITAB_SOURCE  MESSAGE F  LINE G  WORD H.
      IF SY-SUBRC <> 0.
        READ TABLE ITAB_SOURCE INDEX G.
        WRITEF,G,HWRITE:/1 G,'line : 'ITAB_SOURCE.
        STOP.
      ENDIF.

      INSERT REPORT PGNAME FROM ITAB_SOURCE.

      SUBMIT (PGNAMEAND RETURN VIA SELECTION-SCREEN.

      DELETE REPORT PGNAME.

     

     

     

     

    수행하면 위와 같이 파일 선택 창이 나오며 abap소스코드가 저장된 텍스트 문서를 선택하면 선택한 소스코드가 수행된다.

Designed by Tistory.