728x90
반응형
이건 인터넷 조금만 뒤져도 수십개의 소스가 있다.
FORM download_template .
DATA : ls_temp TYPE t_xls.
CLEAR : gt_temp[].
IF gt_temp[] IS INITIAL.
ls_temp-bukrs = '회사코드'(c01).
ls_temp-blart = '전표유형'(c02).
ls_temp-xblnr = '참조전표번호'(c03).
ls_temp-bldat = '증빙일'(c04).
ls_temp-bktxt = '전기일'(c05).
APPEND ls_temp TO gt_temp.
ENDIF.
CALL FUNCTION 'WS_EXCEL' "버튼을 누르면 엑셀파일로 다운로드 된다.
EXPORTING
filename = 'C:\Temp\Migration_header.xls'
TABLES
data = gt_temp
EXCEPTIONS
unknown_error = 1
OTHERS = 2.
ENDFORM. " DOWNLOAD_TEMPLATE
EXPORTING
textline1 = '취소하시겠습니까?'
* TEXTLINE2 = ' '
titel = 'Cancel'
start_column = 25
start_row = 6
defaultoption = 'N'
IMPORTING
answer = result.
ENDFORM. " SUBROUTINE_POPUP
그냥 내가 만들어본 것이라 남겨두려고 올린다.
알아야 할 것은 1. 엑셀 올리기
2. 형식 다운로드해주기
이 두가지를 알아야 한다.
**---------------------------------------------------------------------*
* Program ID : ZFIR0009
* Title : 계정잔액기초 UPLOAD
* Created By : CAB07
* Created On : 2010.06.29
* Category : ALV with Input
* Description : AR/AP/GL MIGRATION.
*---------------------------------------------------------------------*
* Change History
*---------------------------------------------------------------------*
* Mod. # |Date |Developer |Description(Reason)
*---------------------------------------------------------------------*
* 01
*---------------------------------------------------------------------*
REPORT zfir0009 MESSAGE-ID zmfi.
INCLUDE zfir0009top.
INCLUDE zfir0009f01.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
PERFORM init.
PERFORM set_application_toolbar.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
PERFORM appl_toolbar_ext.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM filename_f4 CHANGING filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filenam2.
PERFORM filenam2_f4 CHANGING filenam2.
AT SELECTION-SCREEN ON filename.
PERFORM check_file USING filename.
AT SELECTION-SCREEN ON filenam2.
PERFORM check_file USING filenam2.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
CHECK fullname IS NOT INITIAL
AND fullnam2 IS NOT INITIAL.
PERFORM xls_file_to_tab.
PERFORM xls_file_to_tab2.
PERFORM data_separate.
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
CHECK gt_headitem2[] IS NOT INITIAL.
CALL SCREEN 0100.
* Program ID : ZFIR0009
* Title : 계정잔액기초 UPLOAD
* Created By : CAB07
* Created On : 2010.06.29
* Category : ALV with Input
* Description : AR/AP/GL MIGRATION.
*---------------------------------------------------------------------*
* Change History
*---------------------------------------------------------------------*
* Mod. # |Date |Developer |Description(Reason)
*---------------------------------------------------------------------*
* 01
*---------------------------------------------------------------------*
REPORT zfir0009 MESSAGE-ID zmfi.
INCLUDE zfir0009top.
INCLUDE zfir0009f01.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
PERFORM init.
PERFORM set_application_toolbar.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
PERFORM appl_toolbar_ext.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM filename_f4 CHANGING filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filenam2.
PERFORM filenam2_f4 CHANGING filenam2.
AT SELECTION-SCREEN ON filename.
PERFORM check_file USING filename.
AT SELECTION-SCREEN ON filenam2.
PERFORM check_file USING filenam2.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
CHECK fullname IS NOT INITIAL
AND fullnam2 IS NOT INITIAL.
PERFORM xls_file_to_tab.
PERFORM xls_file_to_tab2.
PERFORM data_separate.
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
CHECK gt_headitem2[] IS NOT INITIAL.
CALL SCREEN 0100.
*************************************************************************************
여기까지가 기본적인 선언이었는데
이제 하나하나 쪼개보자.
TOP 선언부 부터..
INCLUDE zfir0009top.
*&---------------------------------------------------------------------*
*& Include ZFIR0009TOP
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* DATA & TYPE DEFINITION
*----------------------------------------------------------------------*
TYPE-POOLS:
kcde, slis.
TABLES: sscrfields.
* Excel 선언부
DATA:
* Excel
gt_kcde TYPE kcde_intern WITH HEADER LINE,
gt_kcde2 TYPE kcde_intern WITH HEADER LINE,
gv_xls_col TYPE i VALUE 16,
gv_xls_row TYPE i VALUE 65536,
* File
def_path TYPE string,
mask TYPE string VALUE 'Excel-Sheet (*.xls)|*.xls|',
rc TYPE i VALUE 1,
window_title TYPE string VALUE 'Select a file',
files TYPE filetable,
files2 TYPE filetable,
fullname TYPE string,
fullnam2 TYPE string.
*header layout Download.
TYPES:
BEGIN OF t_xls,
bukrs(10),
blart(10),
xblnr(12),
bldat(10),
bktxt(18),
END OF t_xls.
DATA :
gt_temp TYPE STANDARD TABLE OF t_xls,
gs_temp TYPE t_xls.
*Lineitem layout Download.
TYPES:
BEGIN OF t_xls2,
xblnr(10),
buzei(14),
newbs(14),
newko(14),
hkont(10),
newum(10),
anbwa(10),
wrbtr(15),
wmwst(15),
mwsk1(15),
bupla(15),
valut(15),
sgtxt(20),
aufnr(15),
kostl(15),
prctr(15),
END OF t_xls2.
DATA :
gt_temp2 TYPE STANDARD TABLE OF t_xls2,
gs_temp2 TYPE t_xls2.
**************************************************************Excel
* Headitem 선언부
DATA : BEGIN OF gs_headitem, "입력받는 headitem
bukrs LIKE zfis0012-bukrs,
blart LIKE zfis0012-blart,
xblnr LIKE zfis0012-xblnr,
gubun LIKE zfis0012-gubun,
bldat LIKE zfis0012-bldat,
budat LIKE zfis0012-budat,
bktxt LIKE zfis0012-bktxt,
waers LIKE zfis0012-waers, "자동입력
* budgno like zfis0012-budgno, "신규생성 -> 어떤 값인지 체크
END OF gs_headitem.
DATA : BEGIN OF gs_headitem2, "출력하는 headitem2.
bukrs LIKE zfis0012-bukrs,
blart LIKE zfis0012-blart,
xblnr LIKE zfis0012-xblnr,
bldat LIKE zfis0012-bldat,
budat LIKE zfis0012-budat,
bktxt LIKE zfis0012-bktxt,
belnr LIKE bkpf-belnr,
msg1(30),
msg2(30),
END OF gs_headitem2.
DATA : gt_headitem2 LIKE TABLE OF gs_headitem2.
DATA : gt_headitem LIKE TABLE OF gs_headitem.
DATA: e_belnr TYPE belnr_d, "headitem2 에 리턴될 값들 선언.
e_subrc LIKE sy-subrc,
e_return TYPE bapi_msg.
* 입력받는 Lineitem
DATA : BEGIN OF gs_lineitem,
* MARK(1) TYPE C,
xblnr LIKE bsid-xblnr, "필수
buzei LIKE zfis0013-buzei, "필수
newbs LIKE zfis0013-newbs, "전기키 필수
newko LIKE zfis0013-newko, "계정
hkont LIKE zfis0013-hkont,
newum LIKE zfis0013-newum,
anbwa LIKE zfis0013-anbwa,
wrbtr LIKE zfis0013-wrbtr, "전표통화금액 필수
wmwst TYPE zfis0013-wmwst,
mwsk1 LIKE bsid-mwsk1,
bupla LIKE zfis0013-bupla,
valut LIKE zfis0013-valut,
sgtxt LIKE zfis0013-sgtxt, "품목텍스트 필수
aufnr LIKE zfis0013-aufnr,
kostl LIKE zfis0013-kostl,
prctr LIKE bsid-prctr,
END OF gs_lineitem.
DATA : gt_lineitem LIKE TABLE OF gs_lineitem.
DATA : gt_lineitem2 LIKE TABLE OF zfis0013, "출력용 Lineitem.
gs_lineitem2 LIKE LINE OF gt_lineitem2,
gs_migline LIKE gs_lineitem2. "마이그레이션 Line 생성용.
******************************************************Line
* ALV 펑션 선언
DATA:
mycontainer TYPE scrfname VALUE 'G_CUSTOM_CONTAINER1',
gt_exclude TYPE ui_functions,
gs_print TYPE lvc_s_prnt,
gs_sort TYPE lvc_s_sort,
gt_sort TYPE lvc_t_sort,
gs_fcat TYPE lvc_s_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gs_fieldcat2 TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat,
gt_fieldcat TYPE lvc_t_fcat,
gs_fcatlayo TYPE lvc_s_layo,
gs_variant TYPE disvariant,
gs_f4 TYPE lvc_s_f4,
gt_f4 TYPE lvc_t_f4,
mycontainer2 TYPE scrfname VALUE 'G_CUSTOM_CONTAINER2',
gt_exclude2 TYPE ui_functions,
gs_print2 TYPE lvc_s_prnt,
gs_sort2 TYPE lvc_s_sort,
gt_sort2 TYPE lvc_t_sort,
gs_fcat2 TYPE lvc_s_fcat,
gt_fcat2 TYPE lvc_t_fcat,
gt_fieldcat2 TYPE lvc_t_fcat,
gs_fcatlayo2 TYPE lvc_s_layo,
gs_variant2 TYPE disvariant,
i_events TYPE slis_t_event,
w_sort TYPE slis_sortinfo_alv,
i_sort TYPE slis_t_sortinfo_alv,
w_print TYPE slis_print_alv,
g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
g_status TYPE slis_formname VALUE 'STATUS',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
* Fieldcatloag
gt_field TYPE slis_t_fieldcat_alv,
g_fieldcat_s TYPE slis_fieldcat_alv,
g_repid TYPE sy-repid VALUE sy-repid,
g_save,
gt_field2 TYPE slis_t_fieldcat_alv,
g_fieldcat_s2 TYPE slis_fieldcat_alv,
g_repid2 TYPE sy-repid VALUE sy-repid,
g_save2,
* Reference to custom container: neccessary to bind ALV Control
g_docking_container TYPE REF TO cl_gui_docking_container,
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container2 TYPE REF TO cl_gui_custom_container,
g_grid2 TYPE REF TO cl_gui_alv_grid,
* Docking postion
g_window_heigth TYPE i,
g_view_rowcnt TYPE i VALUE 0, "number of rows
g_pixels TYPE i VALUE '12.5', "number of pixels per row
* Selected Rows Information.
gt_rows TYPE lvc_t_row,
gs_row TYPE lvc_s_row,
g_result,
BEGIN OF gt_rowchk OCCURS 0,
index LIKE sy-index,
END OF gt_rowchk,
* Check create object
gv_creobj,
* Cell Color
cell TYPE slis_specialcol_alv,
* Style
style TYPE lvc_s_styl,
lin LIKE sy-tfill.
*alv 클래스 선언
DATA:
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_splitter_1 TYPE REF TO cl_gui_splitter_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid_top TYPE REF TO cl_gui_alv_grid,
go_grid_bottom TYPE REF TO cl_gui_alv_grid,
go_grid_right TYPE REF TO cl_gui_alv_grid,
gs_stable TYPE lvc_s_stbl,
go_grid TYPE REF TO cl_gui_alv_grid,
* g_grid TYPE REF TO cl_gui_alv_grid,
* g_window_heigth TYPE i,
g_view_rowcn TYPE i VALUE 0. "number of rows
* g_pixels TYPE i VALUE '12.5'. "number of pixels per row
DATA : ok_code LIKE sy-ucomm,
save_ok LIKE ok_code.
DATA : gv_post(35).
DATA : result.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: go_event_rcvr TYPE REF TO lcl_event_receiver.
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS : handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
PERFORM handle_double_click USING e_row e_column es_row_no.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN : FUNCTION KEY 1,
function key 2.
SELECTION-SCREEN BEGIN OF BLOCK s00 WITH FRAME TITLE text-t04.
PARAMETERS filename LIKE ibipparms-path." OBLIGATORY.
PARAMETERS filenam2 LIKE ibipparms-path." OBLIGATORY.
SELECTION-SCREEN END OF BLOCK s00.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-t02.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(79) text-004.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK c1 WITH FRAME TITLE text-t03.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(79) text-005.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(79) text-006.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : END OF BLOCK c1.
*& Include ZFIR0009TOP
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* DATA & TYPE DEFINITION
*----------------------------------------------------------------------*
TYPE-POOLS:
kcde, slis.
TABLES: sscrfields.
* Excel 선언부
DATA:
* Excel
gt_kcde TYPE kcde_intern WITH HEADER LINE,
gt_kcde2 TYPE kcde_intern WITH HEADER LINE,
gv_xls_col TYPE i VALUE 16,
gv_xls_row TYPE i VALUE 65536,
* File
def_path TYPE string,
mask TYPE string VALUE 'Excel-Sheet (*.xls)|*.xls|',
rc TYPE i VALUE 1,
window_title TYPE string VALUE 'Select a file',
files TYPE filetable,
files2 TYPE filetable,
fullname TYPE string,
fullnam2 TYPE string.
*header layout Download.
TYPES:
BEGIN OF t_xls,
bukrs(10),
blart(10),
xblnr(12),
bldat(10),
bktxt(18),
END OF t_xls.
DATA :
gt_temp TYPE STANDARD TABLE OF t_xls,
gs_temp TYPE t_xls.
*Lineitem layout Download.
TYPES:
BEGIN OF t_xls2,
xblnr(10),
buzei(14),
newbs(14),
newko(14),
hkont(10),
newum(10),
anbwa(10),
wrbtr(15),
wmwst(15),
mwsk1(15),
bupla(15),
valut(15),
sgtxt(20),
aufnr(15),
kostl(15),
prctr(15),
END OF t_xls2.
DATA :
gt_temp2 TYPE STANDARD TABLE OF t_xls2,
gs_temp2 TYPE t_xls2.
**************************************************************Excel
* Headitem 선언부
DATA : BEGIN OF gs_headitem, "입력받는 headitem
bukrs LIKE zfis0012-bukrs,
blart LIKE zfis0012-blart,
xblnr LIKE zfis0012-xblnr,
gubun LIKE zfis0012-gubun,
bldat LIKE zfis0012-bldat,
budat LIKE zfis0012-budat,
bktxt LIKE zfis0012-bktxt,
waers LIKE zfis0012-waers, "자동입력
* budgno like zfis0012-budgno, "신규생성 -> 어떤 값인지 체크
END OF gs_headitem.
DATA : BEGIN OF gs_headitem2, "출력하는 headitem2.
bukrs LIKE zfis0012-bukrs,
blart LIKE zfis0012-blart,
xblnr LIKE zfis0012-xblnr,
bldat LIKE zfis0012-bldat,
budat LIKE zfis0012-budat,
bktxt LIKE zfis0012-bktxt,
belnr LIKE bkpf-belnr,
msg1(30),
msg2(30),
END OF gs_headitem2.
DATA : gt_headitem2 LIKE TABLE OF gs_headitem2.
DATA : gt_headitem LIKE TABLE OF gs_headitem.
DATA: e_belnr TYPE belnr_d, "headitem2 에 리턴될 값들 선언.
e_subrc LIKE sy-subrc,
e_return TYPE bapi_msg.
* 입력받는 Lineitem
DATA : BEGIN OF gs_lineitem,
* MARK(1) TYPE C,
xblnr LIKE bsid-xblnr, "필수
buzei LIKE zfis0013-buzei, "필수
newbs LIKE zfis0013-newbs, "전기키 필수
newko LIKE zfis0013-newko, "계정
hkont LIKE zfis0013-hkont,
newum LIKE zfis0013-newum,
anbwa LIKE zfis0013-anbwa,
wrbtr LIKE zfis0013-wrbtr, "전표통화금액 필수
wmwst TYPE zfis0013-wmwst,
mwsk1 LIKE bsid-mwsk1,
bupla LIKE zfis0013-bupla,
valut LIKE zfis0013-valut,
sgtxt LIKE zfis0013-sgtxt, "품목텍스트 필수
aufnr LIKE zfis0013-aufnr,
kostl LIKE zfis0013-kostl,
prctr LIKE bsid-prctr,
END OF gs_lineitem.
DATA : gt_lineitem LIKE TABLE OF gs_lineitem.
DATA : gt_lineitem2 LIKE TABLE OF zfis0013, "출력용 Lineitem.
gs_lineitem2 LIKE LINE OF gt_lineitem2,
gs_migline LIKE gs_lineitem2. "마이그레이션 Line 생성용.
******************************************************Line
* ALV 펑션 선언
DATA:
mycontainer TYPE scrfname VALUE 'G_CUSTOM_CONTAINER1',
gt_exclude TYPE ui_functions,
gs_print TYPE lvc_s_prnt,
gs_sort TYPE lvc_s_sort,
gt_sort TYPE lvc_t_sort,
gs_fcat TYPE lvc_s_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gs_fieldcat2 TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat,
gt_fieldcat TYPE lvc_t_fcat,
gs_fcatlayo TYPE lvc_s_layo,
gs_variant TYPE disvariant,
gs_f4 TYPE lvc_s_f4,
gt_f4 TYPE lvc_t_f4,
mycontainer2 TYPE scrfname VALUE 'G_CUSTOM_CONTAINER2',
gt_exclude2 TYPE ui_functions,
gs_print2 TYPE lvc_s_prnt,
gs_sort2 TYPE lvc_s_sort,
gt_sort2 TYPE lvc_t_sort,
gs_fcat2 TYPE lvc_s_fcat,
gt_fcat2 TYPE lvc_t_fcat,
gt_fieldcat2 TYPE lvc_t_fcat,
gs_fcatlayo2 TYPE lvc_s_layo,
gs_variant2 TYPE disvariant,
i_events TYPE slis_t_event,
w_sort TYPE slis_sortinfo_alv,
i_sort TYPE slis_t_sortinfo_alv,
w_print TYPE slis_print_alv,
g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
g_status TYPE slis_formname VALUE 'STATUS',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
* Fieldcatloag
gt_field TYPE slis_t_fieldcat_alv,
g_fieldcat_s TYPE slis_fieldcat_alv,
g_repid TYPE sy-repid VALUE sy-repid,
g_save,
gt_field2 TYPE slis_t_fieldcat_alv,
g_fieldcat_s2 TYPE slis_fieldcat_alv,
g_repid2 TYPE sy-repid VALUE sy-repid,
g_save2,
* Reference to custom container: neccessary to bind ALV Control
g_docking_container TYPE REF TO cl_gui_docking_container,
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container2 TYPE REF TO cl_gui_custom_container,
g_grid2 TYPE REF TO cl_gui_alv_grid,
* Docking postion
g_window_heigth TYPE i,
g_view_rowcnt TYPE i VALUE 0, "number of rows
g_pixels TYPE i VALUE '12.5', "number of pixels per row
* Selected Rows Information.
gt_rows TYPE lvc_t_row,
gs_row TYPE lvc_s_row,
g_result,
BEGIN OF gt_rowchk OCCURS 0,
index LIKE sy-index,
END OF gt_rowchk,
* Check create object
gv_creobj,
* Cell Color
cell TYPE slis_specialcol_alv,
* Style
style TYPE lvc_s_styl,
lin LIKE sy-tfill.
*alv 클래스 선언
DATA:
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_splitter_1 TYPE REF TO cl_gui_splitter_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid_top TYPE REF TO cl_gui_alv_grid,
go_grid_bottom TYPE REF TO cl_gui_alv_grid,
go_grid_right TYPE REF TO cl_gui_alv_grid,
gs_stable TYPE lvc_s_stbl,
go_grid TYPE REF TO cl_gui_alv_grid,
* g_grid TYPE REF TO cl_gui_alv_grid,
* g_window_heigth TYPE i,
g_view_rowcn TYPE i VALUE 0. "number of rows
* g_pixels TYPE i VALUE '12.5'. "number of pixels per row
DATA : ok_code LIKE sy-ucomm,
save_ok LIKE ok_code.
DATA : gv_post(35).
DATA : result.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: go_event_rcvr TYPE REF TO lcl_event_receiver.
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS : handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
PERFORM handle_double_click USING e_row e_column es_row_no.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN : FUNCTION KEY 1,
function key 2.
SELECTION-SCREEN BEGIN OF BLOCK s00 WITH FRAME TITLE text-t04.
PARAMETERS filename LIKE ibipparms-path." OBLIGATORY.
PARAMETERS filenam2 LIKE ibipparms-path." OBLIGATORY.
SELECTION-SCREEN END OF BLOCK s00.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-t02.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(79) text-004.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK c1 WITH FRAME TITLE text-t03.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(79) text-005.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(79) text-006.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : END OF BLOCK c1.
**************************************************************************************
INITIALIZATION.
PERFORM init. 이 부분
PERFORM init. 이 부분
*&---------------------------------------------------------------------*
*& Form init
*&---------------------------------------------------------------------*
FORM init.
CLEAR:
filename,
gt_kcde, gt_kcde[],
gs_headitem, gt_headitem[],
gs_lineitem, gt_lineitem[].
* messtab, messtab[].
filename = 'C:\'.
filenam2 = 'C:\'.
ENDFORM. " init
*& Form init
*&---------------------------------------------------------------------*
FORM init.
CLEAR:
filename,
gt_kcde, gt_kcde[],
gs_headitem, gt_headitem[],
gs_lineitem, gt_lineitem[].
* messtab, messtab[].
filename = 'C:\'.
filenam2 = 'C:\'.
ENDFORM. " init
********************************************************************
PERFORM set_application_toolbar. 이 부분
FORM set_application_toolbar .
sscrfields-functxt_01 = 'Header Layout 다운로드'(btn).
sscrfields-functxt_02 = 'LineItem layout 다운로드'(bt2).
ENDFORM. " SET_APPLICATION_TOOLBAR
sscrfields-functxt_01 = 'Header Layout 다운로드'(btn).
sscrfields-functxt_02 = 'LineItem layout 다운로드'(bt2).
ENDFORM. " SET_APPLICATION_TOOLBAR
*********************************************************************
이제 본체를 볼까?
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
PERFORM appl_toolbar_ext <- 이거
* AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
PERFORM appl_toolbar_ext <- 이거
*&---------------------------------------------------------------------*
*& Form APPL_TOOLBAR_EXT
*&---------------------------------------------------------------------*
FORM appl_toolbar_ext .
CASE sscrfields-ucomm.
WHEN 'FC01'.
PERFORM download_template.
WHEN 'FC02'.
PERFORM download_template2.
WHEN OTHERS.
ENDCASE.
ENDFORM.
*& Form APPL_TOOLBAR_EXT
*&---------------------------------------------------------------------*
FORM appl_toolbar_ext .
CASE sscrfields-ucomm.
WHEN 'FC01'.
PERFORM download_template.
WHEN 'FC02'.
PERFORM download_template2.
WHEN OTHERS.
ENDCASE.
ENDFORM.
다운로드 템플릿 부분.
PERFORM download_template.
-> *&---------------------------------------------------------------------*
*& Form DOWNLOAD_TEMPLATEFORM download_template .
DATA : ls_temp TYPE t_xls.
CLEAR : gt_temp[].
IF gt_temp[] IS INITIAL.
ls_temp-bukrs = '회사코드'(c01).
ls_temp-blart = '전표유형'(c02).
ls_temp-xblnr = '참조전표번호'(c03).
ls_temp-bldat = '증빙일'(c04).
ls_temp-bktxt = '전기일'(c05).
APPEND ls_temp TO gt_temp.
ENDIF.
CALL FUNCTION 'WS_EXCEL' "버튼을 누르면 엑셀파일로 다운로드 된다.
EXPORTING
filename = 'C:\Temp\Migration_header.xls'
TABLES
data = gt_temp
EXCEPTIONS
unknown_error = 1
OTHERS = 2.
ENDFORM. " DOWNLOAD_TEMPLATE
************************************************************
이제 부분 보자.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM filename_f4 CHANGING filename.
PERFORM filename_f4 CHANGING filename.
*&---------------------------------------------------------------------*
*& Form filename_f4
*&---------------------------------------------------------------------*
* get filename
*----------------------------------------------------------------------*
FORM filename_f4 CHANGING p_filename.
* returns default path
CALL METHOD cl_gui_frontend_services=>directory_get_current
CHANGING
current_directory = def_path.
* calls selection-popup
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = window_title
default_filename = space
file_filter = mask
initial_directory = def_path
CHANGING
file_table = files
rc = rc.
READ TABLE files INTO fullname INDEX 1.
* split file and path
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = fullname
IMPORTING
stripped_name = p_filename
EXCEPTIONS
x_error = 1
OTHERS = 2.
ENDFORM. " filename_f4
*& Form filename_f4
*&---------------------------------------------------------------------*
* get filename
*----------------------------------------------------------------------*
FORM filename_f4 CHANGING p_filename.
* returns default path
CALL METHOD cl_gui_frontend_services=>directory_get_current
CHANGING
current_directory = def_path.
* calls selection-popup
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = window_title
default_filename = space
file_filter = mask
initial_directory = def_path
CHANGING
file_table = files
rc = rc.
READ TABLE files INTO fullname INDEX 1.
* split file and path
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = fullname
IMPORTING
stripped_name = p_filename
EXCEPTIONS
x_error = 1
OTHERS = 2.
ENDFORM. " filename_f4
************************************************************
AT SELECTION-SCREEN ON filename.
PERFORM check_file USING filename.
PERFORM check_file USING filename.
-> FORM check_file USING filename TYPE rlgrap-filename.
CHECK sscrfields-ucomm <> 'FC01'
AND sscrfields-ucomm <> 'FC02'.
IF filename NS '.xls' .
MESSAGE s000 DISPLAY LIKE 'E'
WITH 'Upload 할 Excel 을 지정하지 않았습니다.'(e02).
* ELSEIF FILENAM2 NS '.xls'.
* MESSAGE e000 WITH 'Upload 할 Excel 을 지정하지 않았습니다.'(e02).
ENDIF.
ENDFORM. " CHECK_FILE
CHECK sscrfields-ucomm <> 'FC01'
AND sscrfields-ucomm <> 'FC02'.
IF filename NS '.xls' .
MESSAGE s000 DISPLAY LIKE 'E'
WITH 'Upload 할 Excel 을 지정하지 않았습니다.'(e02).
* ELSEIF FILENAM2 NS '.xls'.
* MESSAGE e000 WITH 'Upload 할 Excel 을 지정하지 않았습니다.'(e02).
ENDIF.
ENDFORM. " CHECK_FILE
*******************************************************************
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
CHECK fullname IS NOT INITIAL
AND fullnam2 IS NOT INITIAL.
PERFORM xls_file_to_tab. <- 여기부터 보자
PERFORM xls_file_to_tab2.
PERFORM data_separate.
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
CHECK fullname IS NOT INITIAL
AND fullnam2 IS NOT INITIAL.
PERFORM xls_file_to_tab. <- 여기부터 보자
PERFORM xls_file_to_tab2.
PERFORM data_separate.
**********************************************
FORM xls_file_to_tab.
DATA: xls_file LIKE rlgrap-filename.
CHECK fullname IS NOT INITIAL.
xls_file = fullname.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT' <- 엑셀을 인터널 테이블로 가져온다.
EXPORTING
filename = xls_file
i_begin_col = 1
i_begin_row = 2
i_end_col = gv_xls_col
i_end_row = gv_xls_row
TABLES
intern = gt_kcde
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " xls_file_to_tab
DATA: xls_file LIKE rlgrap-filename.
CHECK fullname IS NOT INITIAL.
xls_file = fullname.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT' <- 엑셀을 인터널 테이블로 가져온다.
EXPORTING
filename = xls_file
i_begin_col = 1
i_begin_row = 2
i_end_col = gv_xls_col
i_end_row = gv_xls_row
TABLES
intern = gt_kcde
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " xls_file_to_tab
*******************************************************************8
PERFORM data_separate. 이 부분은 테이블로 가져온 데이터를 분류하려고 만든것이다.
->
FORM data_separate .
LOOP AT gt_kcde.
CASE gt_kcde-col.
WHEN 1.
gs_headitem-bukrs = gt_kcde-value.
WHEN 2.
gs_headitem-blart = gt_kcde-value.
WHEN 3.
gs_headitem-xblnr = gt_kcde-value.
WHEN 4.
gs_headitem-bldat = gt_kcde-value.
WHEN 5.
gs_headitem-budat = gt_kcde-value.
WHEN 6.
gs_headitem-bktxt = gt_kcde-value.
ENDCASE.
AT END OF row.
gs_headitem-gubun = '1'.
gs_headitem-waers = 'KRW'.
APPEND gs_headitem TO gt_headitem.
MOVE-CORRESPONDING gs_headitem TO gs_headitem2.
APPEND gs_headitem2 TO gt_headitem2.
CLEAR gs_headitem.
CLEAR gs_headitem2.
ENDAT.
ENDLOOP.
LOOP AT gt_kcde2.
CASE gt_kcde2-col.
WHEN 1.
gs_lineitem-xblnr = gt_kcde2-value.
WHEN 2.
gs_lineitem-buzei = gt_kcde2-value.
WHEN 3.
gs_lineitem-newbs = gt_kcde2-value.
WHEN 4.
gs_lineitem-newko = gt_kcde2-value.
WHEN 5.
gs_lineitem-hkont = gt_kcde2-value.
WHEN 6.
gs_lineitem-newum = gt_kcde2-value.
WHEN 7.
gs_lineitem-anbwa = gt_kcde2-value.
WHEN 8.
gs_lineitem-wrbtr = gt_kcde2-value.
WHEN 9.
gs_lineitem-wmwst = gt_kcde2-value.
WHEN 10.
gs_lineitem-mwsk1 = gt_kcde2-value.
WHEN 11.
gs_lineitem-bupla = gt_kcde2-value.
WHEN 12.
gs_lineitem-valut = gt_kcde2-value.
WHEN 13.
gs_lineitem-sgtxt = gt_kcde2-value.
WHEN 14.
gs_lineitem-aufnr = gt_kcde2-value.
WHEN 15.
gs_lineitem-kostl = gt_kcde2-value.
WHEN 16.
gs_lineitem-prctr = gt_kcde2-value.
ENDCASE.
AT END OF row.
APPEND gs_lineitem TO gt_lineitem.
ENDAT.
ENDLOOP.
LOOP AT gt_kcde.
CASE gt_kcde-col.
WHEN 1.
gs_headitem-bukrs = gt_kcde-value.
WHEN 2.
gs_headitem-blart = gt_kcde-value.
WHEN 3.
gs_headitem-xblnr = gt_kcde-value.
WHEN 4.
gs_headitem-bldat = gt_kcde-value.
WHEN 5.
gs_headitem-budat = gt_kcde-value.
WHEN 6.
gs_headitem-bktxt = gt_kcde-value.
ENDCASE.
AT END OF row.
gs_headitem-gubun = '1'.
gs_headitem-waers = 'KRW'.
APPEND gs_headitem TO gt_headitem.
MOVE-CORRESPONDING gs_headitem TO gs_headitem2.
APPEND gs_headitem2 TO gt_headitem2.
CLEAR gs_headitem.
CLEAR gs_headitem2.
ENDAT.
ENDLOOP.
LOOP AT gt_kcde2.
CASE gt_kcde2-col.
WHEN 1.
gs_lineitem-xblnr = gt_kcde2-value.
WHEN 2.
gs_lineitem-buzei = gt_kcde2-value.
WHEN 3.
gs_lineitem-newbs = gt_kcde2-value.
WHEN 4.
gs_lineitem-newko = gt_kcde2-value.
WHEN 5.
gs_lineitem-hkont = gt_kcde2-value.
WHEN 6.
gs_lineitem-newum = gt_kcde2-value.
WHEN 7.
gs_lineitem-anbwa = gt_kcde2-value.
WHEN 8.
gs_lineitem-wrbtr = gt_kcde2-value.
WHEN 9.
gs_lineitem-wmwst = gt_kcde2-value.
WHEN 10.
gs_lineitem-mwsk1 = gt_kcde2-value.
WHEN 11.
gs_lineitem-bupla = gt_kcde2-value.
WHEN 12.
gs_lineitem-valut = gt_kcde2-value.
WHEN 13.
gs_lineitem-sgtxt = gt_kcde2-value.
WHEN 14.
gs_lineitem-aufnr = gt_kcde2-value.
WHEN 15.
gs_lineitem-kostl = gt_kcde2-value.
WHEN 16.
gs_lineitem-prctr = gt_kcde2-value.
ENDCASE.
AT END OF row.
APPEND gs_lineitem TO gt_lineitem.
ENDAT.
ENDLOOP.
***************************************************
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
CHECK gt_headitem2[] IS NOT INITIAL.
CALL SCREEN 0100. <- 이거 보자
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
CHECK gt_headitem2[] IS NOT INITIAL.
CALL SCREEN 0100. <- 이거 보자
********************************************
100번 화면 소스
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100. <- 이건 헤드 텍스트랑 버튼 만드는거고..
MODULE set_alv_grid_0100. <-ALV 셋팅 보자
PROCESS AFTER INPUT.
module save_ok_code.
MODULE exit AT EXIT-COMMAND.
MODULE USER_COMMAND_0100.
MODULE STATUS_0100. <- 이건 헤드 텍스트랑 버튼 만드는거고..
MODULE set_alv_grid_0100. <-ALV 셋팅 보자
PROCESS AFTER INPUT.
module save_ok_code.
MODULE exit AT EXIT-COMMAND.
MODULE USER_COMMAND_0100.
***********************************************************
*&---------------------------------------------------------------------*
*& Module SET_ALV_GRID_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE set_alv_grid_0100 OUTPUT.
IF g_docking_container IS INITIAL.
* FOR BASE ALV
PERFORM create_object. <- 이걸 따라 들어가면
ENDIF.
ENDMODULE. " SET_ALV_GRID_0100 OUTPUT
*& Module SET_ALV_GRID_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE set_alv_grid_0100 OUTPUT.
IF g_docking_container IS INITIAL.
* FOR BASE ALV
PERFORM create_object. <- 이걸 따라 들어가면
ENDIF.
ENDMODULE. " SET_ALV_GRID_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form CREATE_OBJECT
*&---------------------------------------------------------------------*
FORM create_object .
CLEAR: g_repid, gs_fcatlayo, gt_exclude, gt_sort, gt_fieldcat,
gs_variant.
REFRESH: gt_exclude, gt_sort, gt_fieldcat.
* PERFORM field_catalog_build.
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
* REPID =
* DYNNR =
side =
cl_gui_docking_container=>dock_at_left "왼쪽에 붙여
* EXTENSION = 50
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
ratio = 90
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
.
* Use full dynpro size
CALL METHOD go_docking->set_extension "크기 설정
EXPORTING
extension = 99999
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
CREATE OBJECT go_splitter "화면 분할
EXPORTING
* LINK_DYNNR =
* LINK_REPID =
* SHELLSTYLE =
* LEFT =
* TOP =
* WIDTH =
* HEIGHT =
* METRIC = cntl_metric_dynpro
* ALIGN = 15
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
.
CALL METHOD go_splitter->set_column_mode
EXPORTING
mode = cl_gui_splitter_container=>mode_relative
* IMPORTING
* RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
** Set column width: 1st column = 85%, 2nd column = 15%
* CALL METHOD go_splitter->set_column_width
* EXPORTING
* id = 1
* width = 80 " 85%
** IMPORTING
** RESULT =
* EXCEPTIONS
* cntl_error = 1
* cntl_system_error = 2
* OTHERS = 3.
CALL METHOD go_splitter->set_row_height "열 높이 설정 가능
EXPORTING
id = 1
height = 30
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
CREATE OBJECT go_grid_top
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_cell_top
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
CREATE OBJECT go_grid_bottom
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_cell_bottom
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
PERFORM field_catalog_build. <- 필드 카탈로그 만들기
PERFORM exclude_tb_functions CHANGING gt_exclude.
* gs_fcatlayo-SMALLTITLE = 'X'.
gs_fcatlayo-grid_title = 'Header'.
CALL METHOD go_grid_top->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_fcatlayo
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_headitem2
it_fieldcatalog = gt_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
* gs_fcatlayo2-SMALLTITLE = 'X'.
gs_fcatlayo2-grid_title = 'Item'.
CALL METHOD go_grid_bottom->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_fcatlayo2
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_lineitem
it_fieldcatalog = gt_fieldcat2[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 3
OTHERS = 4.
ENDFORM. " CREATE_OBJECT
*&----------------------------------------------------------
*& Form CREATE_OBJECT
*&---------------------------------------------------------------------*
FORM create_object .
CLEAR: g_repid, gs_fcatlayo, gt_exclude, gt_sort, gt_fieldcat,
gs_variant.
REFRESH: gt_exclude, gt_sort, gt_fieldcat.
* PERFORM field_catalog_build.
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
* REPID =
* DYNNR =
side =
cl_gui_docking_container=>dock_at_left "왼쪽에 붙여
* EXTENSION = 50
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
ratio = 90
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
.
* Use full dynpro size
CALL METHOD go_docking->set_extension "크기 설정
EXPORTING
extension = 99999
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
CREATE OBJECT go_splitter "화면 분할
EXPORTING
* LINK_DYNNR =
* LINK_REPID =
* SHELLSTYLE =
* LEFT =
* TOP =
* WIDTH =
* HEIGHT =
* METRIC = cntl_metric_dynpro
* ALIGN = 15
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
.
CALL METHOD go_splitter->set_column_mode
EXPORTING
mode = cl_gui_splitter_container=>mode_relative
* IMPORTING
* RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
** Set column width: 1st column = 85%, 2nd column = 15%
* CALL METHOD go_splitter->set_column_width
* EXPORTING
* id = 1
* width = 80 " 85%
** IMPORTING
** RESULT =
* EXCEPTIONS
* cntl_error = 1
* cntl_system_error = 2
* OTHERS = 3.
CALL METHOD go_splitter->set_row_height "열 높이 설정 가능
EXPORTING
id = 1
height = 30
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
CREATE OBJECT go_grid_top
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_cell_top
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
CREATE OBJECT go_grid_bottom
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_cell_bottom
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
PERFORM field_catalog_build. <- 필드 카탈로그 만들기
PERFORM exclude_tb_functions CHANGING gt_exclude.
* gs_fcatlayo-SMALLTITLE = 'X'.
gs_fcatlayo-grid_title = 'Header'.
CALL METHOD go_grid_top->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_fcatlayo
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_headitem2
it_fieldcatalog = gt_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
* gs_fcatlayo2-SMALLTITLE = 'X'.
gs_fcatlayo2-grid_title = 'Item'.
CALL METHOD go_grid_bottom->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_fcatlayo2
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_lineitem
it_fieldcatalog = gt_fieldcat2[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 3
OTHERS = 4.
ENDFORM. " CREATE_OBJECT
*&----------------------------------------------------------
필드 카탈로그 구경해보자.
*&---------------------------------------------------------------------*
*& Form FIELD_CATALOG_BUILD
*&---------------------------------------------------------------------*
FORM field_catalog_build .
CLEAR: gt_field, gt_fcat.
REFRESH: gt_field, gt_fcat.
g_repid = sy-cprog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' "필드카탈로그 자동 생성
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'GS_HEADITEM2' "이 스트럭쳐로...
i_inclname = g_repid
i_bypassing_buffer = 'X'
i_buffer_active = 'X'
CHANGING
ct_fieldcat = gt_field[] "이 테이블에 필드카탈로그 저장
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
LOOP AT gt_field INTO g_fieldcat_s. "필드카탈로그가 저장된 테이블을 돌면서
MOVE-CORRESPONDING g_fieldcat_s TO gs_fieldcat.
gs_fieldcat-ref_table = g_fieldcat_s-ref_tabname. "참조테이블을 다 똑같이 넣고
gs_fieldcat-ref_field = g_fieldcat_s-ref_fieldname.
IF g_fieldcat_s-fieldname = 'MSG1'. "필드네임이 이거면
gs_fieldcat-scrtext_s = 'MESSAGE1'. "텍스트 이런걸로 넣기
gs_fieldcat-scrtext_l = 'MESSAGE1'.
ELSEIF g_fieldcat_s-fieldname = 'MSG2'.
gs_fieldcat-scrtext_s = 'MESSAGE2'.
gs_fieldcat-scrtext_l = 'MESSAGE2'.
ELSEIF g_fieldcat_s-fieldname = 'XBLNR'.
gs_fieldcat-scrtext_s = '참조'.
gs_fieldcat-scrtext_l = '참조전표번호'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
CLEAR g_fieldcat_s.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' "이거는 라인아이템쪽 필드카탈로그
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'GS_LINEITEM'
i_inclname = g_repid
CHANGING
ct_fieldcat = gt_field2[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
* GT_FIELDCAT[] = GT_FIELD2[].
LOOP AT gt_field2 INTO g_fieldcat_s.
MOVE-CORRESPONDING g_fieldcat_s TO gs_fieldcat.
gs_fieldcat-ref_table = g_fieldcat_s-ref_tabname.
gs_fieldcat-ref_field = g_fieldcat_s-ref_fieldname.
IF g_fieldcat_s-fieldname = 'WRBTR'.
gs_fieldcat-scrtext_s = '금액'.
gs_fieldcat-ref_field = 'WRBTR'.
gs_fieldcat-ref_table = 'BSEG'.
ELSEIF g_fieldcat_s-fieldname = 'XBLNR'.
gs_fieldcat-scrtext_s = '참조'.
gs_fieldcat-scrtext_l = '참조전표번호'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat2.
CLEAR gs_fieldcat.
CLEAR g_fieldcat_s.
ENDLOOP.
ENDFORM. " FIELD_CATALOG_BUILD
*& Form FIELD_CATALOG_BUILD
*&---------------------------------------------------------------------*
FORM field_catalog_build .
CLEAR: gt_field, gt_fcat.
REFRESH: gt_field, gt_fcat.
g_repid = sy-cprog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' "필드카탈로그 자동 생성
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'GS_HEADITEM2' "이 스트럭쳐로...
i_inclname = g_repid
i_bypassing_buffer = 'X'
i_buffer_active = 'X'
CHANGING
ct_fieldcat = gt_field[] "이 테이블에 필드카탈로그 저장
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
LOOP AT gt_field INTO g_fieldcat_s. "필드카탈로그가 저장된 테이블을 돌면서
MOVE-CORRESPONDING g_fieldcat_s TO gs_fieldcat.
gs_fieldcat-ref_table = g_fieldcat_s-ref_tabname. "참조테이블을 다 똑같이 넣고
gs_fieldcat-ref_field = g_fieldcat_s-ref_fieldname.
IF g_fieldcat_s-fieldname = 'MSG1'. "필드네임이 이거면
gs_fieldcat-scrtext_s = 'MESSAGE1'. "텍스트 이런걸로 넣기
gs_fieldcat-scrtext_l = 'MESSAGE1'.
ELSEIF g_fieldcat_s-fieldname = 'MSG2'.
gs_fieldcat-scrtext_s = 'MESSAGE2'.
gs_fieldcat-scrtext_l = 'MESSAGE2'.
ELSEIF g_fieldcat_s-fieldname = 'XBLNR'.
gs_fieldcat-scrtext_s = '참조'.
gs_fieldcat-scrtext_l = '참조전표번호'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
CLEAR g_fieldcat_s.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' "이거는 라인아이템쪽 필드카탈로그
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'GS_LINEITEM'
i_inclname = g_repid
CHANGING
ct_fieldcat = gt_field2[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
* GT_FIELDCAT[] = GT_FIELD2[].
LOOP AT gt_field2 INTO g_fieldcat_s.
MOVE-CORRESPONDING g_fieldcat_s TO gs_fieldcat.
gs_fieldcat-ref_table = g_fieldcat_s-ref_tabname.
gs_fieldcat-ref_field = g_fieldcat_s-ref_fieldname.
IF g_fieldcat_s-fieldname = 'WRBTR'.
gs_fieldcat-scrtext_s = '금액'.
gs_fieldcat-ref_field = 'WRBTR'.
gs_fieldcat-ref_table = 'BSEG'.
ELSEIF g_fieldcat_s-fieldname = 'XBLNR'.
gs_fieldcat-scrtext_s = '참조'.
gs_fieldcat-scrtext_l = '참조전표번호'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat2.
CLEAR gs_fieldcat.
CLEAR g_fieldcat_s.
ENDLOOP.
ENDFORM. " FIELD_CATALOG_BUILD
***************************************************************
이건 필드카탈로그 아래 펑션.
*&---------------------------------------------------------------------*
*& Form exclude_tb_functions
*&---------------------------------------------------------------------*
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
CLEAR: pt_exclude, pt_exclude[].
ls_exclude = cl_gui_alv_grid=>mc_fc_excl_all.
APPEND ls_exclude TO pt_exclude.
ENDFORM. "exclude_tb_functions
*& Form exclude_tb_functions
*&---------------------------------------------------------------------*
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
CLEAR: pt_exclude, pt_exclude[].
ls_exclude = cl_gui_alv_grid=>mc_fc_excl_all.
APPEND ls_exclude TO pt_exclude.
ENDFORM. "exclude_tb_functions
****************************************************************8
MODULE exit AT EXIT-COMMAND.
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
CASE ok_code.
WHEN 'CANC'.
CLEAR : ok_code.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
*-- fill ALV celltab
ENDCASE.
ENDMODULE.
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
CASE ok_code.
WHEN 'CANC'.
CLEAR : ok_code.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
*-- fill ALV celltab
ENDCASE.
ENDMODULE.
*************************************************************
MODULE USER_COMMAND_0100.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
*-- BACK/CANCEL
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
PERFORM subroutine_popup. <- 팝업도 한번 볼까?
CASE result.
WHEN 'J'.
CLEAR : ok_code.
LEAVE TO SCREEN 0.
ENDCASE.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'MIG'.
PERFORM fi_document_posting_fms.
* PERFORM RETURN_MSG_INPUT.
CALL METHOD go_grid_top->refresh_table_display.
CALL METHOD go_grid_bottom->refresh_table_display.
CREATE OBJECT go_event_rcvr.
SET HANDLER go_event_rcvr->handle_double_click FOR go_grid_top.
ENDCASE.
* LEAVE TO SCREEN 0.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
*-- BACK/CANCEL
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
PERFORM subroutine_popup. <- 팝업도 한번 볼까?
CASE result.
WHEN 'J'.
CLEAR : ok_code.
LEAVE TO SCREEN 0.
ENDCASE.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'MIG'.
PERFORM fi_document_posting_fms.
* PERFORM RETURN_MSG_INPUT.
CALL METHOD go_grid_top->refresh_table_display.
CALL METHOD go_grid_bottom->refresh_table_display.
CREATE OBJECT go_event_rcvr.
SET HANDLER go_event_rcvr->handle_double_click FOR go_grid_top.
ENDCASE.
* LEAVE TO SCREEN 0.
ENDMODULE. " USER_COMMAND_0100 INPUT
***********************************************************
팝업 부분넣기
PERFORM subroutine_popup.
-> FORM subroutine_popup .
CALL FUNCTION 'POPUP_TO_CONFIRM_LOSS_OF_DATA'EXPORTING
textline1 = '취소하시겠습니까?'
* TEXTLINE2 = ' '
titel = 'Cancel'
start_column = 25
start_row = 6
defaultoption = 'N'
IMPORTING
answer = result.
ENDFORM. " SUBROUTINE_POPUP
*****************************************************************8
끝!!! -> 차근차근 봐야 이해 가능.
혹시 몰라서 HTML 파일로 소스 올려두었으니 순서대로 잘 찾아보시길...
728x90
반응형
'ERP-SAP > ABAP' 카테고리의 다른 글
<ABAP> ALV - CLASS 로 만들기. ALV GRID CONTROL (0) | 2010.12.03 |
---|---|
<ABAP> Screen Dropdown Listbox 만들기!!! 스크린 드랍다운 리스트박스 (0) | 2010.12.03 |
<ABAP> Selection Screen 만들 시 조건에 따라 출력 필드 다르게 하기 (0) | 2010.12.02 |
<ABAP> 스크린 필드 활성 - 불활성, 조건에 따라 스크린 필드 변경 (0) | 2010.12.02 |
<ABAP> 데이터 마이그레이션(Migration)이 잘못 되었을 때 사용하는 Mass! (0) | 2010.10.26 |