2006 Dec 11 1:53 PM
hallow i use an alv but i thihk its old becouse i cant do a<b> header</b> . use the alv from se83 alv grid.did someone have a ex. to new alv or how i can i do a header in my alv. thankes
this is the alv that i use thankes for your answers
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA:
gt_fieldcatalog TYPE lvc_t_fcat WITH HEADER LINE ,
is_stable TYPE lvc_s_stbl VALUE 'XX' ,
fcat TYPE lvc_t_fcat,
wa_fcat LIKE LINE OF fcat,
ct_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE LINE OF slis_t_fieldcat_alv,
g_save(1) TYPE c,
seltab TYPE TABLE OF rsparams WITH HEADER LINE,
table_header(23) TYPE c.
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
-
START-OF-SELECTION.
*===================
PERFORM get_data.
PERFORM create_field_cat.
CALL SCREEN 100.
END-OF-SELECTION.
*===================
-
&----
*& Module PBO OUTPUT
&----
text
----
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'YHR_Q4_STR'
CHANGING
it_outtab = itab
it_fieldcatalog = fcat. " FOR FIELD CATALOG
ENDIF.
ENDMODULE. " PBO OUTPUT
&----
*& Module PAI INPUT
&----
text
----
MODULE pai INPUT.
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0. "FOR LEAVE THE SCREEN TO THE SCREEN BEFORE
PERFORM exit_program.
WHEN OTHERS.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI INPUT
----
FORM EXIT_PROGRAM *
----
FORM exit_program.
CALL METHOD G_CUSTOM_CONTAINER->FREE.
CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
**********************************************************************************
&----
*& Form create_field_cat
&----
text
----
--> p1 text
<-- p2 text
----
FORM create_field_cat .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'YHR_Q4_STR' "STRUCTRE NAME
CHANGING
ct_fieldcat = ct_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
LOOP AT ct_fieldcat INTO wa_fieldcat.
MOVE-CORRESPONDING wa_fieldcat TO wa_fcat.
CASE wa_fieldcat-fieldname.
WHEN 'OBJID'.
wa_fcat-coltext = text-001.
wa_fcat-outputlen = 9.
WHEN 'STEXT'.
wa_fcat-coltext = text-002.
wa_fcat-outputlen = 15.
WHEN 'YYOBJID_TXT'.
wa_fcat-coltext = text-004.
wa_fcat-outputlen = 30.
WHEN 'STEXT2'.
wa_fcat-coltext = text-003.
wa_fcat-outputlen = 11.
WHEN 'YYQUOTA'.
wa_fcat-fieldname ='YYQUOTA'.
wa_fcat-coltext = text-006.
wa_fcat-datatype ='NUMC'.
wa_fcat-outputlen = 5.
wa_fcat-no_zero = 'X'.
wa_fcat-do_sum = 'X'. " FOR AUTOMATIC SUM
wa_fcat-datatype = 'QUAN'. " FOR SUM WITH CHOOSE
WHEN 'UTIL'.
wa_fcat-coltext = text-007.
wa_fcat-outputlen = 9.
wa_fcat-no_zero = 'X'.
wa_fcat-do_sum = 'X'.
wa_fcat-no_zero = 'X'. "NO ZERO BEFORE THE NUMBER
wa_fcat-datatype = 'QUAN'.
WHEN 'REG'.
wa_fcat-coltext = text-009.
wa_fcat-outputlen = 6.
wa_fcat-do_sum = 'X'.
wa_fcat-no_zero = 'X'.
wa_fcat-datatype = 'QUAN'.
WHEN 'WAIT'.
wa_fcat-coltext = text-008.
wa_fcat-outputlen = 7.
wa_fcat-do_sum = 'X'.
wa_fcat-no_zero = 'X'.
wa_fcat-datatype = 'QUAN'.
WHEN 'KAPZ1'.
wa_fcat-coltext = text-010.
wa_fcat-outputlen = 15.
WHEN 'KAPZ2'.
wa_fcat-coltext = text-011.
wa_fcat-outputlen = 16.
WHEN 'KAPZ3'.
wa_fcat-coltext = text-012.
wa_fcat-outputlen = 15.
ENDCASE.
APPEND wa_fcat TO fcat.
CLEAR wa_fcat.
ENDLOOP.
ENDFORM. " create_field_cat
hallow i use an alv but i thihk its old becouse i cant do a<b> header</b> . use the alv from se83 alv grid.did someone have a ex. to new alv or how i can i do a header in my alv. thankes
this is the alv that i use thankes for your answers
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA:
gt_fieldcatalog TYPE lvc_t_fcat WITH HEADER LINE ,
is_stable TYPE lvc_s_stbl VALUE 'XX' ,
fcat TYPE lvc_t_fcat,
wa_fcat LIKE LINE OF fcat,
ct_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE LINE OF slis_t_fieldcat_alv,
g_save(1) TYPE c,
seltab TYPE TABLE OF rsparams WITH HEADER LINE,
table_header(23) TYPE c.
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
-
START-OF-SELECTION.
*===================
PERFORM get_data.
PERFORM create_field_cat.
CALL SCREEN 100.
END-OF-SELECTION.
*===================
-
&----
*& Module PBO OUTPUT
&----
text
----
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'YHR_Q4_STR'
CHANGING
it_outtab = itab
it_fieldcatalog = fcat. " FOR FIELD CATALOG
ENDIF.
ENDMODULE. " PBO OUTPUT
&----
*& Module PAI INPUT
&----
text
----
MODULE pai INPUT.
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0. "FOR LEAVE THE SCREEN TO THE SCREEN BEFORE
PERFORM exit_program.
WHEN OTHERS.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI INPUT
----
FORM EXIT_PROGRAM *
----
FORM exit_program.
CALL METHOD G_CUSTOM_CONTAINER->FREE.
CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
**********************************************************************************
&----
*& Form create_field_cat
&----
text
----
--> p1 text
<-- p2 text
----
FORM create_field_cat .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'YHR_Q4_STR' "STRUCTRE NAME
CHANGING
ct_fieldcat = ct_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
LOOP AT ct_fieldcat INTO wa_fieldcat.
MOVE-CORRESPONDING wa_fieldcat TO wa_fcat.
CASE wa_fieldcat-fieldname.
WHEN 'OBJID'.
wa_fcat-coltext = text-001.
wa_fcat-outputlen = 9.
WHEN 'STEXT'.
wa_fcat-coltext = text-002.
wa_fcat-outputlen = 15.
WHEN 'YYOBJID_TXT'.
wa_fcat-coltext = text-004.
wa_fcat-outputlen = 30.
WHEN 'STEXT2'.
wa_fcat-coltext = text-003.
wa_fcat-outputlen = 11.
WHEN 'YYQUOTA'.
wa_fcat-fieldname ='YYQUOTA'.
wa_fcat-coltext = text-006.
wa_fcat-datatype ='NUMC'.
wa_fcat-outputlen = 5.
wa_fcat-no_zero = 'X'.
wa_fcat-do_sum = 'X'. " FOR AUTOMATIC SUM
wa_fcat-datatype = 'QUAN'. " FOR SUM WITH CHOOSE
WHEN 'UTIL'.
wa_fcat-coltext = text-007.
wa_fcat-outputlen = 9.
wa_fcat-no_zero = 'X'.
wa_fcat-do_sum = 'X'.
wa_fcat-no_zero = 'X'. "NO ZERO BEFORE THE NUMBER
wa_fcat-datatype = 'QUAN'.
WHEN 'REG'.
wa_fcat-coltext = text-009.
wa_fcat-outputlen = 6.
wa_fcat-do_sum = 'X'.
wa_fcat-no_zero = 'X'.
wa_fcat-datatype = 'QUAN'.
WHEN 'WAIT'.
wa_fcat-coltext = text-008.
wa_fcat-outputlen = 7.
wa_fcat-do_sum = 'X'.
wa_fcat-no_zero = 'X'.
wa_fcat-datatype = 'QUAN'.
WHEN 'KAPZ1'.
wa_fcat-coltext = text-010.
wa_fcat-outputlen = 15.
WHEN 'KAPZ2'.
wa_fcat-coltext = text-011.
wa_fcat-outputlen = 16.
WHEN 'KAPZ3'.
wa_fcat-coltext = text-012.
wa_fcat-outputlen = 15.
ENDCASE.
APPEND wa_fcat TO fcat.
CLEAR wa_fcat.
ENDLOOP.
ENDFORM. " create_field_cat
2006 Dec 11 1:59 PM
have a look at this
*&---------------------------------------------------------------------*
*& Report Y_TOP_PAGE *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT y_top_page .
TABLES : mara.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
END OF it_mara.
*layout
DATA: wa_layout TYPE SLIS_LAYOUT_ALV.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.
START-OF-SELECTION.
SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
I_INTERNAL_TABNAME = 'IT_MARA'
* i_structure_name = 'IT_MARA'
* I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = w_repid
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = it_fieldcat_wrt_off[]
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.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = wa_layout
it_fieldcat = it_fieldcat_wrt_off
TABLES
t_outtab = it_mara
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.
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'CHANDU REPORT'.
APPEND wa_header TO t_header.
CLEAR wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
APPEND wa_header TO t_header.
CLEAR: wa_header.
* Total No. of Records Selected
* describe table it_ekko lines ld_lines.
* ld_linesc = ld_lines.
* concatenate 'Total No. of Records Selected: ' ld_linesc
* into t_line separated by space.
* wa_header-typ = 'A'.
* wa_header-info = t_line.
* append wa_header to t_header.
* clear: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
ENDFORM. "top-of-page
2006 Dec 11 2:01 PM
Hi Antonio,
You can use the below code.
DATA: X_EVENTS TYPE SLIS_ALV_EVENT,
IT_EVENTS TYPE TYPE SLIS_T_EVENT.
X_EVENTS-NAME = 'TOP_OF_LIST'.
X_EVENTS-FORM = 'TOP_OF_LIST'.
APPEND X_EVENTS TO IT_EVENTS.
FORM TOP_OF_LIST.
*- Here you can write the header part.
ENDFORM. "TOP_OF_LIST
Pass IT_EVENTS internal table to your GRID display FM.
Thanks,
Sreekanth
<i>* Please reward if it helps you ;)</i>
2006 Dec 11 2:54 PM
Hi antonio,
the problem here is the statement :
'move-corresponding wa_fieldcat to wa_fcat' .
Declare wa_fieldcat and ct_fieldcat similar to wa_fcat and it_fcat respectively.
and use the fn module <b>'LVC_FIELDCATALOG_MERGE'</b> instead of 'REUSE_ALV_FIELDCATALOG_MERGE'.
Regards,
Vidya.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |