cancel
Showing results for 
Search instead for 
Did you mean: 

class attribute in technical workflow log not updated

0 Kudos

Hi Gurus,

I built a workflow analogous to the famous demo workflow "demoformabs" but with the demo class: CL_SWF_FORMABSENC instead of the BOR: FORMABSENC.

In the BOR Formabsenc there is also an attribute for the "Approver" (USR01) in addition to "Creator" (USR01).

This attribute "Approver" is missing in the class "CL_SWF_FORMABSENC".

So I added this attribute "Approver" also in the class "CL_SWF_FORMABSENC":

data APPROVER type SIBFLPORB value CL_SWF_BOR_TYPES=>MC_USR01.

Finally in the method "approve" I set the value for the attribute "APPROVER".

me->approver-instid = me->APPROVBY.

I can see that the value has been successfully set by setting a binding from this class attribute to a workflow container element.

BUT, in the technical workflow log (container) I can not see the class attribute "Approver" populated.

Here it´s still displayed as < no instance >.

What do I need to do, to make this value appear also in this class attribute in the technical workflow log?

Albeit I know, that it´s working, I am getting confused, that it´s still displayed as empty.

Cheers,

Dominik

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I agree with Modak, just put a break point to the FIND_BY_LPOR method, and then go to open the workflow log. You will see what happens in the code.

In general, you need to understand that you are not basically seeing the same instance during the approval and when opening the workflow log. When you open the log, the object gets instantiated, so whatever you might have done earlier with your approval method to the object instance at the moment of approval does not have effect what you see in workflow. => In your constructor, you need to populate the value for me->approver.

(I hope I have understood your question properly...)

Kind regards,

Karri

Answers (4)

Answers (4)

pokrakam
Active Contributor
0 Kudos

Hi Dominik,

You should not populate attributes in this manner, for the very reason you're experiencing. Attributes are transient and behave like variables, i.e. when the class stops existing they disappear. During binding only the key is transferred, and - if needed - the class is re-instantiated at the other end. If you have implemented some kind of buffering/instance management (not a bad idea), then you may be lucky to have attributes survive if everything happens within the same program context. However once your WF session stops executing, this is lost.

This is why when you look at the log later, it is re-instantiating a completely new instance - where would it know the approver from?

The attribute value must be written to the DB somewhere, so that any later object instantiation (e.g. when you look at the log) will read the value and populate the attributes correctly.

Incidentally this is why OO theory discourages the use of public attributes and suggests GET_ and SET_ methods instead....

Regards,

Mike

0 Kudos

Hi Modak & Karri,

thanks for your helpful answers, that pointed me to the right direction.

If I start the workflow from transcation swus and right after the workflow has finished, open the technical workflow log, the value "Approver" is not populated.

But if I leave 'swus' and afterwards open the technical log again, the value is displayed.

Cheers

Dominik 

I042439
Employee
Employee
0 Kudos

Hi Dominik


How is the method FIND_BY_LPOR coded for CL_SWF_FORMABSENC?

I am sure its creating an instance (or reading from static list) .

There, the approver is not set !!! ????

Just to be sure - put a break point there, go to technical log, expand your CL_SWF_FORMABSENC container....the Break point will stop there. FIND_BY_LPOR gets called to get a runtime instance, by using CREATE OBJECT statement ..... so please first check if FIND_BY_LPOR is getting it or not.

regards,

Modak

I042439
Employee
Employee
0 Kudos

If you are storing your instance (after CREATE OBJECT in FIND_BY_LPOR) in a static table of the same class (to prevent multiple instantiation), then you can do the following:


The place where you give the statement me->approver-instid = me->APPROVBY.

After that, update that internal static table of the class with "Me" so that in method FIND_BY_LPOR, before creating the object, you read it with the key and get the upated instance (else create object and pass back + store in that table for future).

regards,

Modak

Former Member
0 Kudos

you are binding a class attribute to the workflow container. Where would you like to see the class atribute? you only can see container elements there, not the values that are passed to them. Or did I miss something?

0 Kudos

Here you can see what I mean:

Approver is still <No Instance>. But there definitely is a value assigned to this attrribute.

Cheers

Dominik