SchwarzIT / sap-usi-logging-api

An easy-to-use, object-oriented encapsulation around the SAP application log (Transaction SLG1)
Apache License 2.0
24 stars 0 forks source link

Data Containers: Catch Transformation Errors #10

Closed NeumannJoerg closed 1 year ago

NeumannJoerg commented 1 year ago

The following code causes a short dump.

TYPES: BEGIN OF ty_table_line,
         field TYPE n LENGTH 10,
       END   OF ty_table_line,
       ty_table TYPE STANDARD TABLE OF ty_table_line WITH EMPTY KEY.

DATA: table_line TYPE ty_table_line,
      table      TYPE ty_table.

table_line = CONV char10( |{ space WIDTH = 9 }0| ).
INSERT table_line INTO TABLE table.

/usi/cl_bal_factory=>get_instance( )->get_existing_logger( )->add_free_text(
    i_free_text = 'test'
    i_details   = NEW /usi/cl_bal_dc_collection( )->insert(
                          NEW /usi/cl_bal_dc_itab( i_internal_table = table ) ) ).

Dump Logging API

Method /USI/CL_BAL_SERIALIZER=>SERIALIZE_FIELDS does not catch CX_SY_CONVERSION_NO_NUMBER, that is thrown, because table[ 1 ]-field contains value 0 which is not feasible for a field of type NUMC10. Since the exception is not caught, the entire application is terminated with a short dump.

Method /USI/CL_BAL_SERIALIZER=>SERIALIZE_FIELDS should catch cx_root and convert it into /USI/CX_BAL_INVALID_INPUT. The exception /USI/CX_BAL_ROOT needs to be propagated by the marked methods.

This would result in corrupt itab containers being ignored.