cancel
Showing results for 
Search instead for 
Did you mean: 

Get SC GUID from PO in BBP_ALERTING

Former Member
0 Kudos

Hi all,

I'm triggering notification when a PO is created from BADI BBP_ALERTING.

PO is created in SRM once a SC is fully approved.

So, basically, PO is created by WF-BATCH.

Once a PO is created, I need to send a notification to the SC Requisitioner's Manager.

I tried to call the FM BBP_PROCDOC_GETDETAIL and BBP_PD_PO_GETDETAIL, but the return table of E_HEADER_REL is empty.

There is no way I could get the SC GUID using these 2 FM.

I even tried with the FM BBP_PD_OBJREL_READ_VIA_REF, it is also not returning any SC GUID.

FYI, if I run these FM in other BADI or report, it's working fine.

I have no idea why when I put these FM into BBP_ALERTING, it's not working.

Anyone have other method for me to retrieve SC GUID based on the PO GUID?

Is there any instance class that I could use?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi there,

I'm not sure what information you have in this BADI, do you have the GUID I wonder? maybe not...

If you don't, maybe try this.

have a look at transaction BBP_PD to check this out.

SC and follow on PO

You only have the PO number.

For a SC, the follow on PO number is stored in Table BBP_PDBEI-BE_OBJECT_ID

If you had a look in this table in the BADI for the PO number and BE_OBJECT_TYPE BUS2201 you may find the entry.

Then Table BBP_PDBEI-GUID holds the item GUID.

This GUID will then lead you to the CRMD_ORDERADM_I table CRMD_ORDERADM_I-GUID.

To get the header of the document, this will be stored in CRMD_ORDERADM_I-HEADER.

Give it a go if you get no better suggestion,

Hope this helps,

Kind Regards,

Matthew

CRMD_ORDERADM_H

Former Member
0 Kudos

Hi Matthew,

Thanks for your suggestion.

I do a SELECT guid FROM bbp_pdbei WHERE be_object_id = PO number.

And the result is, there is no GUID found for the PO number.

I somehow suspect that in the BADI BBP_ALERTING, when PO is created, the linkage between the PO and SC is still not saved into the database.

Anyone know any other way to get the SC GUID from the PO GUID?

Thanks

Jack

Answers (2)

Answers (2)

Former Member
0 Kudos

This should be able to get you the Requisitioner and from here can get the manager of the Requisitioner.

DATA:

lt_item TYPE bbpt_pd_item,

lt_header_rel TYPE STANDARD TABLE OF bbp_pds_hrel,

lt_account TYPE STANDARD TABLE OF bbp_pds_acc,

lt_orgdata TYPE bbpt_pd_org,

lt_partner TYPE bbpt_pds_partner,

wa_partner TYPE bbp_pds_partner,

lo_employee TYPE REF TO if_bbp_es_employee,

lv_partner_guid TYPE guid.

CALL FUNCTION 'BBP_PROCDOC_GETDETAIL'

EXPORTING

i_guid = iv_object_guid

i_object_id = iv_object_type

i_read_flags = wa_read_flags

IMPORTING

e_header = wa_header

TABLES

e_item = lt_item

e_header_rel = lt_header_rel

e_account = lt_account

e_orgdata = lt_orgdata

e_partner = lt_partner.

LOOP AT lt_partner INTO wa_partner

WHERE partner_fct = '00000016'.

MOVE wa_partner-partner_no TO lv_partner_guid.

ENDLOOP.

TRY.

lo_employee = cl_bbp_es_enterprise=>get_employee_by_guid( lv_partner_guid ).

lv_agent_id = lr_employee->get_username( ).

CATCH cx_bbp_es_not_found.

CATCH cx_bbp_es_not_an_employee.

ENDTRY.

Former Member
0 Kudos

Hi Jack,

Please use below code to get the SC requestor....

iv_doc_guid is the PO GUID

data lo_wf_pdo_src type ref to /sapsrm/if_wf_pdo.

data lx_pdo_ex type ref to cx_static_check.

data lt_document_owner type /sapsrm/t_wf_agent_id.

data lw_document_owner type /sapsrm/s_wf_approver.

try.

  • Get source document instance

lo_wf_pdo_src ?= /sapsrm/cl_wf_pdo_impl_factory=>get_instance(

iv_document_guid = iv_doc_guid

iv_document_type = 'BUS2201'

).

  • Get source document responsible

lt_document_owner = lo_wf_pdo_src->get_document_owner( ).

read table lt_document_owner into lw_document_owner index 1.

rv_owner = lw_document_owner.

catch /sapsrm/cx_pdo_abort into lx_pdo_ex.

raise exception type /sapsrm/cx_wf_abort exporting previous = lx_pdo_ex.

catch /sapsrm/cx_pdo_error into lx_pdo_ex.

raise exception type /sapsrm/cx_wf_error exporting previous = lx_pdo_ex.

endtry.

Thanks Arjun