cancel
Showing results for 
Search instead for 
Did you mean: 

Number Formatting in Message Mapping

Former Member
0 Kudos

Guys

I am getting a decimal number like 30.22 from SAP. I am sending it to a flat file. Now I have a format for the flat file like 5S2 which means 5 total and the last two is decimal part. Also I dont want decimal point in the output. So my output should be 03022. But I am unable to fulfill this as my output? If I use "FormatNum" in airthmetic functions and if I specify it as 00000 then I am able to get 00030. But instead of this I should get 03022. Can any of you guys help me out?

Regards,

---Satish

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Satish,

supposing your number always has a max number of 2 decimal places, you could multiply it by 100 before executing the FormatNum. Then you should get your desired output.

For numbers without decimal places, it would generate additional 0s, which should be correct assuming your flat file works with fixed length.

Regards

Christine

Former Member
0 Kudos

Christine

I believe your solution would definitely work if I have 2 decimal places only. But I may have 2 or 3 or 4. So in this situation I think what you have told will not work. Is there any process to how to resolve this issue?

---Satish

Former Member
0 Kudos

Satish,

you could always write your own user defined function to make it happen. You would have to replace the "." and add leading and trailing zeros if necessary. That should be fairly simple to do in Java.

Just out of curiosity: how will your receiving system recognize how many digits are decimal places? Is there some fixed length to the numbers in the target file?

Regards

Christine

henrique_pinto
Active Contributor
0 Kudos

> Christine

>

> I believe your solution would definitely work if I

> have 2 decimal places only. But I may have 2 or 3 or

> 4. So in this situation I think what you have told

> will not work. Is there any process to how to resolve

> this issue?

>

> ---Satish

Satish,

but if I understanded correctly, the 5S2 standard also only accepts 2 decimal positions, isn't it so? How does 3.457 is represented in 5S2? Isn't it 00345?

If that's the case, then the answer that Christine provided satisfies your needs.

Former Member
0 Kudos

Christine

Now it is fine. I have confirmed from functional guys that since it is only 2decimals 9S2 the solution what you have given works for me. The decimal will not vary since 9S2 and suppose even though it varies say 9S3 then I will multiply with 1000 instead of 100.

After your question only I was curious and went to find out from functional guys. I have not got that into my mind when I was working.

Anyway my thanks to you and pinto for your prompt responses.

Regards,

---Satish

Answers (0)