Handle the Handle Classes correctly

Share on Facebook0Share on LinkedIn5Tweet about this on TwitterShare on Google+1
Please Share!!

Gone are the days where we had the liberty to have import parameters as tables, structures or single fields. SAP has been pushing hard for more than a decade for OOPs. BADI ME_PROCESS_PO_CUST is one of the commonly used enhancement object in Material Management module, where quite a few developers find this BADI difficult to implement.

Check few real time issues faced by real ABAPers.
http://scn.sap.com/message/16059347#16059347
http://scn.sap.com/message/15702382#15702382
http://scn.sap.com/thread/668543
http://scn.sap.com/thread/3758706

[adToAppearHere]

What is the difficulty?
All the methods in this BADI interface has TYPE REF TO importing parameters.. OOPs!! it is a pain.. 🙂

Please find a working code snippet to read PO Header, PO Item and PO Item Service data. Please note lt_poitem, ls_items and lr_item are TYPE REF data types.

Let me show you how the structures, tables and reference objects look at run time.

2

3

4

CL_PO_ITEM_HANDLE_MM is a very important class to handle MM item data. Look closely how we have used the CL_PO_ITEM_HANDLE_MM class above.
Check the interfaces withing the class. We need to use them to get more information as and when needed.

1

Similarly you might need to look the below handle classes for PO for different scenarios.
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

If you wondered what mmpur_dynamic_cast is doing in the code snippet above? Check the macro definition below. It is casiting &2 data to &1, i.e. lr_item ?= ls_items-item.

Hope with the above hint, you would be able to fetch and save data in this BADI or similar BADIs where you have to handle the handle class interfaces and methods. Please drop a note if you have any issue or confusion.

If you want to get notification about the newest posts, please subscribe. Your email is safe with us.
If you liked it, please share it! Thanks!

 

 

Image source: www.cosmopolitan.com

Share on Facebook0Share on LinkedIn5Tweet about this on TwitterShare on Google+1
Please Share!!