‎2009 Mar 20 1:53 PM
All,
I have an ALV using class CL_GUI_ALV_GRID (Editable) and have drop down in 2 different columns , using following but in display both the columns shows same drop down values as OR & AND.
Any Info?
ls_fcat-fieldname = 'DROPDOWN_F4_1'.
ls_fcat-datatype = 'INT4'.
ls_fcat-checktable = '!'.
ls_fcat-no_out = c_x.
append ls_fcat to pt_fieldcat.
clear ls_fcat.
ls_fcat-fieldname = 'DROPDOWN_F4_2'.
ls_fcat-datatype = 'INT4'.
ls_fcat-checktable = '!'.
ls_fcat-no_out = c_x.
append ls_fcat to pt_fieldcat.
ps_dropdown-handle = '1'.
ps_dropdown-value = ' '.
append ps_dropdown to pt_dropdown.
ps_dropdown-handle = '1'.
ps_dropdown-value = 'AND'.
append ps_dropdown to pt_dropdown.
ps_dropdown-handle = '1'.
ps_dropdown-value = 'OR'.
append ps_dropdown to pt_dropdown.
call method g_grid->set_drop_down_table
exporting
it_drop_down = pt_dropdown.
ps_dropdown-handle = '2'.
ps_dropdown-value = ' '.
append ps_dropdown to pt_dropdown.
loop at i_ynetstat.
ps_dropdown-handle = '2'.
ps_dropdown-value = i_ynetstat-status.
append ps_dropdown to pt_dropdown.
endloop.
call method g_grid->set_drop_down_table
exporting
it_drop_down = pt_dropdown.
a®
‎2009 Mar 20 3:39 PM
Hi,
I tried your fieldcatalog and it is working correctly...The only thing I changed is the data type from INT4 to CHAR.
Try changing to CHAR data type.
DATA: ok_code TYPE sy-ucomm,
g_container TYPE scrfname VALUE 'CONTAINER1',
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gs_layout TYPE lvc_s_layo.
DATA: pt_dropdown TYPE lvc_t_drop,
ps_dropdown TYPE lvc_s_drop,
ls_fcat TYPE lvc_s_fcat,
pt_fieldcat TYPE lvc_t_fcat.
TYPES: BEGIN OF type_output,
dropdown_f4_1 TYPE char10,
dropdown_f4_2 TYPE char10,
END OF type_output.
DATA: gt_outtab TYPE TABLE OF type_output.
START-OF-SELECTION.
APPEND INITIAL LINE TO gt_outtab.
* Call the screen.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'TEST'.
SET TITLEBAR 'MAIN100'.
* Create the grid.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
* field catalog.
ls_fcat-fieldname = 'DROPDOWN_F4_1'.
ls_fcat-drdn_hndl = '1'.
ls_fcat-datatype = 'CHAR'. " Changed
ls_fcat-checktable = '!'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'DROPDOWN_F4_2'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-datatype = 'CHAR'. " Changed
ls_fcat-checktable = '!'.
APPEND ls_fcat TO pt_fieldcat.
* Drop down box values 1
ps_dropdown-handle = '1'.
ps_dropdown-value = ' '.
APPEND ps_dropdown TO pt_dropdown.
ps_dropdown-handle = '1'.
ps_dropdown-value = 'AND'.
APPEND ps_dropdown TO pt_dropdown.
ps_dropdown-handle = '1'.
ps_dropdown-value = 'OR'.
APPEND ps_dropdown TO pt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = pt_dropdown.
* Drop down box values 2
ps_dropdown-handle = '2'.
ps_dropdown-value = ' '.
APPEND ps_dropdown TO pt_dropdown.
ps_dropdown-handle = '2'.
ps_dropdown-value = 'X'.
APPEND ps_dropdown TO pt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = pt_dropdown.
* Display the ALV.
gs_layout-edit = 'X'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = gt_outtab.
ENDIF.
ENDMODULE. "pbo OUTPUTThanks
Naren
‎2009 Mar 20 2:25 PM
Have you clear the table PT_DROPDOWN after the first set of values?
Regards,
Naimesh Patel
‎2009 Mar 20 2:49 PM
Naimesh/phani
I have cleared values , and also refresh the table. No use still it showing drop down values as OR & AND in both dropdown fields.
PS Second dropdown values are coming from custom table.
a®
‎2009 Mar 20 2:57 PM
Check if both field refers to different (or same) drop down handle in your fieldcatalog? For first field it should be 1, and for second field it should be 2.
ls_fcat-fieldname = 'DROPDOWN_F4_1'.
ls_fcat-datatype = 'INT4'.
ls_fcat-checktable = '!'.
ls_fcat-no_out = c_x.
ls_fcat-drdn_hndl = '1'.
append ls_fcat to pt_fieldcat.
clear ls_fcat.
ls_fcat-fieldname = 'DROPDOWN_F4_2'.
ls_fcat-datatype = 'INT4'.
ls_fcat-checktable = '!'.
ls_fcat-no_out = c_x.
ls_fcat-drdn_hndl = '2'.
append ls_fcat to pt_fieldcat.
Regards,
Naimesh Patel
‎2009 Mar 20 3:02 PM
Hi,
Did you populated a handle value for each row in the output table?
data: begin of it OCCURS 0.
INCLUDE STRUCTURE sflight.
dATA dd_hndl TYPE int4 .
data end of it.
select * from sflight into CORRESPONDING FIELDS OF it up to 10 rows.
if sy-tabix le 5.
it-dd_hndl = '1'. "show only values with handle = '1' .
else.
it-dd_hndl = '2'. "same for handle = '2'.
endif.
append it.
endselect.
Regards
Marcin
‎2009 Mar 20 3:05 PM
I have checked the handle 1 refers to first field and 2 refers to second field
ls_fcat-fieldname = 'DROPDOWN_F4_1'.
ls_fcat-drdn_hndl = '1'.
ls_fcat-datatype = 'INT4'.
ls_fcat-checktable = '!'.
ls_fcat-no_out = c_x.
append ls_fcat to pt_fieldcat.
clear ls_fcat.
ls_fcat-fieldname = 'DROPDOWN_F4_2'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-datatype = 'INT4'.
ls_fcat-checktable = '!'.
ls_fcat-no_out = c_x.
append ls_fcat to pt_fieldcat.
Still getting wring values
a®
‎2009 Mar 20 3:12 PM
> select * from sflight into CORRESPONDING FIELDS OF it up to 10 rows.
> if sy-tabix le 5.
> it-dd_hndl = '1'. "show only values with handle = '1' .
> else.
> it-dd_hndl = '2'. "same for handle = '2'.
> endif.
I didn't get your suggestion. In my ALV in a row 2 fields a have separate dropdowns , how will we fill value dd_hndl in output table.
a®
‎2009 Mar 20 3:38 PM
It is working good for me.
I copied the program BCALV_EDIT_06 to my Z program.
I have added another Drop-Down for the field INVOICE in the form SET_DRDN_TABLE
data: lt_dropdown type lvc_t_drop,
ls_dropdown type lvc_s_drop.
* First listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = 'KG'.
append ls_dropdown to lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'G'.
append ls_dropdown to lt_dropdown.
* second
ls_dropdown-handle = '2'.
ls_dropdown-value = 'NN'.
append ls_dropdown to lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = 'NP'.
append ls_dropdown to lt_dropdown.
call method g_grid->set_drop_down_table
exporting it_drop_down = lt_dropdown.
I changed the Field catalog in the subroutine BUILD_FIELDCAT
loop at pt_fieldcat into ls_fcat.
if ls_fcat-fieldname eq 'WUNIT'.
ls_fcat-edit = 'X'.
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 7.
ls_fcat-checktable = '!'. "do not check foreign keys
endif.
if ls_fcat-fieldname eq 'INVOICE'.
ls_fcat-edit = 'X'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 2.
ls_fcat-checktable = '!'. "do not check foreign keys
endif.
modify pt_fieldcat from ls_fcat.
endloop.
And it is working good.
Regards,
Naimesh Patel
‎2009 Mar 20 2:26 PM
‎2009 Mar 20 3:27 PM
I thought you want it on cell basis. In this way you would have to fill drdn_hndl in fieldcatalog with 'DD_HNDL' and then when filling the data for output table, each row would store either values for handle 1 or 2.
But as you want it on column basis setting ls_fcat-drdn_hndl = '1' should suffice.
Regards
Marcin
‎2009 Mar 20 3:39 PM
Hi,
I tried your fieldcatalog and it is working correctly...The only thing I changed is the data type from INT4 to CHAR.
Try changing to CHAR data type.
DATA: ok_code TYPE sy-ucomm,
g_container TYPE scrfname VALUE 'CONTAINER1',
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gs_layout TYPE lvc_s_layo.
DATA: pt_dropdown TYPE lvc_t_drop,
ps_dropdown TYPE lvc_s_drop,
ls_fcat TYPE lvc_s_fcat,
pt_fieldcat TYPE lvc_t_fcat.
TYPES: BEGIN OF type_output,
dropdown_f4_1 TYPE char10,
dropdown_f4_2 TYPE char10,
END OF type_output.
DATA: gt_outtab TYPE TABLE OF type_output.
START-OF-SELECTION.
APPEND INITIAL LINE TO gt_outtab.
* Call the screen.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'TEST'.
SET TITLEBAR 'MAIN100'.
* Create the grid.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
* field catalog.
ls_fcat-fieldname = 'DROPDOWN_F4_1'.
ls_fcat-drdn_hndl = '1'.
ls_fcat-datatype = 'CHAR'. " Changed
ls_fcat-checktable = '!'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'DROPDOWN_F4_2'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-datatype = 'CHAR'. " Changed
ls_fcat-checktable = '!'.
APPEND ls_fcat TO pt_fieldcat.
* Drop down box values 1
ps_dropdown-handle = '1'.
ps_dropdown-value = ' '.
APPEND ps_dropdown TO pt_dropdown.
ps_dropdown-handle = '1'.
ps_dropdown-value = 'AND'.
APPEND ps_dropdown TO pt_dropdown.
ps_dropdown-handle = '1'.
ps_dropdown-value = 'OR'.
APPEND ps_dropdown TO pt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = pt_dropdown.
* Drop down box values 2
ps_dropdown-handle = '2'.
ps_dropdown-value = ' '.
APPEND ps_dropdown TO pt_dropdown.
ps_dropdown-handle = '2'.
ps_dropdown-value = 'X'.
APPEND ps_dropdown TO pt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = pt_dropdown.
* Display the ALV.
gs_layout-edit = 'X'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = gt_outtab.
ENDIF.
ENDMODULE. "pbo OUTPUTThanks
Naren
‎2009 Mar 20 3:49 PM
Naren,
I changed to INT4 to CHAR , Now its working. (Strange !!!! But i could not find what will be reason) May be because of custom field values are INT4 that's why
Naimesh/Marcin
Thanks for your time replying.
a®
‎2009 Mar 20 3:47 PM
‎2009 Mar 20 3:50 PM