cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on conversion of .csv to .txt

0 Kudos

Dear Team,


  I am very new to SAP PI. I have a scenario where PI will pick the .csv file from AL11 of SAP and convert to .txt file  and place in to FTP location of of third party system.


I have gone through the SDN but didn't get clear solution.


Info: We are not using ESR part

       .csv file contain pipe delimited between fields.


.csv structure is as attached

  

Could any one please provide step by step procedure.


Thanks,

Sree


Accepted Solutions (1)

Accepted Solutions (1)

apu_das2
Active Contributor
0 Kudos

Hi Sai,

If its pass through , then simply put the file name with extension .txt in the receiver file CC.

This will work without any issue.

Thanks,

Apu

Answers (3)

Answers (3)

former_member207703
Active Participant
0 Kudos

Hi Sai,

If you are new on SAP PI, then use FCC both side, at Sender as well at Receiver CC.


First, at Sender CC, use fieldSeparator as | and endSeparator as 'nl'.

And after that at Receiver CC, use fieldSeparator as '    ' and endSeparator as 'nl'.

Also with that, at Sender CC set document offset = 1, it will ignore header line.

And at Receiver CC set addHeaderLine as '1', that will again add a header line while writing it on FTP.


Save this file as .txt that's easily done at Receiver CC.


Hope it will help you.

If you are good in UDF, then try with that, because that will be much more easy for you.


Regards,

Anoop Kumar Rai

0 Kudos

Dear Anoop,

  Thanks for the information.

sender is .csv and receiver is txt with file name should  be abc_xyz_today's date.txt.

From AL11 PI will pick the file and send it to FTP server of third party system.

CSV file is Tab delimited.

Is it possible without FCC both the ends?

Can you please share me step by step screen shot.

Thanks

former_member207703
Active Participant
0 Kudos

Hi Sai,

For file name conversion you have to write a UDF using dynamic conversion and mapped it with any upper field. You will get this UDF from different places n internet, just Google it with Dynamic Configuration for file name, and change value of filename as your wish and DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","filename");.


It's my recommendation to use FCC in this scenario, because its difficult to hold full TSV file in a string field. Its good to separate line using FCC then spliting it into nodes in Message Mapping.

You can follow this solution to:-

1. At Sender CC, specify only endSeparater as 'nl'.

2. In data type for both Sender and receiver specify only one field like 'Text'.

3. In message mapping, just write a UDF to replace Tab with Space in string and map one to one mapping between Text-to-UDF-to-Text.

4. At Receiver CC, also same thing have to do, specify only endSeparater as 'nl'.


If you don't want to use FCC at all, (i.e, not recommended), then just take whole file content in one string node, and write a UDF to change String Array into ArrayList and then loop on ArrayList to replace Tab with Space for each row.


First specify which way you want to do then only i will able to provide screenshots.

Hope this will be help full.


Regards,

Anoop Kumar Rai

apu_das2
Active Contributor
0 Kudos

Hi Sai,

This is absolutely possible without FCC if your scenario is pass through only and you need to mapping to convert data and put into target structure.

For file name conversion in the target end just put your required file name in the receiver file CC. In the processing tab select add time stamp as file construction mode that will add the date when the file will be processed.

Thanks,

Apu 

0 Kudos

Dear Experts,

  Thanks for your valuable inputs.

  Since we are changing the file extension from .csv to .txt we can bypass the scenario.

  From the sender side i have used NFS. But i am getting empty message and in sxmb_moni i am getting no interface action for sender and receiver found message.

Please guide me on the above issues.

Thanks,

Sree

Harish
Active Contributor
0 Kudos

Hi Sree,

Please check the receiver service and receiver interface determine in Moni (I assum you are working on pipeline configuration). There should be wrong receiver  service or interface.

Also check if the cache is correctly update from ID.

regards,

Harish

Former Member
0 Kudos

Hi Sree,

If you want to change only the file format, do the below

1: Select ASMA in File Sender

2: Mention the file type and select ASMA as below in File reciever

Regards,

Vishal

Harish
Active Contributor
0 Kudos

Hi,

do you only want to change the extension of file or you also want to change the file format?

For changing the extension you can mention the required file name in receiver adapter.

to change the format please provide the target format to provide inputs.

regards,

Harish

0 Kudos

Dear Harish,

  Thanks for your inputs.

Find the .CSV file in this directory(AL11) and rename it as [today’s date (yyyymmdd)]_sample_abc.txt.


     Move the file to FTP directory of third party.

  From sender side file adapter we need to do any FCC?

  For sender side shall we take NFS in the message protocol? At the receiver side FTP since this is from third party.

Flat File structure:

Item     Field     Description     InfoObject template  Type     Length

1          Name       Name                0Name               Char     35

2          Type                                                          Char      1

3          Date          Date                 0Date                DATS     8

4         Payment    payment                                      Char     1

Based on the above txt file structure please suggest and share step by step guide.

Thanks,

Sree        

Harish
Active Contributor
0 Kudos

Hi Sree,

If you do not need to change the content or format of the file you can use the NFS at the sender side and File adapter at the receiver side without any FCC.

Please refer the below blog

http://scn.sap.com/docs/DOC-3716

regards,

Harish

manoj_khavatkopp
Active Contributor
0 Kudos

Sree,

If you need to add the date (YYYYMMDD) at the beginning of the filename this is only possible if you have custom module/Mapping as standard functionality of "Add timestamp" of the FTP adapter adds the time stamp at the end i.e just before the file extension.

Br,

Manoj