아래 소스르 작성해서 실행해보니 그림같은 덤프가 뜨네요.
필드카달로그와 REUSE_ALV_LIST_DISPLAY 그리고 LAYOUT설정을 넣고 해봤는데
뭐가 잘못된지 알려주세요. 아직 ALV기초가 부족한 것 같네요. 기본적인것 같은데
뭐가 잘못됀는지 알수가 없네요. 책보고 참고해서 한것인데..
*&---------------------------------------------------------------------*
*& Report ZTEST0004
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ztest0004_1_alv MESSAGE-ID zfi.
TABLES: spfli, scarr.
DATA: BEGIN OF itab_spfli OCCURS 0.
INCLUDE STRUCTURE spfli.
DATA: END OF itab_spfli.
DATA: BEGIN OF itab_scarr OCCURS 0.
INCLUDE STRUCTURE scarr.
DATA: END OF itab_scarr.
DATA : BEGIN OF itab OCCURS 0,
carrid LIKE spfli-carrid,
carrname LIKE scarr-carrname,
connid LIKE spfli-connid,
cityto LIKE spfli-cityto,
cityfrom LIKE spfli-cityfrom,
END OF itab.
DATA: ok_code LIKE sy-ucomm.
DATA : l_cnt TYPE i.
DATA : l_field(20),
l_value(20).
*// ALV? ?? ?? ?? //*
TYPE-POOLS : slis.
* STATUS
DATA : gv_status TYPE slis_formname VALUE 'STANDARD'.
DATA : gs_extab TYPE slis_t_extab.
** Fieldcat
DATA : gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_fieldcat_ln LIKE LINE OF gt_fieldcat.
** Layout
DATA : gs_layout TYPE slis_layout_alv.
** IT_EVENT_EXIT
DATA : gt_event_exit TYPE slis_t_event_exit.
** I_CALL_USER_COMMANT
DATA : g_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
DATA : r_ucomm TYPE sy-ucomm.
DATA : rs_selfield TYPE slis_selfield.
** VARIANT ?? ??
DATA : gs_variant TYPE disvariant.
*// ALV? ?? ?? ? //*
*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(12) text-002 FOR FIELD p_carrid.
*SELECTION-SCREEN POSITION 32.
PARAMETERS : p_carrid AS CHECKBOX USER-COMMAND pcarrid.
*SELECTION-SCREEN END OF LINE.
*
*SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(12) text-003 FOR FIELD p_carna.
*SELECTION-SCREEN POSITION 40.
PARAMETERS : p_carna AS CHECKBOX USER-COMMAND pcarrname.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK bl1.
*SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_carrid FOR spfli-carrid MODIF ID g1.
SELECTION-SCREEN END OF BLOCK bl2.
*SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK bl3 WITH FRAME TITLE text-003.
SELECT-OPTIONS: s_carrna FOR scarr-carrname NO INTERVALS NO-EXTENSION MODIF ID g2.
SELECTION-SCREEN END OF BLOCK bl3.
*----------------------------------------------------------------------*
* INITIALIZATION.
*----------------------------------------------------------------------*
INITIALIZATION.
s_carrid-sign = 'I'.
s_carrid-option = 'BT'.
s_carrid-low = 'AA'.
s_carrid-high = 'AB'.
APPEND s_carrid.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'G1'.
IF p_carrid EQ 'X'.
screen-active = 1.
ELSE.
screen-active = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'G2'.
IF p_carna EQ 'X'.
screen-active = 1.
ELSE.
screen-active = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* Start of Selection *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM select_data.
PERFORM set_fieldcat.
PERFORM set_layout.
END-OF-SELECTION.
PERFORM display_data.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELECT'.
MESSAGE i001 WITH text-m01.
WHEN 'SELECTALL'.
MESSAGE i001 WITH text-m02.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form select_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM select_data .
IF p_carrid EQ space.
p_carrid = '%'.
ELSE.
CONCATENATE s_carrna '%' INTO s_carrna.
ENDIF.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab_spfli
FROM spfli
WHERE carrid IN s_carrid.
SELECT carrid carrname
INTO CORRESPONDING FIELDS OF TABLE itab_scarr
FROM scarr
FOR ALL ENTRIES IN itab_spfli
WHERE carrid = itab_spfli-carrid AND
carrname IN s_carrna.
* LOOP AT itab_spfli.
*
** 1)
* MOVE-CORRESPONDING itab_spfli TO itab.
* CLEAR itab_scarr.
* READ TABLE itab_scarr WITH KEY carrid = itab_spfli-carrid.
* itab-carrname = itab_scarr-carrname.
*
* APPEND itab.
* CLEAR itab.
*
* 2)
* CLEAR itab_scarr.
* READ TABLE itab_scarr WITH KEY carrid = itab_spfli-carrid.
*
* IF sy-subrc = 0.
* itab-carrname = itab_scarr-carrname.
*
* APPEND itab.
*
* ENDIF.
* CLEAR itab.
*
* IF NOT itab_spfli[] IS INITIAL.
*
* l_cnt = LINES( itab_spfli ).
*
* ENDIF.
*
* ENDLOOP.
*-----------------------------------------------------------------------
IF NOT itab_spfli[] IS INITIAL.
l_cnt = LINES( itab_spfli ).
LOOP AT itab_spfli.
* 1)
MOVE-CORRESPONDING itab_spfli TO itab.
CLEAR itab_scarr.
READ TABLE itab_scarr WITH KEY carrid = itab_spfli-carrid.
itab-carrname = itab_scarr-carrname.
APPEND itab.
CLEAR itab.
ENDLOOP.
ENDIF.
*END-OF-SELECTION.
*
*
* IF NOT itab[] IS INITIAL.
* SET PF-STATUS 'MENUBAR'.
*
* LOOP AT itab.
*
* WRITE:/ sy-vline,
* (10) itab-carrid COLOR 5,
* sy-vline,
* (25) itab-carrname,
* sy-vline,
* (10) itab-connid,
* sy-vline,
* (20) itab-cityto,
* sy-vline,
* (20) itab-cityfrom,
* sy-vline.
* ULINE.
*
* HIDE: itab.
*
* ENDLOOP.
*
* ENDIF.
* ENDIF.
ENDFORM. " select_data
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = gv_status
* i_callback_pf_status_set = sy-pfkey
i_callback_user_command = g_user_command
* I_STRUCTURE_NAME =
is_layout = gs_layout
it_fieldcat = gt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'X'
* i_save = 'A' "U: USER ONLY,X: PUBLIC, A:BOTH
* is_variant = gs_variant
* IT_EVENTS =
* it_event_exit = gt_event_exit
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab[]
* 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.
ENDFORM. " display_data
*&---------------------------------------------------------------------*
*& Form set_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_fieldcat.
CLEAR : gt_fieldcat_ln, gt_fieldcat.
gt_fieldcat_ln-fieldname = 'CARRID'.
gt_fieldcat_ln-col_pos = '1'.
* gt_fieldcat_ln-just = 'L'.
gt_fieldcat_ln-fix_column = 'X'.
gt_fieldcat_ln-reptext_ddic = 'CARR-ID'.
APPEND gt_fieldcat_ln TO gt_fieldcat.
* gt_fieldcat_ln-ref_tabname = 'ZHMSTR'.
* gt_fieldcat_ln-ref_fieldname = 'IDNO'.
* gt_fieldcat_ln-emphasize = 'C610'.
CLEAR gt_fieldcat_ln.
gt_fieldcat_ln-fieldname = 'CARRNAME'.
gt_fieldcat_ln-col_pos = '2'.
gt_fieldcat_ln-just = 'L'.
gt_fieldcat_ln-fix_column = 'X'.
gt_fieldcat_ln-reptext_ddic = 'CARR-NAME'.
APPEND gt_fieldcat_ln TO gt_fieldcat.
CLEAR gt_fieldcat_ln.
gt_fieldcat_ln-fieldname = 'CONNID'.
gt_fieldcat_ln-col_pos = '3'.
gt_fieldcat_ln-just = 'L'.
gt_fieldcat_ln-reptext_ddic = 'CONN-ID'.
APPEND gt_fieldcat_ln TO gt_fieldcat.
CLEAR gt_fieldcat_ln.
gt_fieldcat_ln-fieldname = 'CITYTO'.
gt_fieldcat_ln-col_pos = '4'.
gt_fieldcat_ln-just = 'L'.
gt_fieldcat_ln-reptext_ddic = 'CITY-TO'.
APPEND gt_fieldcat_ln TO gt_fieldcat.
CLEAR gt_fieldcat_ln.
gt_fieldcat_ln-fieldname = 'CITYFORM'.
gt_fieldcat_ln-col_pos = '5'.
gt_fieldcat_ln-just = 'L'.
gt_fieldcat_ln-reptext_ddic = 'CITY-FROM'.
APPEND gt_fieldcat_ln TO gt_fieldcat.
ENDFORM. " set_fieldcat
*&---------------------------------------------------------------------*
*& Form set_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_layout.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
gs_layout-info_fieldname = 'COLOR'.
gs_layout-coltab_fieldname = 'C610'.
gs_layout-box_fieldname = 'CARRID'.
gs_layout-box_tabname = 'ITAB'.
ENDFORM. " set_layout
댓글 4
-
SAYA
2009.03.13 17:06
-
로미오
2009.03.13 21:02
주석처리해도 위 덤프가 뜹니다. ㅡ.ㅡ
-
아상[vaya con dios]
2009.03.14 00:19
DATA : BEGIN OF itab OCCURS 0,
carrid LIKE spfli-carrid,
carrname LIKE scarr-carrname,
connid LIKE spfli-connid,
cityto LIKE spfli-cityto,
cityfrom LIKE spfli-cityfrom,
END OF itab.
gt_fieldcat_ln-fieldname = 'CITYFORM'.
gt_fieldcat_ln-col_pos = '5'.
gt_fieldcat_ln-just = 'L'.
gt_fieldcat_ln-reptext_ddic = 'CITY-FROM'.
APPEND gt_fieldcat_ln TO gt_fieldcat.
cityfrom이랑 CITYFORM이 달라서 아닐까요?
-
앙리
2009.03.14 07:34
맞네요. 감사합니다.
START-OF-SELECTION. 이벤트에서 set_layout 부분 주석처리 하세요.
PERFORM select_data.
PERFORM set_fieldcat.
* PERFORM set_layout. <-- 주석처리
layout 속성을 잘못 설정하셨네요.