2015 Jul 08 11:02 AM
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
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
2015 Jul 08 11:15 AM
Hi Jindrich,
Have you checked ADBC_DEMO program in SAP system.
In this program, the SQL statement has been pass through an variable.
You can try with this way also.
Please find some more ADBC related Demo Programs.
ADBC_DEMO
ADBC_DEMO_LOBS_ORA
ADBC_DEMO_PROC_CALLS_HDB
ADBC_DEMO_QUAINT
ADBC_QUERY
.
Regards,
Praveer
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |