Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to store a file in application server with comma as a delimiter !!

Former Member
0 Kudos
65

<i>Hi,

I'm Creating a file in app. server using "open dataset" statment and populating the file using Transfer stmt.

I like to store the data fields with comma delimiter, since it normally fixed length.

Please let me know Any method available.

Thank You,

Senthil</i>

2 REPLIES 2

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
35

No problem, just concatenate all your fields into one field separated by a comma. Then transfer that field only.



data: your_dataset type localfile default '/usr/sap/TST/SYS/Data1.txt'.
data: output type string.

open dataset your_dataset for output in text mode.
loop at itab.
  concatenate itab-fld1
              itab-fld2
              itab-fld3
                   into output separated by ','.
  transfer output to your_dataset.
endloop.
close dataset your_dataset.

REgards,

Rich Heilman

Former Member
0 Kudos
35

Senthil,

Use the OPEN DATASET to open the file.

Use the statement TRANSFER record to filename to write to the file.

You will have to take care of addding the delimiter wherever you want. So, if you have a internal table with some fields, you will have to concatenate those fields manually separating them with , and then TRANSFER.

REgards,

Ravi