Application Development and Automation 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: 
Read only

ASCII Code in ABAP

Former Member
0 Likes
4,468

Hi Experts,

We need to enter a unique ASCII character called 'US' or Unit Separator in a text file being generated through a program.

The ASCII code for US is 31. However when we try and do it programmatically the character '#' is getting populated.

The code is as follows:

DATA : lv_sep type c.

field-symbols : <xfs> type x.

assign lv_sep to <xfs> casting.

<xfs> = 0031.

write lv_sep.

Kindly help us out.

Thanks and Regards,

Ravi Bhatnagar

3 REPLIES 3
Read only

MarcinPciak
Active Contributor
0 Likes
2,366

Hi,

This character is special one, so you can't print it out. In SAP all special charcter which can't be printed are replaced with placeholder #. They are intended to do theri special purpose in flat file, once you open it.

Do the following:

- use fm HR_KR_XSTRING_TO_STRING to convert xstring with value '1F' (30 decimal value) to string

- write this string to certain place in internal string table (where you want later use it in the file)

- download this table as to file

- special character will do its purpose in text file

This is the same functionality as you would be placing Line Feed (0x0A - 10 dec). It would be shown as # but once you open downlaoded file you don't see hash # anymore, but you see that new line in that place.

Hope this is clear

Regards

Marcin

Read only

0 Likes
2,366

Hi,

I used fm HR_KR_XSTRING_TO_STRING and it worked well ! Many thanks !

Read only

Former Member
0 Likes
2,366

hI Ravi,

Try This.

DATA : lv_sep type c.

DATA : lv_sep1 type c.

data : m_text(2) type c.

field-symbols : <xfs> type x.

field-symbols : <yfs> type x.

assign lv_sep to <xfs> casting.

assign lv_sep1 to <yfs> casting.

<xfs> = 0085.

<yfs> = 0083.

concatenate lv_sep lv_sep1 into m_text.

write:/ m_text.

Regds,

Anil