on 12-19-2012 8:24 AM
Hi Experts,
I am provided with confirmation number and I need to fetch the PO to which that Confirmation is created.
Is there some table or FM by which I can get the same?
Thanks In Advance,
Megha Gupta
Hi,
There are two ways of finding it. One using an FM, and the other using tables.
Use BBP_PD_CONF_GETDETAIL and provide confirmation number in i_object_id to that FM. You'll get the PO number under BE_REFOBJ as Nikhil said, but only in extended classic and classic scenarios. but the SRC_GUID contains the GUID of the PO in all the scenarios including standalone. be_refobj doesnt have a value in standalone scenario. so better use src_guid to fetch it.
and the other way is get the confirmation guid from table CRMD_ORDERADM_H and in table BBP_PDHGP you have both confirmation guid (GUID) and the po guid (SRC_GUID).
Regards,
Karthik Babu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Megha ,
You can create Report or Z Fm . I have created ZFM to find out Po for confirmation in either scenarios classic as well extended classic ..
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_OBJECT_ID) LIKE CRMD_ORDERADM_H-OBJECT_ID
*" EXPORTING
*" VALUE(EO_HEADER) LIKE ZCF_APP_HEADER STRUCTURE ZCF_APP_HEADER
*" TABLES
*" EO_ITEM STRUCTURE ZCF_APP_ITEM OPTIONAL
*" EO_MESSAGES STRUCTURE ZMESSAGES OPTIONAL
*"----------------------------------------------------------------------
TYPES: BEGIN OF ty_status_text,
istat LIKE tj02t-istat,
txt30 LIKE tj02t-txt30,
END OF ty_status_text.
DATA :e_header TYPE bbp_pds_conf_header_d ,
e_item TYPE STANDARD TABLE OF bbp_pds_conf_item_d,
wa_eitem TYPE bbp_pds_conf_item_d,
wa_eitem_temp TYPE bbp_pds_conf_item_d,
e_account TYPE STANDARD TABLE OF bbp_pds_acc,
wa_account TYPE bbp_pds_acc,
e_partner TYPE STANDARD TABLE OF bbp_pds_partner,
wa_partner TYPE bbp_pds_partner,
e_longtext TYPE STANDARD TABLE OF bbp_pds_longtext,
wa_longtext TYPE bbp_pds_longtext,
e_actval TYPE STANDARD TABLE OF bbp_pds_actval,
wa_e_actval TYPE bbp_pds_actval,
v_itemtype TYPE char40 ,
wa_output TYPE zcf_app_item ,
e_item_po LIKE STANDARD TABLE OF bbp_pds_po_item_d,
wa_e_item_po LIKE bbp_pds_po_item_d,
wa_e_item_po1 LIKE bbp_pds_po_item_d,
e_reason_rej TYPE STANDARD TABLE OF bbps_text_fixvalue ,
wa_reason_rej TYPE bbps_text_fixvalue,
ponumber TYPE char10 .
DATA : v_congf_value_total TYPE bbp_value ,
e_status TYPE STANDARD TABLE OF bbp_pds_status,
wa_status TYPE bbp_pds_status,
e_messages TYPE STANDARD TABLE OF bbp_pds_messages,
wa_messages TYPE bbp_pds_messages ,
wae_messages TYPE zmessages ,
istatus_text TYPE STANDARD TABLE OF ty_status_text,
wa_status_text TYPE ty_status_text.
DATA : v_temp_date TYPE char15 .
*Refreshing all the internal tables before using them .
REFRESH : e_item[] ,e_account[] ,e_partner[],e_longtext[],e_status[],e_messages[],eo_messages[],
istatus_text[],e_reason_rej[],e_item[],e_item_po[],e_actval[],eo_item[] .
CLEAR : e_header ,eo_header.
CALL FUNCTION 'BBP_PD_CONF_GETDETAIL'
EXPORTING
i_object_id = i_object_id
i_with_itemdata = 'X'
i_attach_with_doc = ' '
i_item_sorted_by_hierarchy = 'X'
i_read_from_archive = 'X'
IMPORTING
e_header = e_header
* ET_ATTACH =
TABLES
e_item = e_item
e_account = e_account
e_partner = e_partner
e_longtext = e_longtext
e_status = e_status
e_messages = e_messages .
DELETE e_item WHERE del_ind = 'X' .
*Populating the error messages .
DELETE e_messages WHERE msgty NE 'E' .
LOOP AT e_messages INTO wa_messages .
wae_messages-msgty = 'Error'.
wae_messages-message = wa_messages-message .
APPEND wae_messages TO eo_messages .
CLEAR : wae_messages ,wa_messages .
ENDLOOP .
*Getting the status of confirmation.
DELETE e_status WHERE inact = 'X' OR stat = 'I1021'.
IF e_status[] IS NOT INITIAL .
SELECT istat txt30 FROM tj02t
INTO TABLE istatus_text
FOR ALL ENTRIES IN e_status
WHERE istat = e_status-stat
AND spras = sy-langu.
ENDIF .
READ TABLE e_status INTO wa_status WITH KEY p_guid = e_header-guid
stat = 'I1040' .
IF sy-subrc = 0.
eo_header-status = 'Deleted' .
ELSE.
READ TABLE e_status INTO wa_status WITH KEY p_guid = e_header-guid .
IF sy-subrc = 0 .
READ TABLE istatus_text INTO wa_status_text WITH KEY istat = wa_status-stat .
IF sy-subrc = 0.
MOVE wa_status_text-txt30 TO eo_header-status.
ENDIF.
IF eo_header-status CP 'HELD' .
eo_header-status = 'Saved' .
ENDIF .
ENDIF .
ENDIF .
*Populating the header data of the interface .
eo_header-zconfid = e_header-object_id .
* * Get creator name , not the ID .
SELECT SINGLE name_text FROM user_addrp
INTO eo_header-zrequestr
WHERE bname = e_header-created_by.
v_temp_date = e_header-created_at .
eo_header-zcreatedat = v_temp_date.
eo_header-zponumber = e_header-be_refobj.
*Getting the reason of rejection text .
IF e_longtext[] IS NOT INITIAL .
CALL FUNCTION 'BBP_PDH_TEXT_FIXED_VALUES_GET'
EXPORTING
iv_proc_type = 'CONF'
iv_spras = sy-langu
iv_text_id = 'RREJ'
TABLES
et_text_fixvalue = e_reason_rej.
*Reading at index , as the reason is at the header level .
READ TABLE e_longtext INTO wa_longtext INDEX 1 .
IF sy-subrc = 0 .
READ TABLE e_reason_rej INTO wa_reason_rej WITH KEY text_scheme_id = 'CONF'
text_id = 'RREJ'
spras = sy-langu
text_fixvalue_id = wa_longtext-tdline .
eo_header-rsnrej = wa_reason_rej-text_value .
ENDIF .
ENDIF .
* Next part is the item level population .
CLEAR : wa_eitem ,wa_output,v_itemtype,wa_account,wa_partner,wa_e_item_po.
LOOP AT e_item INTO wa_eitem.
wa_output-final_entry = wa_eitem-final_entry .
*Currency .
wa_output-currency = wa_eitem-currency .
*Confirmed quantity .
wa_output-cfquantity = wa_eitem-quantity .
*Item type of PO
CLEAR : v_itemtype .
* SELECT SINGLE be_item_text FROM bbp_pdbei
* INTO v_itemtype
* WHERE
* be_object_id = wa_eitem-be_refobj
* AND be_obj_item = wa_eitem-be_refobj_item.
IF wa_eitem-be_refobj_sbitm IS NOT INITIAL .
* IF v_itemtype CP '*service*' .
wa_output-itm_type = 'SERVICE' .
ELSE .
wa_output-itm_type = 'MATERIAL' .
ENDIF .
*Accounting data
READ TABLE e_account INTO wa_account WITH KEY p_guid = wa_eitem-guid .
IF sy-subrc = 0 .
wa_output-g_l_acct = wa_account-g_l_acct .
wa_output-cost_ctr = wa_account-cost_ctr .
ENDIF .
*Ship to address
READ TABLE e_partner INTO wa_partner WITH KEY p_guid = wa_eitem-parent
partner_fct = '00000027' .
IF sy-subrc = 0 .
wa_output-deladd = wa_partner-name .
wa_output-country = wa_partner-country.
wa_output-c_o_name = wa_partner-c_o_name.
wa_output-city = wa_partner-city.
wa_output-district = wa_partner-district.
wa_output-city_no = wa_partner-city_no.
wa_output-distrct_no = wa_partner-distrct_no.
wa_output-chckstatus = wa_partner-chckstatus.
wa_output-postl_cod1 = wa_partner-postl_cod1.
wa_output-po_box = wa_partner-po_box.
wa_output-street = wa_partner-street .
wa_output-street_no = wa_partner-street_no.
wa_output-house_no = wa_partner-house_no.
wa_output-location = wa_partner-location.
wa_output-building = wa_partner-building .
wa_output-time_zone = wa_partner-time_zone .
wa_output-taxjurcode = wa_partner-taxjurcode.
wa_output-adr_notes = wa_partner-adr_notes .
wa_output-tel1_numbr = wa_partner-tel1_numbr.
wa_output-tel1_ext = wa_partner-tel1_ext.
wa_output-fax_number = wa_partner-fax_number.
wa_output-e_mail = wa_partner-e_mail.
ENDIF .
CLEAR wa_partner .
*Supplier name .
READ TABLE e_partner INTO wa_partner WITH KEY p_guid = e_header-guid
partner_fct = '00000019' .
IF sy-subrc = 0 .
wa_output-suppliername = wa_partner-name .
ENDIF .
*Delivery date
wa_output-deliv_date = wa_eitem-deliv_date .
**Line item number
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
* EXPORTING
* input = wa_eitem-number_int
* IMPORTING
* output = wa_output-zitemno.
*Material/ProductID
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_eitem-ordered_prod
IMPORTING
output = wa_output-zproductid.
*Other details
wa_output-zdescription = wa_eitem-description .
wa_output-unit = wa_eitem-unit .
wa_output-price = wa_eitem-price .
wa_output-price_unit = wa_eitem-price_unit.
wa_output-category = wa_eitem-category_id .
wa_output-ponumber = wa_eitem-be_refobj.
wa_output-zitemno = wa_eitem-number_int.
*The below conversion is for matcing the PO number of conf and PO .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_eitem-be_refobj
IMPORTING
output = ponumber.
*Getting the PO details for the outstanding quantity calculation .
CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
EXPORTING
i_object_id = ponumber
i_attach_with_doc = 'X'
i_with_itemdata = 'X'
i_read_be_data = 'X'
i_item_sorted_by_hierarchy = 'X'
i_without_header_totals = 'X'
i_read_from_archive = 'X'
TABLES
e_item = e_item_po
e_actval = e_actval.
* The below loop is for matching the PO line item with the conf PO line item .
LOOP AT e_item_po INTO wa_e_item_po .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_e_item_po-be_obj_item
IMPORTING
output = wa_e_item_po-be_obj_item.
MODIFY e_item_po FROM wa_e_item_po TRANSPORTING be_obj_item .
CLEAR wa_e_item_po .
ENDLOOP .
*The below conversion is for matcing the PO line item of conf and PO .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_eitem-be_refobj_item
IMPORTING
output = wa_eitem-be_refobj_item.
*Obtaining the outstanding quantity .
IF e_actval[] IS NOT INITIAL.
IF wa_output-itm_type = 'MATERIAL' .
READ TABLE e_item_po INTO wa_e_item_po1 WITH KEY be_object_id = wa_eitem-be_refobj
* be_obj_item = wa_eitem-be_refobj_item .
number_int = wa_eitem-be_refobj_item .
ELSEIF wa_output-itm_type = 'SERVICE' .
READ TABLE e_item_po INTO wa_e_item_po1 WITH KEY be_object_id = wa_eitem-be_refobj
number_int = wa_eitem-number_int.
ENDIF .
IF sy-subrc = 0 .
wa_output-poitem = wa_e_item_po1-be_obj_item.
READ TABLE e_actval INTO wa_e_actval WITH KEY guid = wa_e_item_po1-guid .
IF sy-subrc = 0 .
* if the total PO quantity is exhausted / confirmed .
IF wa_e_actval-quan_cf_e EQ wa_e_actval-quan_po_e .
CLEAR wa_output-outquantity .
ELSE .
wa_output-outquantity = wa_e_actval-quan_po_e - wa_e_actval-quan_cf_e .
ENDIF .
ELSEIF sy-subrc NE 0 .
wa_output-outquantity = wa_e_item_po1-quantity .
ENDIF .
ENDIF .
ELSE .
IF wa_output-itm_type = 'MATERIAL' .
READ TABLE e_item_po INTO wa_e_item_po1 WITH KEY be_object_id = wa_eitem-be_refobj
* be_obj_item = wa_eitem-be_refobj_item .
number_int = wa_eitem-be_refobj_item .
ELSEIF wa_output-itm_type = 'SERVICE' .
READ TABLE e_item_po INTO wa_e_item_po1 WITH KEY be_object_id = wa_eitem-be_refobj
number_int = wa_eitem-number_int.
ENDIF .
IF sy-subrc = 0 .
wa_output-poitem = wa_e_item_po1-be_obj_item.
*e_actval[] is initial when PO has no confirmation done yet.
wa_output-outquantity = wa_e_item_po1-quantity .
ENDIF .
ENDIF .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-poitem
IMPORTING
output = wa_output-poitem.
APPEND wa_output TO eo_item .
*total confirmed value and currency of the header level .
v_congf_value_total = wa_eitem-value + v_congf_value_total .
CLEAR wa_eitem_temp .
wa_eitem_temp = wa_eitem .
AT LAST .
eo_header-zconfvalue = v_congf_value_total .
CLEAR v_congf_value_total .
eo_header-currency = wa_eitem_temp-currency .
ENDAT .
CLEAR : wa_output ,wa_eitem ,wa_partner,wa_account,wa_e_item_po1,wa_e_actval,wa_e_item_po.
ENDLOOP .
Thanks
Sharad
Hi Megha,
You can first get Header GUID of confirmation from BUS2203. Then use FM BBP_PD_CONF_GETDETAIL and provide Confirmation GUID into I_GUID and confirmation number into I_OBJECT_ID.
You will get the PO under E_HEADER from BE_REFOBJ
Regards,
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.