Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Setting default value in select option–Webdynpro ABAP

I have a field purchasing organization in the select option and I want to set it with a default value C100. Below is a piece of code for setting default value in select option.

* Structure for select option

 
TYPES : BEGIN OF S_EKORG,
            SIGN(1)  
TYPE C,                           " Sign

            OPTION(2)
TYPE C,                           " Option
            LOW      
TYPE EKORG,                       " Low
            HIGH     
TYPE EKORG,                       " High
         
END OF S_EKORG.

 
DATA : LT_EKORG TYPE REF TO            DATA,          " Data reference variable

         WA_EKORG
TYPE                   S_EKORG,       " Work Area : Select option
         IT_EKORG
TYPE STANDARD TABLE OF S_EKORG.       " Internal table: Select option

 
FIELD-SYMBOLS : <FS_EKORG> TYPE TABLE.

 
CREATE DATA LT_EKORG TYPE TABLE OF S_EKORG.           " Creating a data reference of type select option


* Assigning the data reference variable to field symbol

 
ASSIGN : LT_EKORG->* TO <FS_EKORG>.

* Populating the default value in field symbol


  WA_EKORG-SIGN =
'I'.
  WA_EKORG-OPTION =
'EQ'
.
  WA_EKORG-LOW =
'C100'
.
 
APPEND WA_EKORG TO
<FS_EKORG>.

* Call the method set range table of select option and set the default value


 
CALL METHOD LV_R_HELPER_CLASS->SET_RANGE_TABLE_OF_SEL_FIELD
   
EXPORTING

      I_ID           =
'EKORG'

      IT_RANGE_TABLE = LT_EKORG.

 

About Arun

2 Comments:

  1. where should this be coded? i have done this after adding the select-options.. but i gettin dump

    ReplyDelete
    Replies
    1. The value has to be set in the select option when it appears on the screen for the first time. So the coding must be written in the 'DOINIT' method.

      Delete

Powered by Blogger.