cancel
Showing results for 
Search instead for 
Did you mean: 

N-step BADI workflow

Former Member
0 Kudos

Hi gurus,

I am using the N-step BADI WF WS14000133 in which it is prequesite to implement the BADI BBP_WFL_APPROV_BADI, using this , my requirement is to get the list of approvers for the requestor. please can any one suggest me how to implement this BADI ,or point me to sources where i can get an idea of how to implement the BADI.

Regards

Narendiran Rathinavelu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

What are the values based on which you want to populate the APPROVAL_TABLE table e.g. like Prod category,cost centre???

Based on this you can populate/append the table "APPROVAL_TABLE" with the approvers/user names.

Also ,along with the name you also need to prefix it with "US" e.g. USDISHA.

In case you need any further help,pls let me know.

BR,

Disha.

Pls reward points for helpful answers.

Former Member
0 Kudos

Hi,

Check the following piece of code...Hope it make sense to u.

Follow the "Append" statement.

Fill the Export tables with the required data.

CASE object_type.

  • ====================== shopping cart =========================== *

WHEN c_shop.

      • get the details of the shopping cart

CALL FUNCTION 'BBP_PD_SC_GETDETAIL'

EXPORTING

i_guid = lv_guid

i_object_id = object_id

IMPORTING

e_header = ls_header.

IF ls_header-total_value < 490000000.

      • 2 step approval

CASE actual_approval_index.

WHEN 0.

ls_approver-approval_index = 1.

ls_approver-approval_agent = 'USMANAGER1'.

ls_approver-name = 'Arthur Manager1'.

ls_approver-approval_description = 'First approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER2'.

ls_approver-name = 'Arnold Manager2'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER4'.

ls_approver-name = 'Thomas Manager4'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

WHEN 1.

ls_approver-approval_index = 1.

ls_approver-approval_agent = 'USMANAGER1'.

ls_approver-name = 'Arthur Manager1'.

ls_approver-approval_description = 'First approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER2'.

ls_approver-name = 'Arnold Manager2'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER4'.

ls_approver-name = 'Thomas Manager4'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

WHEN 2.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER2'.

ls_approver-name = 'Arnold Manager2'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER4'.

ls_approver-name = 'Thomas Manager4'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

WHEN OTHERS.

no_further_approval_needed = 'X'.

ENDCASE.

ELSE.

CASE actual_approval_index.

      • 3 step approval

WHEN 0.

ls_approver-approval_index = 1.

ls_approver-approval_agent = 'USMANAGER1'.

ls_approver-name = 'Arthur Manager1'.

ls_approver-approval_description = 'First approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER2'.

ls_approver-name = 'Arnold Manager2'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER4'.

ls_approver-name = 'Thomas Manager4'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 3.

ls_approver-approval_agent = 'USMANAGER3'.

ls_approver-name = 'Peter Manager3'.

ls_approver-approval_description = 'Third approval step'.

APPEND ls_approver TO approval_table.

WHEN 1.

ls_approver-approval_index = 1.

ls_approver-approval_agent = 'USMANAGER1'.

ls_approver-name = 'Arthur Manager1'.

ls_approver-approval_description = 'First approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER2'.

ls_approver-name = 'Arnold Manager2'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER4'.

ls_approver-name = 'Thomas Manager4'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 3.

ls_approver-approval_agent = 'USMANAGER3'.

ls_approver-name = 'Peter Manager3'.

ls_approver-approval_description = 'Third approval step'.

APPEND ls_approver TO approval_table.

WHEN 2.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER2'.

ls_approver-name = 'Arnold Manager2'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 2.

ls_approver-approval_agent = 'USMANAGER4'.

ls_approver-name = 'Thomas Manager4'.

ls_approver-approval_description = 'Second approval step'.

APPEND ls_approver TO approval_table.

ls_approver-approval_index = 3.

ls_approver-approval_agent = 'USMANAGER3'.

ls_approver-name = 'Peter Manager3'.

ls_approver-approval_description = 'Third approval step'.

APPEND ls_approver TO approval_table.

WHEN 3.

ls_approver-approval_index = 3.

ls_approver-approval_agent = 'USMANAGER3'.

ls_approver-name = 'Peter Manager3'.

ls_approver-approval_description = 'Third approval step'.

APPEND ls_approver TO approval_table.

WHEN OTHERS.

no_further_approval_needed = 'X'.

ENDCASE.

ENDIF.

Let me know if u need any more clarifications...

Regards

Abhishek

