cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic DropDowns using Web Dynpro for ABAP

Former Member
0 Kudos

Hi,

I'm creating my first Web Dynpro for my new client.

The requirement is this:

There are three fields to be displayed on a screen - FieldA, FieldB, FieldC.

All three should appear as DropDowns on the screen.

FieldA determines the possible value list of FieldB.

Once Field B is selected, FieldA and FieldB determines the possible value list of FieldC.

Each of the fields have their own "master" and text tables. (eg: like T005 and T005T).

There is also a "matrix" table that contains all three fields (as Primary Keys). Note: There is also a "Disabled flag" field.

So basically we have 3 tables containing the master records.

We use these values to build a matrix of combinations:

-----------------------------------
FieldA   FieldB   FieldC   Disabled
-----------------------------------
A111     B111     C111     ' '
A111     B111     C222     ' '
A111     B111     C333     'X'
A222     B111     C111     ' '
A222     B111     C333     ' '
A222     B222     C111     ' '
...
-----------------------------------

Now, we want to display the three fields on a Web Dynpro View.

I've created View Context as follows:

CONTEXT
  +-- Header_Data (node)
      +-- FIELDA_NODE (node)
          +-- FIELDA_CODE (attribute)
          +-- FIELDA_TEXT (attribute)

FIELDA_NODE is based on the Disctionary Structore of FieldA's text table (which contains, the LANGU field, and the FieldA Code and Text fields)

Cardinality and Selection are both 0..1

FIELDA_CODE (attribute) has Input Value Mode of "Automatic". When I chose this, SAP derived the Type of Input Help as "Search Help" and Determined Input Help as "ZFIELDA_SH" (which I created using the "master" and text tables).

(Note: FIELDB and FIELDC are defined the same way).

I then created the Layout:

For FEILDA_CODE, I created a DropDownByKey (using the context menu item "Create Container Form"). So now, FIELDA_CODE's property selectedKey is "...HEADER_DATA.FIELDA_NODE.FIELDA_CODE" (as per above View Context).

Now when I run the Web Dynpro Application, I get the error:

Context Path HEADER_DATA.FIELDA_NODE.FIELDA_CODE Cannot Be Resolved (Last Node Is Empty) ?ꯀ ??

Can anybody help with this?

I have no idea why it's doing this. I assume I've missed a step or done something completely wrong!

I've tried DropDownByIndex for FIELDA_CODE, and got the error message:

The ASSERT condition was violated.

(Note: One way that does work is to create a Supply Function (node property) for the FIELDA_NODE. And create a DropDownByIndex for the FIELDA_TEXT field/attribute.)

But, I feel this should be un-necessary. Since I have the master and text tables, I have the Search Help, I should be able to create a DropDownByKey field - without need for any coding.

Also, once FieldA is working.

How can I restrict FieldB and FieldC (based on the matrix table above)?

I created an OnSelect event for FIELDA, but in the EventHandler module I wasn't sure

(1) what was the easiest way to get the selected value of FIELDA, and

(2) how to the restrict the possible values of FIELDB.

Any help would of great value!

Thank you in advance.

Rajendra

PS: Sorry for the long winded explanation, but it's the only way to describe what I've done so far.

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_szcs
Active Contributor
0 Kudos

Hi Rajendra,

In order to use a DropDownByIndex the needs to be set to multiple. Currently, the node is 0..1. Please set it to 0..N and it should work.

The reason why the DropDownByKey does not work is that the node has no element. Using 0..1 means that initially no element is present. You need to supply one.

In summary, a better design would be to decouple the places where the dropdownbykey and dropdownbyindex get their data from or to use two dropdownbyindex with a master/detail relationship.

Best regards,

Thomas