2006 May 30 8:58 AM
Hi,
How to make the F3 function key (go back to previous screen) work in this ALV program?
Thanks,
Helen
REPORT z_pgm.
TYPE-POOLS : slis.
INITIALIZATION.
PERFORM sub_fieldcat_init CHANGING gi_fieldcat.
PERFORM sub_eventtab_build USING gi_events[].
PERFORM sub_event_exit_build CHANGING gi_event_exit.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_xvariant
EXCEPTIONS
not_found = 2.
**********************************************************
*EVENT : AT SELECTION-SCREEN OUTPUT *
**********************************************************
AT SELECTION-SCREEN OUTPUT.
*********************************************************
EVENT : START-OF-SELECTION
********************************************************
START-OF-SELECTION.
PERFORM sub_comment_build USING gi_list_top_of_page.
PERFORM sub_get_data.
*********************************************************
EVENT : END-OF-SELECTION
**********************************************************
END-OF-SELECTION.
IF l_error IS INITIAL.
PERFORM sub_grid_display USING gi_adrc_disp.
ENDIF.
*&----
-
*& Form sub_fieldcat_init
*&----
-
FORM sub_fieldcat_init CHANGING li_fieldcat LIKE gi_fieldcat[]."#EC *
DATA : lw_fieldcat TYPE slis_fieldcat_alv.
REFRESH gi_fieldcat[].
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'SELKZ'.
lw_fieldcat-tabname = 'gi_adrc_disp'.
lw_fieldcat-hotspot = 'X'.
lw_fieldcat-outputlen = '8'.
APPEND lw_fieldcat TO li_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'LOCATION'.
lw_fieldcat-tabname = 'gi_adrc_disp'.
lw_fieldcat-seltext_s = text-002.
lw_fieldcat-seltext_m = text-002.
lw_fieldcat-seltext_l = text-002.
lw_fieldcat-outputlen = '20'.
APPEND lw_fieldcat TO li_fieldcat.
ENDFORM. " sub_fieldcat_init
*&----
-
*& Form SUB_EVENTTAB_BUILD
*&----
-
FORM sub_eventtab_build USING li_events TYPE slis_t_event.
DATA: lw_event TYPE slis_alv_event.
*to call top_of_page event
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = li_events.
READ TABLE li_events WITH KEY name = slis_ev_top_of_page
INTO lw_event.
IF sy-subrc = 0.
MOVE c_formname_top_of_page TO lw_event-form.
APPEND lw_event TO li_events.
ENDIF.
ENDFORM. " SUB_EVENTTAB_BUILD
*----
-
FORM SUB_COMMENT_BUILD *
*----
-
FORM sub_comment_build USING li_lt_top_of_page TYPE slis_t_listheader.
DATA: lw_line TYPE slis_listheader.
Listenüberschrift: Typ H
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = text-013.
APPEND lw_line TO li_lt_top_of_page.
Kopfinfo: Typ S
CLEAR lw_line.
lw_line-typ = 'S'.
lw_line-key = text-014.
lw_line-info = text-015.
APPEND lw_line TO li_lt_top_of_page.
ENDFORM. "SUB_COMMENT_BUILD
*&----
-
*& Form sub_VARIANT_INIT
*&----
-
FORM sub_variant_init .
CLEAR g_variant.
g_variant-report = g_repid.
ENDFORM. " sub_VARIANT_INIT
*&----
-
*& Form SUB_F4_FOR_VARIANT
*&----
-
To get the existing variant
*----
-
FORM sub_f4_for_variant .
g_variant-report = g_repid.
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 = g_xvariant
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.
ENDIF.
ENDFORM. " SUB_F4_FOR_VARIANT
*----
FORM TOP_OF_PAGE
*----
-
FORM top_of_page. "#EC CALLED
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gi_list_top_of_page.
ENDFORM. "TOP_OF_PAGE
FORM sub_grid_display USING li_final_disp LIKE gi_final_disp.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' "#EC *
EXPORTING
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_program = g_repid
i_callback_user_command = 'SUB_CB_USER_COMMAND'
i_grid_title = l_title
it_fieldcat = gi_fieldcat
is_layout = gw_layout
i_save = g_save
is_variant = g_variant
it_events = gi_events[]
it_event_exit = gi_event_exit[]
IMPORTING
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = gs_exit_caused_by_user
TABLES
t_outtab = gi_adrc_disp
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " sub_grid_display
*&----
-
*& Form *
*&----
-
FORM sub_get_data .
CLEAR l_error.
IF NOT rb_loc IS INITIAL.
IF p_loc EQ space.
MESSAGE i100(zm01) WITH
'Please Enter Location Code and SET ID'.
l_error = 'X'.
ENDIF.
SELECT addrnumber location name1 name2 building floor
name_co country street str_suppl1 str_suppl3 city1
city2 region post_code1 transpzone
INTO TABLE gi_adrc_disp
FROM adrc
WHERE region = p_region
AND str_suppl3 = p_loc.
ELSEIF NOT rb_all IS INITIAL.
SELECT addrnumber location name1 name2 building floor
name_co country street str_suppl1 str_suppl3 city1
city2 region post_code1 transpzone
INTO TABLE gi_adrc_disp
FROM adrc
WHERE transpzone NE space.
ENDIF.
IF sy-subrc NE 0.
l_error = 'X'.
MESSAGE i100(zm01) WITH
'No Record Exists for Input'.
EXIT.
ENDIF.
lw_adrc-selkz = c_add.
MODIFY gi_adrc_disp FROM lw_adrc TRANSPORTING selkz
WHERE transpzone = space.
lw_adrc-selkz = c_remove.
MODIFY gi_adrc_disp FROM lw_adrc TRANSPORTING selkz
WHERE transpzone NE space.
ENDFORM. " sub_get_data
*&----
-
*& Form sub_cb_user_command
*&----
-
FORM sub_cb_user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
l_index = rs_selfield-tabindex.
ENDFORM. "sub_cb_user_command
*&----
-
*& Form sub_cb_user_command
*&----
-
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'MAIN'.
ENDFORM. "set_pf_status
2006 May 30 9:14 AM
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'MAIN'.
ENDFORM. "set_pf_status
the above means you are using you own status. If you really need it make sure it is copied from the satndard one properly. Look at STANDARD status of function group SALV.
If you don't need a special one, remove the I_CALLBACK_PF_STATUS_SET value.
2006 May 30 9:14 AM
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'MAIN'.
ENDFORM. "set_pf_status
the above means you are using you own status. If you really need it make sure it is copied from the satndard one properly. Look at STANDARD status of function group SALV.
If you don't need a special one, remove the I_CALLBACK_PF_STATUS_SET value.
2006 May 30 9:31 AM
Hi,
this is for setting the PF-status.
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'MAIN'.
ENDFORM. "set_pf_statusand double click on main and see what is the Function key and function code associated for BACK.
FORM sub_cb_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when <b>'BACK'.</b> <<<<i assumed Focde is BACK for BACK
leave to screen 0.
endform.Regards
vijay
2006 May 30 9:47 AM
you will not be able to handle pf3 as Vijay suggests. It is more complex than that for exit commands. You need to put an entry in the event_exit table -IT_EVENT_EXIT.
2006 May 30 10:05 AM
2006 May 30 9:31 AM
Hi helen,
1. Copy the STANDARD gui status
from SALV Function Group
thru SE80,
by right-clicking on the same.
2. Then use it in your program,
after modifying,
and after ACTIVATING the gui status.
regards,
amit m
2006 May 30 10:16 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |