‎2010 Feb 05 8:45 PM
Hi,
I just want to execute the Select statement dynamically using open cursor statement and without Open cursor statment (Just Select statement).....
How can i do that in the program...
data s_cursor type cursor.
data:it_mara TYPE TABLE OF mara,
v_stmt type string.
* Case 1 - Open cursor
v_stmt = 'SELECT * FROM MARA.'.
OPEN CURSOR WITH HOLD s_cursor FOR
v_stmt . "How can i execute the Select statement here
DO.
FETCH NEXT CURSOR s_cursor APPENDING TABLE it_mara.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDDO.
* Case 2- No Open Cursor
v_stmt.
‎2010 Feb 05 9:22 PM
‎2010 Feb 05 9:27 PM
‎2010 Feb 05 9:32 PM
Check the ABAP documentation for SELECT and look at the columns and source areas. That shows you how to do exactly (I think) what you want. Get back to the forum if you have problems after reading that.
Rob
‎2010 Feb 05 11:14 PM
I used normal Select like the below. But i want to execute dynamic open SQL statments using Open Curosr, This is my requirement.
Like this OPEN CURSOR WITH HOLD s_cursor FOR (Open SQL statement).
data s_cursor type cursor.
data:it_mara TYPE TABLE OF mara.
v_stmt type string.
Case 1 - Open cursor
v_stmt = 'SELECT * FROM MARA.'.
OPEN CURSOR WITH HOLD s_cursor FOR
select * from mara.
DO.
FETCH NEXT CURSOR s_cursor APPENDING TABLE it_mara.
IF sy-subrc 0.
EXIT.
ENDIF.
ENDDO.
Case 2- No Open Cursor
select * from mara into table it_mara.
‎2010 Feb 06 12:12 AM
Hi fract_get,
I wonder why you want to use OPEN CURSOR at all because I can not imagine any requirement that makes it obligatory. You may correct me when I say that OPEN CURSOR and FETCH are from the very early times when the database interface could not really help you much.
Using an ECC600 system this is simply obsolete. There are better ways.
Please convince me there are good reasons to use OPEN CURSOR WITH HOLD. What are the 'dynamics'?
I'm always happy if I can learn something.
Regards,
Clemens
‎2010 Feb 07 4:34 PM
I am using OPEN CURSOR for downloading the table data in multiple files based on package size. I want to use Open sql statment as a input from file. Here is my requirement...How can i make it executable the Open SQL statements here OR Is there any other way.....
DATA: BEGIN OF IT_OPEN_SQL OCCURS 0,
QUERY TYPE STRING,
END OF IT_OPEN_SQL.
DATA: V_SIZE TYPE I.
LOOP AT IT_OPEN_SQL.
OPEN CURSOR WITH HOLD C_CURSOR FOR
(IT_OPEN_SQL-QUERY).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE V_SIZE.
IF SY-SUBRC NE 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
* Downloading into file.......
ENDDO.
ENDLOOP.
‎2010 Feb 07 8:09 PM