Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- UTF-8
- EXIT
- KOSA
- 동적 쿼리
- ABAP
- alv 정형화
- List box
- 방화벽
- FI 용어정리
- Standard Function
- SAP
- Enhancement
- Smart Forms
- fi
- 엑소버드
- badi
- sapa
- 머니플랜
- function
- 이명박
- 유닉스
- ALV
- 가계부
- gimp
- 오라클 함수
- selection screen
- Java
- ole
- 스마트폼
- EUC-kr
Archives
- Today
- Total
Drunken Lion
ALV 정형화 2/2 본문
ALV프로그램에서 공통으로 사용할수 있는 INCLUDE 예문
위와 같이 늘 해야하는 데이터 정이나 서브루틴 정의 등을 미리 지정해 놓고,
호출해서 사용하면 간편하며.. 유지보수시에도 편리하다.
노가다를 상당부분 줄일 수 있을 듯..
*----------------------------------------------------------------------*
* INCLUDE ZTESTALV *
*----------------------------------------------------------------------*
* INCLUDE ZTESTALV *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TYPES
*----------------------------------------------------------------------*
TYPE-POOLS slis.
* TYPES
*----------------------------------------------------------------------*
TYPE-POOLS slis.
*----------------------------------------------------------------------*
* CONSTANTS
*----------------------------------------------------------------------*
CONSTANTS : gc_status_set TYPE slis_formname VALUE 'STATUS',
gc_user_command TYPE slis_formname VALUE 'USER_COMMAND',
gc_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
* CONSTANTS
*----------------------------------------------------------------------*
CONSTANTS : gc_status_set TYPE slis_formname VALUE 'STATUS',
gc_user_command TYPE slis_formname VALUE 'USER_COMMAND',
gc_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
*----------------------------------------------------------------------*
* DATA: Variable
*----------------------------------------------------------------------*
DATA : gv_repid TYPE sy-repid,
gv_tabix LIKE sy-tabix,
gv_tabname TYPE slis_tabname. " itab name
* DATA: Variable
*----------------------------------------------------------------------*
DATA : gv_repid TYPE sy-repid,
gv_tabix LIKE sy-tabix,
gv_tabname TYPE slis_tabname. " itab name
*----------------------------------------------------------------------*
* DATA: Structure. (Field strings : Working area)
*----------------------------------------------------------------------*
DATA : gs_sort TYPE slis_sortinfo_alv,
gs_fieldcat TYPE slis_fieldcat_alv,
gs_events TYPE slis_alv_event,
gs_extab TYPE slis_extab,
gs_toplist TYPE slis_listheader,
gs_layout TYPE slis_layout_alv.
* DATA: Structure. (Field strings : Working area)
*----------------------------------------------------------------------*
DATA : gs_sort TYPE slis_sortinfo_alv,
gs_fieldcat TYPE slis_fieldcat_alv,
gs_events TYPE slis_alv_event,
gs_extab TYPE slis_extab,
gs_toplist TYPE slis_listheader,
gs_layout TYPE slis_layout_alv.
*----------------------------------------------------------------------*
* DATA: Internal Table.
*----------------------------------------------------------------------*
DATA : gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_events TYPE slis_t_event,
gt_extab TYPE slis_t_extab,
gt_toplist TYPE slis_t_listheader.
* DATA: Internal Table.
*----------------------------------------------------------------------*
DATA : gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_events TYPE slis_t_event,
gt_extab TYPE slis_t_extab,
gt_toplist TYPE slis_t_listheader.
*&---------------------------------------------------------------------*
*& Form set_event_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_event text
* -->p_form text
*----------------------------------------------------------------------*
FORM set_event_form USING p_event
p_form.
*& Form set_event_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_event text
* -->p_form text
*----------------------------------------------------------------------*
FORM set_event_form USING p_event
p_form.
CLEAR gs_events.
READ TABLE gt_events WITH KEY name = p_event
INTO gs_events.
IF sy-subrc = 0.
gs_events-form = p_form.
MODIFY gt_events FROM gs_events INDEX sy-tabix.
ENDIF.
READ TABLE gt_events WITH KEY name = p_event
INTO gs_events.
IF sy-subrc = 0.
gs_events-form = p_form.
MODIFY gt_events FROM gs_events INDEX sy-tabix.
ENDIF.
ENDFORM. " set_event_form
*&---------------------------------------------------------------------*
*& Form SET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GUBUN text
* -->P_FNAME text
* -->P_FVAL text
*----------------------------------------------------------------------*
FORM set_fieldcat USING p_gubun
p_fname
p_fval.
*&---------------------------------------------------------------------*
*& Form SET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GUBUN text
* -->P_FNAME text
* -->P_FVAL text
*----------------------------------------------------------------------*
FORM set_fieldcat USING p_gubun
p_fname
p_fval.
DATA : lv_fname(40).
FIELD-SYMBOLS : <fs>.
FIELD-SYMBOLS : <fs>.
IF p_gubun = 'S'.
CLEAR : gs_fieldcat, gv_tabix.
READ TABLE gt_fieldcat INTO gs_fieldcat
WITH KEY fieldname = p_fname.
gv_tabix = sy-tabix.
EXIT.
ENDIF.
CLEAR : gs_fieldcat, gv_tabix.
READ TABLE gt_fieldcat INTO gs_fieldcat
WITH KEY fieldname = p_fname.
gv_tabix = sy-tabix.
EXIT.
ENDIF.
CONCATENATE 'GS_FIELDCAT-' p_fname INTO lv_fname.
ASSIGN (lv_fname) TO <fs>.
MOVE p_fval TO <fs>.
ASSIGN (lv_fname) TO <fs>.
MOVE p_fval TO <fs>.
* DATA APPEND
CHECK p_gubun = 'E'.
MODIFY gt_fieldcat FROM gs_fieldcat INDEX gv_tabix.
CHECK p_gubun = 'E'.
MODIFY gt_fieldcat FROM gs_fieldcat INDEX gv_tabix.
ENDFORM. " SET_FIELDCAT
*&---------------------------------------------------------------------*
*& Form SET_SORT
*&---------------------------------------------------------------------*
* P_GUB -> 시작 ,종료 구분.
* P_FNAME -> FIELDNAME
* P_CON -> FILED 값.
* P_
*----------------------------------------------------------------------*
FORM set_sort USING p_gubun
p_fname
p_fval
p_tabname.
*&---------------------------------------------------------------------*
*& Form SET_SORT
*&---------------------------------------------------------------------*
* P_GUB -> 시작 ,종료 구분.
* P_FNAME -> FIELDNAME
* P_CON -> FILED 값.
* P_
*----------------------------------------------------------------------*
FORM set_sort USING p_gubun
p_fname
p_fval
p_tabname.
DATA : lv_fname(40),
lv_tabname LIKE feld-name.
lv_tabname LIKE feld-name.
FIELD-SYMBOLS : <fs>,
<table> TYPE STANDARD TABLE.
<table> TYPE STANDARD TABLE.
IF p_tabname <> space.
lv_tabname = p_tabname.
ASSIGN (lv_tabname) TO <table>. " not headerline
ENDIF.
lv_tabname = p_tabname.
ASSIGN (lv_tabname) TO <table>. " not headerline
ENDIF.
CONCATENATE 'GS_SORT-' p_fname INTO lv_fname.
ASSIGN (lv_fname) TO <fs>.
MOVE p_fval TO <fs>.
ASSIGN (lv_fname) TO <fs>.
MOVE p_fval TO <fs>.
CHECK p_gubun = 'E'.
APPEND gs_sort TO <table>.
APPEND gs_sort TO <table>.
ENDFORM. " SET_SORT
*&---------------------------------------------------------------------*
*& Form call_alv_fieldcat
*&---------------------------------------------------------------------*
* 화면에 출력할 Internal Table 각 필드속성을 가져옴
*----------------------------------------------------------------------*
* -->P_REPID text
* -->P_TABNAME text
* <--P_FIELDCAT[] text
*----------------------------------------------------------------------*
FORM call_alv_fieldcat USING p_repid
p_tabname TYPE slis_tabname
CHANGING p_fieldcat TYPE slis_t_fieldcat_alv.
*&---------------------------------------------------------------------*
*& Form call_alv_fieldcat
*&---------------------------------------------------------------------*
* 화면에 출력할 Internal Table 각 필드속성을 가져옴
*----------------------------------------------------------------------*
* -->P_REPID text
* -->P_TABNAME text
* <--P_FIELDCAT[] text
*----------------------------------------------------------------------*
FORM call_alv_fieldcat USING p_repid
p_tabname TYPE slis_tabname
CHANGING p_fieldcat TYPE slis_t_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = p_repid
i_internal_tabname = p_tabname
i_inclname = p_repid
CHANGING
ct_fieldcat = p_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
EXPORTING
i_program_name = p_repid
i_internal_tabname = p_tabname
i_inclname = p_repid
CHANGING
ct_fieldcat = p_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " call_alv_fieldcat
*&---------------------------------------------------------------------*
*& Form call_alv_event
*&---------------------------------------------------------------------*
* ALV에서 사용되는 Event에 대한 정보 읽어옴
*----------------------------------------------------------------------*
* -->P_GV_ENENTS text
*----------------------------------------------------------------------*
FORM call_alv_event USING p_events TYPE slis_t_event.
*&---------------------------------------------------------------------*
*& Form call_alv_event
*&---------------------------------------------------------------------*
* ALV에서 사용되는 Event에 대한 정보 읽어옴
*----------------------------------------------------------------------*
* -->P_GV_ENENTS text
*----------------------------------------------------------------------*
FORM call_alv_event USING p_events TYPE slis_t_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_events.
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_events.
ENDFORM. " call_alv_event
*&---------------------------------------------------------------------*
*& Form call_alv_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GV_REPID text
* -->P_C_STATUS_SET text
* -->P_C_USER_COMMAND text
* -->P_GV_LAYOUT text
* -->P_GV_FCAT_SUB[] text
* -->P_GV_EXTAB[] text
* -->P_GV_SORT[] text
* -->P_GV_EVENTS text
* -->P_INT_ALL[] text
*----------------------------------------------------------------------*
FORM call_alv_display USING p_repid
p_status_set
p_user_command
p_top_of_page
p_title TYPE lvc_title "ALV list title
p_layout
p_fieldcat TYPE slis_t_fieldcat_alv
p_extab TYPE slis_t_extab
p_sort TYPE slis_t_sortinfo_alv
p_events
p_table_name.
*&---------------------------------------------------------------------*
*& Form call_alv_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GV_REPID text
* -->P_C_STATUS_SET text
* -->P_C_USER_COMMAND text
* -->P_GV_LAYOUT text
* -->P_GV_FCAT_SUB[] text
* -->P_GV_EXTAB[] text
* -->P_GV_SORT[] text
* -->P_GV_EVENTS text
* -->P_INT_ALL[] text
*----------------------------------------------------------------------*
FORM call_alv_display USING p_repid
p_status_set
p_user_command
p_top_of_page
p_title TYPE lvc_title "ALV list title
p_layout
p_fieldcat TYPE slis_t_fieldcat_alv
p_extab TYPE slis_t_extab
p_sort TYPE slis_t_sortinfo_alv
p_events
p_table_name.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
DATA lv_table_name LIKE feld-name.
DATA lv_table_name LIKE feld-name.
* get the table, which belongs to the tc *
CONCATENATE p_table_name '[]' INTO lv_table_name. "table body
ASSIGN (lv_table_name) TO <table>. "not headerline
CONCATENATE p_table_name '[]' INTO lv_table_name. "table body
ASSIGN (lv_table_name) TO <table>. "not headerline
*... call alv grid list function
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = p_repid
i_callback_pf_status_set = p_status_set
i_callback_user_command = p_user_command
i_callback_top_of_page = p_top_of_page
is_layout = p_layout
* i_grid_title = p_title
it_fieldcat = p_fieldcat[]
it_excluding = p_extab[]
it_sort = p_sort[]
it_events = p_events
TABLES
t_outtab = <table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = p_repid
i_callback_pf_status_set = p_status_set
i_callback_user_command = p_user_command
i_callback_top_of_page = p_top_of_page
is_layout = p_layout
* i_grid_title = p_title
it_fieldcat = p_fieldcat[]
it_excluding = p_extab[]
it_sort = p_sort[]
it_events = p_events
TABLES
t_outtab = <table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " call_alv_display
*&---------------------------------------------------------------------*
*& Form set_extab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GV_EXTAB[] text
*----------------------------------------------------------------------*
FORM set_extab USING p_fcode
p_tabname.
*&---------------------------------------------------------------------*
*& Form set_extab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GV_EXTAB[] text
*----------------------------------------------------------------------*
FORM set_extab USING p_fcode
p_tabname.
DATA : lv_tabname LIKE feld-name.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
IF p_tabname <> space.
lv_tabname = p_tabname.
ASSIGN (lv_tabname) TO <table>. " not headerline
ENDIF.
lv_tabname = p_tabname.
ASSIGN (lv_tabname) TO <table>. " not headerline
ENDIF.
CLEAR gs_extab.
gs_extab-fcode = p_fcode.
APPEND gs_extab TO <table>.
gs_extab-fcode = p_fcode.
APPEND gs_extab TO <table>.
ENDFORM. " set_extab
*---------------------------------------------------------------------*
* FORM top_of_page *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM top_of_page.
*---------------------------------------------------------------------*
* FORM top_of_page *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM top_of_page.
* PERFORM alv_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'LGHS_LOGO'
it_list_commentary = gt_toplist.
EXPORTING
i_logo = 'LGHS_LOGO'
it_list_commentary = gt_toplist.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form set_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_header USING p_typ
p_key
p_info
p_tabname.
*&---------------------------------------------------------------------*
*& Form set_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_header USING p_typ
p_key
p_info
p_tabname.
DATA : lv_tabname LIKE feld-name.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
IF p_tabname <> space.
lv_tabname = p_tabname.
ASSIGN (lv_tabname) TO <table>. " not headerline
ENDIF.
lv_tabname = p_tabname.
ASSIGN (lv_tabname) TO <table>. " not headerline
ENDIF.
CLEAR gs_toplist.
MOVE p_typ TO gs_toplist-typ.
MOVE p_key TO gs_toplist-key.
MOVE p_info TO gs_toplist-info.
APPEND gs_toplist TO <table>.
MOVE p_typ TO gs_toplist-typ.
MOVE p_key TO gs_toplist-key.
MOVE p_info TO gs_toplist-info.
APPEND gs_toplist TO <table>.
ENDFORM. " set_header
*&---------------------------------------------------------------------*
*& Form alv_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_layout.
gs_layout-box_tabname = 'gt_ZCHECK'.
gs_layout-box_fieldname = 'MARK'.
*&---------------------------------------------------------------------*
*& Form alv_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_layout.
gs_layout-box_tabname = 'gt_ZCHECK'.
gs_layout-box_fieldname = 'MARK'.
ENDFORM. " alv_layout
위와 같이 늘 해야하는 데이터 정이나 서브루틴 정의 등을 미리 지정해 놓고,
호출해서 사용하면 간편하며.. 유지보수시에도 편리하다.
노가다를 상당부분 줄일 수 있을 듯..
'SAP > ALV' 카테고리의 다른 글
Subtotal Sample Source (0) | 2007.12.17 |
---|---|
ALV 참고 자료 (0) | 2007.11.09 |
ALV 정형화 1/2 (0) | 2007.11.06 |
IT_FIELDCAT (0) | 2007.10.04 |
IS_LAYOUT (0) | 2007.10.04 |