cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to get Descriptive Alerts in BPM using wlg4714

Former Member
0 Kudos

<a href="/people/community.user/blog/2006/10/16/simple-steps-to-get-descriptive-alerts-from-bpm-in-xi:///people/community.user/blog/2006/10/16/simple-steps-to-get-descriptive-alerts-from-bpm-in-xi

Hi I am trying to get a descriptive BPM Alert as per the Weblog above.

But I am not good at Java UDF.

The UDF featured how/where do I put this coding.

Scenario

BPM transform step fails and throws exception BPM_ALERT.

Within the Exception branch I setup a transform message mapping for my message MY_MESSAGE to an error message type MY_ERROR.

Within the mapping message_type --> error_message_type graphical mapping

I have mapping to node error_text.

Do I create a UDF called triggerAlert context Queue

then add the code in here? what about ResultList...

IF it needs to be a compiled class. I have tried this in the SAP Web Developer Studio Tool to write class and compile but it is erroring and will not compile...

package AlertMessage;

public class triggerAlert {

public static void triggerAlert(

String alertSubject,

String[] alertMessage) {

String strAlert = new String();

String strAlertXML = new String();

ArrayList returnStr = new ArrayList();

// split message if length more than 132.

String newAlrtMsg = new String();

int j = 0;

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

newAlrtMsg = alertMessage<i>;

try {

while (newAlrtMsg.length() > 130) {

newAlrtMsg = newAlrtMsg.substring(130);

j++;

strAlertXML

+= "<item><ELEMENT>XI_ERROR_MESSAGE</ELEMENT><TAB_INDEX>"

+ (j)

+ "</TAB_INDEX><ELEMLENGTH>255</ELEMLENGTH><TYPE>C < / TYPE > < VALUE > "

+ newAlrtMsg

+ " < / VALUE > < / item > ";

}

j++;

strAlertXML

+= "<item><ELEMENT>XI_ERROR_MESSAGE</ELEMENT><TAB_INDEX>"

+ (j)

+ "</TAB_INDEX><ELEMLENGTH>255</ELEMLENGTH><TYPE>C < / TYPE > < VALUE > "

+ newAlrtMsg

+ " < / VALUE > < / item > ";

} catch (Exception e) {

System.out.println(newAlrtMsg + "" + e.getMessage());

}

}

try {

// Calling Alert RFC SALERT_CREATE

Channel channel =

LookupService.getChannel(

"<XI_Servername>”,”XICommunicationChannelName");

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

String rfcxml =

"<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:SALERT_CREATE xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><IP_APPLICATION_GUID/><IP_CAT><AlertCategoryName></IP_CAT><IT_CONTAINER>"

+"<item><ELEMENT>XI_ERROR_SUBJECT</ELEMENT><TAB_INDEX>000000</TAB_INDEX><ELEMLENGTH>255</ELEMLENGTH><TYPE>C</TYPE><VALUE><alertSubjectText>"

"</VALUE></item>”strAlertXML+ </IT_CONTAINER></ns0:SALERT_CREATE>";

InputStream inputStream =

new ByteArrayInputStream(rfcxml.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload rfcOutPayload = null;

rfcOutPayload = accessor.call(payload);

} catch (com.sap.aii.mapping.lookup.LookupException e) {

throw new RuntimeException(

" Error in raising Alert: <CC_MMGlobal_RFCLookUp_Alert> Communication Channel lookup failed",

e);

}

}

}

What to do, How to do it...

thanks,

V

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Bhavesh,

thanks for your reply. I have read your blog too and though Good not sure it meets my requirements.

My scenario is this.

multiple xml files collected in BPM Loop.

Transform collected files to single file. Eg.

<LIST>

<S_STX>

message1

</S_STX>

</LIST>

<LIST>

<S_STX>

message2

</S_STX>

</LIST>

transforms to

<LIST>

<S_STX>

message1

</S_STX>

<S_STX>

message2

</S_STX>

...

</LIST>

This single message type is then mapped using a BIC mapping in the Send Step.

IF message2 has an error in its structure elements then the transform step fails and I get no resultant single message structure.

I Throw an ALERT which tells me I have an error in the transformation step but no details. The messages in the collect loop are completed with chequered flags but for the first one which triggered the BPM and stays in green flag mode. There is no way to easily find which message errorred and correct the payload or rerun the process.

Revised scenario

I would like to know which message I had a problem with was it message index 2 or 20 or 99.

I would like to have in the XML messages processing Log a Payload I can refer to and use to repost.

So I tried to introduce a UDF that issues a count of the message index in the mapping (In test mapping the message index is written to the Log) but in runtime I can see no log for this. For example

Messages transform to single Message

1 --> (Index 1)

2 --> (Index 2)

3 --> (Error in structure)

Transform step fails Container has MAPPING messages and TRACE in Workflow Log.

Transform Step Container not accessible from BPM Container.

TransformationExceptionRaised

Transformation ExceptionBranch

Step 1 Transform Multi Message List to Error

Step 2 Send Error so I have some Payload to work with

Step 3 Throw Alert with Error Message to get user to do something.

In my Throw Alert branch I have added a transformforalert step to try to output some sort of Payload from the multiple messages list so that I know which xml messages at least are involved to make it easier to manually go and get the files from the Archive folder. In this mapping to an error message I thought I would try this UDF to trigger the ALERT message but my Java skills are at best rusty and very limited. I am trying to learn.

It is not satisfactory for the users to have a Workflow Log they have to analyse to guess which messages were collected up and then to try to find the one message that is stopping all the messages being processed.

I thought the Alerting would be helpful which it is but not informative enough!! Hence why I am trying the advanced stuff which currently I sort of understand but need to get a working example to really understand.

thanks,

Ginny

bhavesh_kantilal
Active Contributor
0 Kudos

Ginny

Am kind of lost.

I understand what your concern / problem is : To identify which Messages in the N:1 mapping are causing the error / issue.

I do not understand the solution you are working on? I know you typed a rather detailed post ( I myself tend to do the same as well when I raise a question ) but I am lost.. Would it be possivble to restate the problem once more?

Thanks,

Bhavesh

Answers (4)

Answers (4)

Former Member
0 Kudos

Correlation was problem for green flag.

Interface mapping occurrence of messages defined the issue with mapping a multiline container to a faultmessage container with a dummy mapping. Created a payload (though with no content)

UDF not resolved but was too complicated and my uderstnding too limited to implement.

Former Member
0 Kudos

Hi bhavesh, I managed to get the green flag solved asper your point. Correlation.

I also managed to get an output payload mapping the multiline message to the faultmessage but with no content...And I noted in the transform step log in workflow the trace container element did say which message id index caused the error. Not ideal but at least the users can follow steps to diagnose the error once the alert is raised.

I didn't get far with my UDF though I have learnt something in the process I am sure. Thankyou for your help..

G

Former Member
0 Kudos

Bhavesh,

I do go on...

Problem:- I have re-engineered a BPM to reduce long runtimes in Collect Scenario.

(1) Incoming to XI single xml messages --> collected in a folder on XI server.

(2) Trigger renaming of messages extension to *.xml in folder at specific time ie once daily.

(3) Receiving Communication Channel (type File) is first step in BPM gets triggered.

(4) BPM block 1 Receive step in loop collects messages (1,2,3...n) into multiline container of same type as messages.

(5) After 2 minutes Deadline Branch triggered.

(6) Ends Block 1 moves to Block 2

(7) Block 2 Transform Step of multiline container to single message type.

Simple mapping ie

<LIST> 1..unbounded --> <LIST> 1

<S_STX> --> <S_STX> 1..unbounded

message1 message1

<S_STX> <S_STX> 2..

<LIST>

<LIST>

<S_STX>

message2

<S_STX>

<LIST> --> <LIST>

(8) Send step Single Message mapped using BIC Mapping to a Report XSLT Template.

If the process is successful then I get in XML message Monitor an entry and a payload. Of the concatenated messages.

If the process has an error the users want to be told about it as soon as possible hence I set up Alerting. Which works.

But on running a test scenario where message3 (structure is incorrect) at Step (7) the BPM throws the Alert correctly (no information passed as to error) and the Workflow Finishes.

In XML message Monitor the result is message1 is Greenflag. Message2, and Message3 are chequered flag.

No Message Payload generated from the BPM.

The users are not happy with this nor am I.

(1) I look at Workflow Log of BPM and see that step(7) the transformation step has information in the container elements MAPPING and TRACE (no way to reference these from BPM I know of).

(2) I read blogs etc and discover I should perhaps try to add more steps to my Exception/Alert Branch to try to deliver a Payload so the XML message Monitor shows something. Is this a correct assumption?

(3) I try to make my Alert message more informative but I am not skilled in what information is available to identify the error. The Workflow Container is not enough.

If I add a container operation to instantiate a container variable I would like to grab the Payload at least of the multiline element.

(4) To produce a Payload in the Exception Branch to output from the multiline element do I have to do a Loop and Container Operation to Split the multiline message up again into individual messages to send out to an error folder.

(5) I am trying to make it easier for the users to find the errorred files than searching through the Archive folder from the initial receive step.

(6) I am trying to stretch my knowledge of XI Error reporting so I can deliver a better solution to the users.

(7) I have some Java Skills from 10 years ago when life was simpler hence very rusty and am finding it difficult to fit it into the context of UDF's (what information can be accessed etc).

I hope this is clearer about my self made problem. I should never have mentioned error messaging to the users...

thanks,

V

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Intresting interesting problem.

My first question - why does the BPM for the first message end up with the Green Status Flag in the outbound side? This is rather strange.. Is you Correlation defined as a local correlation? Check the standard BPM patterns shipped by SAP in the SAP Basis SWCV and see how the Correlation Scopr is defined as local by defining the Correlation local to a block. Is this how you have defined the BPM? If no, I would suggest you do the collect loop inside a block with the correspodning local correlation so that the Green Flag issue doesnt happen.

><i>(2) I read blogs etc and discover I should perhaps try to add more steps to my Exception/Alert Branch to try to deliver a Payload so the XML message Monitor shows something. Is this a correct assumption?</i>

Not sure what you mean here.. I ve nevr had such a use case where I have had XI to intelligently from a BPM say out of these N messages this message errored out.. This seems to be helluva task and am also now got my thinking cap on to see how to approach this problem / rather strange requirement.

If something does strike, I ll update the thread! To me this is not a question of Java skills... it seems to be more of being innovative and brining up a solution out of the box.. If it helps, you are not the only one lost with this problem

Thanks,

Bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi

Can you let me know what is the end objective of this exercise?

Do you want to trigger a Alert from a BPM? If not why not use the standard Throw Alert Step.

If you want to trigger alert from a UDF, then the Code is used to call an RFC that triggers this alert. I have described the same scenario in this blog of mine as well,

/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function

Regards

Bhavesh