cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I set a value to Object attributes?

Former Member
0 Kudos

Hi , everyone.

I have some question.

I built a workflow and added a business object in WF container.

And then I pass the object to container in a step ans finally pass the object in step to object method linked to step using parameter.

The passing way is call by reference?

I absolutely change the object attribute in the method of object linked to step.

But the attribute is not updated in the two container's objects.

What happen?

Humm..

If you know what I make mistake. let me know on that in detail.

Wait for your reply..

Regards Jun.

Accepted Solutions (0)

Answers (2)

Answers (2)

KKilhavn
Active Contributor
0 Kudos

This is a bit of a shot in the dark, but you provide very little specific information about your problem.

Have you ruled out the possibility of an error in your method's code? Remember, it is not enough to change an attribute in the object's (private) data structure, you have to update the container element.

Also, for methods you should return data instead of or in addition to updating attributes. If you have a virtual attribute you should update it in the code for the virtual attribute, so you don't have to call a method to get the value.

Former Member
0 Kudos

Workflow Object in container -


pass--> Task Object in container -


pass--> Method parameter linked to Task.

and then below is the method statement.

BEGIN_METHOD SET_TITLE CHANGING CONTAINER.

DATA:

APPID TYPE ZWFL00-APPID.

OBJECT-TITLE = 'My title'.

SWC_SET_ELEMENT CONTAINER '_WI_OBJECT_ID' SELF.

END_METHOD.

What I really want is setting the object's 'TITLE' attribute to 'My title'.

Former Member
0 Kudos

Hi,

I think Kjetil has replied recently to you about this in one of the threads:

Have a look ..

Regards,

Akshay

KKilhavn
Active Contributor
0 Kudos

Yes, it seems that is relevant for this case as well.

Former Member
0 Kudos

IF object-uname IS INITIAL.

object-uname = sy-uname.

ENDIF.

swc_set_element container 'UserName' object-uname.

end_method.

I don't understand why this code "swc_set_element container 'UserName' object-uname" is needed.

I think the statement means that "UserName" element in a container is set to object-uname.

Is that right?

Does it mean the object's uname attribute and "UserName" element in a container are linked as reference?

Sorry for my foolish.

It takes a long time to get used a SAP W/F and It is a hard time learning it.^^

former_member184495
Active Contributor
0 Kudos

Hi,

I assume you are passing the values from your method to parameters, then from parameters to your task container... if that is so...

check the macro you must have written in your method as it should be

swc_set_element container 'parameter' variable.

if thats perfect check whether your parameter is of export type.

if thats perfect check whether your task container is of import and export type.

Hope it helps,

Aditya

Former Member
0 Kudos

The Object Attribute is not assigned to the method's export parameter.

System alert "Value of expression '&_WI_OBJECT_ID.TITLE& cannot be used as the target of an assignment."

Hum...

If the mapping Object attribute to export parameter is allowed. everything will be OK.

KKilhavn
Active Contributor
0 Kudos

First of all - the following is <b>NOT Good</b>

SWC_SET_ELEMENT CONTAINER '_WI_OBJECT_ID' SELF.

The container element "_WI_Object_ID" is a system-controlled container element, so you shouldn't mess with it.

Second, are you trying to bind something into "_WI_Object_ID.Title" when returning from the method? That is not possible. Title is an attribute of the object in the container, not a container element. You can only bind to container elements - possibly also into individual structure elements now, but surely not into an attribute of an object.

You're saying that the object attribute is not assigned to the method's export parameter. That's fine as a statement, but if you want someone here to tell you how to solve the problem you should also tell us what the definition of the export parameter is and the code you use to set the export parameter. As it is now, I can only give you the general information. If I have understood you correct your problem is that you try to bind to the attribute Title, but if the problem is in the code, here are two simple rules:

1) Your export parameter should be defined with reference to a type compatible with the data type of the field you try to write to the container. Normally you would use the same data type.

2) You have to use the correct macro to set the export parameter (swc_set_element for ordinary parameters, and swc_set_table for those defined as multiline parameters).