08-01-2005 11:44 PM
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
08-02-2005 12:14 AM
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.
08-02-2005 7:49 AM
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
08-02-2005 7:54 AM
08-02-2005 8:21 AM
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!
08-02-2005 8:37 AM
Hi Oscar,
transfer file to pc and make gui_upload.
what happens now ?
Andreas
08-02-2005 4:27 AM
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
08-02-2005 5:04 AM
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?