Skip to Content
0
Former Member
Jul 08, 2015 at 10:02 AM

ABAP ADBC - method EXECUTE_UPDATE - (INSERT dbtab FROM fieldsymbol)

686 Views

Hi guys,

I'm wondering. Is it possible to use method EXECUTE_UPDATE with statement "INSERT dbtab FROM <field_symbol>"?

My goal is to catch exception in more detailed way than SY-SUBRC and use application log class interface IF_RECA_MESSAGE_LIST which is ready to store messages from catched exceptions.

My expectation is something like this (I used MARA table just for an example)

DATA: it_internal TYPE mara,

ld_rows_processed TYPE i,

lo_sqlstmt TYPE REF TO cl_sql_statement,

lo_sql_exception TYPE REF TO cx_sql_exception,

lo_parameter_invalid TYPE REF TO cx_parameter_invalid.

.

FIELD-SYMBOLS: <ls_internal> TYPE mara.

CREATE OBJECT lo_sqlstmt.

LOOP lt_internal ASSIGNING <ls_internal>

..... do some work here......

TRY.

CALL METHOD LO_SQLSTMT->EXECUTE_UPDATE

EXPORTING

STATEMENT = 'INSERT ZDBTAB FROM <ls_internal>'

RECEIVING

ROWS_PROCESSED = ld_rows_processed

.

CATCH cx_sql_exception INTO lo_sql_exception.

CATCH cx_parameter_invalid INTO lo_parameter_invalid.

ENDTRY.

ENDLOOP.

But if I do it in this way I get general error, that SQL statement is wrong.

SQL0104N An unexpected token "ZDTAB" was found following "INSERT ". Expected tokens may include: "JOIN". SQLSTATE=42601