Application Development and Automation 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: 
Read only

ABAP connect SQL run SQL insert into Error

Former Member
0 Likes
927

Dear All

I have a problem in ABAP connect SQL,Below is my code snippet sentence.

CONCATENATE 'Insert Into [timportcortrol]'

'(zucode,zstate,zdate,zkind) Values('''

VG_PCID ''','''

'1'','''

SY-DATUM ''','''

'1' ''')'

INTO SQL.

CALL METHOD OF REC 'Execute'

EXPORTING #1 = SQL

#2 = CON

#3 = '1'.

IF NOT SY-SUBRC = 0.

MESSAGE I000 WITH 'Download to [timportcortrol] failure,Please Check the SQL Connect!!! '.

EXIT.

ENDIF.

*******************************************************************

"Con:is the connect SQL String ,the connect SQL is Okay.

I debug this code,when I used u2018Select u2026sentenceu2019,the program can work.if I use u2018insert intou2019 then canu2019t work,but I copied the SQL of the u2018inset Into sentenceu2026u2019run it into SQL server then it can work also.

And I found the SY-SUBRC eq u20182u2019.whatu2019s mean about of the sy-subrc eq u20182u2019.

I think the insert into sentence in abap I have write the wrong ,but I canu2019t assurance.

The Insert Into Sentence is:u2019 Insert Into [timportcortrol](zucode,zstate,zdate,zkind) Values('20080807094713','1','20080807','1')u2019

Could you give me some advice for this issue?

Thanks of all

Sun.

4 REPLIES 4
Read only

former_member787646
Contributor
0 Likes
851

Hi

I think the problem is with the date format "20080807094713". You should know first how the date is stored in the underlying database. In that format we have to pass the date in the SQL DML statements.

Try "07-Aug-2008' for example and check.

Hope it helps.

Murthy

Read only

0 Likes
851

hi,Murthy

Thanks for your help.

But the field in SQL database is not date format ,is char.so i think is not the format wrong.

Thanks

Sun

Read only

Former Member
0 Likes
851

Thanks a lot

Read only

0 Likes
851

Hi can you just help out for the procedure to connect SAP TO SQL SERVER is there any Bapi for the same .

Regards

Shankar