Hi Expert,
I try to insert a external SQL TABLE Like below.
And I try to insert this SQL TABLE by below abap program:
*Connect to DB
*Get connection
SELECT SINGLE text INTO i_con2 FROM zmmt66
WHERE name = 'CTO_REPORT'
AND con_txt1 = s_werks-low
AND seqno = '001'.
* checks if connection works
TRY.
IF i_con2 <> ''.
EXEC SQL.
SET CONNECTION :I_CON2
ENDEXEC.
ENDIF.
* retry again if failed.
IF sy-subrc <> 0.
EXEC SQL.
CONNECT TO :I_CON2 => Connecting is successful
ENDEXEC.
ENDIF.
CATCH cx_root INTO l_oref.
* force disconnect at any unexpected error
EXEC SQL.
DISCONNECT :I_CON2
ENDEXEC.
RETURN.
ENDTRY.
*Insert table
LOOP AT t_mocl2.
CLEAR: wa.
CLEAR: lv_time.
wa-zseqid = t_mocl2-zseqid.
wa-aufnr = t_mocl2-aufnr.
wa-matnr = t_mocl2-matnr.
wa-resbmatnr = t_mocl2-resbmatnr.
wa-menge = t_mocl2-menge.
wa-editor = 'SAPAUTO'.
t1 = sy-datum.
CONCATENATE sy-uzeit+0(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2) INTO t2.
CONCATENATE t1 t2 INTO lv_time SEPARATED BY space.
wa-cdt = lv_time.
wa-udt = lv_time.
TRY.
EXEC SQL.
INSERT INTO [CTO_REPORT].[dbo].[SAP_PULL_LIST]
([Sequence No]
,[MO ]
,[SKU number]
,[IECPN]
,[Qty]
,[Editor]
,[Cdt]
,[Udt])
VALUES (:wa-zseqid,
:wa-aufnr,
:wa-matnr,
:wa-resbmatnr,
:wa-menge,
:wa-editor,
:wa-cdt,
:wa-udt)
ENDEXEC.
EXEC SQL.
Commit
ENDEXEC.
ENDTRY.
ENDLOOP.
But get below error msg,(Please click this PIC to see the error msg)
The insert data is like below
The question is I use same insert program in SQL to insert is ok.
Is any problem in my program,please kindly advise!
INSERT INTO [CTO_REPORT].[dbo].[SAP_PULL_LIST]
([Sequence No]
,[MO ]
,[SKU number]
,[IECPN]
,[Qty]
,[Editor]
,[Cdt]
,[Udt])
VALUES (:wa-zseqid,
:wa-aufnr,
:wa-matnr,
:wa-resbmatnr,
:wa-menge,
:wa-editor,
:wa-cdt,
:wa-udt)