2011 Oct 11 6:36 PM
The code I have implemented below is working fine toi retrieve all of the PO header, line item, and accounting information. In the PROCESS_HEADER METHOD. For this particular scenario the logic only breaks into the PROCESS_HEADER method. This data is needed to compare to the line item that is being processed/.
How do I tell tell which line item is trying to be changed (or processed) at the time,so I have something to compare my data to below? Or a method to call that will check what these values were in the Purchase requisition? get_exkn? not sure how to do this.
METHOD if_ex_me_process_po_cust~process_header.
DATA: rzcl_im_4ppi_glpo4 TYPE REF TO zcl_im_4ppi_glpo4.
DATA : lt_items TYPE purchase_order_items.
DATA : ls_mepoheader TYPE mepoheader.
DATA: ls_item TYPE purchase_order_items.
DATA: zcl_po TYPE REF TO cl_po_header_handle_mm.
DATA: ls_items TYPE purchase_order_item.
DATA: lt_mepoitem TYPE STANDARD TABLE OF mepoitem.
DATA: ls_mepoitem TYPE mepoitem.
DATA: lt_accounting TYPE purchase_order_accountings.
DATA: ls_accounting TYPE purchase_order_accounting.
DATA: lt_mepoacct TYPE STANDARD TABLE OF mepoaccounting.
DATA: ls_mepoacct TYPE mepoaccounting.
*create the class instance from P.O. class interface
CREATE OBJECT rzcl_im_4ppi_glpo4.
*get header and item data
ls_mepoheader = im_header->get_data( ).
* ls_item = im_header->get_items( ).
*created a second instance from cl_po_header_handle_mm
CREATE OBJECT zcl_po
EXPORTING
im_po_number = ls_mepoheader-ebeln.
*--------------------------------------------------**
* Extract PO Item Information **
*--------------------------------------------------**
REFRESH : lt_items.
lt_items = zcl_po->if_purchase_order_mm~get_items( ).
LOOP AT lt_items INTO ls_items.
ls_mepoitem = ls_items-item->get_data( ).
APPEND ls_mepoitem TO lt_mepoitem.
ENDLOOP.
* --------------------------------------------------**
** Extract PO Account Assignments
** --------------------------------------------------**
REFRESH : lt_accounting.
lt_accounting = ls_items-item->get_accountings( ).
LOOP AT lt_accounting INTO ls_accounting.
ls_mepoacct = ls_accounting-accounting->get_data( ).
APPEND ls_mepoacct TO lt_mepoacct.
ENDLOOP.
ENDMETHOD.Edited by: Tom Matys on Oct 11, 2011 1:37 PM
2011 Oct 11 6:56 PM
You can't know which Item is being processed in the PROCESS_HEADER as Header BADI is being called with all items.
If you need to know which Item is being processed in your logic, you should move it to PROCESS_ITEM or CHECK. CHECK gets triggered before saving.
Regards,
Naimesh Patel
The code I have implemented below is working fine toi retrieve all of the PO header, line item, and accounting information. In the PROCESS_HEADER METHOD. For this particular scenario the logic only breaks into the PROCESS_HEADER method. This data is needed to compare to the line item that is being processed/.
How do I tell tell which line item is trying to be changed (or processed) at the time,so I have something to compare my data to below? Or a method to call that will check what these values were in the Purchase requisition? get_exkn? not sure how to do this.
METHOD if_ex_me_process_po_cust~process_header.
DATA: rzcl_im_4ppi_glpo4 TYPE REF TO zcl_im_4ppi_glpo4.
DATA : lt_items TYPE purchase_order_items.
DATA : ls_mepoheader TYPE mepoheader.
DATA: ls_item TYPE purchase_order_items.
DATA: zcl_po TYPE REF TO cl_po_header_handle_mm.
DATA: ls_items TYPE purchase_order_item.
DATA: lt_mepoitem TYPE STANDARD TABLE OF mepoitem.
DATA: ls_mepoitem TYPE mepoitem.
DATA: lt_accounting TYPE purchase_order_accountings.
DATA: ls_accounting TYPE purchase_order_accounting.
DATA: lt_mepoacct TYPE STANDARD TABLE OF mepoaccounting.
DATA: ls_mepoacct TYPE mepoaccounting.
*create the class instance from P.O. class interface
CREATE OBJECT rzcl_im_4ppi_glpo4.
*get header and item data
ls_mepoheader = im_header->get_data( ).
* ls_item = im_header->get_items( ).
*created a second instance from cl_po_header_handle_mm
CREATE OBJECT zcl_po
EXPORTING
im_po_number = ls_mepoheader-ebeln.
*--------------------------------------------------**
* Extract PO Item Information **
*--------------------------------------------------**
REFRESH : lt_items.
lt_items = zcl_po->if_purchase_order_mm~get_items( ).
LOOP AT lt_items INTO ls_items.
ls_mepoitem = ls_items-item->get_data( ).
APPEND ls_mepoitem TO lt_mepoitem.
ENDLOOP.
* --------------------------------------------------**
** Extract PO Account Assignments
** --------------------------------------------------**
REFRESH : lt_accounting.
lt_accounting = ls_items-item->get_accountings( ).
LOOP AT lt_accounting INTO ls_accounting.
ls_mepoacct = ls_accounting-accounting->get_data( ).
APPEND ls_mepoacct TO lt_mepoacct.
ENDLOOP.
ENDMETHOD.Edited by: Tom Matys on Oct 11, 2011 1:37 PM
2011 Oct 11 6:56 PM
You can't know which Item is being processed in the PROCESS_HEADER as Header BADI is being called with all items.
If you need to know which Item is being processed in your logic, you should move it to PROCESS_ITEM or CHECK. CHECK gets triggered before saving.
Regards,
Naimesh Patel
2011 Oct 11 7:03 PM
I do have logic in process_item as well. When I was finally able to figure out how to call it from the process_header the methods within it were abending with "NULL Object". So, I opted to use Process_Header. I am assuming when I called it, I didn't pass it enough information to it. Below are the first two methods that I use in process_item that do not wrk when calling it from process_header.
What is the correct way to call process_item from process_header? And what needs to be passed?
Thank-You.
IN PROCESS_ITEM
call method im_item->get_previous_data
importing
ex_data = ex_prev_data
exceptions
no_data = 1.
*get item data
call method im_item->get_data
receiving
re_data = lw_item.Edited by: Tom Matys on Oct 11, 2011 2:04 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |