Skip to Content
0
Former Member
Sep 24, 2012 at 08:58 AM

SAP to SQL data transfer : Variable declaration issue..,

22 Views

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.