cancel
Showing results for 
Search instead for 
Did you mean: 

Send an Email upon SFC done

former_member186078
Active Participant
0 Kudos

Dear Friends,

     I am novice into SAP ME. I am looking for achieving a simple requirement in SAP. Upon successful completion of an SFC on the last operation of the routing, I would like to send an Email to a set of users. For that requirement, I have created a new Message type which uses "Simple" process workflow.

Now, I am unable to understand, how to link this to the last operation so that it can trigger upon POST COMPLETE step of an SFC COMPLETE. Ideally, we would need some Activity hook point for this, does any one whether we have any generic Activity which we can use for triggering emails.

    Just an FYI, we are using SAP ME 6.1.4 version.

    Appreciate your help in advance.

Thanks,

Adithya K

Accepted Solutions (1)

Accepted Solutions (1)

former_member196557
Active Contributor
0 Kudos

Hi Adithya,

With ME 6.1.4 you can create an MII Transaction that you can call from a Post Complete Activity Hook using the MII Transaction Extension in SAP ME. You can hook the MII Extension activity to the Post Complete activity for the last operation on the route.  The Transaction will receive the Context of the complete activity containing, SFC, Operation, Resource etc., and it is relatively straightforward to create a mail connection and send emails from MII Transactions.

The SAP ME help references to the MII Transaction Extension are here and here.  Also,read SAP Note 1908404.

Regards, Steve

former_member186078
Active Participant
0 Kudos

Thanks Steve, will give a try and will let you know.

But, out of curiosity, don't we have any out-of-box activity which initiates a particular Message type.

Thanks,

Adithya K

former_member182330
Active Contributor
0 Kudos

The's a pod plugin CREATE_MESS_PLUGIN that could be added to Complete button, but it would require additional operator action to send a message.

After quick look, I couldn't find a hookable activity that can trigger a message, thus creating your own simple activity hook could be an option. Obviously this requires custom development skills.

Regards,
KC

former_member186078
Active Participant
0 Kudos

Hi Steve,

   I did try to create a service extension and execute it. But, I dont see anything happening. Here are the steps I did perform:

1. Create a new simple MII transaction to send an email using completeSFCRequest information. I have executed from MII, with sample input XML, it is working fine.

2. Went to Service extension in SAP ME, created a POST execution point for service "SfcCompleteService", method - "completeSfc". Under the options tab, I have added the transaction name as "Project/Transaction_name" created in MII. Parameters field blank. Because, it's an option and it should be dynamic.

3. Now, upon performing the Complete step on any of the operation from the POD, I dont get any email. I am even unable to tell, whether any my extension got triggered.

  I do have the SAP_XMII_USER role as well.

  Can you please help me out in figuring what am I missing? In addition, where can we trace whether the service extension is getting triggered. I dont see in MII Log viewer.

Thanks in advance. I think I am close to solve it, but not yet done.

Appreciate your help.

Regards,

Adithya K

former_member196557
Active Contributor
0 Kudos

Hi Adithya,

Don't use the transaction as a Service Extension.  There is another way documented in the help references and SAP Note (downloads)  to use the transaction as a Hook Point.  You use MII_TRANS_EXT as the hook activity;  Hook to POST_COMPLETE for the last Operation on your route.  Here is a screen shot from Operation Maintenance showing how the hook is attached:

This shows a POST_START hook point, you would use POST_COMPLETE.

The user argument is:  transactionName=project/folder/folder2/trxname;

From MII, copy the transaction name in workbench and paste it after transactionName= , and terminate with a semicolon (;).  Refer to the Javadocs for details on the DTO passed to the transactions input_xml property.

Regards, Steve

former_member206397
Contributor
0 Kudos

Hi Adithya,

As you are trying to do using MII Custom BLS then here is one option for you if you have one routing. You can create a custom MII BLS and within the BLS you can take inputXML in Transaction Input. From the inputXML you will get the StepId and Operation number. Now you can put a condition action block to check if the Step Id = <your last step id of routing> or by operation number if Operation = <Your last operation number> then you can use send mail action block.

