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: 

Question Regarding Dataset

Former Member
0 Kudos

How to transfer trailing spaces to a file in datasets? I am using SAP 7.0 and unable to output trailing spaces to a file instead it truncates in transfer dataset.

I want to output as below after '000000001A' I should output 3 spaces basically at end of the record which I am unable to figure how to pass spaces at the end of record.

"3020060504155309 000000000001 000000001A "

Any of your experience will help.

Regards,

Ramesh

7 REPLIES 7

former_member181962
Active Contributor
0 Kudos

open the dataset in bin mode instead of text mode.

0 Kudos

Hi,

Open dataset for output in<b> BIN mode</b>.

Regards,

Santosh

Former Member
0 Kudos

hii

use

OPEN DATASET <file name> FOR <u>{<b>OUTPUT</b>/</u><i>INPUT/APPENDING</i>}

IN {<i>TEXT</i>/<u><b>BINARY</b>}</u> MODE

The READ or TRANSFER will be character wise. Each time ‘n’’ characters are READ or transferred. The next READ or TRANSFER <b>will start from the next character</b> position and not on the next line.

HOPE THIS HELPS

Thanks&Regards

Naresh

0 Kudos

Thanks for your instant replies Opening in Binary mode did not help. I read the documentation they recommend using data type 'STRING' in TEXT MODE.

Alternative 2

... TEXT MODE encoding [linefeed]

Effect:

The addition IN TEXT MODE opens the file as a text file. The addition ENCODING defines how the characters are represented in the text file. When writing to a text file, the content of a data object is converted to the representation entered after ENCODING, and transferred to the file. If the data type is character-type and flat, trailing blanks are cut off. In the data type string, trailing blanks are not cut off. The end-of-line selection of the relevant platform is applied to the transferred data by default. When reading from a text file, the content of the file is read until the next end-of-line selection, converted from the format specified after ENCODING into the current character format, and transferred to a data object. The end-of-line selection used is controlled using the addition linefeed (as of Release 7.0).

But this also is not helping.

0 Kudos

Use the option 'LENGTH n' where 'n' is the length of the string you are downloading. This will work for transfer to the application server using OPEN,READ/TRANSFER, CLOSE DATASET commands.

Alternatively, you can increase the length of your output string by 1 character and fill in this last character with some record end indicator. That way you can prevent it from truncating the trailing spaces. But for, you have to ask the receiving application to ignore this last character.

0 Kudos

Thanks for your replies again!

Infact I also used LENGTH during DATASET TRANSFER that did not help it still truncates. It is good option to have line feed at end of file indicator but I thought it might be possible without that. Anyway I will check with the receiving application if it will be ok to send an end of record indicator.

0 Kudos

I am sure it worked for me in lower versions, but I am not in 7.0 so I cannot be sure about it there. Check the documentation if it tells you something.