Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

Ok. Are you getting any error message out of the exception handling?

0 Kudos

No Rudhra..,

after performing the insert process its moved to disconnect  'dbcon'.