cancel
Showing results for 
Search instead for 
Did you mean: 

Searching organizational structure in a background task

Former Member
0 Kudos

Hello, SAP experts.

This is my first post here in the SDN so hopefully you'll pardon if I make a few mistakes here and there.

I'm working as an internal workflow developer for my company, and I'm in the testing phase of a customized Purchase Requisition Overall Release workflow based on the standard model. The release process works by escalating the requisition up through the organizational structure depending on the most part on the total price of the requisition. During the release procedures, I've been informed that there might be cases where no user will belong to a particular release strategy in the organizational structure chain being considered.

For example, suppose user 001 has superiors 002, 003, and 004. 002 is responsible for release code AA, 003 for BB, and 004 for DD. Now suppose 001 releases a requisition that needs to go through a release strategy with necessary codes AA, BB, CC, and DD. Normally for this strategy there would always be a user to approve each of those levels. But in 001's case, no superior of his/hers exists that can approve with code CC.

The solution we've come up with for this is that in cases such as the one above, where no user exists in the current chain that can perform a specific release, then have the system automatically perform that release through a background task. First, though, the workflow should determine if indeed this background approval should take place. For this, a second background method was developed that performs this check by going up the organizational structure (using the SWX_GET_MANAGER and RH_STRUC_GET modules) and finding if a user with a given release code exists in the current chain. It is in this step where I run into problems.

I've already created a subobject of the standard BUS2105 purchase requisition business object which implements the two methods and delegates them to the standard. I've tested the two methods through object testing and instancing and they both work. For the check method, it correctly goes through the organizational structure and determines if the release task should be performed in background or dialog. However, when I actually start the workflow, the check method hangs. When I check the tRFC log in transaction SWU2, it says that the RFC call terminated via an error: "There is no chief position for US ." I've seen this error before, and it's when the SWX_GET_MANAGER is given no user and thus can't find any superior.

I have my suspicions as to what is causing the problem, but I'd like to hear any other thoughts as well. I think that in the logical destination being targeted by the tRFC, namely WORKFLOW_LOCAL_<client_no.>, there is no defined organizational structure. This would explain why the method can't find any agents and why I'm getting the above error. If this were the case, how would I go about fixing it, and if not, what else could be causing the problem or what other solutions could I adopt?

Pardon the long post, but as you can see it's a complicated process to meet the company's requirements and I want to make sure it's understandable, if not concise. Thanks in advance for your help, gurus.

Greetings

Juan Ramos

Accepted Solutions (1)

Accepted Solutions (1)

ramki_maley
Active Contributor
0 Kudos

Welcome to the Forum world Juan!! You have explained your problem very well.

WORKFLOW_LOCAL_<client_no.> need not have any org structure. Have you verified that the check method is getting a user id as expected from task container? Check your container element definitions (WF, Task and Method)all refer to the same data type.

Cheers,

Ramki Maley.

Former Member
0 Kudos

Hello Ramki

Thanks for the info. I've checked all the bindings all the way from the workflow to the function module I'm using, and they all look fine. Curiously though, either the function module or its calling business object method don't seem to be getting a value. The workflow consultant working here suggested it might somehow be a problem with timing: the method is starting and calling the FM before the workflow can pass on the container elements properly.

I tested the workflow by setting the parameters in the FM call inside the method to be constants, and this way the workflow runs properly. What do you think? Thanks again.

Greetings

Juan Ramos

ramki_maley
Active Contributor
0 Kudos

Juan,

<i>The workflow consultant working here suggested it might somehow be a problem with timing: the method is starting and calling the FM before the workflow can pass on the container elements properly.</i>

That cannot be the reason. It is your responsibility to ensure all elements in the WF to Task binding have the required values at the time of the task instantiation.

What is the input to your FM in the check method and where is it in the WF container?

Thanks,

Ramki Maley.

Former Member
0 Kudos

Hi Ramki

The problem wasn't in the binding itself; that was all correct. The problem was that some of the containers were not marked as export parameters. Once that was done agent resolution works fine.

Thanks for the help! Points awarded.

Greetings

Juan Ramos

Answers (0)