[LIKELY JUNK]ABAP OO - OBJECT NOT INSTANTIATED
Dart, Jocelyn
jocelyn.dart at sap.com
Wed Jan 14 17:25:31 EST 2009
Hi Tom,
Ok - your basic approach is correct but watch your details....
For instance in your constructor method you pass your class name as a
literal in lower case 'z_cl_...' - don't give any opportunity for
confusion. Such a literal should always be in upper case as it refers
to a technical id which is upper case.
Also in your constructor method you concatenate belnr and bukrs but in
your find_by_lpor method you use a structure to break them down - never
assume that concatenate will maintain correct field placings with
multiple key instances - always use a structure - easiest way to make
sure the same structure is available to all methods is to create a type
in your class or use DDIC element.
And also read Florin's comments - as explained in the blogs you must
first instantiate the object before using it - just as you did in BOR.
Often of course your object is instantiated by the incoming event, but
if you are not using an event to pass your object instance you need to
instantiate it yourself.
That is, you must have two steps in your workflow - first step is a task
to instantiate the object and put the instance reference in your
workflow container, then in the second step you call your task that
calls your retrieve anek method - passing in your object instance.
Usually if methods work directly when called in the class but not when
called from workflow it is because you have a problem in your lpor or
find_by_lpor method - they must agree absolutely on the value of the
persistent object reference as this is the reference workflow uses to
navigate to/from classes. You never see the workflow directly call
these methods - they are "behind the scenes" - but they are absolutely
critical to getting the solution to work.
Hope that helps.
Regards,
Jocelyn
________________________________
From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf
Of Simon, Tom
Sent: Thursday, 15 January 2009 1:57 AM
To: sap-wug at mit.edu
Subject: [LIKELY JUNK]ABAP OO - OBJECT NOT INSTANTIATED
I am using a method in a class(z_cl_liv_assets) that I created for a
workflow task. The object does not get instantiated by the workflow. I
have read all the blogs by Jocelyn Dart and wondered if anyone could
look over my structures and provide insight into why it does not work.
When I test the instant constructor and pass in the doc num and company
code it works. If I pass the import parameters directly to the method it
works. But if I try to use the instant attributes it does not work
created by the constructor it does not work.
When I test the task in swus it does not instantiate the object?
Any help is apprecitated?
Thank you,
Tom Simon
Bindings in the task to class z_cl_liv_assets~retrieve_anek:
wf container task container
docnum -> im_belnr
company code -> im_bukrs
ex_anek <- ex_anek
z_cl_liv_assets <- wi_object_id
bindings from task to method retrieve_anek.
im_belnr to im_belnr
im_bukrs to im_bukrs
Class: z_cl_liv_assets;
Attributes:
BELNR InstanPubl Type ANEK-BELNR
BUKRS InstanPubl Type ANEK-BUKRS
T_ANEK InstanPubl Type FAA_T_ANEK
M_POR InstanProt Type SIBFLPOR
GJAHR InstanPubl Type ANEK-GJAHR
Methods:
Parameters:
LPOR Importing Type SIBFLPOR
RESULT Returning Type Ref To BI_PERSISTENT
METHOD bi_persistent~find_by_lpor.
DATA: lv_liv_doc TYPE anek-belnr,
lv_liv_co TYPE anek-bukrs.
MOVE lpor-instid(10) TO lv_liv_doc.
MOVE lpor-instid+10(4) TO lv_liv_co.
CREATE OBJECT result
TYPE
z_cl_liv_assets
EXPORTING
im_belnr = lv_liv_doc
im_bukrs = lv_liv_co.
ENDMETHOD.
Parameters:RESULT Returning Type SIBFLPOR
METHOD bi_persistent~lpor.
DATA: lpor TYPE sibflpor.
lpor-catid = 'CL'.
lpor-typeid = 'Z_CL_LIV_ASSETS'.
CONCATENATE me->belnr me->bukrs INTO lpor-instid.
result = lpor.
ENDMETHOD.
parameters:
IM_BELNR Type ANEK-BELNR
IM_BUKRS Type ANEK-BUKRS
METHOD constructor.
me->belnr = im_belnr.
me->bukrs = im_bukrs.
me->M_por-catid = 'CL'.
me->M_por-typeid = 'z_cl_liv_assets'.
CONCATENATE me->belnr me->bukrs INTO me->M_por-instid.
* me->m_por-instid = me->belnr.
ENDMETHOD.
Parameters:
EX_ANEK Exporting Type FAA_T_ANEK
METHOD retrieve_anek.
CALL FUNCTION 'ANEK_READ_MULITPLE'
EXPORTING
i_belnr = me->belnr
i_bukrs = me->bukrs
TABLES
t_anek = ex_anek.
IF sy-subrc = 0.
me->t_anek = ex_anek.
ENDIF.
ENDMETHOD.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20090115/890f8cbe/attachment.htm
More information about the SAP-WUG
mailing list