12-27-2006 7:40 AM
Hi
I want to create custom F4 help on one of fields of ALV List.
Can you please let me know the procedure if possible with sample code.
Your co-operation will be highly appreciable.
Regards,
Kumar
12-27-2006 8:30 AM
hI SREE RAM,
CHECK OUT THIS EXAMPLE CODING.
Program name:BCALV_GRID_EDIT_DELTA
12-27-2006 7:53 AM
HI,
check the example program below in se38.
<b>BCALV_GRID_F4_HELP</b>
12-27-2006 8:08 AM
Hi,
I got it from SDN.Check this.
Global data definitions for ALV.......................................
DATA : alvgrid TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container,
fieldcatalog TYPE lvc_t_fcat.
table to contain fields that require f4...............................
DATA : lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
ok_code declaration...................................................
DATA : ok_code TYPE sy-ucomm.
Tables declaration....................................................
TABLES : zaemp.
Types declaration.....................................................
TYPES : BEGIN OF ty_emp,
code LIKE zaemp-code,
designation LIKE zaemp-designation,
END OF ty_emp.
Internal table declaration............................................
DATA : i_emp TYPE TABLE OF ty_emp.
Workarea declaration..................................................
DATA : wa_emp TYPE ty_emp.
Selection screen parameters...........................................
SELECT-OPTIONS : s_code FOR zaemp-code.
----
CLASS lcl_event_handler DEFINITION
----
........ *
----
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS :
handle_on_f1 FOR EVENT onf1 OF cl_gui_alv_grid
IMPORTING e_fieldname es_row_no er_event_data,
handle_on_f4 for event onf4 of cl_gui_alv_grid
importing e_fieldname es_row_no er_event_data
.
ENDCLASS.
----
CLASS lcl_event_handler IMPLEMENTATION
----
........ *
----
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_on_f1.
custom f1 help for code field.......................................
IF e_fieldname = 'code'.
CALL SCREEN 3001.
ENDIF.
to prevent processing of standard f1 help............................
er_event_data->m_event_handled = 'X'.
ENDMETHOD.
Method handle_on_f4.
standard f4 help will be invoked......................................
endmethod.
ENDCLASS.
start of selection....................................................
START-OF-SELECTION.
SELECT code designation FROM zaemp
INTO CORRESPONDING FIELDS OF TABLE i_emp
WHERE code IN s_code.
CALL SCREEN 3000.
&----
*& Module STATUS_3000 OUTPUT
&----
text
----
MODULE status_3000 OUTPUT.
SET PF-STATUS 'ZTOOL'.
SET TITLEBAR 'ZTITLE'.
IF alvgrid IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = 'ZCONTAINER'.
CREATE OBJECT alvgrid
EXPORTING
i_parent = custom_container.
PERFORM prepare_f4.
CALL METHOD alvgrid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[]
.
creating instance for event handler..................................
DATA : event_handler TYPE REF TO lcl_event_handler.
CREATE OBJECT event_handler.
SET HANDLER event_handler->handle_on_f1 FOR alvgrid.
SET HANDLER event_handler->handle_on_f4 FOR alvgrid.
preparing field catalog..............................................
PERFORM prepare_fieldcatalog CHANGING fieldcatalog.
CALL METHOD alvgrid->set_table_for_first_display
EXPORTING
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = i_emp
it_fieldcatalog = fieldcatalog
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_3000 OUTPUT
preparing field catalog...............................................
FORM prepare_fieldcatalog CHANGING i_fieldcatalog TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'code'.
ls_fcat-ref_table = 'zaemp'.
ls_fcat-coltext = 'EMPLOYEE ID'.
APPEND ls_fcat TO i_fieldcatalog.
CLEAR ls_fcat.
ls_fcat-fieldname = 'designation'.
ls_fcat-ref_table = 'zaemp'.
ls_fcat-coltext = 'EMPLOYEE NAME'.
APPEND ls_fcat TO i_fieldcatalog.
ENDFORM.
&----
*& Module USER_COMMAND_3000 INPUT
&----
text
----
MODULE user_command_3000 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT
&----
*& Module USER_COMMAND_3001 INPUT
&----
text
----
MODULE user_command_3001 INPUT.
CASE ok_code.
WHEN 'SAVE'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_3001 INPUT
&----
*& Module STATUS_3001 OUTPUT
&----
text
----
MODULE status_3001 OUTPUT.
SET PF-STATUS 'GUI'.
SET TITLEBAR 'TITLE'.
*
ENDMODULE. " STATUS_3001 OUTPUT
preparing fields to be registered for f4 help.........................
FORM prepare_f4.
lt_f4-fieldname = 'designation'.
lt_f4-register = 'X'.
lt_f4-getbefore = 'X'.
lt_f4-chngeafter = 'X'.
APPEND lt_f4.
ENDFORM.
12-27-2006 8:09 AM
12-27-2006 8:12 AM
hi,
BCALV_GRID_F4_HELP
Purpose:
~~~~~~~~
This report illustrates the use of f4-Help in an alv grid control.
*----
-
Background:
~~~~~~~~~~~
There a two possibilities to implement an f4-Help in the alv grid
control: one can either use standard f4-help or write one by Hand.
For the former there is nothing to do at all. This report shows how
to implement user-defined f4-help.
*----
-
The user should look at the definition of classes grid_application
and lcl_event_receiver:
all the grid-specific things happen there, while the rest
of the program is concerned with dynpro programming
*----
-
To check program behavior
~~~~~~~~~~~~~~~~~~~~~~~~~
For each choice it is explained in detail which functionality the
f4-help dispalys. Just try out different modes at the start-dynpro.
We also included a message signaling when datatable update actually
occurs.
*----
-
Essential steps (search for '§')
~~~~~~~~~~~~~~~
First you must define and set an event handler for event onf4
of class cl_gui_alv_grid, just as with any event in the object
model. In our case, its method on_f4 of (the local) class
lcl_event_receiver (definition see below).
We set the handler in PBO-module create_object of dynpro 100.
*
For the easiest case where you don't want to make changes do step
1. Register all columns for which you want to define an f4-help.
1a.You can deregister columns during run-time to use standard f4-help.
1b.Or register additional columns during run-time.
2. Implement your event handler method.
3. Set attribute m_event_handled of er_event_data to avoid standard
f4-help.
If you want to allow the user to change data via f4-help you have to
4. set in the fieldcatalog the corresponding column editable (see
Documentation). It does not suffice to set the complete grid
editable.
5. Declare data and field-symbols for values to be changed.
6. Assign the values for the corresponding cells you want to edit:
you can edit any cells. Do not refresh your table!
7. If your f4-help relates to other values of your table, you must
set parameters getbefore and/or chngeafter during registration.
8. In case the column you want to define an f4-help has no standard
f4-help defined, you must set parameter F4AVAILABL in the field
catalog.
9. If you want to check the data yourself, you can register for the
events data_changed and/or data_changed_finished. For the former
you can check where the event was raised and act accordingly.
*10. Often one uses drop down boxes instead of f4-help. To do so, you
first have to extend your datatable by one field and set the
fieldcatalog parameter drdn_field accordingly.
*11. Then you have to prepare a drop down table, give it to your grid
and fill in the additional field of your datatable appropritately.
*!! If you define a drop down box for a column, you can not define an
f4-help for the same column.
12-27-2006 8:30 AM
hI SREE RAM,
CHECK OUT THIS EXAMPLE CODING.
Program name:BCALV_GRID_EDIT_DELTA
05-23-2007 11:34 AM