on 03-03-2014 10:02 AM
Dear all,
I have the following structure
If incoming value for the field externalid is empty then i have to raise a alert message to end user "externalid field is empty for the id : id number" and for all incoming values it should work. I used the following udf on field externalid with two arguments
if(externalid.equals(""))
{
throw new RuntimeException("externalid field empty for the following id : " +id);
}
else
{
return externalid;
}
This is working fine for single record. But for many records(multiple occurences), this logic is not working as if records 2 and 3 fails it is showing exception externalid field is empty for the id : record 2.
how to achieve the tranformation logic ?
Regards
Koti Reddy
Hello,
Try this:
execution type: all values of a conext
Input: externalid, id
for(int i=0;i<externalid.length;i++)
{
if(externalid[i].equals(""))
{
throw new RuntimeException("externalid field empty for the following id : " +id[i]);
}
else
{
result.addValue(externalid);
}
}
Note - check for syntax errors
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
I have tried the above udf, but still stuck-up.
For the above structure shown in image, i have tested giving the following payload
<?xml version="1.0" encoding="UTF-8"?>
<ns0:upsertRequest xmlns:ns0="http://sap.com/xi/SFIHCM01">
<sessionId/>
<upsert>
<type/>
<sfobject>
<id>1</id>
<businessKeys>1</businessKeys>
<type>1</type>
<status>1</status>
<externalId>1</externalId>
<username>1</username>
<firstName>1</firstName>
<lastName>1</lastName>
<mi>1</mi>
<gender>1</gender>
<email>1</email>
<managerExternalId>1</managerExternalId>
<hrExternalId>1</hrExternalId>
<department/>
<jobCode/>
<division/>
<location/>
<timeZone>1</timeZone>
<hireDate/>
<empId/>
<title/>
<businessPhone/>
<fax/>
<addressLine1/>
<addressLine2/>
<city/>
<state/>
<country/>
<zipCode/>
<reviewFreq/>
<lastReviewDate/>
<matrixManagerExternalIds/>
<defaultLocale/>
<customManagerExternalIds/>
<secondManagerExternalId/>
<loginMethod/>
<proxy/>
</sfobject>
<sfobject>
<id>2</id>
<businessKeys>2</businessKeys>
<type>2</type>
<status>2</status>
<externalId>2</externalId>
<username>2</username>
<firstName>2</firstName>
<lastName>2</lastName>
<mi>2</mi>
<gender>2</gender>
<email>2</email>
<managerExternalId>2</managerExternalId>
<hrExternalId/>
<department/>
<jobCode/>
<division/>
<location/>
<timeZone/>
<hireDate/>
<empId/>
<title/>
<businessPhone/>
<fax/>
<addressLine1/>
<addressLine2/>
<city/>
<state/>
<country/>
<zipCode/>
<reviewFreq/>
<lastReviewDate/>
<matrixManagerExternalIds/>
<defaultLocale/>
<customManagerExternalIds/>
<secondManagerExternalId/>
<loginMethod/>
<proxy/>
</sfobject>
<processingParam>
<name/>
<value/>
</processingParam>
</upsert>
</ns0:upsertRequest>
No node is creating for success records, instead it throws exception that "externalid field is missing for the id": id for empty externalid field value in second record.
But my requirement is..... when i process 50 records, records with missing value for field externalid should raise an alert message to end user intimating him to check the externalid field for particular id. If the value for externalid field is present in incoming record/payload, then it should be passed to target system.
How can i implement this logic ?
Regards
Koti Reddy
Hi Koti -
If you would like to send successfull records to target system and failed records as email in a single message then you can go with the below approach.
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=90570965
Hi,
Sorry I missed your reply to Amit.
As per your requirement need to do few changes in Amit's code ,that is enough
String body ;
int count =0
for(int i=0;i<externalid.length;i++)
{
if(!externalid[i].equals(""))
{
result1.addValue(""); //populating value to your target structure
}
else
{
count =1;
body = body + "externalid field empty for the following id : " +id[i]) +"/n"
}
}
if(count == 1)
{
result2.addValue("");// open mail segment or MT
result3.addValue(body);// pass this to content
}
Regards
Venkat
Hi,
You have 2 options 1)3 mappings 2)As above said by Hareesh handle it in udf .
I personally recommend below option.
1)Using enhanced receiver determination check the conditions and open ur receiver as per your validations.
2)Mapping1 b/w source and target (based on validation)
3)Mapping2 b/w source and mail (based on validation)
I think my udf will be suitable for second approach.
For 1st approach split the udf into two.
Regards
Venkat
Hi Koti,
You need to change the UDF with all values in queue and to do a FOR in order to get all the values incorrects.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Koti,
Correct me if im wrong, do you need to concatenate all the IDs that are wrong in a single exception?.
If im right you need to work with the UDF execution type, check this wiki UDF Execution Type - Context and Queue. - Process Integration - SCN Wiki
The idea is to check all the values for a determinate tag in one UDF execution, am i right?
Regards.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.