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

Problem reading DATASET into xstring

Former Member
0 Likes
1,934

Hi,

I am facing a curious problem where I'd appreciate a helping hand: when I read data from a dataset into a variable of fixed-length, everything works fine. When I try to do the same with a variable-length type, nothing is read.

This code works fine:

<i>DATA binarydata(32000) TYPE x,

alen TYPE i.

OPEN DATASET filename FOR INPUT IN BINARY MODE.

READ DATASET filename INTO binarydata ACTUAL LENGTH alen.</i>

Here alen contains the correct number of bytes read (eg. 19000).

But if I try:

<i>DATA binarydata TYPE xstring,

alen TYPE i.

OPEN DATASET filename FOR INPUT IN BINARY MODE.

READ DATASET filename INTO binarydata ACTUAL LENGTH alen.

</i>

Here alen is 0.

Can anybody tell me what's wrong here ?

Thanks & Regards

Heiko

7 REPLIES 7
Read only

Former Member
0 Likes
1,245

Hi,

For the string one try giving mode as TEXT instead of BINARY.

DATA binarydata TYPE xstring,

alen TYPE i.

OPEN DATASET filename FOR INPUT IN <b>TEXT</b> MODE.

READ DATASET filename INTO binarydata ACTUAL LENGTH alen.

Thanks,

Naren

Read only

0 Likes
1,245

Hi Naren,

sorry, if I do that, I get a shortdump saying "For the statement 'READ DATASET ... INTO f' only character-type data objects are supported at the argument position 'f'".

Thanks,

Heiko

Read only

0 Likes
1,245

Hello Heiko

If you are using NON-UNICODE system, please try by unselecting the checkbox "Unicode Checks Active" in program attributes.

While using UNICODE system, need to use as STRING.

Reason:

In UNICODE enabled or when Unicode Checks is active, system can transfer data between structures only when both are of characater format.

In your case, the data is read in text mode i.e character format but trying to move to XSRTING which is sequence of 'X' type characters. Hence resulting in dump.

Just for your info:

<b>The elementary data type STRING is similar to data type C and refers to a variable-length string. Accordingly, the elementary data type XSTRING is similar to data type X and refers to a variable-length byte sequence.</b>

Hope the above info clarifies you.

Kind Regards

Eswar

Read only

0 Likes
1,245

Hello Eswar,

thanks for your answer which helps to clarify the issue. But I already face the next problem: when I unselect "Unicode Checks Active" (I am using a non-unicode system), I cannot activate my report. I get an error saying "The program 'Z_HEIKO_UPLOAD' is not Unicode-compatible, according to its program attributes". Any hints on how to solve that ?

Thanks a lot,

Kind Regards

Heiko

Read only

0 Likes
1,245

Dear Heiko

This error will be encountered in UNICODE system. To check the same, you can use menupath System->Status.

In tab SAP System Data, if <b>Unicode System</b> has value 'YES', the system is unicode enabled. Please check whether the value is YES or NO in your system.

Kind Regards

Eswar

Read only

0 Likes
1,245

Hello Eswar,

sorry for the late reply but I have been gone last week.

But regarding my problem: I had already checked System->Status and for Unicode System it says "No".

Any ideas ?

Thanks & Regards

Heiko

Read only

0 Likes
1,245

Hello Heiko

Check you report using transaction <b>UCCHECK</b> and see what the report tells you about unicode-errors.

Regards

Uwe