cancel
Showing results for 
Search instead for 
Did you mean: 

BADI Issue - PO is going in Awaiting Approval for No Approval Required = X

pankajs_dwivedi
Participant
0 Kudos

Hi All,

I have a requirement where i am using the N Step Approval BADI for PO approvals. I have an Implementation of BADI - BBP_WFL_APPROV_BADI where i am handling all the scenarions.

IF_EX_BBP_WFL_APPROV_BADI~GET_REMAING_APPROVERS.

My SRM System is 5.0

Issue is here even if i found that approvers are not requierd and I send back the flag NO_FURTHER_APPROVAL_NEEDED = 'X', still the PO document is going in status as Awaiting Approval.

Actually it should come as Approved status.

If anyone has worked on this issue please let me know.

Thanks & Regards,

Pankaj Dwivedi

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi,

What exactly have you done to set the approval levels?

BR,

Disha.

pankajs_dwivedi
Participant
0 Kudos

Hi Disha,

Thanks for looking into this matter.

My requirement is when a SC creator is Creating the PO he doesnt requires an approval and i am sending the Approavl flag not required = X. But the POs are going in Awaiting Approval status. But in this case it should be Approved.

Here is the code for it.

Thanks

MOVE guid TO lv_guid.

CASE object_type.

  • ====================== purchase order ============================= *

WHEN c_po.

  • Get the details of the PO Changed. this gives Creator and changer correctly.

CALL FUNCTION 'BBP_PD_PO_GETDETAIL'

EXPORTING

i_object_id = object_id

i_with_itemdata = gc_x

i_without_header_totals = gc_x

IMPORTING

e_header = lw_header

TABLES

e_item = lt_po_item.

  • Get the details of the PO created

CALL FUNCTION 'BBP_PROCDOC_GETDETAIL'

EXPORTING

i_guid = lv_guid

i_object_id = object_id

i_with_itemdata = 'X'

IMPORTING

e_header = lw_header_init

TABLES

e_item = lt_pd_po_item.

lv_object_id = object_id.

CALL FUNCTION 'BBP_PD_OBJREL_READ_VIA_REF'

EXPORTING

iv_objectkey = lv_object_id

iv_object_type = c_po

TABLES

et_header = lt_sc_header

et_item = lt_sc_item.

READ TABLE lt_sc_header INTO lw_sc_header INDEX 1.

  • First Track the Creation change along with SC creation

LOOP AT lt_sc_item INTO lw_sc_item.

READ TABLE lt_po_item INTO lw_po_item

WITH KEY number_int = lw_sc_item-number_int.

IF sy-subrc = 0.

IF lw_sc_item-category_id NE lw_po_item-category_id

OR lw_sc_item-quantity NE lw_po_item-quantity

OR lw_sc_item-ordered_prod NE lw_po_item-ordered_prod

OR lw_sc_item-price NE lw_po_item-price.

lv_creation_change = gc_x.

ENDIF.

ENDIF.

ENDLOOP.

  • Then Track the chagnes made in the PO in change mode and this will override the creation flag

LOOP AT lt_pd_po_item INTO lw_pd_po_item.

READ TABLE lt_po_item INTO lw_po_item

WITH KEY number_int = lw_pd_po_item-number_int.

IF sy-subrc = 0 AND lw_header-total_value > 0.

IF lw_pd_po_item-category_id NE lw_po_item-category_id

OR lw_pd_po_item-quantity NE lw_po_item-quantity

OR lw_pd_po_item-ordered_prod NE lw_po_item-ordered_prod

OR lw_pd_po_item-price NE lw_po_item-price.

lv_change = gc_x.

ENDIF.

ENDIF.

ENDLOOP.

  • Scenario no 1

  • 1. SC created by Requisitioner & assigned Source of supply in SC – No Approval Required for PO ( Fast Track )

IF lw_header-created_by = lw_header-changed_by

AND lw_sc_header-object_id IS NOT INITIAL

AND lw_header-total_value EQ lw_header_init-total_value

AND lw_header-total_value EQ lw_sc_header-total_value

AND lw_header-created_by EQ lw_sc_header-created_by

AND lw_sc_header-created_by(3) NE 'RFC'

AND lv_creation_change NE gc_x

AND lv_change NE gc_x

AND lv_value_set NE gc_x.

  • No Approver required

no_further_approval_needed = 'X'.

lv_value_set = gc_x.

EXIT.

ENDIF.

  • 2. SC created by Requisitoner , with out Source of Supply – Buyer creates PO in sourcing cockpit with out change in price

*which has come from Shopping cart : No Approval required ( Gated )

IF lw_header-created_by = lw_header-changed_by

AND lw_sc_header-object_id IS NOT INITIAL

AND lw_header-total_value EQ lw_header_init-total_value

AND lw_header-total_value EQ lw_sc_header-total_value

AND lw_header-created_by EQ lw_sc_header-created_by

AND lw_sc_header-created_by(3) NE 'RFC'

AND lv_creation_change NE gc_x

AND lv_change NE gc_x

AND lv_value_set NE gc_x.

  • No Approver required

no_further_approval_needed = 'X'.

lv_value_set = gc_x.

EXIT.

ENDIF.

LOOP AT lt_approval_agent_obj INTO lo_wa_agent_obj.

swf_get_property lo_wa_agent_obj 'User' lo_user.

swf_get_property lo_user 'NameWithLeadingUS'

lw_approval_agent-approval_agent.

swf_get_property lo_user 'Name' lv_usr01_name.

MOVE lv_usr01_name TO lw_approval_agent-name.

lw_approval_agent-approval_index = lv_index.

lw_approval_agent-approval_branch = 1.

lw_approval_agent-initial_index = lv_index.

lw_approval_agent-initial_agent =

lw_approval_agent-approval_agent.

lw_approval_agent-approval_state = c_wf_not_instanced.

APPEND lw_approval_agent TO lt_approval_init_agents.

lv_index = lv_index + 1.

ENDLOOP.

  • Evaluate the list of remaining approvers. The actual approver i.e. History table belongs to the list as well.

LOOP AT approval_history_table INTO

lw_wa_approval_history WHERE type NE c_i.

LOOP AT lt_approval_init_agents INTO

lw_wa_approval_init_agents.

IF lw_wa_approval_init_agents-approval_index LT

lw_wa_approval_history-approval_index.

DELETE lt_approval_init_agents.

ENDIF.

ENDLOOP.

ENDLOOP.

  • Fill the import table APPROVAL_TABLE

CLEAR lw_wa_approval_init_agents.

LOOP AT lt_approval_init_agents INTO

lw_wa_approval_init_agents.

CLEAR lw_wa_approval_history.

MOVE-CORRESPONDING lw_wa_approval_init_agents TO

lw_wa_approval_history.

APPEND lw_wa_approval_history TO approval_table.

ENDLOOP.

IF approval_table[] IS INITIAL.

no_further_approval_needed = 'X'.

ENDIF.

ENDCASE.