on 05-14-2013 11:24 AM
Hi All,
I want to make a drop down list with key and value. I know it can be possible by customization.
But my requirement is to make it as default for all. All should see the drop down with key and value without doing the customization for each.
Is there any logic which i can implement in V- method for this. Please help me out.
Thanks
Satya
Hi Satyaranjan,
If it is for one drop down you can do some thing like concatenating your key and the value into value by separating with a ''-'' probably.
This is the sample code assuming you have the values you are showing in ddlb in lt_ddlb already.
DATA: ls_ddlb type BSP_WD_DROPDOWN_LINE,
lt_ddlb type BSP_WD_DROPDOWN_TABLE.
LOOP AT lt_ddlb INTO ls_ddlb.
CONCATENATE ls_ddlb-key '-' ls_ddlb-value INTO ls_ddlb-value.
MODIFY lt_ddlb INDEX sy-tabix FROM ls_ddlb.
ENDLOOP.
This would be the simple solution for what you are trying to achieve.
Regards
Vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinod,
Thanks for your kind input.
I have tried the option. But it's not working, because here we are passing value into the input field by concatenating the Key and Value field values. But the Input Field length is less than the concatenated value .While saving the record an error message is coming saying the field length is less.
My question is when we make personalize setting to see both Key and Value in drop down list , then how it's working. It's not showing any error.
As per my understanding ,I think we have to go for F4 Search Help Value option to get the solution.
Please provide your inputs.
Thanks
Satya
Hi Satya,
The values that you are concatenating into the value field is Text80 i.e.e 80 Characters. So at the time of display in the value help you concatenate the values and then display it to the user, but at the time of saving you can use the key field to convert the value back to the one which can be used in the database.
If required let me know if can create a sample code and provide you the same.
Many thanks in advance.
Best Regards,
Samantak.
Hi Satyaranjan,
What ever you show in the value is generally not stored to the Database, it is just for displaying to the user. It is the Key we store and in your case you are not going to modify the Key only the value. So I am not able to understand what is going wrong in your case.
Can you paste your code so that we will understand the problem exactly.
Regards
Vinod
Hi All,
Thanks all of yours inputs.
I am able to create a drop down. There us no issue. But my question is to create a Drop Down which will show both Key and Description. I tried it by concatenating both values into the Key field and Value field, but it's not working.
I know It can be possible by Personalize settings , where you can check ' Show Keys in dropdown lists' then the drop down will come with Key and description . But i want it to be hard coded, so that all can see the Key and Desc .
Thanks
SAtya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satyaranjan,
The issue in your code was you were passing the concatenated value to both KEY and VALUE
LOOP AT lt_act_catgor INTO ls_act_catgor.
CONCATENATE ls_act_catgor-category ls_act_catgor- descriptionINTO lv_value SEPARATED BY ' ' .
ls_ddlb-key = lv_value."sy-tabix. ---------------------> wrong
ls_ddlb-key = ls_act_catgor-category -------------------> try this, it will work.
CONDENSE ls_ddlb-key.
ls_ddlb-value = lv_value.
APPEND ls_ddlb TO lt_ddlb.
CLEAR ls_ddlb.
ENDLOOP.
Hey Satya,
Do 1 thing, once you set that flag in the personalize settings, then put a break point in the Get method of that attribute. In the Get method, see how both key and value are coming for that attribute. Right now i do not have access to a CRM system, else i would have checked and answer to you. Thanks.
Best Regards,
RK
Hi Satyaranjan,
The attribute for which Dropdown Needs to be Provided will have a GET_P Method,
Get_P method controls the property of a field, ie whether the field should be dropdown or a normal text field or a field of any other kind
In Get_p method of your attribute add the following code
CASE iv_property.
WHEN IF_BSP_WD_MODEL_SETTER_GETTER=>FP_FIELDTYPE.
* field type: picklist
RV_VALUE =
CL_BSP_DLC_VIEW_DESCRIPTOR=>FIELD_TYPE_PICKLIST.
To Trigger a Server Round trip on value selection following code can be added and handled in DO_HANDLE_EVENT
WHEN IF_BSP_WD_MODEL_SETTER_GETTER=>FP_SERVER_EVENT.
rv_value = ‘partner_type_selected
This converts the field into a Dropdown( Picklist), now values needs to be populated into a Dropdown for this purpose the Get_V Method needs to be redefined.
If you want to fill the Values from a Domain Use the following code to retrieve data from Domain
DATA:
LV_DOMAIN_NAME type DOMNAME,
LT_DOMAIN_ENTRIES type standard table of DD07V.
LV_DOMAIN_NAME = IV_DOMAIN_NAME.
call function 'DD_DOMVALUES_GET'
exporting
DOMNAME = LV_DOMAIN_NAME
LANGU = SY-LANGU
TEXT = 'X'
tables
DD07V_TAB = LT_DOMAIN_ENTRIES.
Once you retrieve the values
Do the following coding in GET_V Method of the same attribute
‘
DATA:
lt_sel_table TYPE bsp_wd_dropdown_table,
l_ref_ddlb_type TYPE REF TO cl_crm_uiu_ddlb,
ls_sel_table TYPE BSP_WD_DROPDOWN_LINE.
IF l_ref_ddlb_type IS NOT BOUND.
CREATE OBJECT l_ref_ddlb_type
EXPORTING iv_source_type = 'T'.
ENDIF.
ls_sel_table-key = '1'.
ls_sel_table-value = '1'.
APPEND ls_sel_table TO lt_sel_table.
ls_sel_table-key = '2'.
ls_sel_table-value = '2'.
APPEND ls_sel_table TO lt_sel_table.
l_ref_ddlb_type->set_selection_table( it_selection_table = lt_sel_table ).
rv_valuehelp_descriptor = l_ref_ddlb_type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is very good document available in SDN which is provided below.
http://scn.sap.com/docs/DOC-5197
I hope this will provide you with a good details for the value helps.
Let me know if this is fine or else will look further for more analysis.
Thanks in advance.
Best Regards,
Samantak.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
go to get_v method of that attribut and put hte below code.
DATA : lt_ddlb TYPE bsp_wd_dropdown_table,
wa_ddlb like line of lt_ddlb.
wa_ddlb-key = '1'.
wa_ddlb-value = 'CENTRAL'.
append wa_ddlb to lt_ddlb.
IF gr_ddlb1 is not bound.
CREATE OBJECT gr_ddlb1
EXPORTING
iv_source_type = 'T'.
endif.
IF gr_ddlb1 is bound.
gr_ddlb1->set_selection_table( it_selection_table = lt_ddlb ).
ENDIF.
rv_valuehelp_descriptor = gr_ddlb1.
create a variable in context class of that attribute
gr_ddlb1 instanse public type ref to cl_crm_uiu_ddlb
and then in get_p method
CASE iv_property.
WHEN if_bsp_wd_model_setter_getter~fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_picklist.
WHEN if_bsp_wd_model_setter_getter=>fp_server_event.
rv_value = 'DUMMY'.
ENDCASE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sathyarajan,
Check the document from the below link.
http://scn.sap.com/docs/DOC-5197
Regards,
Sachin N M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Satyaranjan,
you can check the following code for dropdown used in V method.And modify according to your requirement.
METHOD get_v_category.
DATA: lt_act_catgor TYPE STANDARD TABLE OF crmc_act_cat_t.
DATA: ls_act_catgor LIKE LINE OF lt_act_catgor.
DATA: lt_ddlb TYPE bsp_wd_dropdown_table,
lv_value TYPE char80,
ls_ddlb TYPE bsp_wd_dropdown_line,
lv_display_only TYPE string,
gr_dropdown TYPE REF TO cl_crm_uiu_ddlb,
ls_values TYPE LINE OF vrm_values.
SELECT * FROM crmc_act_cat_t INTO CORRESPONDING FIELDS OF TABLE lt_act_catgor WHERE langu = 'E'.
DELETE ADJACENT DUPLICATES FROM lt_act_catgor.
LOOP AT lt_act_catgor INTO ls_act_catgor.
CONCATENATE ls_act_catgor-category ls_act_catgor- description INTO lv_value SEPARATED BY ' ' .
ls_ddlb-key = lv_value."sy-tabix.
CONDENSE ls_ddlb-key.
ls_ddlb-value = lv_value.
APPEND ls_ddlb TO lt_ddlb.
CLEAR ls_ddlb.
ENDLOOP.
IF gr_dropdown IS NOT BOUND.
FREE gr_dropdown.
CREATE OBJECT gr_dropdown
EXPORTING
iv_source_type = 'T'.
INSERT INITIAL LINE INTO lt_ddlb INDEX 1.
IF sy-subrc = 0.
gr_dropdown>set_selection_table( it_selection_table = lt_ddl b ).
ENDIF.
ENDIF.
rv_valuehelp_descriptor = gr_dropdown.
ENDMETHOD.
Regards,
Harish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.