Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Try.Catch problem with CATCH SYSTEMEXCEPTIONS

Hi,

I'm using this example coding

  IF sy-batch <> ''.
    CATCH SYSTEM-EXCEPTIONS
      dataset_too_many_files = 90
      open_dataset_no_authority = 91
      dataset_write_error = 92
      dataset_cant_close = 93
      dataset_read_error = 94
      .
    ENDCATCH.
  ELSE.
    o_material = zcl_sales_material_base=>factory( ).

    TRY.
        o_material->reload_matnr(
            i_matnr = l_tab_daemon_input-matnr
            i_vkorg = l_tab_daemon_input-vkorg
            i_vtweg = l_tab_daemon_input-vtweg
               ).
      CATCH zcx_sales_material .
        sy-subrc = 99.
    ENDTRY.
  ENDIF.

The code itself should not matter, however, the syntax check gives me the error:

TRY and CATCH SYSTEM-EXCEPTIONs cannot be used simultaneously

.

While I understand this error when using nested coding like this

 
    TRY.
       CATCH SYSTEM-EXCEPTIONS
        dataset_too_many_files = 90
        open_dataset_no_authority = 91
        dataset_write_error = 92
        dataset_cant_close = 93
        dataset_read_error = 94
      .
      ENDCATCH.
      CATCH zcx_sales_material .
        sy-subrc = 99.
    ENDTRY.
  ENDIF.

I don't understand why the parser throws the mentioned error in the coding on the top. IMO the CATCH..ENDCATCH and TRY..ENDTRY are two separate blocks independent of each other. So what's the deal here?

Not what you were looking for? View more on this topic or Ask a question