cancel
Showing results for 
Search instead for 
Did you mean: 

mail adapter question

Former Member
0 Kudos

I have a question regarding the mail adapter scenario. Firstly data goes to ECC and some validations are performed and if there are any errors, ECC will provide me with some indicator saying this record has errors.

Now, the same structures are used in the opposite direction and I have to count the number of error records based of that and send that info as an email. If I created a UDF to count the number of error records, how do I put that information in the email ?

Is there anyway, I can capture that info in the mail adapter ?

Any useful links will be appreciated.

-V

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you can write the UDF to count the number of records which are into error, then passing that to the target structure won't be difficult. The output of the UDF will be the count which you can use in one of the fields that will make the part of the email payload.

Former Member
0 Kudos

I thought it was straight forward to have the UDF but I am not sure how to get the entire xml thats being generated as my input to the function. The reason why I am asking this is because I have to be able to count the number of records which have the error fields flagged with the letter "e".

How do I proceed with this type of configuration ? I am fairly new to PI. That will be great if someone could shed some light on this. An example would be even better. I really appreciate that. Thanks a lot.

Former Member
0 Kudos

I can give the logic, you have to implement the code ...

I assume that there will be one field in your structure, which will say whether there is an error or not. So, that particular field will be the only input to your UDF.

You can read the all the values for that field and count the number of occurrences when there is an error "e". The execution type for the UDF will be queue.

This is pretty straight-forward and shouldn't be a problem in writing the code.

Former Member
0 Kudos

Hi,

Many thanks for the prompt reply. When I select the type queue in my UDF, its automatically creating the return type of the function to be of type void. Where can I change the return type of the function to be of type something like "int" ?

Thanks.

Former Member
0 Kudos

"void" that you are talking about is not the return type .. it's the declaration of the function.

For further details, please search on SAP Help as UDF has been discussed in details over there. More over, these are basic questions and should be searched.

Former Member
0 Kudos

Thanks again but my understanding, especially being from a Java background is that every method/function declaration is supposed to have the return type and I was told that behind the scenes Java is being run which is why I assumed that thats a return type. My bad, if I am wrong. I am trying to understand the reason why they have type information as part of the declaration. Again, I am fairly new and I am in the process of learning things.

I assume the code looks something like this...

public static int count = 0;

public void getCount(String[] ecode, ResultList result, Container container){

for (int i=0; i<ecode.length-1;i++)

{

if (ecode<i>.startsWith("e"))

count++;

}

return count;

}

}

The problem is I did not understand the use of ResultList class in this case.

I am looking for some examples wherein they use queue execution types but I am a little bit confused as to the usage of that.

Any useful example would be appreciated. I am trying to find out some concrete info on this.

Former Member
0 Kudos

being from a Java background is that every method/function declaration is supposed to have the return type and I was told that behind the scenes Java is being run which is why I assumed that thats a return type.Again, I am fairly new and I am in the process of learning things.

For simple UDF (cache = Value), returns string.

For advanced UDF (Cache = Context or Queue), returns array of strings.

The problem is I did not understand the use of ResultList class in this case.

Refer this -

http://help.sap.com/saphelp_nw04/helpdata/en/7d/028c4057d5701de10000000a1550b0/frameset.htm

use queue execution types but I am a little bit confused as to the usage of that.

Because of u201Cqueueu201D function, the arguments that we define automatically become arrays, because PI is assuming that we want to operate on multiple input values with this function. That's the reason you are able to traverse through each and every value of the field "ecode".

Any useful example would be appreciated.

Refer this:-

http://wiki.sdn.sap.com/wiki/display/XI/JAVAFunctionsin+XI

http://help.sap.com/saphelp_nw04/helpdata/en/40/7b8e40496f6f1de10000000a1550b0/content.htm

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=79955426

I am fairly new and I am in the process of learning things.

No short-cuts study and hands-on.

Former Member
0 Kudos

awesome...thank you...!

Former Member
0 Kudos

If your issue has been resolved, kindly close this thread. Thanks!

Former Member
0 Kudos

In my scenario, do I have to create a seperate structure so that emails can be send out to so and so addresses ?

I am not sure how PI picks up the from and to email addresses. Also, since the content should include the "count" value,

how does PI handle that ? Do I have to have another seperate structure for that ?

Thanks,

V

GabrielSagaya
Active Contributor
0 Kudos

You can download the mail structure from the following link

https://websmp205.sap-ag.de/~sapidb/012006153200000361852004E/ximail30_xsd.txt

/people/santhosh.kumarv/blog/2008/02/20/mdm-to-mail-exploit-udf

Former Member
0 Kudos

I did create the required structure with from, to and subject fields. On the sender structure, I created a TO field and mapped that to the receiver TO field. I want to include the body of the "COUNT" field as part of my payload. So, I mapped the count field on the sender side to the content field on the receiver mail structure. Pl let me know if I am correct upto this point.

Now, I want to write something in the content like "this is the count <count value from the payload goes here>".

Is there anyway I can do that ?

Thanks a lot.

-V

GabrielSagaya
Active Contributor
0 Kudos

you can use concat function to have such output.

Concat(Constant("This is the count")+count)-->Target

Former Member
0 Kudos

Is there a way I can have the email content in a HTML format.

So, the email that I am going to send should have something like a HTML formatted content in it.

Do I have to use XSL Transformations for that ? If yes, how would the source and target data types come into picture in that

XSL ? I am aware that XSLT is usually used to convert from xml to any other format but I think in PI , when we create the DTs, we actually have the xsd , not the xml right. So how are we going to transform this ? I guess I am a little confused as to how I should probably need to proceed. Any help will be appreciated. Thanks a lot.

Answers (1)

Answers (1)

Former Member
0 Kudos

additional question on the same topic...regarding xsl transformation to display content as a HTML.