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: 

problem for read dataset

Former Member
0 Kudos

Hi,

i have a problem to read a file with datasets. This is my report:

************************************

data: begin of record,

MATNR_001(018),

MBRSH_002(001),

MTART_003(004),

...

...

HERKL_088(003),

end of record.

( 953 characters length )

OPEN DATASET P_DATASET

FOR INPUT IN TEXT MODE

ENCODING DEFAULT.

do.

read dataset p_dataset into record.

...

...

enddo.

*********************************************

When 'p_dataset' is read 'record' has only the first 240 characters of the dataset and the other fields of structure 'record' are empty.

Which is the problem?

If I see the file with AL11, its only shows the first 240 characters of each row but if I download the file to my pc it contains all fields completely.

Anyone can help me?

Thanks in advance

7 REPLIES 7

former_member221770
Contributor
0 Kudos

Oscar,

What happens if you READ the dataset into a char1000 string first then pass it into RECORD?

ie.

data: g_string(1000) type c.

OPEN DATASET P_DATASET

FOR INPUT IN TEXT MODE

ENCODING DEFAULT.

do.

read dataset p_dataset into g_string.

record = g_string.

...

...

enddo.

Cheers,

Pat.

0 Kudos

Hi Patrick,

I tried to READ dataset into a char1000 and into a string but it continues taking the first 240 characters. I think that it take 255 characters long by defect, but 240 to 270 character is a entire field.

I don't know what happens.

Thanks

0 Kudos

Hi Oscar,

try to open in binary mode ?

Andreas

0 Kudos

Hi Andreas,

if I open in binary mode and read in a target field 400 chars long, it take the first 240 first chars of the row 1 of my file and then take the 160 first chars of the row 2 of the file.

But a row of my line have more than 240 chars!

Thanks!

0 Kudos

Hi Oscar,

transfer file to pc and make gui_upload.

what happens now ?

Andreas

Former Member
0 Kudos

See this sample coding

*   Retrieve Data file from Application server(Upload from Unix)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

    OPEN DATASET i_file FOR INPUT IN TEXT MODE.
    IF sy-subrc NE 0.
      MESSAGE e999(za) WITH 'Error opening file' i_file.
    ENDIF.
    DO.
*     Reads each line of file individually
      READ DATASET i_file INTO wa_datatab.
*     Perform processing here
*     .....   
    ENDDO.

Also check this one

http://www.sapdevelopment.co.uk/file/file_updown.htm

Former Member
0 Kudos

Hi, Oscar Alonso

Can you explain more detail on your file content?

after the 240 character, what content exist in the file, as you estimate?