Former Member
0 Kudos

hi Abhishek,

Are we supposed to implement this inside the the method

GET_REMAING_APPROVERS of the Badi BBP_WFL_APPROV_BADI if so then please can you tell me from where lv_guid

and object_id can be obtained inside the method GET_REMAING_APPROVERS .

Regards

Narendiran Rathinavelu

Former Member
0 Kudos

I am giving u the initial data decleration part.

Any variable starting with "l" is local variable. U have to declare and use it as per ur requirement.

There are set of "import" & "export" parameters.

U can use the importing values, manupulate them and send the the required result through the exporting parameters.

Ur entire operations is bound withing these parameters.

take a look at the following piece of code. this will come just before the code i have given u earlier.

**************************************************

  • -------------------------------------------------------------------- *

  • Interface parameters:

  • -------------------------------------------------------------------- *

  • OBJECT_ID TYPE CRMT_OBJECT_ID "Import

  • OBJECT_TYPE TYPE CRMT_SUBOBJECT_CATEGORY "Import

  • GUID TYPE BBP_GUID_32 "Import

  • ACTUAL_APPROVAL_INDEX TYPE SWH_NUMC10 "Import

  • APPROVAL_HISTORY_TABLE TYPE BBP_WFL_APPROVAL_HISTORY_BADI "Import

  • ITEM_APPROVAL_HISTORY_TABLE TYPE BBPT_WFL_ITEM_APPROVAL_BADI "Import

  • APPROVAL_TABLE TYPE BBPT_WFL_APPROVAL_TABLE_BADI "Export

  • ITEM_APPROVAL_TABLE TYPE BBPT_WFL_ITEM_APPROVAL_BADI "Export

  • NO_FURTHER_APPROVAL_NEEDED TYPE BOOLEAN "Export

  • ITEM_APPROVAL_OBJ TYPE BBPT_WFL_ITEM_APPROVAL_OBJ "Changing

  • -------------------------------------------------------------------- *

  • This is the 2nd example of the BADI implementation that includes

  • dynamic spending limit approval for PO

INCLUDE <swfcntn01>. "Workflow

DATA:

ls_header TYPE bbp_pds_sc_header_d,

ls_approver TYPE bbp_wfl_approval_table_badi,

lv_approval_index TYPE swh_numc10,

lv_guid TYPE crmt_object_guid,

lo_new_instance TYPE swf_bor_object,

lt_approval_agent_obj TYPE TABLE OF swf_bor_object,

ls_wa_agent_obj TYPE swf_bor_object,

lo_user TYPE swf_bor_object,

ls_approval_agent TYPE bbp_wfl_approval_table,

lv_index TYPE syindex,

lv_usr01_name TYPE ad_namtext,

lt_approval_init_agents TYPE TABLE OF bbp_wfl_approval_table,

ls_wa_approval_init_agents TYPE bbp_wfl_approval_table,

ls_wa_approval_history TYPE bbps_wfl_history_line_badi.

  • Business objects type (local constants)

CONSTANTS:

c_po TYPE crmt_subobject_category_db VALUE 'BUS2201',

c_biddingdoc TYPE crmt_subobject_category_db VALUE 'BUS2200',

c_quotation TYPE crmt_subobject_category_db VALUE 'BUS2202',

c_grse TYPE crmt_subobject_category_db VALUE 'BUS2203',

c_invoice TYPE crmt_subobject_category_db VALUE 'BUS2205',

c_shop TYPE crmt_subobject_category_db VALUE 'BUS2121',

c_contract TYPE crmt_subobject_category_db VALUE 'BUS2000113',

c_salescontract TYPE crmt_subobject_category_db VALUE 'BUS2000114',

c_avl TYPE crmt_subobject_category_db VALUE 'BUS2206',

c_invoicegrp TYPE crmt_subobject_category_db VALUE 'BUS2207',

c_vendor_obj TYPE crmt_subobject_category_db VALUE 'BUS1006200'.

      • workflow approval states

CONSTANTS:

c_wf_approved TYPE bbp_wfl_approvalstate VALUE '0',

c_wf_rejected TYPE bbp_wfl_approvalstate VALUE '1',

c_wf_not_instanced TYPE bbp_wfl_approvalstate VALUE '2',

c_wf_changed TYPE bbp_wfl_approvalstate VALUE '3',

c_wf_partialapproved TYPE bbp_wfl_approvalstate VALUE '4',

c_wf_step_in_process TYPE bbp_wfl_approvalstate VALUE '5'.

CLEAR: lt_approval_init_agents[], lt_approval_agent_obj[],

ls_wa_agent_obj, ls_approval_agent, ls_wa_approval_init_agents,

ls_wa_approval_history.

  • -------------------------------------------------------------------- *

  • map input data to local data

  • map char32 to raw16

MOVE guid TO lv_guid.

Former Member
0 Kudos

Hi

Thanks for the input you are a life saver.

Regards

Narendiran Rathinavelu

Former Member
0 Kudos

Abhishek,

Thanks. This was very helpful. I did try filling/appending table 'approval_table' similar to what you did in you example. When the SC was 'Ordered' theSC was sent to the first approver for approval. However, once the that approved the SC the system (EBP) thinks there was a change to the SC (i.e approver changes SC) and re-routed the SC back to the submitter.

Is there some configuration or code ing needed? I know I need to activate the n-level WF and hte BAdI.

Thanks,

Naing

BTW. I want to give you points for you response, but do not know how to do tat.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi (again),

I am very new to EBP and SRM, so please forgive me if I ask the obvious or ask a question that has already been asked on this forum. I posted this on another thread, but no one responded . May be I'll get some resposes in this thread. Any hint, help or suggestion is appreciated.

We are trying to develop an implementation the BBP_WFL_APPROV_BADI for item-level n-step approval.

In the example BAdI SAP provides they have a FUNCTION 'BBP_WFL_DIN_ITEM_APPROVAL_GET'

'BBP_WFL_DIN_ITEM_APPROVAL_GET'

EXPORTING

sc_guid = ls_header-guid

item_guid = ls_item-guid

approval_index = '1'

approval_description = 'Cost center approval'

hide_items_not_responsible = 'X'

criterion1 = c_cost_centre

value1 = lv_call_value1

CHANGING

approval_table = approval_table

item_approval_table = item_approval_table

item_approval_obj = item_approval_obj.

ENDLOOP.

What values do you enter/populate the tables 'approval_table', 'item_approval_table' and 'item_approval_obj'?

Here is the parameter definition for the BAdi

OBJECT_ID Transaction Number &#61671; I assume this is the Shopping Cart number

OBJECT_TYPE Business Transaction Category &#61671; BUS2121 (for SC)

GUID Globally Unique Identifier in 32-Character Display

I don’t know what I enter for the rest of the fields.

ACTUAL_APPROVAL_INDEX Current Approval Step

APPROVAL_HISTORY_TABLE Table for Approval History for BADI

ITEM_APPROVAL_HISTORY_TABLE Old Assignment of Items to Approval Objects

DELETE_REJECTED_ITEMS Single-Character Indicator

IN_UPDATE General Flag

APPROVAL_TABLE Table of Approval Steps and Approvers

APPROVAL_ADMINISTRATORS Administrators for Missing Approvers

ITEM_APPROVAL_TABLE New Assignment of Items to Approval Objects

NO_FURTHER_APPROVAL_NEEDED Boolean Variable (X=True, -=False, Space=Unknown)

ITEM_APPROVAL_OBJ Assignment of Approval Objects to Approval Criteria

The definition of table APPROVAL_TABLE is:

APPROVAL_INDEX

APPROVAL_BRANCH

APPROVAL_AGENT

NAME

APPROVAL_DESCRIPTION

APPROVAL_OBJECT_GUID

HIDE_ITEMS_NOT_RESPONSIBLE

I don’t know what to enter in the fields in table APPROVAL_TABLE and table ITEM_APPROVAL_TABLE.

My understanding is that to implement item-level n-step approval, I only need to fill these tables correctly. The Workflow will handle the rest. Is this conclusion correct?

Thanks in advance,

Naing

Former Member
0 Kudos

Hi Narendiran Rathinavelu,

You can refer to the standard Implementations of the BADI - BBP_WFL_APPROV_BADI, which is provided by SAP using SE19 transaction.

Hope this help you design your requirements. Incase you need further help on this, let me know.

Regards

- Atul

Former Member
0 Kudos

Hi,

You have to go to T-code : SE19

Type the BAdI name and and create a custom instance of the standard one.

Typically we name it starting with Y or Z and then the original name.

There will be more than one interfaces. Choose the one for ur requirement.

Double click on it and start writing the code init.

Note: In BAdIs u need to use OOABAP.

reward point if u find this helpful

Regards,

Abhishek

Former Member
0 Kudos

Abhishek,

Thanks for the input, i need to get the list of approvers using this badi. can you help out how to go about with this, can you please send me some sample codes?

Regards

Narendiran Rathinavelu