본문 바로가기
카테고리 없음

[ABAP]엑셀템플릿 업로드, 다운로드

by wonieee 2024. 12. 3.

원래는 SMW0를 많이 사용했는데 템플릿 변경이 필요한 경우에 번거로워서 다른방법 업로드 

프로그램내에서 템플릿 만들고 수정하는 방법 

 

1. TOP

*엑셀 업로드 하기 위한 엑셀 타입 선언 
TYPES : BEGIN OF gty_temp, 
        bukrs(30),
        werks(30), 
        END OF gty_temp. 
        
types : gtt_temp type standard table of gty_temp.

DATA : GT_TEMP TYPE gtt_temp.

 

2.at selection-screen. 

템플릿 버튼 마다 sy-ucomm 버튼이 할당되어있을테니 

DATA : lv_fullpath TYPE string, 
       lv_user_action TYPE I,
       lv_filename    TYPE string,
       lv_path        TYPE string.
 
 CALL METHOD cl_Gui_fronted_Services=>file_Save_dialog
 EXPORTING
    window_title = 'EXCEL UPLOAD Template Download'
    default_extension = 'xls'
    default_file_name = 'first template' "변수로도 사용가능 
 CHAINGING 
    filename = lv_filename
    path     = lv_path
    fullpath = lv_fullpath
    user_action = lv_user_action 
 EXCEPTIONS 
    cntl_Error = 1 
    error_no_gui = 2
    not_supported_by_gui = 3
    OTHERS 	= 4.
    
 IF lv_user_action = cl_gui_frontend_Services=>action_Cancel.
	LEAVE LIST-PROCESSING.
    
ELSE.

	CALL FUNCTION 'GUI_DOWNLOAD'
    	EXPORTING 
        	filename = lv_fullpath 
        	filetype = 'ASC'
        	write_field_separator = 'X'
    	TABLES 
        	data_Tab = lt_Temp
    	EXCEPTIONS
        	file_open_error = 1 
        	file_write_error = 2
        	OTHERS           = 3.
 ENDIF.

 

템플릿 여러개일경우 perform 으로 만들어서 table 파라미터를 standard table 타입으로 사용해도됨

댓글