‎2010 Jul 07 2:07 PM
Hello colleagues,
hier ist my Problem:
open dataset has sy-subrc code 0
read dataset has sy-subrc code 4
Exceptions are not caught
what is the error?
OPEN DATASET file_server FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 8.
MESSAGE mess TYPE 'I'.
ENDIF.
DATA: oerror TYPE REF TO cx_root,
txt_error TYPE string.
DO.
TRY.
READ DATASET file_server INTO platzhalter.
CATCH CX_SY_CODEPAGE_CONVERTER_INIT INTO oerror.
txt_error = oerror->get_longtext( ).
MESSAGE txt_error TYPE 'I' DISPLAY LIKE 'E'.
CATCH CX_SY_CONVERSION_CODEPAGE INTO oerror.
txt_error = oerror->get_longtext( ).
MESSAGE txt_error TYPE 'I' DISPLAY LIKE 'E'.
CATCH cx_sy_file_authority INTO oerror.
txt_error = oerror->get_longtext( ).
MESSAGE txt_error TYPE 'I' DISPLAY LIKE 'E'.
CATCH cx_sy_file_open INTO oerror.
txt_error = oerror->get_longtext( ).
MESSAGE txt_error TYPE 'I' DISPLAY LIKE 'E'.
CATCH cx_sy_pipe_reopen INTO oerror.
txt_error = oerror->get_longtext( ).
MESSAGE txt_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
IF sy-subrc <> 0.
MESSAGE i006(zerror).
EXIT.
ENDIF.
SPLIT platzhalter AT c_trennzeichen INTO
wa_inputdata-t_kunde
wa_inputdata-firma
wa_inputdata-city
wa_inputdata-street
wa_inputdata-zaehlpunkt
wa_inputdata-zaehlernr
wa_inputdata-bkreis
wa_inputdata-bkreis_n
wa_inputdata-kundengruppe
wa_inputdata-zaehlverfahren
wa_inputdata-slp_zuordnung
wa_inputdata-j_verbrauch
wa_inputdata-lif_beginn
wa_inputdata-bil_beginn
wa_inputdata-st_id.
APPEND wa_inputdata TO it_container.
IF sy-subrc <> 0.
MESSAGE i007(zerror).
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file_server.
Edited by: Aytac Kale on Jul 7, 2010 3:08 PM
‎2010 Jul 07 2:14 PM
For open dataset
sy-subrc Description
0 File was opened.
8 Operating system could not open file.
For read dataset
sy-subrc Meaning
0 Data was read without reaching end of file.
4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
‎2010 Jul 07 2:14 PM
For open dataset
sy-subrc Description
0 File was opened.
8 Operating system could not open file.
For read dataset
sy-subrc Meaning
0 Data was read without reaching end of file.
4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
‎2010 Jul 07 2:35 PM
thank you vinraaj,
how can i solve it?
Edited by: Aytac Kale on Jul 7, 2010 3:36 PM
‎2010 Jul 07 2:50 PM
Data: platzhalter(50000) type c.
Edited by: Aytac Kale on Jul 7, 2010 3:50 PM
‎2010 Jul 07 3:26 PM
Aytec, please format your code as IF sy-subrc <> 0 doesn't display <>!
Now sy-subrc = 4 is not an error when you use READ DATASET, it just indicates the end of file, so just don't display the message:
IF sy-subrc <> 0.
MESSAGE i007(zerror).
EXIT.
ENDIF.
Note that your code is buggy as sy-subrc may be changed by GET_LONGTEXT method. So you should place the code above right after the READ DATASET.
‎2010 Jul 07 3:25 PM
data:wf_string type string.
data: lf_ref TYPE REF TO cx_root.
DO.
TRY.
READ DATASET file_server INTO platzhalter.
*Catch system exceptions
CATCH cx_root INTO lf_ref. "#EC CATCH_ALL
wf_string = lf_ref->get_text( ).
IF wf_string IS NOT INITIAL.
MESSAGE s904(zf) WITH wf_string DISPLAY LIKE 'E'.
ENDIF.
ENDTRY.
if sy-subrc ne 0.
IF sy-index EQ 1. "No data in the file
EXIT.
ELSE. "End of File
CLOSE DATASET file_server.
EXIT.
ENDIF.
endif.
SPLIT platzhalter AT c_trennzeichen INTO
wa_inputdata-t_kunde
wa_inputdata-firma
wa_inputdata-city
wa_inputdata-street
wa_inputdata-zaehlpunkt
wa_inputdata-zaehlernr
wa_inputdata-bkreis
wa_inputdata-bkreis_n
wa_inputdata-kundengruppe
wa_inputdata-zaehlverfahren
wa_inputdata-slp_zuordnung
wa_inputdata-j_verbrauch
wa_inputdata-lif_beginn
wa_inputdata-bil_beginn
wa_inputdata-st_id.
APPEND wa_inputdata TO it_container.
ENDDO.
‎2010 Jul 07 4:37 PM
read dataset reads nothing, if sy-tabix = 1 and 2 ...
nothing..there are in the csv.table 5 data records
Edited by: Aytac Kale on Jul 7, 2010 5:55 PM
‎2010 Jul 07 4:57 PM
‎2010 Jul 07 5:06 PM
the problem is that no data is read. Like if sy-index 1 or 2 or 3 .... is a nothing is accepted, because nothing is read. inothing. In no time through the loop will read anything.
OPEN DATASET FOR INPUT IN TEXT MODE file_server ENCODING DEFAULT sy-subrc = 0 , the file is open, why is not a single record read?
Edited by: Aytac Kale on Jul 7, 2010 6:20 PM
Edited by: Aytac Kale on Jul 7, 2010 6:21 PM
‎2010 Jul 07 5:43 PM
though sy-subrc is set to 4, something may have been read (sy-subrc = 4 just indicates the end of file has been reached). Check in debug whether the variable contains something or not.