Another option is - You can check the parameter "isLastReportingStep" value true from inputXML also if you have multiple routing or through the SAP ME PAPI service you can check SFC status "Done" then execute your mail sending action block.

The same BLS path you can put in yieldConfirmationRequest message Type in MEINT workflow configuration. It will send mail for the last operation of your SFC.

Thanks

Chandan

former_member186078
Active Participant
0 Kudos

Hi Chandan,

     Interesting, I did try your method as well. It did work partially, but seeing an issue.

As you suggested, I did try to use the BLS in the yeildBackflushrequest, since I am working on the Planned orders. I did receive the email, but the message ended up in the queue monitor as warning and the backflush didnt happen on the ERP as well. See the snapshots below:

 

     Can you please check it and let me know your thoughts?

Thanks

former_member206397
Contributor
0 Kudos

Hi Adithya,

Please make sure that at the end of your BLS you are assigning the transaction parameter status = "PASSED" and assign inputXML to outputXML for successful execution. Also please assign the message. Please check those thinks and let me know if any issue.

For your own testing purpose you can also use "Write File" action block within your BLS to write the value within a file and to know the required steps are executed or not.

Thanks

Chandan

former_member186078
Active Participant
0 Kudos

Thanks Steve. Your suggestion worked.

I got the note applied and tested, its working perfect.

Appreciate your help. Will see if I can write something to share on the blogs.

former_member186078
Active Participant
0 Kudos

Thanks Chandan. Your solution too worked for my requirement. Appreciate your help.

former_member186078
Active Participant
0 Kudos

Hi Steve,

   Thanks for your input. I have updated a blog page on the SCN. Thanks once again. Here is the blog page for it.

Former Member
0 Kudos

Hi Chandan,

and what about the error/exception handling? How can I propagate the result of this MII transaction to ME? When Assigning INPUT to OUTPUT, no error message is displayed. If I skip this step, allway an "internal error occured" is displayed. I tried to use "status" and "message" as transaction output variables, but I did not manage to propagate the error message from MII to the ME UI.

I am using the MII Transaction as service extension and would like to return error from MII to ME so the service extension will be rolled-back or not commited.

Or should I open an OSS-Message, since it should work with "status" and "message".

Regards,

Andrej

Answers (1)

Answers (1)

Former Member
0 Kudos

Adithya

You can also consider creating a custom Message Type and then create a message of this type via a Routing script just before the complete. Bear in mind that routing scripts don't execute if there is only one path, but you can get around this by creating another identical path from the last step to the Done step.

Stuart

Former Member
0 Kudos

Stuart,

it would be also helpful to trigger/call an MII Transaction from the Collaboration Links, as there are events defined like "SFC DONE", which are more general that an activity hook on a concrete routing step/operation.

Is there really no other possibility, than use the SAP ME SDK to create a Java Class which calls the MII transaction via HTTP-Post?

The introduced "MII_TRANS_EXT" mentioned by Steve could be somehow extended for the Collaboration Links. I assume the already existing EJB could be re-used and the rest could be some dummy/empty formatter/transporter.

Or did someone manage to call an MII transaction directly from the collaboration link without utilizing the SDK?


Regards,

Andrej

former_member186078
Active Participant
0 Kudos

Hi Andrej,

       Look at the following blog. We have achieved it without using any ME SDK.

Thanks,

Adithya K

Former Member
0 Kudos

Adithya K,

thank you for your reply, I noticed your blog and it is very good that you documented the use of activity hook with MII transaction.

But there are a lot of eventens in the Collaboration Framework, like "SFC Done" or "Shop Order Complete", which are more general than an activity hook assignment on a concrete operation.

And therefore it would be handy to have to possiblity to execute a MII transaction as a Collaboration Link.

Regards,

Andrej

former_member186078
Active Participant
0 Kudos

Hi Andrej,

           You are correct. We wish if we have atleast Message types enabled based on the Status codes that we have in SAP ME like 404, etc.