Let’s delve into the Handle the Handle Classes correctly. Gone are the days where we had the freedom to have import boundaries as tables, designs or single fields. SAP has been pushing hard for over 10 years for Oh no. BADI ME_PROCESS_PO_CUST is one of the usually utilized upgrade object in Material Administration module, where many engineers find this BADI challenging to carry out.
What is the difficulty? Handle the Handle Classes correctly
Every one of the strategies in this BADI interface has TYPE REF TO bringing in boundaries.. Oh no!! it is an aggravation..
Kindly track down a functioning code scrap to peruse PO Header, PO Thing and PO Thing Administration information. If it’s not too much trouble, note lt_poitem, ls_items and lr_item are TYPE REF information types.
Strategy if_ex_me_process_po_cust~process_header.
DATA: ls_poheader TYPE mepoheader,
* Table Interface with PO Item External View
lt_poitem TYPE purchase_order_items, " Table IF_PURCHASE_ORDER_ITEM_MM
* Line Interface PO Item External View
ls_items TYPE purchase_order_item, " Line IF_PURCHASE_ORDER_ITEM_MM
lt_esll TYPE mmsrv_esll,
ls_item_data TYPE mepoitem,
* Handle for Item of a Purchasing Document
lr_item TYPE REF TO cl_po_item_handle_mm.
* Get PO Header data in structure
ls_poheader = im_header->get_data( ).
* Ref Table with PO Items
lt_poitem = im_header->get_items( ).
* Loop through interface
LOOP AT lt_poitem INTO ls_items.
* PO Item data in strucrue
ls_item_data = ls_items-item->get_data( ).
* Macro to get item
mmpur_dynamic_cast lr_item ls_items-item. " cl_po_item_handle_mm
* Use method of IF_SERVICES_MM interface to fetch Service data
CALL METHOD lr_item->if_services_mm~get_srv_data
EXPORTING
im_packno = ls_item_data-packno
IMPORTING
ex_esll = lt_esll.
ENDLOOP.
ENDMETHOD.
Allow me to show you how the designs, tables and reference objects see run time.
CL_PO_ITEM_HANDLE_MM is a vital class to deal with MM thing information. Look carefully the way that we have utilized the CL_PO_ITEM_HANDLE_MM class above.
Check the connection points withing the class. We really want to involve them to get more data as and when required.
Also you could have to look the beneath handle classes for PO for various situations.
a) CL_PO_HEADER_HANDLE_MM : Handle of a Purchasing Document
b) CL_PO_PARTNER_HANDLE_MM : Purchasing Document Partner
c) CL_PO_SCHEDULE_HANDLE_MM : Schedule Line of a Purchasing Document
d) CL_PO_ACCOUNTING_HANDLE_MM : Purchasing Document Account Assignment
e) CL_PO_ACCOUNTING_HANDLE_FM_MM : Purchasing Document Account Assignment
On the off chance that you thought about the thing mmpur_dynamic_cast is doing in the code bit previously? Really look at the full scale definition underneath. It is casiting &2 information to &1, for example lr_item ?= ls_items-thing.
*---------------------------------------------------------------------* * MACROS for Dynamic Cast *---------------------------------------------------------------------* * use: dynamic_cast reference_target_type reference_source_type * result: a) cast works (reference_target_type assigned) * b) cast doesn't work (reference_target_type cleared) * sy-subrc = 1 DEFINE mmpur_dynamic_cast. catch system-exceptions move_cast_error = 1. &1 ?= &2. endcatch. if sy-subrc = 1. clear: &1. endif. END-OF-DEFINITION.
Trust with the above hint, you would have the option to bring and save information in this BADI or comparative BADIs where you need to deal with the handle class connection points and techniques. If it’s not too much trouble, drop a note on the off chance that you have any issue or disarray.
YOU MAY LIKE THIS
How to find badi in sap abap ?
Program Exits in Work Item for Workflow
Create and Consume Business Add-in(BAdI) in ABAP