2023 Jun 05 8:37 PM
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.
2023 Jun 06 7:20 AM
That seems to me to be exactly the right approach. What is your concern?
Except I'd use AND OPERAND IN ('FLAG1', 'FLAG2')
2023 Jun 06 2:42 PM
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.
2023 Jun 06 7:55 AM
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.2023 Jun 06 2:24 PM
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.
2023 Jun 06 2:30 PM
Use Add a Comment - don't submit an answer.
2023 Jun 14 10:02 PM
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).