2015 Oct 07 6:00 PM
Hi there,
I have many codes like this:
EXEC SQL.
INSERT INTO T_ORACLE_TABLE ( field1, field2, field3 )
VALUES ( :t_sap_table-field1, :t_sap_table-field2, :t_sap_table-field3 )
ENDEXEC.
This is just an example, but the real queries are bigger than that.
I would like to save this query with values in a Ztable, something like a string "insert into oracle_Table(field1,field2,field3) values('value1', 'value2', 'value3')".
Does anyone know if is it possible to get the query I'm doing?
2015 Oct 08 12:50 AM
Why you just do not use the ADBC and tries to dynamically run your DML statements?
(Just a suggestion for improvements).
BR,
Raphael Pacheco.
2015 Oct 07 11:27 PM
You can execute one or more pre-created queries in your Z table by doing the following steps:
1) Loop through the Z table of queries
2) for each query you want to execute, add five rows to a itab of code lines as follows:
code_itab = 'FORM one_of_n.'. APPEND code_itab.
code_itab = 'EXEC SQL.'. APPEND code_itab.
code_itab = '<query string here>'. APPEND code_itab.
code_itab = 'ENDEXEC.'. APPEND code_itab.
code_itab = 'ENDFORM.'. APPEND code_itab.
3) create a utility report containing your query using this command:
GENERATE SUBROUTINE POOL code_itab NAME zmy_utility MESSAGE errors.
4) Call each query in turn
PERFORM one_of_n in PROGRAM z_my_utility CHANGING results.
PERFORM two_of_n in PROGRAM z_my_utility CHANGING results2.
PERFORM three_of_n in PROGRAM z_my_utility CHANGING results3.
that should work nicely. Here are a couple of tips.
You might try defining "code_itab" as follows:
DATA: code_itab TYPE STANDARD TABLE OF tline-tdline.
See below for a complete solution to a simpler but similar problem:
2015 Oct 08 12:50 AM
Why you just do not use the ADBC and tries to dynamically run your DML statements?
(Just a suggestion for improvements).
BR,
Raphael Pacheco.
2015 Oct 08 11:56 AM
2015 Oct 08 1:36 PM
Thanks for your feedback.
Show to him the demo program called "ADBC_DEMO", it's a sample program what explain all statements using ADBC.
Warm regards,
Raphael Pacheco.