2009 Jun 17 10:33 AM
Hi all,
I've a file on the AL11 which I need to read in binary mode line by line.
I've did it but I cant reach to do line by line, when the read dataset sentence is executed it returns all the data contained in the file and, as there is any kind of character which can be used as separator I'm not able to know how to split it.
Does anybody know how to read only one line?
Thanks in advance,
Regards.
Hi all,
I've a file on the AL11 which I need to read in binary mode line by line.
I've did it but I cant reach to do line by line, when the read dataset sentence is executed it returns all the data contained in the file and, as there is any kind of character which can be used as separator I'm not able to know how to split it.
Does anybody know how to read only one line?
Thanks in advance,
Regards.
2009 Jun 17 10:35 AM
Use SPLIT command for splitting the data.
Refer following code:
==================
Local data delaration.
DATA: v_string TYPE string.
Opening the file from the given location.
OPEN DATASET p_pathup FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc 0.
MESSAGE i000 WITH text-018.
LEAVE LIST-PROCESSING.
ENDIF.
File opened, Reading the contents and transfering to internal table.
DO.
READ DATASET p_pathup INTO v_string.
IF sy-subrc = 0.
SPLIT v_string AT c_sep
INTO w_upload-lifnr
w_upload-loevm_ven
w_upload-banksrec
w_upload-bankkrec
w_upload-banknrec
w_upload-loevm_rec
w_upload-waers
w_upload-bankssnd
w_upload-bankksnd
w_upload-loevm_snd
w_upload-chainno
w_upload-chainbankt
w_upload-chainbanks
w_upload-chainbankk
w_upload-chainbankn
w_upload-loevm_cor.
ELSE.
EXIT.
ENDIF.
APPEND w_upload TO i_upload.
CLEAR: w_upload,
v_string.
ENDDO.
Closing the file.
CLOSE DATASET p_pathup.
Let me know if you need any help on understanding the logic.
Regards
2009 Jun 17 10:37 AM
2009 Jun 17 11:12 AM
Hi thanks for your replies,
the split option is not valid because I've no mark to know when there is a end of line.
I were checking the refered link but any of my test worked, it allways returns all the data contained on the file, so which is the correct option to read only one line?
2009 Jun 17 11:15 AM
Hi,
OPEN DATASET p_pathup FOR INPUT IN BINARY MODE ENCODING DEFAULT
give binary instead of text.
hope it'll help.
Regards,
Sneha.
2009 Jun 17 11:24 AM
Yes Sneha,
but this instruction return all the data conteined on the file on a single execution, is there any option to read the data line by line as in the text mode?
Regards,
2009 Jun 17 2:26 PM
When you open a file in binary mode, the system expects an unstructured sequence of bytes in the file. If you have fixed number of bytes in a line, then try using the MAXIMUM LENGTH addition while reading the file.
Why do you have to read the file in binary mode only?
Regards,
Susanta
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |