10-18-2012 5:35 PM
Hi All,
I have a internal table with all the required values for f4 help. Can anybody tell me how to assign a custom F4 Help using my internal table values in alv grid editable field output.I am using normal ABAP (REUSE_ALV_GRID_DISPLAY).
I am doing as below.
TYPES: BEGIN OF TY_F4,
MATNR TYPE MARA-MATNR,
END OF TY_F4.
DATA: IT_F4 TYPE STANDARD TABLE OF TY_F4,
WA_F4 TYPE TY_F4.
SELECT MATNR FROM MARA INTO TABLE IT_F4.
IF SY-SUBRC = 0.
SELECT ZMATNR FROM ZMARA APPENDING TABLE IT_F4. "ZMARA is a custom table which has some more material numbers.
These materials are not present in MARA.
ENDIF.
FIELDCAT-FIELDNAME = 'MATNR'.
FIELDCAT-REF_TABNAME = 'IT_F4'.
FIELDCAT-REF_FIELDNAME = 'MATNR'.
FIELDCAT-EDIT = GC_X.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR: FIELDCAT.
Here my internal table has all the required fields. But, I am stuck in crating a F4 help using this internal table on the ALV grid editable field.
Please help.
Thanks,
Nani.
10-18-2012 5:43 PM
10-18-2012 5:51 PM
Hi Max,
Thanks for the reply. I need F4 help on the ouput of ALV grid for one of the column.
Like say for example:
My output in ALV grid is:
MATNR (which is editable column) -----> Here I need F4 nelp and when I click on F4 help I need my entries in internal table IT_F4 to be displayed.
10-18-2012 5:58 PM
Ok
the problem is a F4 custom has to be managed by the event ONF4, this event is not directly supported by the fm REUSE_ALV_GRID_DISPLAY.
So you need to catch the instance in order to do it by fm GET_GLOBALS_FROM_SLVC_FULLSCR, you can call it in an event called once (just like TOP-OF-LIST or TOP-OF-PAGE
Max
10-18-2012 6:11 PM
Thanks again for the reply Max. Do you have a sample code to achieve this using GET_GLOBALS_FROM_SLVC_FULLSCR. I tried different ways and lost hope on achieving this. Can you please guide me how to do this?
Right now in my program I am using top of page and User command events through FM.
Thanks,
Nani.
10-18-2012 5:45 PM
10-18-2012 5:56 PM
Hi Maria,
Thanks for the reply. I am using normal abap with Function modules and my fielcatalog does not have f4availabl. It is giving me error when I try to use this.
10-18-2012 6:34 PM
Hi
This is a piece of code of my report:
CLASS lcl_event_receiver DEFINITION DEFERRED.
.........
DATA: l_receiver TYPE REF TO lcl_event_receiver.
.................
* Class Definition
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS onf4
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname
e_fieldvalue
es_row_no
er_event_data.
ENDCLASS.
* Class Implementation
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD onf4.
DATA return_tab TYPE STANDARD TABLE OF ddshretval.
DATA return_w TYPE ddshretval.
DATA l_new_val TYPE lvc_s_modi.
DATA: pop_grid TYPE REF TO cl_gui_alv_grid.
DATA: characteristics TYPE STANDARD TABLE OF bapi_char,
char_values TYPE STANDARD TABLE OF bapi_char_values.
DATA: characteristic TYPE bapi_char,
char_value TYPE bapi_char_values.
DATA: l_value TYPE text30,
t_value_tab LIKE STANDARD TABLE OF l_value.
DATA: field_w TYPE dfies,
field_tab TYPE STANDARD TABLE OF dfies.
DATA: l_f4_ko TYPE flag.
FIELD-SYMBOLS: <fs_data> TYPE ANY TABLE.
READ TABLE t_class INTO t_class INDEX es_row_no-row_id.
CALL FUNCTION 'BAPI_CLASS_GET_CHARACTERISTICS'
EXPORTING
classnum = t_class-classnum
classtype = classtype
TABLES
characteristics = characteristics
char_values = char_values.
* Get values
READ TABLE characteristics INTO characteristic
WITH KEY name_char = t_class-charact.
LOOP AT char_values INTO char_value
WHERE name_char = characteristic-name_char.
l_value = char_value-char_value.
APPEND l_value TO t_value_tab.
l_value = char_value-descr_cval.
APPEND l_value TO t_value_tab.
ENDLOOP.
IF sy-subrc = 0.
field_w-tabname = 'CAWN'.
field_w-fieldname = 'ATWRT'.
APPEND field_w TO field_tab.
field_w-tabname = 'CAWNT'.
field_w-fieldname = 'ATWTB'.
APPEND field_w TO field_tab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ATWRT'
IMPORTING
user_reset = l_f4_ko
TABLES
value_tab = t_value_tab
field_tab = field_tab
return_tab = return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
l_f4_ko = 'X'.
ENDIF.
ELSE.
CASE characteristic-object_table.
WHEN 'MARA'.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = 'MARA'
fieldname = 'MATNR'
searchhelp = 'MAT1'
IMPORTING
user_reset = l_f4_ko
TABLES
return_tab = return_tab
EXCEPTIONS
field_not_found = 1
no_help_for_field = 2
inconsistent_help = 3
no_values_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
l_f4_ko = 'X'.
ENDIF.
WHEN OTHERS.
l_f4_ko = 'X'.
ENDCASE.
ENDIF.
IF l_f4_ko IS NOT INITIAL.
EXIT.
ENDIF.
READ TABLE return_tab INTO return_w INDEX 1.
CHECK sy-subrc = 0.
ASSIGN er_event_data->m_data->* TO <fs_data>.
l_new_val-row_id = es_row_no-row_id.
l_new_val-sub_row_id = es_row_no-sub_row_id.
l_new_val-fieldname = e_fieldname.
MOVE return_w-fieldval TO: t_class-value, l_new_val-value.
INSERT l_new_val INTO TABLE <fs_data>.
MODIFY t_class FROM t_class INDEX es_row_no-row_id.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = pop_grid.
*
pop_grid->refresh_table_display( ).
ENDMETHOD. "ONF4
ENDCLASS.
* Call grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = is_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = is_layout
it_fieldcat = it_fcat
TABLES
t_outtab = t_output.
* Form for PF-Status: here I set the event for F4
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
DATA: my_grid TYPE REF TO cl_gui_alv_grid.
DATA: ls_extab TYPE slis_extab.
DATA: lit_f4 TYPE lvc_t_f4,
lw_f4 TYPE lvc_s_f4.
IF fl_popup IS INITIAL.
SET PF-STATUS 'MY_ALV' EXCLUDING rt_extab.
ELSE.
SET PF-STATUS 'MY_POPUP' EXCLUDING rt_extab.
ENDIF.
CHECK fl_popup = 'X'.
CHECK l_receiver IS INITIAL.
lw_f4-fieldname = 'VALUE'.
lw_f4-register = 'X'.
APPEND lw_f4 TO lit_f4.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = my_grid.
CALL METHOD pop_grid->register_f4_for_fields
EXPORTING
it_f4 = lit_f4.
CREATE OBJECT l_receiver.
SET HANDLER l_receiver->onf4 FOR my_grid.
ENDFORM. "set_pf_status
of course you need to replace the code for implemantation
Max
04-17-2021 12:31 PM
Hi in the above code "t_class" types is missing and could you please tell me how it is actually filling because above the READ TABLE t_class INTO t_class INDEX es_row_no-row_id , it is not filling in this code. could you please tell us!!!!
Thanks for knowledge sharing!!