cancel
Showing results for 
Search instead for 
Did you mean: 

'fractionDigits' not throwing exception

Former Member
0 Kudos

Hi Experts,

I am facing an issue with the xsd:decimal, totalDigits and fractionDigits in my mapping

I have declared my target field as type-xsd:decimal,totalDigits=15, fractionDigits =4 and when I pass the value to it as 9.1234567891234567, its not throwing any exception in PI and executing successfully where I was expecting it to fail as the total number of fraction digits is more than 4, which I have declared.

This mapping output is passed to the proxy, there I can see a system error in SAP. The ABAP tech type is DEC(15) in the proxy.

Ideally I was expecting a mapping error in PI , please provide your inputs on this

thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

This is pure XML validation. Since you dont do XML Validation during pipeline step, it wont validate your data against schema definition. Remember if you use PI 7.1 and later there is an option to do xml validation and you can configure in sender agreement(both adapter engine (java) and integration engine(abap) for the inbound message and receiver agreement (abap stack) in the outbound message. But triggering xml validation might cause performance issue too.

Refer this link for example

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d026d253-3108-2c10-69a0-a5460fc1f...

You can do business validation in the backend system and send error response if the fraction digit is not with requirement or correct the data in mapping using udf or standard function.

Former Member
0 Kudos

Hi Bhaskar,

Thanks for the reply.

We are using PI7.0, so your suggestion would be to handle this through UDF/standard function to raise exception?

anjaneya_bhardwaj2
Contributor
0 Kudos

XML validation is possible form PI 7.1 as it is a new pipeline step .. UDF is the way to move forward ,,,

Former Member
0 Kudos

Hi,

you can use the formatNumber (double click on that function and give format as 00.0000 [after dot it should be 4 zeros]) function in b/w source and target fields mapping.

If you want to throw an exception in the mapping use this UDF.

String tempVar = "";

tempVar = strAmtVal.replaceAll(",", "");

String strValidChars = ".0123456789.";

int dotcounter = 0;

char strChar;

boolean binResult = true;

if(strAmtVal.trim().length() > 0)

{

for (int i = 0; i < tempVar.length() && binResult == true; i++)

{

strChar = tempVar.charAt(i);

if(strChar=='.') dotcounter++;

if (strValidChars.indexOf(strChar) == -1)

binResult = false;

if(dotcounter>3)

{

binResult = false;

break;

}

}

if (binResult == true)

{

int len1=0;

len1=tempVar.length();

int len2= tempVar.indexOf(".");

if (len2 == -1)

len2 = len1;

int diff = len1 - len2;

if(diff < 4)

return tempVar;

else throw new RuntimeException("Error: More than 4 digits exist after decimal");

}

else

throw new RuntimeException("Number Format Exception");

}

else

throw new RuntimeException("Number Format Exception");

Here "strAmtVal" is the input parameter and also in this UDF contains extra validation (number format, accepts only numeric values), if you don't want those validation then you can remove the those validations code.

Regards,

Venkata Ramesh

Former Member
0 Kudos

removing my reply

already suggested above by Venkata

Former Member
0 Kudos

hi all,

thanks for the replies and inputs

Answers (0)