Another spell for the hacker book
The object oriented programming in APO uses in many cases the singleton pattern. An object static method (class method in standard object oriented talk) is used to obtain the object instance. If it is the first time the object is created and stored in a static attribute (class attribute). Then further calls to the method return the instance stored in the attribute. A practical result of this coding logic is that these objects become global structures of data because as long they were initialized at a given point of time, they are can be accessed at any later time just by calling the static method. For example, the object /SAPAPO/CL_ATPFIELD_BUF can be called in ATP user-exits to get the field catalog (some user-exits don’t have the field catalog available in the input parameters).
CALL METHOD /sapapo/cl_atpfield_buf=>get_atpfield
EXPORTING
iv_ordid = lv_ordid
iv_delps = lv_delps
IMPORTING
et_atpfield = lt_atpfield.
This works because the field catalog is stored in a static attribute of the object.
For global classes (like /SAPAPO/CL_ATPFIELD_BUF) this is very simple, but ABAP also allows the definition of local classes. For example, the main objects for the ATP calculation (LCL_REQUIREMENT_ATP, etc) are classes defined inside program /SAPAPO/SAPLATPT. I always wanted to have access to these objects inside user-exits (because it means having access to all ATP information). Something like this trick for global variables but able to access the objects.
After many failed attempts, this one works fine.
DATA:
l_name(150) TYPE c,
l_tabtype(150) TYPE c,
ldr_reqref TYPE REF TO data.
FIELD-SYMBOLS:
<reqref_t> TYPE ANY TABLE.
l_name = '\PROGRAM=/SAPAPO/SAPLATPT\CLASS=LCL_REQUIREMENT_ATP'.
l_tabtype = '\PROGRAM=/SAPAPO/SAPLATPT\TYPE=TBL_REQREF'.
CREATE DATA ldr_reqref TYPE (l_tabtype).
ASSIGN ldr_reqref->* TO <reqref_t> CASTING TYPE (l_tabtype).
CALL METHOD (l_name)=>get_instances
RECEIVING rt_reqref = <reqref_t>.
Now this pointer <reqref_t> is a pointer to a list of all LCL_REQUIREMENT_ATP object instances relevant for the current ATP check.
2 Comments:
hiee........is there any other way to find out the hidden BADI'S in R/# side.
in R/3 Side
Post a Comment
<< Home