메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT ZSAPTIP_002.

sapjoy 2009.02.20 21:06 조회 수 : 3208

REPORT  ZSAPTIP_002.


*&-------------------------------------------------------------*


*&    DATA & TABLES DEFINE


*&-------------------------------------------------------------*


TYPE-POOLS: CTSLG.


 


TABLES: E070.


 


DATA: BEGIN OF GT_STDOUT OCCURS 0,


         LINE(700),


      END OF GT_STDOUT.


 


DATA: BEGIN OF GT_RELEASE OCCURS 0,


        STEPID TYPE TSTRFCOFIL-FUNCTION,


        RC     TYPE TSTRFCOFIL-RETCODE,


      END OF GT_RELEASE.


 


DATA: GT_EPSFILI   LIKE EPSFILI OCCURS 0 WITH HEADER LINE.


 


DATA: GS_COFILE     TYPE CTSLG_COFILE,


      GS_SYSTEM     TYPE CTSLG_SYSTEM,


      GS_STEP       TYPE CTSLG_STEP.


 


 


DATA: GV_PATH       LIKE SAPB-SAPPFAD,


      GV_TARGETPATH LIKE SAPB-SAPPFAD,


      GV_FILENAME(30),


      GV_DIR_NAME   LIKE EPSF-EPSDIRNAM,


      GV_FILE_MASK  LIKE EPSF-EPSFILNAM,


      CMD(255).


 


PARAMETERS: P_TRKORR LIKE E070-TRKORR OBLIGATORY.


 


*&-------------------------------------------------------------*


START-OF-SELECTION.


*&-------------------------------------------------------------*


 


  SELECT SINGLE *


           FROM E070


          WHERE TRKORR = P_TRKORR.


 


  IF SY-SUBRC NE 0.


     LEAVE LIST-PROCESSING.


  ENDIF.


 


  PERFORM CHECK_RELEASE.


 


  PERFORM FILE_DOWN.


 


*&-------------------------------------------------------------*


*&      Form  CHECK_RELEASE


*&-------------------------------------------------------------*


form CHECK_RELEASE .


 


  CALL FUNCTION 'TR_READ_GLOBAL_INFO_OF_REQUEST'


       EXPORTING


            IV_TRKORR = P_TRKORR


       IMPORTING


            ES_COFILE = GS_COFILE.


 


  LOOP AT GS_COFILE-SYSTEMS INTO GS_SYSTEM.


    LOOP AT GS_SYSTEM-STEPS INTO GS_STEP.


      GT_RELEASE-STEPID = GS_STEP-STEPID.


      GT_RELEASE-RC     = GS_STEP-RC.


      COLLECT GT_RELEASE.


    ENDLOOP.


  ENDLOOP.


 


  LOOP AT GT_RELEASE WHERE STEPID = 'E'.


    EXIT.


  ENDLOOP.


  IF SY-SUBRC NE 0.


     WRITE:/ '요청', P_TRKORR, '이 릴리즈되지 않았습니다.'.


     STOP.


  ENDIF.


 


endform.                    " CHECK_RELEASE


*&-------------------------------------------------------------*


*&      Form  FILE_DOWN


*&-------------------------------------------------------------*


form FILE_DOWN .


 


  CMD = 'pwd'.


 


  CALL 'SYSTEM' ID 'COMMAND' FIELD CMD


        ID 'TAB'     FIELD GT_STDOUT-*SYS*.


 


  READ TABLE GT_STDOUT INDEX 1.


  CHECK SY-SUBRC EQ 0.


  GV_DIR_NAME = GT_STDOUT.


 


  CONCATENATE 'tar cvf - `find /usr/sap/trans -name ''*'


               P_TRKORR+4(6)


               '*'' -print`'


               INTO CMD.


  CONCATENATE 'bona' P_TRKORR '.tar' INTO GV_FILENAME.


 


  CONCATENATE CMD '>' GV_FILENAME


              INTO CMD SEPARATED BY SPACE.


 


  CALL 'SYSTEM' ID 'COMMAND' FIELD CMD


        ID 'TAB'     FIELD GT_STDOUT-*SYS*.


 


 


  GV_FILE_MASK = GV_FILENAME.


  CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'


       EXPORTING


            DIR_NAME               = GV_DIR_NAME


            FILE_MASK              = GV_FILE_MASK


       TABLES


            DIR_LIST               = GT_EPSFILI


       EXCEPTIONS


            INVALID_EPS_SUBDIR     = 1


            SAPGPARAM_FAILED       = 2


            BUILD_DIRECTORY_FAILED = 3


            NO_AUTHORIZATION       = 4


            READ_DIRECTORY_FAILED  = 5


            TOO_MANY_READ_ERRORS   = 6


            EMPTY_DIRECTORY_LIST   = 7


            OTHERS                 = 8.


 


  SORT GT_EPSFILI BY SIZE DESCENDING.


  READ TABLE GT_EPSFILI INDEX 1.


 


  CHECK GT_EPSFILI-SIZE > 0.


 


  CONCATENATE GV_DIR_NAME '/' GV_FILENAME INTO GV_PATH.


  CONCATENATE 'C:' GV_FILENAME INTO GV_TARGETPATH.


 


  CALL FUNCTION 'ARCHIVFILE_SERVER_TO_CLIENT'


       EXPORTING


            PATH       = GV_PATH


            TARGETPATH = GV_TARGETPATH


       EXCEPTIONS


            ERROR_FILE = 1


            OTHERS     = 2.


 


  IF SY-SUBRC = 0.


    WRITE:/ '파일 다운로드 완료:', GV_TARGETPATH.


  ELSE.


    WRITE:/ '파일 다운로드 실패’.


    STOP.


  ENDIF.


 


endform.                    " FILE_DOWN

번호 제목 글쓴이 날짜 조회 수
351 Z16_001TOP sapjoy 2009.09.21 2593
350 REPORT ZSMARTFORMS_08. [2] sapjoy 2009.02.27 2604
349 REPORT zsaptip_006. sapjoy 2009.02.21 2075
348 REPORT zsaptip_005. [2] sapjoy 2009.02.20 1836
347 REPORT zsaptip_004. sapjoy 2009.02.20 1849
» REPORT ZSAPTIP_002. sapjoy 2009.02.20 3208
345 sap_debug.txt file sapjoy 2009.02.20 2523
344 TOTAL sapjoy 2009.02.19 2686
343 REPORT ZDYNAMIC_ITAB_12. sapjoy 2009.02.16 2643
342 REPORT ZDYNAMIC_ITAB_11. [1] sapjoy 2009.02.16 2012
341 REPORT ZDYNAMIC_ITAB_10. [1] sapjoy 2009.02.16 1864
340 REPORT ZDYNAMIC_ITAB_09. sapjoy 2009.02.16 2138
339 REPORT ZDYNAMIC_ITAB_08. sapjoy 2009.02.16 2760
338 REPORT ZDYNAMIC_ITAB_07. sapjoy 2009.02.16 2583
337 REPORT ZDYNAMIC_ITAB_06. sapjoy 2009.02.16 1972
336 REPORT ZDYNAMIC_ITAB_05. sapjoy 2009.02.16 2156
335 REPORT ZDYNAMIC_ITAB_04. sapjoy 2009.02.16 2031
334 REPORT ZDYNAMIC_ITAB_03 sapjoy 2009.02.16 2503
333 REPORT ZDYNAMIC_ITAB_02. sapjoy 2009.02.16 1870
332 REPORT ZDYNAMIC_ITAB_01. sapjoy 2009.02.13 1873