cancel
Showing results for 
Search instead for 
Did you mean: 

Cross dependency among 2 drop down fields?

former_member202077
Participant
0 Kudos

Hello

I developed my_wdc, my_wda, my_view

Now, my requirement goes is as below,

1) I need to place my_button on my_view

2) When user clicks the my_button, then a popup should displayed

3) This popup should have a EDITABLE TABLE with 2 colums, fixed # of rows (30), say, 1st column is ZONE and the 2nd column is COUNTRY

4) The above 2 fields should drop down fileds, in such a way that user can pick a value from the drop down list

5) But, the 2nd (COUNTRY) drop down field list box values should based on the user selected entry in the 1st ZONE field, say, example,

Say, the 1st ZONE field has Asia, North America, Europe.

The 2nd COUNTRY field has China, Thailand, US, Canada, Germany, France.

Now, user picks the Europe in the 1st field, then the moment user selects the Europe then i need to filter the 2nd drop down field list as Germany & France for the SPECIFIC row

Bcz of too many steps i want to avoid the ALV (Editable) grid on the popup, just i want to go with simple TABLE UI element

We are storing all these data (Zone & Country) in a Z table, hence data pulling is no issues, its available all the time

Pls. let me know how can i achive my req.? like,

1) In the table, wht kind of TEXT EDITOR i need to select, just a INPUT FIELD or DROP DOWN by KEY or DROP DOWN by INDEX?

2) If so, how can i fielter the 2nd field as soon as user picks a value in 1st field?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello MSR,

1) In the table, wht kind of TEXT EDITOR i need to select, just a INPUT FIELD or DROP DOWN by KEY or DROP DOWN by INDEX?

Create two drop down by key.

and fill all the valve in the drop-down in the do-init method of view. Just for filing here we will write code rest of work on drop-down selection.

2) If so, how can i filter the 2nd field as soon as user picks a value in 1st field?

Create a method on DDBK " on_select" and use the following steps.

Now firstly you have to get the row where user selected any drop-down.(without lead-selection.)

First check if lead_selection is not initial,..

<<< get the selected row >>>

else.

DATA lr_element TYPE REF TO if_wd_context_element.
  
DATA lv_index type i.
   lr_element
= wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
   lv_index
= lr_element->get_index( ).

index will give you the row on which you have clicked.

using index read the whole table and find the selected row.and do your work.

endif.

now you have selected/used row.

<<< Code for 1st drop-down,>>>

Now check if first drop-down is not initial then again filter the all result of second DD based on first DDBK value and bind valueset again for 2nd drop-down. so now 2nd DDBK will have only filtered result based on Zone..

else.

fill all the value in 2nd dd.

endif.

** Add one extra value in your drop-down saying (others)..

<<<< 2nd drop-down..

Now suppose user directly came to 2nd DD and select some value then filter first DD based on 2nd and fill 1st DD and Set the result in DD also.

** Because here 1:N relationship... zone:city. so on selection of city we need to set zone by default. 

Hope this will help you..

former_member202077
Participant
0 Kudos

Thank you.

I implemented ur suggestion, well. But, kind of an issue, like below

Say, I have 3 rows in the popup table, in 1st row: user selected Europe in 1st DDBK, at this pooint my onSelect triggered and filtered the 2nd DDBK list into Germany, France, well.

But, at this point if user clicks DIRECTLY the 2nd row's 2nd DDBK (i mean, without seelcting 1st DDBK of 2nd same row), then user can see only the above said Germany & France only (actually, suppose to have all the countries list, right?)!

OK, now, if user selects Asia in 2nd row's 1st DDBK, then again my onSelect will trigger and filter the 2nd row's 2nd DDBK list into China and Thailand, well

Now, if user clicks the 1st row's 2nd DDBK, then user will see China & Thailand in the list (actually, as the 1st DDBK is Europe it suppose to Germay & France)!

So, as i captured the user working/user picked ROW # on table, then, i wish i can fill the DDBK list only SPECIFICALLY for that row's 2nd DDBK field ONLY? any idea? bcz now am filling the 2nd (1st as well) DDBK by using VALUE_SET method, here its fillling the DDBK list for all rows of table, bcz row represents the field, here its COUNTRY

Pls. let me know do we hv a chance to fill the DDBK list specifically to one specified row's filed/COUNTRY fld?

Thank you

Former Member
0 Kudos

Hello,

Using IF_WD_CONTEXT_NODE_INFO=>SET_ATTRIBUTE_VALUE_SET and a new attribute, you should be able to customize the entries of this second DDBK upon the line selection.

If you want DDBK value set to be separate, you should different context attributes mapped to the DDBK.

Is it answering your question ?

EDIT: Also, you can use the method WDDOMODIFYVIEW, for example, to catch other screen modifications. I recommend you to centralize the updates of your attr_valueset in almost one method to avoid differents calls and logics in many different methods.

Former Member
0 Kudos

Hello MSR, i think we can't achieve this in WDP using 2 attribute. if you go to write code in WDmodifyview then it will make your application too slow.

One suggestion: Don't give no. of blank/empty row to user. Give a button on top saying Add Row. On pressing of that add a blank/empty row to your table view.. so every time when user want to save some row he/she can add row according to their choice.

ramakrishnappa
Active Contributor
0 Kudos

Hi MSR,

We can achieve the same as below

Steps:

  1. Create search help ZSH_REGION - which gives the region list
  2. Create search help ZSH_COUNTRY - which gives the country list based on REGION_CODE entry
  3. Create Structure ZST_TEST with fields REGION_CODE, COUNTRY_CODE
  4. Attach search help ZSH_REGION to structure field REGION_CODE
  5. Attach search help ZSH_COUNTRY to structure field COUNTRY_CODE and map REGION_CODE to structure field ZST_TEST-ZST_TESTREGION_CODE as well
  6. Create context node by using DDIC structure: ZST_TEST with cardinality 0...n
  7. You can use TABLE UI / ALV

Now based on region key selected in column1, the column2 entries are pulled from structure - search help fields mapping.

Hope this helps you.

Regards,

Rama

former_member202077
Participant
0 Kudos

Thank you.

Sorry, i didn't get you at all, pls. eloborate, like in a steps by step mannner

Using IF_WD_CONTEXT_NODE_INFO=>SET_ATTRIBUTE_VALUE_SET and a new attribute, you should be able to customize the entries of this second DDBK upon the line selection.

If you want DDBK value set to be separate, you should different context attributes mapped to the DDBK.

Regards

Answers (1)

Answers (1)

former_member219762
Contributor
0 Kudos

Hi,

Go through this link http://scn.sap.com/docs/DOC-48672

Regards,

Sreenivas.