Skip to Content
author's profile photo Former Member
Former Member

REUSE_ALV_COMMENTARY_WRITE

hey dont mind for pasting this much long code check the output nothing is printed on top of page plz check the error and let me know its urgent.

REPORT Z_ALV_DEMO_1 .

TYPE-POOLS: slis.

  • DB-Table

TABLES sflight.

  • Includes

INCLUDE <icon>.

INCLUDE <symbol>.

*

CONSTANTS:

c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

DATA: i_fieldcat TYPE slis_t_fieldcat_alv,

i_layout TYPE slis_layout_alv,

i_sp_group TYPE slis_t_sp_group_alv,

i_events TYPE slis_t_event,

i_print TYPE slis_print_alv,

i_sort TYPE slis_t_sortinfo_alv.

*internal table for data to be displayed

DATA: BEGIN OF i_sflight OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA: box,

lights.

DATA: END OF i_sflight.

*

DATA: w_repid LIKE sy-repid.

DATA: i_list_top_of_page TYPE slis_t_listheader.

  • Report Selections

SELECT-OPTIONS s_carrid FOR sflight-carrid.

SELECT-OPTIONS s_connid FOR sflight-connid.

SELECT-OPTIONS s_fldate FOR sflight-fldate.

*SELECTION-SCREEN SKIP 1.

  • Parameters

PARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selection

SELECTION-SCREEN SKIP 1.

  • Variant for ALV display

SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.

PARAMETERS: p_varnt LIKE disvariant-variant.

SELECTION-SCREEN END OF BLOCK 0.

  • Layout of the report display

SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.

PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ', "Striped pattern

p_nocolh AS CHECKBOX DEFAULT ' ', "No column heading

p_novlin AS CHECKBOX DEFAULT ' ', "No vertical lines

p_colopt AS CHECKBOX DEFAULT ' ', "Optimizes col. wd

p_keyhot AS CHECKBOX DEFAULT ' ', "Key fields hot

p_noinpt AS CHECKBOX DEFAULT ' '. "No field for input

SELECTION-SCREEN END OF BLOCK a.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.

PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',

p_lightc AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK b.

SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.

PARAMETERS: 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-004.

PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',

p_detpop AS CHECKBOX DEFAULT 'X',

p_groupb AS CHECKBOX DEFAULT ' ',

p_groups AS CHECKBOX DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK d.

SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.

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: w_boxnam TYPE slis_fieldname VALUE 'BOX',

w_f2code LIKE sy-ucomm VALUE '&ETA',

w_lignam TYPE slis_fieldname VALUE 'LIGHTS',

w_save(1) TYPE c,

w_default(1) TYPE c,

w_exit(1) TYPE c,

i_variant LIKE disvariant,

i_variant1 LIKE disvariant.

----


INITIALIZATION.

w_repid = sy-repid.

PERFORM fieldcat_init USING i_fieldcat.

PERFORM eventtab_build USING i_events.

PERFORM comment_build USING i_list_top_of_page.

PERFORM sp_group_build USING i_sp_group.

PERFORM t_sort_build USING i_sort.

  • Set Options: save variant userspecific or general

  • 'A or 'U' are for user-specific variants list

  • 'X' or 'space' for general

w_save = 'A'.

PERFORM variant_init.

  • Get default variant

i_variant1 = i_variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = w_save

CHANGING

cs_variant = i_variant1

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_varnt = i_variant1-variant.

ENDIF.

  • Process on value request (list of possible variants)

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.

PERFORM f4_for_variant.

  • PAI

AT SELECTION-SCREEN.

PERFORM pai_of_selection_screen.

START-OF-SELECTION.

PERFORM selection.

END-OF-SELECTION.

PERFORM layout_build USING i_layout. "wg. Parameters

PERFORM print_build USING i_print. "wg. Parameters

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = w_repid

  • i_internal_tabname = 'I_SFLIGHT'

i_structure_name = 'SFLIGHT'

i_client_never_display = 'X'

i_inclname = w_repid

CHANGING

ct_fieldcat = i_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Call ABAP/4 List Viewer

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

i_callback_program = w_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

i_structure_name = 'SFLIGHT'

i_background_id = 'ALV_BACKGROUND'

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = i_layout

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

it_special_groups = i_sp_group[]

it_sort = i_sort[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = w_save

is_variant = i_variant

it_events = i_events[]

  • IT_EVENT_EXIT =

is_print = i_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 = i_sflight

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.

  • CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

  • EXPORTING

  • i_callback_program = w_repid

  • i_structure_name = 'SFLIGHT'

  • is_layout = i_layout

  • it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • it_special_groups = i_sp_group[]

  • it_sort = i_sort[]

    • IT_FILTER =

    • IS_SEL_HIDE =

    • i_default = W_DEFAULT

  • i_save = w_save

  • is_variant = i_variant

  • it_events = i_events[]

    • IT_EVENT_EXIT =

  • is_print = i_print

    • 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 =

  • TABLES

  • t_outtab = i_sflight.

  • ----


    • FORM FIELDCAT_INIT *

    ----


    • --> L_FIELDCAT *

    ----


    FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.

    DATA: ls_fieldcat TYPE slis_fieldcat_alv.

    *

    CLEAR ls_fieldcat.

    ls_fieldcat-fieldname = 'SEATSOCC'.

    *The field is not displayed in the initial output, can be interactively

    • chosen for display

    ls_fieldcat-no_out = 'X'.

    *This field is assigned to a special group with tech. key 'A' and can be

    *displayed using the special group buttons

    ls_fieldcat-sp_group = 'A'.

    *The field cannot be summed irrespective of its data type

    ls_fieldcat-no_sum = 'X'.

    APPEND ls_fieldcat TO l_fieldcat.

    *

    CLEAR ls_fieldcat.

    ls_fieldcat-fieldname = 'SEATSMAX'.

    ls_fieldcat-no_out = 'X'.

    ls_fieldcat-sp_group = 'A'.

    APPEND ls_fieldcat TO l_fieldcat.

    *

    CLEAR ls_fieldcat.

    ls_fieldcat-fieldname = 'PRICE'.

    ls_fieldcat-no_out = 'X'.

    ls_fieldcat-sp_group = 'B'.

    APPEND ls_fieldcat TO l_fieldcat.

    *

    CLEAR ls_fieldcat.

    ls_fieldcat-fieldname = 'CARRID'.

    ls_fieldcat-outputlen = 7.

    APPEND ls_fieldcat TO l_fieldcat.

    ENDFORM.

    ----


    • FORM DATA_ADD *

    ----


    • --> L_SFLIGHT

    ----


    FORM data_add TABLES l_sflight STRUCTURE i_sflight.

    LOOP AT l_sflight.

    IF sy-tabix > 10.

    l_sflight-box = 'X'.

    l_sflight-lights = '3'.

    ELSE.

    IF sy-tabix = 1.

    l_sflight-lights = '2'.

    ELSE.

    l_sflight-lights = '1'.

    ENDIF.

    ENDIF.

    MODIFY l_sflight.

    ENDLOOP.

    ENDFORM.

    ----


    • FORM EVENTTAB_BUILD *

    ----


    • --> l_EVENTS *

    ----


    FORM eventtab_build USING l_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 = l_events.

    READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.

    IF sy-subrc = 0.

    MOVE c_formname_top_of_page TO ls_event-form.

    APPEND ls_event TO l_events.

    ENDIF.

    ENDFORM.

    ----


    • FORM COMMENT_BUILD *

    ----


    • --> L_TOP_OF_PAGE *

    ----


    FORM comment_build USING l_top_of_page TYPE slis_t_listheader.

    DATA: ls_line TYPE slis_listheader.

    ***Header

    CLEAR ls_line.

    ls_line-typ = 'H'.

    • LS_LINE-KEY: not used for this type

    ls_line-info = 'Heading list'.

    APPEND ls_line TO l_top_of_page.

    ***Selection

    CLEAR ls_line.

    ls_line-typ = 'S'.

    ls_line-key = 'Key 1'.

    ls_line-info = 'Information'.

    APPEND ls_line TO l_top_of_page.

    ls_line-key = 'Key 2'.

    APPEND ls_line TO l_top_of_page.

    ***Action

    CLEAR ls_line.

    ls_line-typ = 'A'.

    • LS_LINE-KEY: not used for this type

    Ls_line-info = 'Status list'.

    APPEND ls_line TO l_top_of_page.

    ENDFORM.

    ----


    • FORM LAYOUT_BUILD *

    ----


    • <-> LS_LAYOUT *

    ----


    FORM layout_build USING ls_layout TYPE slis_layout_alv.

    ls_layout-f2code = w_f2code.

    ls_layout-zebra = p_zebra.

    ls_layout-colwidth_optimize = p_colopt.

    IF p_chkbox = 'X'.

    *Fieldname for check box on the report output

    ls_layout-box_fieldname = w_boxnam.

    ELSE.

    ls_layout-box_fieldname = space.

    ENDIF.

    ls_layout-no_input = p_noinpt.

    ls_layout-no_vline = p_novlin.

    ls_layout-no_colhead = p_nocolh.

    IF p_lights = 'X' OR p_lightc = 'X'.

    **Fieldname for lights on the report output

    ls_layout-lights_fieldname = w_lignam.

    ELSE.

    CLEAR ls_layout-lights_fieldname.

    ENDIF.

    ls_layout-lights_condense = p_lightc.

    ls_layout-totals_text = p_totext.

    ls_layout-subtotals_text = p_sttext.

    ls_layout-totals_only = p_totonl.

    ls_layout-key_hotspot = p_keyhot.

    ls_layout-detail_popup = p_detpop.

    ls_layout-group_change_edit = p_groups.

    • E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.

    • ls_layout-group_buttons = 'X'.

    ENDFORM.

    ----


    • FORM SP_GROUP_BUILD *

    ----


    • --> L_SP_GROUP *

    ----


    FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv.

    DATA: ls_sp_group TYPE slis_sp_group_alv.

    *Fields are assigned to the special group

    CLEAR ls_sp_group.

    ls_sp_group-sp_group = 'A'.

    ls_sp_group-text = 'Reservation status'.

    APPEND ls_sp_group TO l_sp_group.

    CLEAR ls_sp_group.

    ls_sp_group-sp_group = 'B'.

    ls_sp_group-text = 'Flight charges'.

    APPEND ls_sp_group TO l_sp_group.

    ENDFORM.

    ----


    • FORM SELECTION *

    ----


    FORM selection.

    SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight

    UP TO p_maxrow ROWS WHERE carrid IN s_carrid

    AND connid IN s_connid AND fldate IN s_fldate.

    PERFORM data_add TABLES i_sflight.

    ENDFORM.

    ----


    • FORM TOP_OF_PAGE *

    ----


    • ........ *

    ----


    FORM top_of_page.

    *

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    i_logo = 'ENJOYSAP_LOGO'

    it_list_commentary = i_list_top_of_page.

    ENDFORM.

    ----


    • FORM F4_FOR_VARIANT *

    ----


    FORM f4_for_variant.

    *

    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

    EXPORTING

    is_variant = i_variant

    i_save = w_save

    • it_default_fieldcat =

    IMPORTING

    e_exit = w_exit

    es_variant = i_variant1

    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 w_exit = space.

    p_varnt = i_variant1-variant.

    ENDIF.

    ENDIF.

    ENDFORM.

    &----


    *& Form PAI_OF_SELECTION_SCREEN

    &----


    • to check whether right variant is entered on the selection scr

    ----


    FORM pai_of_selection_screen.

    *

    IF NOT p_varnt IS INITIAL.

    MOVE i_variant TO i_variant1.

    MOVE p_varnt TO i_variant1-variant.

    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

    EXPORTING

    i_save = w_save

    CHANGING

    cs_variant = i_variant1.

    i_variant = i_variant1.

    ELSE.

    PERFORM variant_init.

    ENDIF.

    ENDFORM. " PAI_OF_SELECTION_SCREEN

    &----


    *& Form VARIANT_INIT

    ----


    FORM variant_init.

    *

    CLEAR i_variant.

    i_variant-report = w_repid.

    ENDFORM. " VARIANT_INIT

    ----


    • FORM PRINT_BUILD *

    ----


    • ........ *

    ----


    FORM print_build USING l_print TYPE slis_print_alv.

    *

    l_print-print = p_print.

    l_print-no_print_selinfos = p_nosinf.

    l_print-no_coverpage = p_nocove.

    l_print-no_new_page = p_nonewp.

    l_print-no_print_listinfos = p_nolinf.

    l_print-reserve_lines = p_reserv.

    l_print-print = p_print.

    ENDFORM.

    ----


    • FORM T_SORT_BUILD *

    ----


    FORM t_sort_build USING l_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 l_sort.

    ENDFORM.

    definitely u will get points.

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    6 Answers

    • Best Answer
      author's profile photo Former Member
      Former Member
      Posted on Dec 11, 2006 at 12:05 PM

      I executed ur code the out which i got is

      Heading list

      Key 1 Information

      Key 2 Information

      Status list

      On left side & SAPlogo on right side

      i didnt get any error.May i know wats ur requirement

      Add a comment
      10|10000 characters needed characters exceeded

    • author's profile photo Former Member
      Former Member
      Posted on Dec 11, 2006 at 01:57 PM

      Hi...

      Just go through this.It will work.

      In ur code u have not passed I_CALLBACK_TOP_OF_PGAE in ALV grid Display.

      Pass The form name i.e., 'comment_build' to that variable in ALV_GRID_DISPLAY function module.

      Regards,

      Srinivas

      Add a comment
      10|10000 characters needed characters exceeded

    • Posted on Dec 11, 2006 at 12:00 PM

      Hi,

      Heading are coming on the top of page for this code.

      Change the values in this part of code for custom heading data.

      <b>

      FORM comment_build USING l_top_of_page TYPE slis_t_listheader.

      DATA: ls_line TYPE slis_listheader.

      ***Header

      CLEAR ls_line.

      ls_line-typ = 'H'.

      • LS_LINE-KEY: not used for this type

      ls_line-info = 'Heading list'.

      APPEND ls_line TO l_top_of_page.

      ***Selection

      CLEAR ls_line.

      ls_line-typ = 'S'.

      ls_line-key = 'Key 1'.

      ls_line-info = 'Information'.

      APPEND ls_line TO l_top_of_page.

      ls_line-key = 'Key 2'.

      APPEND ls_line TO l_top_of_page.

      ***Action

      CLEAR ls_line.

      ls_line-typ = 'A'.

      • LS_LINE-KEY: not used for this type

      Ls_line-info = 'Status list'.

      APPEND ls_line TO l_top_of_page.

      ENDFORM.

      </b>

      Regards,

      Amit

      What heading you are looking for here, as this is a sample code and the data is getting displayed.

      If you want to make any changes in them then just change the constant values in the above code.

      Message was edited by:

      Amit Khare

      Add a comment
      10|10000 characters needed characters exceeded

    • author's profile photo Former Member
      Former Member
      Posted on Dec 11, 2006 at 12:04 PM

      Hello Ravi,

      I am getting the header for the same program.

      Run it agian.

      Vasanth

      Add a comment
      10|10000 characters needed characters exceeded

    • author's profile photo Former Member
      Former Member
      Posted on Dec 11, 2006 at 12:10 PM

      Hi Ravi,

      Seems we are able to execute your Program and Top of Page is getting displayed.

      If its not Displayed in your system, then might be some <b>issue with the WINDOWs or Operating system.</b>Some patch has to be applied. Let me find that.....

      Anyway Check if you <b>Print the Report</b> and able to see TOP OF PAGE content.

      Hope this helps.

      Manish

      Add a comment
      10|10000 characters needed characters exceeded

    • author's profile photo Former Member
      Former Member
      Posted on Dec 12, 2006 at 11:45 AM

      I got the solution

      Add a comment
      10|10000 characters needed characters exceeded

      • Former Member

        Hi Ravi,

        I got the same problem.Everything looks fine in both REUSE_ALV_COMMENTARY_WRITE and Grid display FM.But still Iam able to find the header of TOP OF PAGE in the output of Grid display.

        Would be great if you can send how did u solve it.

        Thanks in advance.

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.