일단 수정해서 올리긴 했는데요.. 검증이 안됩니다.
데이터가 없어요.....
-_-;;;;
데이터만 있으면 제대로 해 볼 수 있는데 아쉽네요.
그리고 활성화 되니까 한번 테스트 해보시구요
*<<<<<< 추가부분 - START >>>>>>>>>>>>>>>>>>>
*<<<<<< 추가부분 - END >>>>>>>>>>>>>>>>>>>
이런식으로 주석을 달아두었으니까 그 부분들만 보시면 될것 같습니다 ^^;;
수고하세요
*&---------------------------------------------------------------------*
*& Report ZSHIN_TEST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT zshin_test NO STANDARD PAGE HEADING.
* ALV
TYPE-POOLS: slis.
* DB-Table
TABLES sflight.
* Includes
INCLUDE <icon>.
INCLUDE <symbol>.
*
CONSTANTS:
gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_layout TYPE slis_layout_alv,
gs_print TYPE slis_print_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_sp_group TYPE slis_t_sp_group_alv,
gt_events TYPE slis_t_event.
* Data to be displayed
*<<<<<< 추가 부분 - START >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DATA : t_colinfo_table TYPE slis_t_specialcol_alv WITH HEADER LINE.
*<<<<<< 추가 부분 - END >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DATA: BEGIN OF gt_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: add1,
carrname LIKE scarr-carrname,
box,
lights,
*<<<<<< 추가 부분 - START >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
alv_color TYPE slis_t_specialcol_alv.
*<<<<<< 추가 부분 - END >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DATA: END OF gt_sflight.
*
DATA: g_repid LIKE sy-repid.
DATA: gt_list_top_of_page TYPE slis_t_listheader.
* Report Selections
SELECT-OPTIONS carrid FOR sflight-carrid.
SELECT-OPTIONS connid FOR sflight-connid.
SELECT-OPTIONS fldate FOR sflight-fldate.
SELECTION-SCREEN SKIP 1.
* Parameters
PARAMETERS: p_maxrow TYPE i DEFAULT 30.
SELECTION-SCREEN SKIP 1.
* Variante
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-006.
PARAMETERS: p_vari LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK 0.
* Layout
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-060.
PARAMETERS:
p_zebra AS CHECKBOX DEFAULT ' ',
p_nocolh AS CHECKBOX DEFAULT ' ',
p_novlin AS CHECKBOX DEFAULT ' ',
p_colopt AS CHECKBOX DEFAULT ' ',
p_keyhot AS CHECKBOX DEFAULT ' ',
p_noinpt AS CHECKBOX DEFAULT ' ',
p_merge AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-061.
PARAMETERS:
p_lights AS CHECKBOX DEFAULT ' ',
p_lightc AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-062.
PARAMETERS:
p_before AS CHECKBOX DEFAULT ' ',
p_totonl AS CHECKBOX DEFAULT ' ',
p_totext(60),
p_sttext(60).
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-063.
PARAMETERS:
p_gpce AS CHECKBOX DEFAULT ' ',
p_chkbox AS CHECKBOX DEFAULT ' ',
p_detpop AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK d.
SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-064.
PARAMETERS:
p_print AS CHECKBOX DEFAULT ' ',
p_nosinf AS CHECKBOX DEFAULT ' ',
p_nocove AS CHECKBOX DEFAULT ' ',
p_nonewp AS CHECKBOX DEFAULT ' ',
p_nolinf AS CHECKBOX DEFAULT ' ',
p_reserv TYPE i.
SELECTION-SCREEN END OF BLOCK e.
DATA: g_boxnam TYPE slis_fieldname VALUE 'BOX',
p_f2code LIKE sy-ucomm VALUE '&ETA',
p_lignam TYPE slis_fieldname VALUE 'LIGHTS',
g_save(1) TYPE c,
g_default(1) TYPE c,
g_exit(1) TYPE c,
gx_variant LIKE disvariant,
g_variant LIKE disvariant.
*---------------------------------------------------------------------*
INITIALIZATION.
g_repid = sy-repid.
PERFORM e01_fieldcat_init USING gt_fieldcat[].
PERFORM e03_eventtab_build USING gt_events[].
PERFORM e04_comment_build USING gt_list_top_of_page[].
PERFORM e06_t_sort_build USING gt_sort[].
PERFORM e07_sp_group_build USING gt_sp_group[].
** Schalter Varianten benutzerspezifisch/allgemein speicherbar setzen
* Set Options: save variants userspecific or general
g_save = 'A'.
PERFORM variant_init.
* Get default variant
gx_variant = g_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = gx_variant-variant.
ENDIF.
* Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
*<<<<<< 추가 부분 - START >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
AT LINE-SELECTION.
PERFORM grid_select_line_color_change.
*<<<<<< 추가 부분 - END >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
* PAI
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
START-OF-SELECTION.
PERFORM selection.
END-OF-SELECTION.
PERFORM e05_layout_build USING gs_layout. "wg. Parameters
PERFORM e08_print_build USING gs_print. "wg. Parameters
* Call ABAP/4 List Viewer
*<<<<<< 추가 부분 - START >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
gs_layout-coltab_fieldname = 'ALV_COLOR'.
*<<<<<< 추가 부분 - END >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_background_id = 'ALV_BACKGROUND'
i_callback_program = g_repid
i_structure_name = 'SFLIGHT'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_special_groups = gt_sp_group[]
it_sort = gt_sort[]
i_save = g_save
is_variant = g_variant
it_events = gt_events[]
is_print = gs_print
TABLES
t_outtab = gt_sflight.
*&---------------------------------------------------------------------*
*& Form GRID_SELECT_LINE_COLOR_CHANGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM grid_select_line_color_change.
DATA : l_tabix TYPE sy-tabix.
LOOP AT gt_sflight.
l_tabix = sy-tabix.
if l_tabix eq sy-listi.
REFRESH t_colinfo_table.
CLEAR t_colinfo_table.
t_colinfo_table-fieldname = 'LOAN'.
t_colinfo_table-color-col = 5.
t_colinfo_table-nokeycol = 'X'.
APPEND t_colinfo_table.
gt_sflight-alv_color[] = t_colinfo_table[].
MODIFY gt_sflight INDEX l_tabix.
endif.
ENDLOOP.
ENDFORM. " GRID_SELECT_LINE_COLOR_CHANGE
*---------------------------------------------------------------------*
* FORM E01_FIELDCAT_INIT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E01_LT_FIELDCAT *
*---------------------------------------------------------------------*
FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
*
* CLEAR LS_FIELDCAT.
* LS_FIELDCAT-COL_POS = 1.
* LS_FIELDCAT-FIELDNAME = 'ADD1'.
* LS_FIELDCAT-REPTEXT_DDIC = '?'.
* LS_FIELDCAT-OUTPUTLEN = 1.
* LS_FIELDCAT-NO_OUT = 'X'.
* LS_FIELDCAT-INPUT = 'X'.
* LS_FIELDCAT-SP_GROUP = 'A'.
* APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CARRNAME'.
ls_fieldcat-col_pos = 2.
ls_fieldcat-key = 'X'.
ls_fieldcat-key_sel = 'X'.
ls_fieldcat-ref_tabname = 'SCARR'.
APPEND ls_fieldcat TO e01_lt_fieldcat.
*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSOCC'.
ls_fieldcat-do_sum = 'X'.
APPEND ls_fieldcat TO e01_lt_fieldcat.
*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-do_sum = 'X'.
APPEND ls_fieldcat TO e01_lt_fieldcat.
*
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'CARRID'.
* ls_fieldcat-ref_fieldname = 'SFLIGHT'.
ls_fieldcat-text_fieldname = 'CARRNAME'.
APPEND ls_fieldcat TO e01_lt_fieldcat.
*
* clear ls_fieldcat.
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-key_sel = 'X'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-outputlen = 7.
APPEND ls_fieldcat TO e01_lt_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E02_DATA_ADD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E02_LT_SFLIGHT *
*---------------------------------------------------------------------*
FORM e02_data_add TABLES e02_lt_sflight STRUCTURE gt_sflight.
LOOP AT e02_lt_sflight.
IF sy-tabix > 10.
e02_lt_sflight-add1 = 'A'.
e02_lt_sflight-box = 'X'.
e02_lt_sflight-lights = '3'.
ELSE.
IF sy-tabix = 1.
e02_lt_sflight-lights = '2'.
ELSE.
e02_lt_sflight-lights = '1'.
ENDIF.
ENDIF.
MODIFY e02_lt_sflight.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E03_EVENTTAB_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E03_LT_EVENTS *
*---------------------------------------------------------------------*
FORM e03_eventtab_build USING e03_lt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
*
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = e03_lt_events.
READ TABLE e03_lt_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_formname_top_of_page TO ls_event-form.
APPEND ls_event TO e03_lt_events.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E04_COMMENT_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E04_LT_TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM e04_comment_build USING e04_lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
*
* Listenuberschrift: Typ H
CLEAR ls_line.
ls_line-typ = 'H'.
* LS_LINE-KEY: not used for this type
ls_line-info = text-100.
APPEND ls_line TO e04_lt_top_of_page.
* Kopfinfo: Typ S
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = text-101.
ls_line-info = text-102.
APPEND ls_line TO e04_lt_top_of_page.
ls_line-key = text-103.
ls_line-info = text-104.
APPEND ls_line TO e04_lt_top_of_page.
* Aktionsinfo: Typ A
CLEAR ls_line.
ls_line-typ = 'A'.
* LS_LINE-KEY: not used for this type
ls_line-info = text-105.
APPEND ls_line TO e04_lt_top_of_page.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E05_LAYOUT_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* <-> E05_LS_LAYOUT *
*---------------------------------------------------------------------*
FORM e05_layout_build USING e05_ls_layout TYPE slis_layout_alv.
e05_ls_layout-f2code = p_f2code.
e05_ls_layout-zebra = p_zebra.
e05_ls_layout-cell_merge = p_merge.
e05_ls_layout-colwidth_optimize = p_colopt.
IF p_chkbox = 'X'.
e05_ls_layout-box_fieldname = g_boxnam.
ELSE.
e05_ls_layout-box_fieldname = space.
ENDIF.
e05_ls_layout-no_input = p_noinpt.
e05_ls_layout-no_vline = p_novlin.
e05_ls_layout-no_colhead = p_nocolh.
IF p_lights = 'X' OR p_lightc = 'X'.
e05_ls_layout-lights_fieldname = p_lignam.
ELSE.
CLEAR e05_ls_layout-lights_fieldname.
ENDIF.
IF p_before = 'X'.
e05_ls_layout-totals_before_items = 'X'.
ENDIF.
IF p_gpce = 'X'.
e05_ls_layout-group_change_edit = 'X'.
ENDIF.
e05_ls_layout-lights_condense = p_lightc.
e05_ls_layout-totals_text = p_totext.
e05_ls_layout-subtotals_text = p_sttext.
e05_ls_layout-totals_only = p_totonl.
e05_ls_layout-key_hotspot = p_keyhot.
e05_ls_layout-detail_popup = p_detpop.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E06_T_SORT_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E06_LT_SORT *
*---------------------------------------------------------------------*
FORM e06_t_sort_build USING e06_lt_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv.
*
* ls_sort-fieldname = 'CARRID'.
* ls_sort-spos = 1.
* ls_sort-up = 'X'.
* ls_sort-subtot = 'X'.
* append ls_sort to e06_lt_sort.
CLEAR ls_sort.
ls_sort-fieldname = 'CARRNAME'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
* ls_sort-subtot = 'X'.
APPEND ls_sort TO e06_lt_sort.
CLEAR ls_sort.
ls_sort-fieldname = 'CONNID'.
ls_sort-spos = 2.
ls_sort-up = 'X'.
* ls_sort-subtot = 'X'.
APPEND ls_sort TO e06_lt_sort.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E07_SP_GROUP_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E07_LT_SP_GROUP *
*---------------------------------------------------------------------*
FORM e07_sp_group_build USING e07_lt_sp_group TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
*
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = text-005.
APPEND ls_sp_group TO e07_lt_sp_group.
ENDFORM.
*---------------------------------------------------------------------*
* FORM E08_PRINT_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> E08_LS_PRINT *
*---------------------------------------------------------------------*
FORM e08_print_build USING e08_ls_print TYPE slis_print_alv.
*
e08_ls_print-print = p_print.
e08_ls_print-no_print_selinfos = p_nosinf.
e08_ls_print-no_coverpage = p_nocove.
e08_ls_print-no_new_page = p_nonewp.
e08_ls_print-no_print_listinfos = p_nolinf.
e08_ls_print-reserve_lines = p_reserv.
e08_ls_print-print = p_print.
ENDFORM.
*---------------------------------------------------------------------*
* FORM SELECTION *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM selection.
* select * from sflight into corresponding fields of table gt_sflight
* up to p_maxrow rows
* where carrid in carrid
* and connid in connid
* and fldate in fldate.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_sflight FROM
( sflight LEFT JOIN scarr
ON sflight~carrid = scarr~carrid )
UP TO p_maxrow ROWS
WHERE sflight~carrid IN carrid
AND sflight~connid IN connid
AND sflight~fldate IN fldate.
*
PERFORM e02_data_add TABLES gt_sflight.
ENDFORM.
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM top_of_page.
*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = 'HTMLCNTL_TESTHTM2_SAPLOGO'
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = gt_list_top_of_page.
ENDFORM.
*---------------------------------------------------------------------*
* FORM F4_FOR_VARIANT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM f4_for_variant.
*
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
* it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pai_of_selection_screen.
*
IF NOT p_vari IS INITIAL.
MOVE g_variant TO gx_variant.
MOVE p_vari TO gx_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant.
g_variant = gx_variant.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*& Form VARIANT_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM variant_init.
*
CLEAR g_variant.
g_variant-report = g_repid.
ENDFORM. " VARIANT_INIT