on 12-01-2017 4:28 AM
Hi Gurus,
Some how my workflow is driving me nuts. need your expert advise again.
I am trying to instantiate a class to display default method under 'objects and assignment' in a user decision step of WF. i have a Zclass with 3 attributes: 2 key fileds(Instance and public) and one MS_LPOR(instance & public).
Have a method called 'instantiate_CL' importing document no from workflow task. this document no is then passed to constructor and instance of the class is created as required.
My code for instantiation
TRY.
CREATE OBJECT cl_instance
EXPORTING
iv_irdoc = iv_doc
iv_year = iv_gjahr.
CATCH cx_bo_error.
ENDTRY.
instance of above code
i have to catch this back in workflow task. some how i am not able to get this instance properly in workflow task.
CL_INSTANCE value in workflow task.
your inputs would be higly helpfull in resolving this.
Firstly, you don't need a task to instantiate a class. Just call a static method in a container operation.
%zcl_name.get_instance( i_year = &YEAR& i_docno = &DOCNO& )%
Secondly, as Anjan already suggested, I don't think your LPOR/FIND_BY_LPOR is working correctly. Make sure that FIND_BY_LPOR returns your object instance. Post your code if it doesn't work / not sure.
PS. Tags are for tagging things to make them searchable. It does not alert anyone. Putting someone's name in a tag only means someone looking for Sandra Rossi will find this post. As I already know my name, I do not usually search SCN for it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mike, Thanks for the response. below is my code.
My observation: Value of importing parameter LPOR inside method FIND_BY_LPOR is always initial.
****************************************FIND_BY_LPOR
METHOD bi_persistent~find_by_lpor.
DATA: lv_docno TYPE rseg-belnr,
lv_year TYPE rseg-gjahr.
lv_docno = lpor+0(10).
lv_year = lpor+10(4).
TRY.
CREATE OBJECT result
TYPE Zcl_wf_ap_payblock
EXPORTING
iv_irdoc = lv_docno
iv_year = lv_year.
CATCH cx_bo_error .
*------ object not found
EXIT.
ENDTRY.
ENDMETHOD
****************************************Method LPOR
METHOD bi_persistent~lpor.
result = me->ms_lpor.
ENDMETHOD.
***************************************Constructor
METHOD constructor.
DATA: lv_id TYPE char14.
CONCATENATE iv_irdoc iv_year INTO lv_id.
me->gv_irdoc = iv_irdoc.
me->gv_year = iv_year.
me->ms_lpor-instid = lv_id.
me->ms_lpor-catid = 'CL'.
me->ms_lpor-typeid = '/ESTA/CL_WF_AP_PAYBLOCK'.
ENDMETHOD.
*******************************************Initiate
This method gets gets iv_gjahr iv_doc from workflow task
METHOD instantiate_cl.
DATA: lv_id TYPE char14,
rak TYPE c.
CONCATENATE iv_doc iv_gjahr INTO lv_id.
TRY.
CREATE OBJECT cl_instance
EXPORTING
iv_irdoc = iv_doc
iv_year = iv_gjahr.
CATCH cx_bo_error.
ENDTRY.
ENDMETHOD.<br>
Is your class named ZCL_WF_AP_PAYBLOCK?
So, why did you enter:
me->ms_lpor-typeid = '/ESTA/CL_WF_AP_PAYBLOCK'.
Shouldn't it be:
me->ms_lpor-typeid = 'ZCL_WF_AP_PAYBLOCK'.
?
Hi Sandra,
Able to resolve the issue this morning.
Its the issue with code written in constructor. i have explained the reason below.
Thanks a lot Sandra for your time. your inputs were really helpful through out this WF development.
METHOD constructor.
DATA: lv_id TYPE char14.
CONCATENATE iv_irdoc iv_year INTO lv_id.
me->gv_irdoc = iv_irdoc.
me->gv_year = iv_year.
me->ms_lpor-instid = lv_id.
me->ms_lpor-catid = 'CL'.
Below line is the cause of error. My class name is start with '/ETSA*' but i have hard coded as '/ESTA'. so find_by_LPOR is not able to catch the instance created. it's all fixed now.
me->ms_lpor-typeid = '/ESTA/CL_WF_AP_PAYBLOCK'.
ENDMETHOD.
Hi,
You have to first check two things. Is the class uses if_workflow interface. And LPOR and Find_by_lpor method properly implemented or not
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.