Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

WD4A - Selection screen default values loading

Hi,

We are developing one new report using WD4A and that report has a huge logic and big selection screen with 86 fields. Along with it, we do have to simulate the Selection Screen Variant Operation(Create/Display/Change/Delete Variants).

Since the number of fields being high, we decided to use a RSPARAMS Table(Context element with 0-n cardinality) to store in the entire selection screen values.

We were able to capture the values of Selection screen into this Context variable using one generic code, without using any specific field name.

But now I am stuck with repopulating the Sel Screen fields with the Context Variables. Like I have the Sel Screen data in the Context and when I trying to set the values of each field dynamically, I get an error/dump since the HIGH/LOW field types changes dynamically based on the field type.

So I was wondering if any one have faced a similar problem ? What could be the solution ? Or atleast it would be great, if someone could provide a snippet of code that sets the default values of the 4 fields of selection screen.

Hope Am clear.

Regards

<i><b>Raja Sekhar</b></i>

Former Member
replied

My code was working as long as i dont have loop on selection, as soon as I introducded the Loop, it stopped working, after further changes, i found out that

you need to uncomment below line in your code.

 wd_this->l_handler->RESET_SELECTION_FIELD( i_id = <field>-m_id ).

I am adding my code below which smiliar to yours:

*   get the range table of that field
  DATA LIT_RANGE_TABLE TYPE REF TO  DATA.

  FIELD-SYMBOLS: <LT_NEW_RANGE_TABLE> TYPE TABLE,
                 <FS_RANGE> TYPE ANY,
                 <field> TYPE any,
                 <LOW> TYPE ANY,
                 <SIGN> TYPE ANY,
                 <HIGH> TYPE ANY.
DATA: lt_fields TYPE IF_WD_SELECT_OPTIONS=>TT_SELECTION_SCREEN_ITEM,
      wa_fields LIKE LINE OF lt_fields.

wd_this->m_handler->get_selection_fields( importing et_fields = lt_fields ).

 loop at lt_fields INTO wa_fields.

CLEAR: LIT_RANGE_TABLE.

 wd_this->m_handler->RESET_SELECTION_FIELD( i_id = wa_fields-m_id ).

  LIT_RANGE_TABLE = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( wa_fields-m_id ).

* Get the pointer of the new table and form it freshly
  ASSIGN LIT_RANGE_TABLE->* TO <LT_NEW_RANGE_TABLE>.

  INSERT INITIAL LINE INTO TABLE <LT_NEW_RANGE_TABLE> ASSIGNING <FS_RANGE>.

  ASSIGN COMPONENT 'SIGN' OF STRUCTURE <FS_RANGE> TO <SIGN>.
  ASSIGN COMPONENT 'LOW' OF STRUCTURE <FS_RANGE> TO <LOW>.
  ASSIGN COMPONENT 'HIGH' OF STRUCTURE <FS_RANGE> TO <HIGH>.

IF wa_fields-m_id EQ 'S_CARR_ID'.

<SIGN> = 'I'.

  <LOW> = 'AA'.
  <HIGH> = 'LH'.
ELSEIF wa_fields-m_id EQ 'S_CONN_ID'.
<SIGN> = 'E'.

  <LOW> = '400'.
  <HIGH> = '412'.
ENDIF.


  INSERT INITIAL LINE INTO TABLE <LT_NEW_RANGE_TABLE> ASSIGNING <FS_RANGE>.

  ASSIGN COMPONENT 'SIGN' OF STRUCTURE <FS_RANGE> TO <SIGN>.
  ASSIGN COMPONENT 'LOW' OF STRUCTURE <FS_RANGE> TO <LOW>.
  ASSIGN COMPONENT 'HIGH' OF STRUCTURE <FS_RANGE> TO <HIGH>.

IF wa_fields-m_id EQ 'S_CARR_ID'.

<SIGN> = 'I'.

  <LOW> = 'AF'.
ELSEIF wa_fields-m_id EQ 'S_CONN_ID'.
<SIGN> = 'E'.

  <LOW> = '712'.

ENDIF.
*  APPEND <FS_RANGE> TO <LT_NEW_RANGE_TABLE>.
CALL METHOD WD_THIS->M_HANDLER->UPD_SELECTION_FIELD
  EXPORTING
    I_ID                      = wa_fields-m_id "'S_CARR_ID'
*    I_WITHIN_BLOCK            = MC_ID_MAIN_BLOCK
*    I_DESCRIPTION             =
*    I_IS_AUTO_DESCRIPTION     = ABAP_TRUE
    IT_RESULT                 =  LIT_RANGE_TABLE
*    I_OBLIGATORY              = ABAP_FALSE
*    I_COMPLEX_RESTRICTIONS    =
*    I_USE_COMPLEX_RESTRICTION = ABAP_FALSE
*    I_NO_COMPLEX_RESTRICTIONS = ABAP_FALSE
*    I_VALUE_HELP_TYPE         = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_NONE
*    I_VALUE_HELP_ID           =
*    I_VALUE_HELP_MODE         =
*    I_HELP_REQUEST_HANDLER    =
*    I_LOWER_CASE              =
*    I_MEMORY_ID               =
*    I_NO_EXTENSION            = 'X'
*    I_NO_INTERVALS            = 'X'
*    I_AS_CHECKBOX             = ABAP_FALSE
*    I_AS_DROPDOWN             = ABAP_FALSE
*    IT_VALUE_SET              =
*    I_READ_ONLY               = ABAP_FALSE
*    I_EXPLANATION             =
*    I_TOOLTIP                 =
    .
ENDLOOP.

ENDMETHOD.

Hope this time you will solve this issue.

Raja T

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question