on 04-04-2016 8:16 PM
Hi experts.
I'm implementing a custom WF, using a Z class, so, I implemented FIND_BY_LPOR and LPOR methods. My class instance is alredy created, but I can't modify any non-key attribute, I mean, my constructor is something like this:
**This is my static method
METHOD zme_politic_constructor.
CREATE OBJECT politic
EXPORTING
i_vbeln = i_vbeln.
** from this point, there are no changes in my instance attributes
politic->zme_politic_get_marg( ).
politic->zme_politic_id_difer( ).
politic->zme_politic_escala( ).
politic->zme_politica_get_authorizers( ).
ENDMETHOD.
METHOD constructor.
me->vbeln = i_vbeln.
m_lpor-instid = i_vbeln.
m_lpor-catid = 'CL'.
m_lpor-typeid = 'ZCL_FLUJO_WF'.
ENDMETHOD.
I don't know what to do in order to modify any other attribute. Do you have any ideas?
Best regards!
I am not sure I fully understand the question. The code you post doesn't touch instance attributes. At what point are you expecting to modify attributes? Who or what is supposed to modify them?
To reuse your code:
METHOD constructor.
me->vbeln = i_vbeln.
m_lpor-instid = i_vbeln.
m_lpor-catid = 'CL'.
m_lpor-typeid = 'ZCL_FLUJO_WF'.
some_public_attribute = 'Hello World!'. " <---- modify attribute
ENDMETHOD.
Is this what you're after?
Regards,
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Mike.
I'm trying to do this modification from a WF task, I have built a WF where the instance is created, but when I try to use an instance method, I can´t modify my attributes.
I'm giving the instance to the method trough my task interface and I can't modify them at all. And yes, that's what I want to do: modify some public instance attribute.
Regards.
OK, so one node creates the instance and another wants to modify the attributes?
It doesn't work like that. An instance exists in memory, attributes are populated in code. If a method sets an attribute, the instance's attribute gets changed. If the workflow stops, the instance is gone. The next time it instantiates, it gets reloaded from the database.
So, if my understanding is correct, what you really need is to update the database. This is usually done via update methods on the class.
Hope that helps,
Mike
Yes, I understand that, but I'm keeping the instance from the class to the WF and viceversa, I also implemented FIND_BY_LPOR an LPOR persistence methods in my class. But I think I will do as you say, keep data in the DB or use the public section of my class without creating an instance.
Thanks!
If your object is not currently stored in the DB you may not need IF_WORKFLOW at all. And it is always possible to modify attributes of a class, unless declared read-only. This is standard ABAP.
Could you explain what you're trying to accomplish? Maybe then we could give a better informed opinion.
No, it's not, it's just a runtime object.
What I'm trying to do is this:
I have a WF where a lot of parameters were declared, so, I want to optimeze it as much as I can. I created a Z class to manage this parameters.
It's constructor has only 1 parameter (VBELN), and then it has many simple calculation methods (go to table A, retrieve parameter P1, go to table B and get P2), and this methods has to modify instance variables in order to have a fully described object through the execution of the methods.
I wanted to do this step by step inside the WF, but then, with your help, I realized that I could do that with some Static methods or by using some table, so, I will use static methods and won't try to modify my container reference, instead, I'm using an Import/Export table parameter, in this way, I avoid the use of instance methods.
Hope this is a good explanation.
Hello Alejandro,
OK, understand. You can also access static methods directly, without any need for IF_WORKFLOW. For example, use a container operation to assign:
&ELEM& = %zcl_myclass=>get_value( )%
or:
&ELEM& = %zcl_myclass=>get_value( i_param = &BLAH& )%
Another way would be to use a class constructor to populate the attributes in the same way as my first post, then you could always read %zcl_myclass=>attrib1% directly.
There is a small benefit in that it will be cached throughout a single dialog session, which could be several steps in WF.
Or you could use a persistent class, or even BRF+.
Regards,
Mike
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.