cancel
Showing results for 
Search instead for 
Did you mean: 

Reg Drop-Down option Handling in WDA

former_member186491
Contributor
0 Kudos

Hi,

I've one wda application running fine till last month. In that application, selection screen for date has logic that only three previous months should be listed in the drop-down. For your reference, selection screen has two fields -- Year and Months. Earlier this was running fine; coz, after 4th month only one year should be listed in drop-down for Year.

Now, as this is 1st month, previous three months fall under previous year. Hence, we need to add previous year in the drop-down list for Year field. Here comes the problem. When I checked in debugger, lt_n_year - which is typed on the element N_YEAR ( Node for Year ) - is getting populated with this previous year. However, while passing this internal table to bind, it is not remaining on the selection-screen.

I'm unable to figure out as to while binding the values, where does the value get lost. Can you please give me idea as to what is going wrong..? For your reference, I'm giving my code here --


** data declaration
  DATA lt_n_year TYPE wd_this->Elements_n_year.
  DATA ls_n_year LIKE LINE OF lt_n_year.
  DATA: YEAR TYPE GJAHR,
        KEY TYPE I.

  data: month type n length 2.              " For controlling options in Year Drop-Down
* @TODO compute values
* e.g. call a data providing FuBa
  LS_N_YEAR-KEY = ' '.
  LS_N_YEAR-YEAR = 'Please Select'.
  APPEND LS_N_YEAR TO LT_N_YEAR.

  YEAR = SY-DATUM+0(4).

  month = sy-datum+4(2).                    " For controlling options in Year Drop-Down

  If month le 03.                           " For controlling options in Year Drop-Down
  DO 2 TIMES.
    KEY = KEY + 1.
    LS_N_YEAR-YEAR = YEAR.
    LS_N_YEAR-KEY = KEY.
    APPEND LS_N_YEAR TO LT_N_YEAR.
*    YEAR = YEAR - 1.

*    APPEND LS_N_YEAR TO LT_N_YEAR.
    IF SY-SUBRC NE 0.
    EXIT.
    ENDIF.
    YEAR = YEAR - 1.
    

  ENDDO.
  else.                                                                " For controlling options in Year Drop-Down
  do 1 times.                                                       " For controlling options in Year Drop-Down
    key = key + 1.                                                " For controlling options in Year Drop-Down
    ls_n_year-year = year.                                  " For controlling options in Year Drop-Down
    ls_n_year-key = key.                                     " For controlling options in Year Drop-Down
    year = year - 1.                                             " For controlling options in Year Drop-Down
    APPEND LS_N_YEAR TO LT_N_YEAR.        " For controlling
    enddo.                                                           " For controlling options in Year Drop-Down

* bind all the elements
  node->bind_table(
    new_items            =  lt_n_year
    set_initial_elements = abap_true ).
  endif.                                                              " For controlling options in Year Drop-Down
 

In N_YEAR, there are two elements --

1. YEAR type STRING

2. KEY type CHAR1

LT_N_YEAR is typed on this N_YEAR.

Just to make my problem clear -- code-part from

DO 1 TIMES

is working fine and passing values after binduing. While

DO 2 TIMES

is not passing any value after binding and hence, Drop-Down reamains blank in this case.

Please guide me coming out of this problem.

Thanks.

Kumar Saurav.

Edited by: Kumar Saurav on Jan 11, 2011 6:38 AM

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

Hi

you have explained your question quite well.

but if you can debug you will get the answer.

well answer is ..

you are binding the table to the node only in the case when month is less more than 3. i.e. in second case.

so please put the code for binging the table to the node outside the if condition and it will work.

* bind all the elements
  node->bind_table(
    new_items            =  lt_n_year
    set_initial_elements = abap_true ).
  endif.

put this code after the

endif.

statement

thanks

sarbjeet singh

former_member186491
Contributor
0 Kudos

Hi Sarbjeet,

Blunder at my part, you can say....

Thanks for pointing that out and you deserve full marks.

Thanks.

Kumar Saurav.

Answers (0)