on 2006 Sep 29 9:12 PM
Hi,
I have this abap/exec sql code to extract data from as400/db2.
I am getting data by a "select" statement and i am trying to append the records with append statements.
but, not works.
EXEC SQL.
CONNECT TO 'SATDBR'
ENDEXEC.
EXEC SQL.
--->(HERE THE PROBLEM) OPEN C1 FOR.
SELECT A,B,C,D
FROM SAPTEST.XX1
ENDEXEC.
EXEC SQL.
OPEN C1
FETCH NEXT C1 INTO
:ZTABLE.AA, :ZTABLE.BB, :ZTABLE.CC, :ZTABLE.DD
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ELSE.
APPEND ZTABLE.
ENDIF.
ENDDO.
EXEC SQL.
CLOSE C1
ENDEXEC.
EXEC SQL.
DISCONNECT 'SATDBR'
ENDEXEC.
I need to declare the cursor??? whats wrong in my code :S
the runtime error is "A SQL mistake has appeared by the execution of Native SQL."
i would appreciate your help.
thanks
vicky
Hi,
i]
<b>--->(HERE THE PROBLEM) OPEN C1 FOR.</b> </i>
Do you have period " ." after FOR , you are better off if you remove the period..as it thinks it is end of statement and is not able to compile properly..
Regards
Manga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
I recommend you, make the select and test it first in the DB2 console.
Only delcare your internal tables, your variable with abap code.
To extract the data with the select statement is enough, to fill the table with several records use this code:
EXEC SQL.
CONNECT TO 'DB2' " the name of the connection
ENDEXEC.
EXEC SQL.
OPEN C1 FOR
SELECT A,B,C,D
FROM SAPTEST.XX1
ENDEXEC.
DO
EXEC SQL.
OPEN C1
FETCH NEXT C1 INTO
:ZTABLE
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ELSE.
APPEND ZTABLE.
ENDIF.
ENDDO.
EXEC SQL.
CLOSE C1
ENDEXEC.
EXEC SQL.
DISCONNECT 'DB2'
ENDEXEC.
The ZTABLE must have the same order in which you put on the fields in the "select"
DATA: BEGIN OF ztable OCCURS 0,
A(1) TYPE c
B(8) TYPE c
C(17)TYPE N
D(19 TYPE c
DATA: END OF ZTABLE.
I HOPE THIS INFORMATION HELPS YOU!!
REGARDS
VICKY
Message was edited by: Victoria León
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.