cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger MDM Workflow in Webdynpro

Former Member
0 Kudos

Hello,

I want to execute a MDM Workflow from Webdynpro using Java API's. I have the WorkflowId,session Id and the RecordId in the Webdynpro. Can somebody please send the code for the same.?

Any help would be highly appreciated.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member210630
Active Participant
0 Kudos

Hi,

Check the pdf at the below link.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/600333e0-9bf7-2c10-1f99-bf5dcf661...

Try using this code for calling MDM workflow:

RetrieveWorkflowTasksCommand task_command = new RetrieveWorkflowTasksCommand(connections);

task_command.setSession(sessionId);

task_command.setTableId(new TableId(1));

try {

task_command.execute();

} catch (Exception e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

//Retrieving the tasks after execting the command

WorkflowTask [] task = task_command.getWorkflowTasks();

for(int i = 0 ; i < task.length ; i++)

{

WorkflowJob job = task.getJob();

job_id= job.getId();

System.out.println(job_id.getIdValue());//This is will give the Job ID of all the workflows in MDM.

}

Thanks

Pawan

Former Member
0 Kudos

Thanks for the reply. I have also written the same code but when I try to execute the Workflow job after that using the following code , I get the exception as below:

LaunchWorkflowJobCommand LWJC = new LaunchWorkflowJobCommand(connections);

LWJC.setSession(session);

WorkflowJobId WJID = new WorkflowJobId(wfjc.getWorkflowJobId()); // where wfjc is of Type CreateWorkflowJobCommand

LWJC.setJobId(WJID);

try

{

LWJC.execute();

}

catch (CommandException e)

{

e.printStackTrace();

return;

}

but at runtime it gives me the following exception :

com.sap.mdm.internal.protocol.manual.ServerException: Illegal value for parameter

Please help.

Thanks

Former Member
0 Kudos

Hello,

The root cause to this problem is the Java API code which is trying to launch a workflow job that is already launched.

In the MDM Data Manager please check the Autolaunch parameter (for a specific Workflow).

Possible solutions are:

1. Delete the LaunchWorkflowJobCommand from Java API code and set Autolaunch to Immediately.

or

2. Set the Autolaunch parameter to None, and leave the LaunchWorkflowJobCommand command.

Please see the attached screenshot.

Thanks,

Tamir

junwu
Active Contributor
0 Kudos

we opened two tickets to SAP....

initially we use modifyrecordcommand to update a record, it works and workflow is triggered, but performance sucks...it takes 15 seconds to update one record, we have hundred records to be updated, so it will takes hours. the worst thing is the whole system will be frozen for hours....

then we turned to modifyrecordscommand to make bulk update, the update is very fast, unfortunately the workflow is not triggered. sap's reply says it it the right behavior....

so we have to use api to manually trigger the workflow, then the exception mentioned in this post is shown....SAP is still working on it...

i hope the sap won't just give us those two possible workaround, which i think won't work, at least in my case.

Former Member
0 Kudos

Hi Jun,

Which exception you receive now? If it is "Illegal value for parameter" exception, please use the second solution provided above.

I tested it and it works fine.

Thanks,

Tamir

junwu
Active Contributor
0 Kudos

if i set the autolaunch to none, which means the workflow will not be launched automatically, right?

but we need to have this workflow to be launched automatically....this workflow is not just used in bulk update case.

our exception is com.sap.mdm.commands.CommandException:Illegal value for parameter(0x80000001)

Former Member
0 Kudos

Hi Jun,

If you set the autolaunch to none, workflow will not be launched automatically.

The "Illegal value for parameter" exception is thrown because you are trying to launch a workflow job that is already launched.

In case you suffer from a frozen system during the update process, please consider using slicing parameters (starting MDM 7.1 SP06 and above). Comprehensive details about the slicing usage could be found in the MDM documentation.

Hope this helps,

Thanks,

Taamir

junwu
Active Contributor
0 Kudos

Hi Tammir,

thanks for the info. I will check slicing.

the workflow is not launched(SAP confirmed), that's why I have to manually launch it with code.

Best regards,

Jun

junwu
Active Contributor
0 Kudos

Hi Tamir,

i checked the slicing.

it seems to be valid for

CheckoutRecordsCommand, CheckinRecordsCommand, ExecuteAssignmentCommand.

but I am using ModifyRecordCommand, which is executed in a while loop.

do you think slicing will help in this case?

Best regards,

Jun

Former Member
0 Kudos

Hi Jun,

Since you are using modifyrecordcommand, you are performing a non-bulk operation. MDM doesn't support slicing for modify non-bulk operations (unless it is done via Data Manager).

I would suggest to find the root cause why update of one record takes ~15 seconds. Normal execution time is around one second.

Thanks,

Tamir

junwu
Active Contributor
0 Kudos

Hi Tamir,

each update(modifyrecordcommand) will trigger a workflow, which takes the time. I don't think we can make improvement in that part for now.

when we use modifyrecordscommand to update the records, the workflow is not triggered (which is expected to be triggered)and sap told us it is the right behavior. it is really unacceptable.

so we use code to trigger it manually. actually the workflow is triggered successfully, but the exception is thrown. (what's the problem here)

if the autolaunch is set to immediate,  the workflow is started when we use CreateWorkflowJobCommand? no need to call LaunchWorkflowJobCommand?

CreateWorkflowJobCommand cwfjc = new CreateWorkflowJobCommand(

                                    ctx);

                            cwfjc.setRecordIds(rcrds);

                            cwfjc.setWorkflowId(wfid);

                            cwfjc.execute();

Best regards,

Jun

Former Member
0 Kudos

Hi Jun,

Why each record update triggers a workflow job in your application? I assume it cause unnecessary load on your system. You have the option to add multiple records to a workflow job and launch them all together.

You are right, if the autolaunch is set to immediate, the workflow is started when you call the CreateWorkflowJobCommand and you don't need to call the LaunchWorkflowJobCommand command.

Thanks,

Tamir.

junwu
Active Contributor
0 Kudos

Hi Tamir,

mdm part is done by others...out of my control.

I  comment out the launch command.

everything is good now.

Best regards,

Jun