Skip to Content
0

Dynamic access to attributes of the object at runtime

Jan 08 at 04:08 AM

63

avatar image

Dear Experts,

We'd like to program our logic in SDK in ABSL in the following manner:

Based on certain conditions we need to access one of z-amount fields created for a standard object. It should be dynamic access, e.g. the decision which field to take is made at runtime.

Like in ABAP world:
ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>.

or something similar.

Is it achievable in SDK using ABSL?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Horst Schaude
Jan 08 at 01:30 PM
0

Hello Andrei,

The same dynamic is not possible with ABSL.
Please describe your requirement in more details.
Maybe we can find a solution. :-)

Bye,
. Horst

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Horst,

Easy. We have a custom integration done via pressing a button. We have an action assigned to this button. Button is required because only the user knows when he wants to replicate the object.

Action behind the button gathers the data to be sent out via outbound web service (SOAP) call.

And we need to pass a table of pricing conditions among all other things. e.g. "condition type - amount" pairs.

These amounts are basically 10 KUT fields defined in the object.

The reason for dynamic access: we'd like to have a mapping like

KUTField1 = ConditionType5

KUTField2 = ConditionType41

etc.

To make the future life easier when power user will add another KUT field for another amount he will be able to easily map KUT field to Condition type. Mapping part is achievable, no issues. But this power user doesn't have and doesn't want to have access to SDK to add a "hardcoded" mapping for the new field.

0
Andrei Vishnevsky

Hello Andrei,

What about an additional Extension Field which defines the mapping?
TypeCode which is based on "ContitionType1", "ConditionType2", ...

HTH,
. Horst

0

Hi Horst,

The mapping is not the issue. I've done it via BCO and "code-description" there represents my "KUTField-ConditionType" mapping. All good.

Basically I'd like to do the following:

1. GetAllDescriptions for my BCO maintained in Fine-tuning. It will mean I have all pairs to map. E.g mapping table.

2. Loop through this mapping table.

3. For each entry in the mapping table I would read an attribute from the actual object instance (e.g. particular KUT field on each step of the loop) and move its value into conditions table with corresponding condition type.

So the issue is in step 3. How to read an attribute dynamically from the object once I know its technical name?

0
Andrei Vishnevsky

Hello Andrei,

Got it.
So you have the name of the Extension Field as string and you need something like

var myExtensionField = myNode.GetElementByName( "KUTField1" );
if (!myExtensionField.IsInitial()) myExtensionField = ....

Sorry, this is not available in ABSL. :-(

Bye,
. Horst

0