Application Development and Automation 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: 
Read only

ALV Report input enabled drop down list

Former Member
0 Likes
7,286

Dear All,

I am looking for one ALV report where one of the column is input enabled with drop down list and when when user chooses a value and presses SAVE button at the top, then the value should be saved into a table for that particular line item.

Please can you help me out?

Best wishes,

Atanu

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,529

Hi,

For drop down list in alv refer:-

BCALV_EDIT_06 -- Dropdown Listbox at Column Level

BCALV_EDIT_07 -- Dropdown Listbox at Cell Level

Refer this code will reflect all the changes into the internal table that is being displayed.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = v_rep_id       " report id
     i_callback_pf_status_set          = 'PF'           " for PF-STATUS
     i_callback_user_command           = 'USER_COMMAND' " for User-Command
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
     it_sort                           = it_sort        " sort info
    TABLES
      t_outtab                          = it_final      " internal table
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  pf
*&---------------------------------------------------------------------*
*       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
*       ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
*       -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_STAT'.
ENDFORM.                    "pf

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is SAVE then save records into internal table
    WHEN 'SAVE'.

* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

"now at this time you have modified internal table

* refresh the ALV Grid output from internal table
      l_selfield-refresh = 'X'.

"alv output is refreshed as per changes in internal table

  ENDCASE.

ENDFORM.                    "USER_COMMAND

Hope this helps you.

Regards,

Tarun

8 REPLIES 8
Read only

Former Member
0 Likes
2,529

Hi,

This can be done.

For the input enabled column in the ALV in the fieldcat You will have to include edit = 'X' and f4availabl = 'X'.

Once this is done, you can use OO ABAP to design the ALV for F4 help. To get pointers to this see the program :

BCALV_F4

BCALV_GRID_F4_HELP_APPLICATIO

BCALV_GRID_F4_HELPM01

BCALV_TEST_GRID_F4_HELP

More options on F4 would be in the program BCALV_TEST_GRID_F4_HELP

Regards,

Mansi.

Edited by: SAP USER on Apr 17, 2009 11:51 AM

Read only

Former Member
0 Likes
2,529

Hi,

Kindly refer Standard SAP Prog BCALV_EDIT_06 & BCALV_EDIT_07 for your reference.

Hope it will help you in developing,

Pratik

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,530

Hi,

For drop down list in alv refer:-

BCALV_EDIT_06 -- Dropdown Listbox at Column Level

BCALV_EDIT_07 -- Dropdown Listbox at Cell Level

Refer this code will reflect all the changes into the internal table that is being displayed.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = v_rep_id       " report id
     i_callback_pf_status_set          = 'PF'           " for PF-STATUS
     i_callback_user_command           = 'USER_COMMAND' " for User-Command
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
     it_sort                           = it_sort        " sort info
    TABLES
      t_outtab                          = it_final      " internal table
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  pf
*&---------------------------------------------------------------------*
*       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
*       ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
*       -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_STAT'.
ENDFORM.                    "pf

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is SAVE then save records into internal table
    WHEN 'SAVE'.

* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

"now at this time you have modified internal table

* refresh the ALV Grid output from internal table
      l_selfield-refresh = 'X'.

"alv output is refreshed as per changes in internal table

  ENDCASE.

ENDFORM.                    "USER_COMMAND

Hope this helps you.

Regards,

Tarun

Read only

former_member203501
Active Contributor
0 Likes
2,529

hi ,

check the report BCALV_EDIT_06 is good for drop down and selection....but u need to write the coding for save in it

Read only

Former Member
0 Likes
2,529

Hi,

Try this.

Make it editable and dropdown enabled in the fieldcatalog. Along with the other data use the below two fields of the fieldcatalog structure to fulfill your requirement.

data: wa_fieldcat type lvc_s_fcat.

wa_fieldcat-edit = 'X'.

wa_fieldcat_-drdn_hndl = '1'.

data: i_dropdown TYPE lvc_t_drop,

wa_dropdown TYPE lvc_s_drop,

wa_dropdown-handle = '1'.

MOVE <required value> TO wa_dropdown-value.

APPEND wa_dropdown TO i_dropdown.

CLEAR : wa_dropdown.

<required value> -


the values you want to display in the drop down.

Regards,

Sharin.

Read only

dharma_esampalli
Participant
0 Likes
2,529

Hi,

I have followed the above steps. But I'm getting Drop down(same drop down table) to all the columns in my ALV output.

But my requirement is i want it only to a particular column. How to fix the Internal table that I have created as Dropdown to my single column.

Steps I followed,

1) In Field catalog, DRDN-HNDL = '1' & EDIT = 'X'

2) Defined a drop down table of type LVC_T_DROP and appended a few entries to it.

3) ref_grid -> SET_DROP_DOWN_TABLE & passed my drop down table in Exporting table.

4) then displayed the ALV,  ref_grid->set_table_for_first_display.

where to give the condition.

Read only

0 Likes
2,529

Hi Sekhar,

Loop at your filedcatalog internal table.

write a case statement. This case statemnet will hold the field values for which you want the drop down. And, then append the values.

For example,

LOOP AT gt_fieldcat INTO ls_fcat.

    CASE ls_fcat-fieldname.

      WHEN 'FIELD1'.

        ls_fcat-drdn_hndl = '1'.

        MODIFY gt_fieldcat FROM ls_fcat.

       WHEN 'FIELD2'.

        ls_fcat-drdn_hndl = '2'.

        MODIFY gt_fieldcat FROM ls_fcat.

    ENDCASE.

  ENDLOOP.

hope this helps.

Thanks,

Namrata