Web Dynpro – Setting a Default Select-Option

Home / SAP / ABAP Coding / Web Dynpro – Setting a Default Select-Option

Well, there are some things I take for granted, and that’s how easy things seem to be inside of standard ABAP programming.  I come realize this whenever I try to do one of these “simple” activities in Web Dynpro.  Take today’s adventure.  I had some select-option fields, and I just wanted to default a value in there.  Sounds so easy.  And eventually it was.  here’s what I finally found.

I had a select option for ERDAT (creation date).  I’m not going to go into the select option creation.  I think I talked about that a while ago, so just search my blog if you need more info.  SERDAT is the ID of my option that I want to default a value for.

*** SET DEFAULT FOR ERDAT
DATA lo_nd_range_erdat TYPE REF TO if_wd_context_node.
DATA lt_range_erdat TYPE wd_this->Elements_range_erdat.
DATA ls_range_erdat TYPE wd_this->Element_range_erdat.
*** here’s the magic ***

FIELD-SYMBOLS<LT_RANGE_ERDAT> TYPE TABLE.
CREATE DATA LT_RANGE TYPE TABLE OF /JVS/SO_ERDAT.
ASSIGN LT_RANGE->TO <LT_RANGE_ERDAT>.

*** end the magic ***

*** this code is just setting the value back to my context node.
* navigate from <CONTEXT> to <RANGE_ERDAT> via lead selection
lo_nd_range_erdat wd_context->get_child_nodename wd_this->wdctx_range_erdat ).
ls_range_erdatsign ‘I’.
ls_range_erdatoption ‘BT’.
ls_range_erdathigh sydatum.
ls_range_erdatlow sydatum 30.
APPEND ls_range_erdat to lt_range_erdat.
lo_nd_range_erdat->bind_tablenew_items lt_range_erdat set_initial_elements abap_true ).
*** back to the default ***
*** notice I needed to set the value to the DATA field symbol.
APPEND ls_range_erdat to <LT_RANGE_ERDAT>.
LR_HELPER->SET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
I_ID ‘SERDAT’
IT_RANGE_TABLE LT_RANGE ).

*** end the default code

 

I hope you can find a use for this,
Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *