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: 

Select after fetch cursor in Do..Endo

ricky_shaw
Contributor
0 Kudos
388

Hi,

I am getting huge dataset into an internal table using open cursor & fetch cursor.

After this, I need to use for all entries in my select query.

Is it advisable to write my select query in this way after Fetch cursor?

OPEN DATASET g_file FOR OUTPUT IN TEXT MODE WITH WINDOWS LINEFEED ENCODING DEFAULT.
DO.
FETCH NEXT CURSOR dbc_dm INTO TABLE intab PACKAGE SIZE 5000.
IF sy-subrc <> 0.
EXIT.
ELSE.
* Get the active installation facts for p_from to p_to
select * from ettifn into TABLE @data(it_ettifn)
for all entries in intab[]
WHERE anlage intab-anlage
and ( OPERAND = 'FLAG1'
or OPERAND = 'FLG2')
and ab <= @sy-datum
and bis >= @sy-datum.
enddo.
CLOSE CURSOR dbc_dm.<br>CLOSE DATASET g_file.

6 REPLIES 6

matt
Active Contributor
0 Kudos
259

That seems to me to be exactly the right approach. What is your concern?

Except I'd use AND OPERAND IN ('FLAG1', 'FLAG2')

matt
Active Contributor
0 Kudos
259

It is entirely correct to use what you've done in a loop. That's the purpose of the cursor. You can't do it in a single select, so you break it up into packages and process in a loop.

Sandra_Rossi
Active Contributor
259

What is your concern?

If your question is about wrong data, only you can debug your program.

You'd better worry about code recommendation only after you have fixed the issue.

ricky_shaw
Contributor
0 Kudos
259

My concern is : i need to use Select Stmt for all entries based on intab[] which is obtained from above Fetch cursor stsmt. But the Fetch Cursor stsmt in enclosed between Do..endo loop.

matt
Active Contributor
259

Use Add a Comment - don't submit an answer.

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
259

ricky.shaw Exactly. -- This is not an "answer", so please convert it to a comment (probably in the comment section of Matthew's answer above).