2012 Sep 24 9:58 AM
Hi to all,
One of my object is to move data from SAP to native SQL in direct method.
I have created a database connection with username and password, while executing the program the connection obtained successfully.
Now what my problem is i am having data in my internal table ( local table called LT_FINAL ) , i looped the table and try to assign the values to SQL variables.
But its not taking the variable assignments.
Here the code what i write for your reff..
data kunnr type kna1-kunnr.
TRY.
LOOP AT lt_final INTO lw_final.
kunnr = lw_final-kunnr .
EXEC SQL.
DECLARE @v1 varchar(10);
SET @v1 = :KUNNR ; " this variable assignment not yet accepted
BEGIN TRANSACTION;
insert into [SAPIT].[DBO].[customer_details] ( KUNNR , name1 )
values ( @V1 , 'IUY') ;
COMMIT TRANSACTION;
ENDEXEC.
ENDLOOP.
CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
MESSAGE error_text TYPE 'E'.
ENDTRY.
help me to solve the issue.
Advance thanks,
M.S.Amirtharajvijay.
Hi to all,
One of my object is to move data from SAP to native SQL in direct method.
I have created a database connection with username and password, while executing the program the connection obtained successfully.
Now what my problem is i am having data in my internal table ( local table called LT_FINAL ) , i looped the table and try to assign the values to SQL variables.
But its not taking the variable assignments.
Here the code what i write for your reff..
data kunnr type kna1-kunnr.
TRY.
LOOP AT lt_final INTO lw_final.
kunnr = lw_final-kunnr .
EXEC SQL.
DECLARE @v1 varchar(10);
SET @v1 = :KUNNR ; " this variable assignment not yet accepted
BEGIN TRANSACTION;
insert into [SAPIT].[DBO].[customer_details] ( KUNNR , name1 )
values ( @V1 , 'IUY') ;
COMMIT TRANSACTION;
ENDEXEC.
ENDLOOP.
CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
MESSAGE error_text TYPE 'E'.
ENDTRY.
help me to solve the issue.
Advance thanks,
M.S.Amirtharajvijay.
2012 Sep 24 11:59 AM
Hi,
Why don't you try this? ( KUNNR is CHAR10 so should be same as VARCHAR(10).
insert into [SAPIT].[DBO].[customer_details] ( KUNNR , name1 )
values ( :KUNNR , 'IUY') ;
Hope it helps.
Regards,
R
2012 Sep 24 12:22 PM
Hi Rudra Roy,
thanks for the reply..,
Its also not working Rudra..,
In SQL TRACE its returning "
BEGIN TRANSACTION; insert into [SAPIT].[DBO].[customer_details] ( KUNNR, name1 ) values ( ? , 'IUY' ) ; COMMIT TRANSACTION;
"
In this Values ( ? , 'IUY' ) in the place :kunnr its making ?
thanks ,
M.S.AmirtharajVIjay
2012 Sep 24 1:29 PM
Ok. Are you getting any error message out of the exception handling?
2012 Sep 24 1:41 PM
No Rudhra..,
after performing the insert process its moved to disconnect 'dbcon'.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |