cancel
Showing results for 
Search instead for 
Did you mean: 

how to code APPROVAL_ADMINISTRATORS in n-step WF?

sap_2605
Active Participant
0 Kudos

Dear SAP gurus,

I see that if we are using n-step WF we need to define an administrator where we have to fill out table APPROVAL_ADMINISTRATORS. However I'm a bit confused of how to code this. Seeing from the threads in this forum, many people mention that we should code no_further_approval_needed = X, and i follow the suggestion. So I code like this:

IF approval_table[] IS INITIAL.

*to select admin from default WF admin

SELECT SINGLE * FROM swd_custom

INTO ls_swd_custom

WHERE user_name EQ c_sap.

ls_approv_name = ls_swd_custom-def_admin+2(12).

ls_administrators-approval_index = actual_approval_index.

ls_administrators-approval_agent = lv_agent.

ls_administrators-name = 'Administrator'.

ls_administrators-approval_description = 'Administrator is the approvar'.

APPEND ls_administrators TO approval_administrators.

no_further_approval_needed = 'X'.

ENDIF.

However if I code like that, though no agent is determined, i got no approval required which I believed happens because the no_further_approval_needed = 'X'.

Then I read in the library that the admin will only be read IF the agents cannot be determined AND approval is required. As such I deduce it means that I should not put X into no further approval needed. So I just remove the X, and guess what happen? The admin got determined, and as an admin, I approve the SC. And when I approve the line got read again, and admin got determined and the admin got the work item again. So this is coming into an endless loop.

How should I code this? Please help.

Best regards,

John

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

<b>Please provide the System version details -></b>

<u>Administrator Approval Determination - coding</u>

<b>Also check SAP OSS Note -> </b>

Note 978709 - Administrator receives no work item for the BADI workflow

<u>First check whether the approval_table[] is initial.If so,you will have to populate the table approval_administrators so that the SC is sent to the default administrator if the approvers are not found. Also make sure in the field "approval_agent",you are assigning the username as "USXXXXX".</u>

Hope this will help. Do let me know.

Regards

- Atul

sap_2605
Active Participant
0 Kudos

Hi Atul,

Im working on SRM server 550 with SP08. Thanks for your reply. I have checked your note and it is not applicable in our system. While for the sdn posting, one of it telling that no_further_approval_needed = 'X'.

I have tried that already. And I think because the BADI get no_further_approval_needed = 'X' it will trigger no further approval and it is instantly approved and ignoring the admin. It seems to be consistent with the documentation of the BADI as I quote below:

-startquote

APPROVAL_ADMINISTRATORS

List of administrators in case no approver is found, but approval is required.

(also see the Export Parameter NO_FURTHER_APPROVAL_NEEDED!).

ITEM_APPROVAL_TABLE

Only relevant for item-based approval!

List of approval objects and the corresponding items(s) in the shopping cart, that are to be approved in the future.

NO_FURTHER_APPROVAL_NEEDED

Boolean variable.

If true -> no further approval is required

-endquote.

so interpreting from here the admin only be read IF no agent defined AND approver is required (no_further_approval_needed is initial). But get back to my problem if I coding it initial, it will go to endless loop.

So can someone share me one working coding or explain to me how the admin should behave when he got the workitem in his inbox. Does it meant to be completed manually through SWIA??

Best regards,

John

Answers (3)

Answers (3)

former_member526144
Active Contributor
0 Kudos

Hi,

I have seen your BADI code and i am planning to implement N-step BADI for this. I would like to know the sample code for this.

Thanks

Ravi

martin_nooteboom
Active Contributor
0 Kudos

Hi John,

I think your code should work apart from one minor mistake which causes the endless loop: you set the approval_index of the administrator table at the actual_approval_index. Change actual_approval_index to the fixed value of 1 and it should work.

Also you should add an if statement for the actual approval index, if it is le 1 fill the adminstrator table in the else set no_further_approval_needed.

Regards,

Martin

Message was edited by:

M. Nooteboom

Just remembered place and purpose of no_further_approval_needed (hard to remember when last WF in SRM was more than one year ago and system available )

sap_2605
Active Participant
0 Kudos

Hi Martin,

Thanks for the reply. Actually I have tried like that as well. But this is what I find during debugging. When the admin approve it in the first time the index is 1 (when SC is created the index is 0), but then it goes to the loop it goes back to the admin. Guess what happen when the admin approve it in the second time? The index is still 1. So in here whenever the admin approve it the index is always 1. So the coding that I put is having the same effect as hardcode 1 to it.

As the consequence if I put if statement actual_index le 1 and else no_further_approval = 'X', it will never be read, because in this case the index is never greater than 1 anyway.

Best regards,

John

martin_nooteboom
Active Contributor
0 Kudos

Hi John,

That presents a nice challenge. Unfortunately I don't have access to a SRM system (or had access for a while). I am not sure but maybe the task of the administrator is not to approve but to add another approver? Maybe you can check with a functional SRM consultant. Otherwise if you want the administrator to approve the SC, then just add him to approval table when no approvers are found so you always have a approver. As I think about it I don't think the administrator table is designed to have 'real' approvers.

Regards,

Martin

khan_voyalpadusman
Active Contributor
0 Kudos

Hi,

The flag no_further_approval_needed = 'X'. needs to be set when there is no other approver involved in the approval chain.

This means when the last approver in the N-Step badi has approved the document , then the badi should be coded to set the value of no_further_approval_needed to X.

and approval_administartors are required when the badi is not able to determine any approvers , this means the table approval_table is empty.

approval administrators are not required when the N-step badi approval is working correctly.

only when the system is not able to determine the approvers , system should be able to find approval adminstrator.