‎2009 Apr 17 10:45 AM
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
‎2009 Apr 17 10:51 AM
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
‎2009 Apr 17 10:50 AM
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
‎2009 Apr 17 10:50 AM
Hi,
Kindly refer Standard SAP Prog BCALV_EDIT_06 & BCALV_EDIT_07 for your reference.
Hope it will help you in developing,
Pratik
‎2009 Apr 17 10:51 AM
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
‎2009 Apr 17 10:52 AM
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
‎2009 Apr 17 10:52 AM
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.
‎2009 Apr 17 10:53 AM
Hi,
Kindly go through these links below:
Hope it helps
Regards
Mansi
‎2013 Jan 12 7:18 AM
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.
‎2013 Jan 13 10:10 AM
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