09-04-2014 6:19 AM
Hi ABAPers,
I Have a question regarding drop down list in ALV. I Know how to implement it but want to display two fields in dropdown list.
How we can implement it.
It must look like this.
Thanks in advance.
Regards.
Dhananjay
09-04-2014 6:58 AM
Hi Dhananjay,
You could use F4 Help inside ALV which can have more than one fields ..
For the field catalog, set this
fldcat-f4availabl = 'X'.
fldcat-ref_table = 'Table'.
fldcat-ref_field = 'field'.
Give the value range in the domain for this field in SE11.
When you click on F4 both the columns (text and description) will come.
You could assign the description ie the account no to the second field.
You can get some sample programs on the net for the same.
09-04-2014 7:09 AM
Hi Susmitha,
Thanks for your quick reply.
I have to implement it through dropdown.
I know F4 Search help method.
Is is possible??
If yes then please tell me.
Thanks.
Dhananjay
09-04-2014 7:35 AM
Hi Dhananjay
Create an internal table and add drop down text
as below code.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
* First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND
ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value
= '02 Lower Secondary'.
APPEND
ls_dropdown TO lt_dropdown.
After the Append just call the below method.
*method to display the dropdown in ALV
CALL
METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
09-04-2014 9:42 AM
The users would like to get an ability to choose a value with a start writing … name or code…
For example- currently they can type the code -> LOV is scrolled to the first value that is beginning with this code but where it will go if they start typing text??
09-04-2014 7:39 AM
09-04-2014 9:43 AM
09-04-2014 10:26 AM
I've read your previous reply and I'm a bit confused by the requirements.
Maybe you want smth like what has recently been discussed?
It'll be possible to search also by text but the prerequisites are quite high and full text search is possible only in special DBs like SAP HANA.
09-04-2014 12:20 PM
May we display multiple fields?? First this is my priority.
Thanks.
Dhananjay
09-05-2014 7:09 AM
Hi, Dhananjay!
I'm not sure whether it is possible to have a "live" search proposals in alv as it is in web forms. It seems to me that unless you hit enter or transfer the focus to another cell nothing can be triggered. I would be extremely happy to know that it's not like that (And again - they say that in 7.40 you have the option of "live" search with just one checkbox but I have no place to test it).
You can try to show dropdown list with several columns manually (sorry, the code is dirty, I'm very short of time, it's just to illustrate the idea).
If you don't want to open the list, you can choose the value by entering, e.g., "01" in the second field and pressing enter.
If you need to populate some neighbour columns by chosen text value, it can be done in events like data_changed.
REPORT ztest6.
TYPES: BEGIN OF gty_s_alv,
vbeln TYPE vbak-vbeln,
fistl_txt TYPE text20,
END OF gty_s_alv,
gty_t_alv TYPE TABLE OF gty_s_alv.
DATA: g_grid TYPE REF TO cl_gui_alv_grid.
DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
ls_fcat LIKE LINE OF gt_fieldcat.
DATA: gt_outtab TYPE gty_t_alv.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
SELECT vbeln
FROM vbak
INTO TABLE gt_outtab
WHERE vbtyp = 'G'.
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'CONT'.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSD_LIST_ORDER_ALV' " vbeln, fistl_txt and some more columns
CHANGING
ct_fieldcat = gt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'VBELN'.
WHEN 'FISTL_TXT'.
ls_fcat-drdn_hndl = '1'. " handle of dropdown table
ls_fcat-edit = abap_true. " To be able to choose smth
MODIFY gt_fieldcat FROM ls_fcat.
WHEN OTHERS.
ls_fcat-tech = abap_true.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
* Populated manually according to your data
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Some 1st stuff'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Some 2nd stuff'.
APPEND ls_dropdown TO lt_dropdown.
* Set drop down table
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.
CALL SCREEN 0100.
09-05-2014 7:12 AM
Hi,
Yesterday i gave the same solution but he needs something diff
09-05-2014 7:46 AM
Hi, Anoop!
Indeed, the main idea of your suggestion is the same. Sorry, didn't notice, I should have mentioned it.
I just added some of my reflexions about what is possible to do in alv.
09-05-2014 8:31 AM
Hi,
You can concatenate the two field values seperated by '|' or any mark and assign the same to
ls_dropdown-value = 'field1 | field2' .(As Anoop said above) . After user selection put your logic to seperate the fields and put in respective input fields , if required .
Regards
DJ