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

read dataset has sy-subrc code 4

Former Member
0 Likes
3,784

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,574

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.

9 REPLIES 9
Read only

Former Member
0 Likes
2,575

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.

Read only

0 Likes
2,574

thank you vinraaj,

how can i solve it?

Edited by: Aytac Kale on Jul 7, 2010 3:36 PM

Read only

0 Likes
2,574

Data: platzhalter(50000) type c.

Edited by: Aytac Kale on Jul 7, 2010 3:50 PM

Read only

0 Likes
2,574

Aytec, please format your code as IF sy-subrc &lt;&gt; 0 doesn't display &lt;&gt;!

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 &lt;&gt; 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.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,574

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.
Read only

0 Likes
2,574

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

Read only

0 Likes
2,574

Please make it more clear.

Read only

0 Likes
2,574

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

Read only

0 Likes
2,574

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.