Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Grid Events not calling

karthikk6734
Explorer
0 Kudos
762

Hi Everyone,

I tried to create a report that output using ALV grid (FM : REUSE_ALV_GRID_DISPLAY). When I tried to add TOP_OF_PAGE and PF_STATUS Events in the FM I followed below two approaches.

  1. Directly give it in the export parameter like i_callback_top_of_page = 'top_of_page'
  2. Added the events in Internal Table and passed as a exporting parameter it_events = lt_events

In Both the cases I'm not getting the output (please check the below image). PF Status consists of two buttons on application toolbar but in the output screen it brings out the same buttons from the selection screen.

Also for the top of page only the container is displaying, there is also no data.

If someone could help, please. I'll attach the code below FYR.

*&---------------------------------------------------------------------*
*& Report ZPRG_SALES_ORDER
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report zprg_sales_order.

include zdata_sales_order. "Data declarations

include zsel_sales_order. "selection screen

at selection-screen.
call function 'ZFM_SALES_ORDER'
exporting
s_erdat = so_erdat[]
s_ernam = so_ernam[]
importing
lt_output = lt_output
exceptions
no_sales = 1
no_item = 2
others = 3.

if sy-subrc <> 0.
case sy-subrc.
when 1.
message i001(zmsg_salesord).
when 2.
message i002(zmsg_salesord).
endcase.
else.
perform fieldcatelog_gen using '1' 'VBELN' text-001 changing lt_fieldcat.

perform fieldcatelog_gen using '2' 'POSNR' text-002 changing lt_fieldcat.

perform fieldcatelog_gen using '3' 'MATNR' text-003 changing lt_fieldcat.

perform fieldcatelog_gen using '4' 'MAKTX' text-004 changing lt_fieldcat.

perform fieldcatelog_gen using '5' 'KWMENG' text-005 changing lt_fieldcat.

perform fieldcatelog_gen using '6' 'VRKME' text-006 changing lt_fieldcat.

perform build_eventcat using lt_events.

call function 'REUSE_ALV_GRID_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = 'SY-REPID'
* i_callback_pf_status_set = 'PF_STATUS'
* I_CALLBACK_USER_COMMAND = ' '
* i_callback_top_of_page = 'top_of_page'
* I_CALLBACK_HTML_TOP_OF_PAGE = ''
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = lt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
it_events = lt_events
* IT_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
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = lt_output
exceptions
program_error = 1
others = 2.

endif.

*&---------------------------------------------------------------------*
*& Form FIELDCATELOG_GEN
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_ text
* -->P_ text
* -->P_TEXT_001 text
* <--P_LT_FIELDCAT text
*&---------------------------------------------------------------------*
form fieldcatelog_gen using value(p_col) type string
value(p_field) type string
p_text_001 type string
changing p_lt_fieldcat type slis_t_fieldcat_alv.

wa_fieldcat-col_pos = p_col.
wa_fieldcat-fieldname = p_field.
wa_fieldcat-seltext_l = p_text_001.
append wa_fieldcat to p_lt_fieldcat.
clear : wa_fieldcat.

endform.

form top_of_page.
data : lt_list_com type slis_t_listheader,
wa_list_com type slis_listheader.

wa_list_com-typ = 'H'.
wa_list_com-info = text-007.
append wa_list_com to lt_list_com.
clear : wa_list_com.


if so_erdat-low is not initial and so_erdat-high is initial.
perform convert_date using so_erdat-low changing lv_start.
wa_list_com-typ = 'S'.
wa_list_com-key = text-008.
wa_list_com-info = lv_start.
append wa_list_com to lt_list_com.
clear : wa_list_com.
elseif so_erdat-low is not initial and so_erdat-high is not initial.
perform convert_date using so_erdat-low changing lv_start.
perform convert_date using so_erdat-high changing lv_end.
wa_list_com-typ = 'S'.
wa_list_com-key = text-008.
concatenate lv_start ' ' text-010 ' ' lv_end into wa_list_com-info separated by space.
append wa_list_com to lt_list_com.
clear : wa_list_com.
endif.

if so_ernam is not initial.
wa_list_com-typ = 'S'.
wa_list_com-key = text-009.
wa_list_com-info = so_ernam-low.
append wa_list_com to lt_list_com.
clear : wa_list_com.
endif.

wa_list_com-typ = 'A'.
wa_list_com-info = text-011.
append wa_list_com to lt_list_com.
clear : wa_list_com.

call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = lt_list_com.

endform.

form convert_date using p_date changing p_outdate.
concatenate p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) into p_outdate.
endform.

form pf_status using rt_extab type slis_t_extab.
set pf-status 'SALES'.
endform.

form build_eventcat using pt_events type slis_t_event.

data : l_c_top type string value 'top_of_page'.

data : l_events type slis_alv_event.


call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = pt_events.

* This is for the top of the page event
read table pt_events into l_events
with key name = slis_ev_top_of_page.

if sy-subrc = 0.
move l_c_top to l_events-form.
* To establish interface for the form.
modify pt_events from l_events index sy-tabix.
endif.

clear : l_c_top.
l_c_top = 'PF_STATUS'.

read table pt_events into l_events
with key name = slis_ev_pf_status_set.

if sy-subrc = 0.
move l_c_top to l_events-form.
* To establish interface for the form.
modify pt_events from l_events index sy-tabix.
endif.


endform.
1 ACCEPTED SOLUTION

thilakan_t
Participant
0 Kudos
679

It is necessary to pass correct values to the FM parameters. There are many blogs available for REUSE_ALV_GRID_DISPLAY. Please search/refer it before posting question.

        i_callback_program       = 'SY-REPID'     "should not hard code SY-REPID. it is a variable. just mention as sy-repid
* i_callback_pf_status_set = 'PF_STATUS' "it looks fine. uncomment the line
* i_callback_top_of_page = 'top_of_page' "should be in caps('TOP_OF_PAGE'). uncomment the line
9 REPLIES 9

matt
Active Contributor
679

I recommend you just switch to CL_SALV_TABLE. Much easier to use and anyway REUSE_ALV_GRID_DISPLAY is very old.

And not use FORM/PERFORM. They're essentially obsolete and shouldn't be used in new programs.

Sandra_Rossi
Active Contributor
679

Matthew +1

You should not display anything during AT SELECTION-SCREEN.

Try to understand the difference between AT SELECTION-SCREEN and START-OF-SELECTION. If it's not clear, please tell us what you understand and what is not clear.

karthikk6734
Explorer
0 Kudos
679

Sandra,

I put at selection screen for the data process fm(ZFM_SALES_ORDER) only, in that selection i have some errors need to be displayed so I put it under at selection. Is that something that causes the issue? I don't understand. if that's the case the whole output should not come right?

Sandra_Rossi
Active Contributor
0 Kudos
679

Your code is not immediately testable (only you can test it on your server), hence I can only deduce and propose general recommendations. It's fast at your side to test. A second thing you can quickly test is the SOS consistency check for ALV.

karthikk6734
Explorer
0 Kudos
679

Sandra,

I understand. I removed the selection screen events even though the output is same. Also, I've done the SOS consistency check but there is no inconsistency found in that.

Matthew/ Sandra if I can do these same events with cl_salv_table please suggest some sample program/documentation that could help with the implementation. I searched but I didn't find anything.

matt
Active Contributor
679

There are many many blogs about CL_SALV_TABLE. I suggest you search.

thilakan_t
Participant
0 Kudos
680

It is necessary to pass correct values to the FM parameters. There are many blogs available for REUSE_ALV_GRID_DISPLAY. Please search/refer it before posting question.

        i_callback_program       = 'SY-REPID'     "should not hard code SY-REPID. it is a variable. just mention as sy-repid
* i_callback_pf_status_set = 'PF_STATUS' "it looks fine. uncomment the line
* i_callback_top_of_page = 'top_of_page' "should be in caps('TOP_OF_PAGE'). uncomment the line

0 Kudos
679

Thank You! The sy-repid caused the problem.

Also, In my case, There is no need for handling each and every event using the seperate export parameter I used it_events parameter to export the events.

karthikk6734
Explorer
0 Kudos
679

Sure, Thank You!