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: 

Dynamic value help in ALV

Former Member
0 Kudos

Hello Experts,

I am new to abap UI programming. I want to use dynamic f4 help in ALV report. Can anyone explain in simple way to perform it either through OOP or function module?

Kindly explain using simple example excluding samples like: BCALV_TEST_GRID_EDIT_0, BCALV_EDIT_04 etc... I am expecting simple to understand samples.

Thanks in advance,

Viral.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Marchin,

Thanks for the example and explanation.

Dynamic value help is available but i am not able to retreive f4 value to the UI. (Not able to select value from f4 help sub screen)

Thanks,

Viral Patel

Edited by: Viral Patel on Jul 26, 2010 6:16 AM

Edited by: Viral Patel on Jul 26, 2010 6:18 AM

6 REPLIES 6

Former Member
0 Kudos

First you have to make the corresponding field editable.

For that EDIT field of field catalog to 'X'.

For drop down, you have to call a method SET_DROP_DOWN_TABLE of grid.


  wa_dropdown-handle = '1'.
  wa_dropdown-value = text-013."Accepted
  APPEND wa_dropdown TO t_dropdown.
  wa_dropdown-handle = '1'.
  wa_dropdown-value = text-014. "'Rejected'.
  APPEND wa_dropdown TO t_dropdown.
CALL METHOD gr_alvgrid->set_drop_down_table
      EXPORTING
        it_drop_down = t_dropdown.
    LOOP AT t_fieldcat INTO wa_fieldcat.
      CASE wa_fieldcat-fieldname.
**    To assign dropdown in the fieldcataogue
        WHEN 'ZSTATUSDESC'.
          wa_fieldcat-drdn_hndl = '1'.
          wa_fieldcat-outputlen = 15.
          MODIFY t_fieldcat  FROM wa_fieldcat.
      ENDCASE.
    ENDLOOP.


*   Call ALV
    CALL METHOD gr_alvgrid->set_table_for_first_display
      EXPORTING
        is_layout                     = ls_layout
        it_toolbar_excluding          = t_toolbar_excl
      CHANGING
        it_outtab                     = t_output
        it_fieldcatalog               = t_fieldcat
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.

Edited by: Nikhil V Kumar on Jul 21, 2010 6:28 PM

MarcinPciak
Active Contributor
0 Kudos

Instead of using dropdown I would suggest to use simple F4 functionality. This must be overwritten by you with event i.e handle_on_f4 . What you need is:

- handler method for this cl_gui_alv_grid event


"our handler class
CLASS lcl_gui_alv_event_receiver DEFINITION.
PUBLIC SECTION.
    METHODS:
"         To control F4
          handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
                           IMPORTING e_fieldname e_fieldvalue er_event_data,
ENDCLASS.

CLASS lcl_gui_alv_event_receiver IMPLEMENTATION.
METHOD handle_on_f4.
    DATA: repid LIKE sy-repid,
          dynnr LIKE sy-dynnr,
          field TYPE help_info-dynprofld.

    MESSAGE 'User defined value input' TYPE 'I'.
    repid = sy-repid.
    dynnr = sy-dynnr.

    field = e_fieldname.
    "this part work excatly as standard search help for this field
    "but is processed by a user althought looks like standard processing
    CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
      EXPORTING
        tabname     = 'SFLIGHT'
        fieldname   = 'SEATSMAX_F'
        dynpprog    = repid
        dynpnr      = dynnr
        dynprofield = field.  "return to same screen field which triggered the event

    "prevent furhter standard processing
    er_event_data->m_event_handled = 'X'.
  ENDMETHOD.                    
ENDLCASS.

- now in your main program you need to register this event telling the system who it is hanled by


DATA: "alv grid reference variable
      g_alv_grid_ref TYPE REF TO cl_gui_alv_grid.

DATA: "alv event receiver class
      g_alv_event_ref TYPE REF TO lcl_gui_alv_event_receiver.

CREATE OBJECT g_alv_event_ref.
SET HANDLER  g_alv_event_ref->handle_on_f4 FOR g_alv_grid_ref.

- before you display your ALV you need one last thing, namely activate the F4 events which are by default turned off


  DATA: lt_fields_f4 TYPE lvc_t_f4,
             ls_fields_f4 TYPE lvc_s_f4.

"register the fields which you want custom input help for
ls_fields_f4-fieldname = 'SEATSMAX_F'.
ls_fields_f4-register = 'X'.
APPEND ls_fields_f4 TO lt_fields_f4.

CALL METHOD g_alv_grid_ref->register_f4_for_fields
    EXPORTING
      it_f4 = lt_fields_f4.

- finally display your ALV


CALL METHOD g_alv_grid_ref->set_table_for_first_display ...

Regards

Marcin

0 Kudos

Hello Marcin,

Thanks for explaining so well. I could implement a dynamic value help with this. But now when I try to select a value from the list and show it on the field in the UI that part does not work. What should be done for that?

Former Member
0 Kudos

Hello Marchin,

Thanks for the example and explanation.

Dynamic value help is available but i am not able to retreive f4 value to the UI. (Not able to select value from f4 help sub screen)

Thanks,

Viral Patel

Edited by: Viral Patel on Jul 26, 2010 6:16 AM

Edited by: Viral Patel on Jul 26, 2010 6:18 AM

0 Kudos

Hi Viral,

In order you could select the value and pass it back to ALV you need that fied editable. Otherwise it is read-only so you not able to place there new value. So in your fieldcatalog set option edit = 'X' for that particular column you want F4 for. This should work.

Regards

Marcin

Former Member
0 Kudos

Thanks Marcin for valuable help and support.

Thanks & Regards,

Viral

Edited by: Viral Patel on Jul 28, 2010 9:28 AM