cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP: set_attribute( name = 'SOME_ATTR' value = ... ).

Former Member
0 Kudos

Hello,

I need to set attribute of a context to some values that come from a database table. It is not a single value but a set of values.

When I call a set_attribute method one of the parameters that it takes is VALUE of type DATA (values that set the attribute). When I pass a single value everything works out fine but I need to pas a table into it. I get an error when I try to pass a table to it.

How can I pass a set of data and not just a single value?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Georgy,

What is the type of your 'SOME_ATTR' attribute? Table or simple type?

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

type of 'SOME_ATTR' is a column of a datbase table.

For example, /SCA/ABC-XYZ.

Thanks.

former_member182372
Active Contributor
0 Kudos

Hi Georgy,

Create node with the same type like your table, add required attributes and after loading data to the table just bind context node with table.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

Here are couple of things that I did.

I have a database table that has some data, let's call it /SCA/ABC

Context has one node TABLE_OVERVIEW which is mapped to Dictionary Structure /SCA/ABC with Cardinality 0...n

On the screen there is a table that is bound to this context node.

In WDDOINIT I set this node this way (so the user can see the data):

DATA: lt TYPE TABLE OF /sca/abc.

SELECT *

INTO CORRESPONDING FIELDS OF TABLE lt

FROM /sca/abc.

wd_context->bind_table( new_items = lt ).

When WDDOINIT method is executed I get the following error message: Number of Elements of the Collection of Node ... Violates the Cardinality.

I am not exactly sure if this line of code wd_context->bind_table( new_items = lt ) binds my context node to the table.

Could you comment?

Thank you.

Georgy

former_member182372
Active Contributor
0 Kudos

Hi Georgy,

But you are binding table not to your node but to root node!

Try to use


data: TABLE_NODE type ref to IF_WD_CONTEXT_NODE.
TABLE_NODE = WD_CONTEXT->GET_CHILD_NODE( 'TABLE_OVERVIEW ' ).
TABLE_NODE->bind_elements( lt ).

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hello Maksim,

Yes, you are right.

Thanks for your help.

I awarded you 10 points.

Georgy

Answers (0)