cancel
Showing results for 
Search instead for 
Did you mean: 

File to File with Tab Delimiter

former_member650236
Participant
0 Kudos

Hi Experts,

I am currently new to BCM Swift integrated with PI.My Requirement is to get a tag file from BCM and need to do FCC with tab delimiter.

OUTPUT FILE details (Below is the sample data which i need to conevert):

SAAL0311032132055020USD2015053128000,0020150531031100120151611-61343

7000,00SA9150000000032048815917ROBERT SMITHSAAL3500,001500,003000,001000,002029864994

-

After the end of the file it should be with - and also i want to achieve last 2 digits with , ex: 3500,00

How can i achieve this with FCC in SAP PI .

Need urgent help

Regards,

Shaik

Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

you can add - with the use of endSeparator,by assigning value as - to the endSeparator.

Converting XML in the Receiver File/FTP Adapter to Text Format - Configuring the File/FTP Adapter in...

And for adding last 2 digits,you should handle it in the mapping.

former_member650236
Participant
0 Kudos

Hi Raghu ,

Thanks for prompt reply,

In my scenario sender is also file so i have to do FCC for sender and receiver?

In receiver FCC what are the parameters i need to specify?

can you give some clear understanding.

In mapping how to achieve the logic by using string ?

Regards,

Shaik

former_member182412
Active Contributor
0 Kudos

Hi Shaik,

Can you paste the sender file example also here??

If you are getting decimal separator as '.' in the sender file then you can use java mapping to replace dot with comma and append '-' character at the end of the string without doing FCC configurations in sender and receiver file communication channels.


public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)

  throws StreamTransformationException {

  try{

  InputStream inputStream = transformationInput.getInputPayload().getInputStream();

  OutputStream outputStream = transformationOutput.getOutputPayload().getOutputStream();

  byte[] buf = new byte[inputStream.available()];

  inputStream.read(buf);

  String inputPayloadString = new String(buf,"UTF-8");

  inputPayloadString = inputPayloadString.replaceAll("\\.", ",").concat("-");

  outputStream.write(inputPayloadString.getBytes());

  }catch(Exception e){

  throw new StreamTransformationException(e.getMessage());

  }

  }

Note: Make sure you are not receiving dot character in any of the other fields.

Regards,

Praveen.

former_member186851
Active Contributor
0 Kudos

Hello Shaik.

If your getting Flat file yes you need to FCC at both the side.

For Sender FCC paramters check the below link

Converting Text Format in the Sender File/FTP Adapter to XML - Advanced Adapter Engine - SAP Library

For receiver already link shared.

Check the below link for an example

XI/PI: File Content Conversion for Complex Structures

In mapping how to achieve the logic by using string ?

You wish to add 00 at the end right?use formatnumber function or concat '00' with the string.

former_member650236
Participant
0 Kudos

Thanks raghu,

What ever the value i get from the last 2 digits it should have comma.

For ex: I am getting like 20000 then i want it as 200,00.

Regards,

Shaik

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

Try the below UDF and check if it works

input =input.substring(0,input.length()-2);

input = input.concat(,00);

return input;

Note:The Input length should be greater than 2 else it will fail.

bhavesh_kantilal
Active Contributor
0 Kudos

Please use the FormatNum standard function for this. You can specify format as ###,###

Regards,

Bhavesh

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

You can use FormatNUM as Bhavesh suggested if  the length is fixed.

Else you can use mine which is dynamic.

former_member650236
Participant
0 Kudos

Hi Raghu,

It is not fixed it is dynamically change the value.

Ex: If the value is 000 also i want 0,00 from the last 2 digits , will be there..

Can't i achieve this through standard functions.

Regards,

Shaik

bhavesh_kantilal
Active Contributor
0 Kudos

Standard FormatNum as far I know has no restriction. It is based on DecimalFormat (Java Platform SE 7 )

For your requirement: ########,## should do the trick.

This will make sure that last 2 numbers have a , irrespective of length.

Did you try it?

Regards

Bhavesh

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

Try with Formatnum as Bhavesh suggested,I doubt on that.

If its not working use that small UDF.

bhavesh_kantilal
Active Contributor
0 Kudos

Just tried this. I have given #,## as my input to FormatNum,

  • If input - 123 , output is 1,23
  • If input - 12345, output is 1,23,45
  • In input is 123456, output is 12,34,56

Basically, the Format Number formats the numbers to the hundreds digits. There is no dependency on the Input Number length.

Now if the requirement is to have only last 2 digits with a "," as 1,23 or 1234,56 or 12,34 then the format number will not work but to me it doesnt make sense to have the separator just for the last 2 digits. You either use it everywhere or nowhere else the number itself does nt make sense.

Do note in European SAP System 1234,56 is 1234.56. Europeans nations denote a decimal place with a ",". If the requirement is to denote decimal notations as "," then Format number with #,## with decimal separator as "," will also work.

Regards

Bhavesh

former_member186851
Active Contributor
0 Kudos

Yes Bhavesh,I understand.

But will it add 00 as well irrespective of length?

I doubt it.

bhavesh_kantilal
Active Contributor
0 Kudos

Where is the requirement to add 00? The requirement is to add a comma to the last 2 digits of the number..

Also do not my response I am not adding 0's. I am formatting the number!

former_member186851
Active Contributor
0 Kudos

ok I misunderstood..I thought 00 should be added at last.

@ Shaik..As Bhavesh suggested FormatNum should work for you.

former_member650236
Participant
0 Kudos

Hi Bhavesh,

Thanks for the reply.

In my target it must get , only last 2 digits whatever may be the value.

Ex: Proposed valid format is 12345678,90(Last 2 digits , is must)

  • If input - 123 , output is 1,23
  • If input - 12345, output is 123,45
  • In input is 123456 output is 1234,56

Regards,

Shaik

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

This is not possible with standard functions.

Try with the below UDF

String A = Input.Substring(0,Input.length()-2);

String B= Input.Substring(Input.length()-2,Input.length());

String out= A + "," +B;

Return Out;

former_member650236
Participant
0 Kudos

Ok thanks raghu i will try and get back to you .

Regards,

Shaik

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

Use the below one(some Typo errors in the above code)

String A = Input.substring(0,Input.length()-2);

String B= Input.substring(Input.length()-2,Input.length());

String out= A + "," +B;

return out;

And I can see its working as per requirement.

former_member650236
Participant
0 Kudos

Hi Raghu,

Can you help with full code am getting error.

Atleast one public class is required.

Regards,

Shaik

former_member186851
Active Contributor
0 Kudos

Hello Shaik,

Just see the above reply.

String A = Input.substring(0,Input.length()-2);

String B= Input.substring(Input.length()-2,Input.length());

String out= A + "," +B;

return out;

I tested it as well.

former_member650236
Participant
0 Kudos

Hi Raghu,

I need to add any public class with string to get the output value.

Regards,

Shaik

former_member186851
Active Contributor
0 Kudos

Nopes Shaik,

Just create the UDF,Change the name of string to "Input" and add the code which is recent( I mean the one with the screenshots).

former_member650236
Participant
0 Kudos

Like this am trying in UDF..

public class input {

   String A = Input.substring(0,Input.length()-2);

   String B= Input.substring(Input.length()-2,Input.length());

   String out= A + "," +B;

return out;

Regards,

Shaik

former_member186851
Active Contributor
0 Kudos

No need to include public class Input {


Already class will be ter.


Just copy the below code and paste it in the editor.

Screenshot below

former_member650236
Participant
0 Kudos

Hi Praveen,

This is my requirement can you help ..

source file MT 100 Payroll payment sample file                                                          

RequestType#mt100-payroll

Housebank#USDDXXXX

TransactionCounter#00001

USDD0XXX

100

USDD0XXX

MOL#74603-01

:20:1857000810

:32A:151006USD1,00

:50:STREAM COMP

:52A:USDD0XXX

:53B:/3231649009940

:57A:USDD

:SAL:0.00

:HRA:0.00

:OTH:1.00

:DED:0.00

:ID:2353361070

:59:/SA6320000001010171949940

ALEXANDER JOSEPH MARTINA

SA -  TEXAS

:70:No.53000/

Target File is Tabdelimiter

Header Info

First Row 2 items we have to hardcode it(AAL  0247 Values).

AAAL 0247 032401361054 USD 20150528 100,00(this value is increasing if there are 2 cusotmers then 200,00)   02470012015148 1-123310

Footer

Netamnt  Employee account Emp Name    Bankcode Typ paymnt Basic HRA OTH Deduct Emp ID Txn Refrnumb Txnstats TxnDate

100,00 SA5655000000025931400134 ALEXANDER JOSPEH DSFR Salary 50,00 50,00 0,00 0,00 2212746529 SRE1515110700001 Success 20150601

Please let me know how to achieve this in mapping. I have to increment the number with simple UDF when ever the values changes?

Netamnt i can concatenate it with salary,HRA ....

Regard,

Shaik

Answers (0)