가장 기본적인 ALV 템플릿으로 데이터 조회할 수 있는 프로그램을 만들었는데, 아예 빈화면으로 실행이 안되네요.
제가 놓친 부분이 있는지 확인해 주실 수 있으실까요 ㅜㅜ
*&---------------------------------------------------------------------*
*& Report ZEX1_3_ABAP_A01
*&
*&---------------------------------------------------------------------*
REPORT z_alv_templete.
INCLUDE z_alv_templete_top.
INCLUDE z_alv_templete_pbo.
INCLUDE z_alv_templete_pai.
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
IF sy-subrc EQ 0.
CALL SCREEN 100.
ELSE.
WRITE : '오류 수정 필요'.
ENDIF.
&---------------------------------------------------------------------*
*& Include Z_ALV_TEMPLETE_TOP
*&---------------------------------------------------------------------*
*TYPE-POOLS : slis. <-- 왜 들어가야하는지 이유를 모르겠습니다.
TABLES : ekko.
TYPES : BEGIN OF ty_str,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bsart TYPE ekko-bsart,
END OF ty_str.
DATA : gs_disp type ty_str.
DATA : gt_disp TYPE TABLE OF ty_str.
DATA : con1_ref TYPE REF TO cl_gui_custom_container.
DATA : g_grid TYPE REF TO cl_gui_alv_grid.
DATA : ok_code TYPE sy-ucomm.
DATA : gt_fieldcat TYPE lvc_t_fcat.
DATA : gs_fieldcat TYPE lvc_s_fcat.
DATA : gs_layout TYPE lvc_s_layo.
*&---------------------------------------------------------------------*
*& Include Z_ALV_TEMPLETE_PBO
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
ENDMODULE. "status_0100 OUTPUT
*----------------------------------------------------------------------*
* MODULE set_alv_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE set_alv_0100 OUTPUT.
PERFORM setting_alv_0100.
ENDMODULE. "set_alv_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form SETTING_ALV_100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM setting_alv_0100 .
IF g_grid IS INITIAL.
"인스턴스 생성
PERFORM create_object.
"필드카탈로그 생성
PERFORM set_fieldcatalog.
"레이아웃 세팅
PERFORM set_layout.
"ALV 호출
PERFORM display_alv.
ELSE.
PERFORM refresh_data.
ENDIF.
ENDFORM. " SETTING_ALV_100
*&---------------------------------------------------------------------*
*& Form CREATE_OBJECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM create_object .
CREATE OBJECT con1_ref
EXPORTING
container_name = 'con1'.
CREATE OBJECT g_grid
EXPORTING
i_parent = con1_ref.
ENDFORM. " CREATE_OBJECT
*&---------------------------------------------------------------------*
*& Form SET_FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_fieldcatalog .
CLEAR : gs_fieldcat.
CLEAR : gt_fieldcat.
gs_fieldcat-fieldname = 'EBELN'.
gs_fieldcat-coltext = '구매문서'.
gs_fieldcat-key = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR : gs_fieldcat.
gs_fieldcat-fieldname = 'BUKRS'.
gs_fieldcat-coltext = '회사코드'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR : gs_fieldcat.
gs_fieldcat-fieldname = 'BSART'.
gs_fieldcat-coltext = '문서유형'.
APPEND gs_fieldcat TO gt_fieldcat.
ENDFORM. " SET_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_layout.
CLEAR : gs_layout.
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'A'.
gs_layout-sel_mode = 'D'.
ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv .
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gt_disp
it_fieldcatalog = gt_fieldcat.
ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form REFRESH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM refresh_data .
CALL METHOD g_grid->refresh_table_display.
ENDFORM. " REFRESH_DATA
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_data.
CLEAR gt_disp.
SELECT ebeln bukrs bsart
INTO CORRESPONDING FIELDS OF TABLE gt_disp
FROM ekko UP TO 10 ROWS.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Include Z_ALV_TEMPLETE_PAI
*&---------------------------------------------------------------------*
MODULE exit_0100 input.
CASE ok_code.
WHEN 'back' or 'exit' or 'canc'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
스크린 100번 만드셨나요?
다음과 같은 데모 프로그램 참고해보세요.
BCALV_GRID_DEMO