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

SQL: Package selection with entry-point/up to rows

Weiskopf
Participant
0 Likes
604

Hello together,

I would like to ask for a "mathematical" question concerning select clause with entry-point to build package wise selection.

If I have one key, I just can set the where-clause by keyfield > keyfield as next entry point, e.g.:

select * from mara into table lt_mara

up to 1000 rows

where matnr > lv_last_matnr.

lv_last_matnr = {last selected row].

But if I have more keys, so I need all relevant components in the where-clause.

(There is a requirement with more than 10 key elements)

Is there a general rule, where can be used to formulate the corresponding where-clause?

Thanks & best regards,

Kurt.

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
564

Did you look into using the PACKAGE SIZE option of the SELECT statement? This does automatically on database level what you're trying to simulate here on the application server.

Thomas

3 REPLIES 3
Read only

ThomasZloch
Active Contributor
0 Likes
565

Did you look into using the PACKAGE SIZE option of the SELECT statement? This does automatically on database level what you're trying to simulate here on the application server.

Thomas

Read only

0 Likes
564

Hello Thomas,

thank you for your answer.

Unfortunately, I cannot use this type of selection, because I'll have commit process that will close the prior opened cursor (equals select ... endselect).

I'm looking for a general rule cause the program will be very generic; any table will be selected with different keys.

Thanks & best regards,

Kurt.

Read only

0 Likes
564

I see, but I think it would be quite difficult to come up with a generic solution.

Regarding the commit work, there is a workaround using OPEN CURSOR ... WITH HOLD that still allows you to use PACKAGE SIZE:

OPEN CURSOR WITH HOLD ... FOR SELECT ...
DO.
  FETCH NEXT CURSOR ... PACKAGE SIZE ...
  IF SY-SUBRC <> 0.
    EXIT.
  ENDIF.
* do something that requires a periodic DB commit
  CALL FUNCTION 'DB_COMMIT'.
ENDDO.
CLOSE CURSOR ...

Thomas