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

Data selection using select

Former Member
0 Likes
500

I am selecting data from COEP(CO Object: Line Items (by Period)) table, which has huge data.

The selection is done using OBJNR field, which is part of secondary index.

...

SELECT

objnr

kstar "Cost Element

rbest "Reference Document Number

....

....

INTO CORRESPONDING FIELDS OF TABLE i_covp

FROM covp

FOR ALL ENTRIES IN i_kstar

WHERE lednr EQ c_ledger

AND objnr IN r_objnr

.....

.....

Now this since r_objnr can be represented by Cost Center/Internal Orders or WBS. This can be very large.

If I try to run the program using this in foreground or background. It dumps, because the select statement is not able to cope up with this range r_objnr....

There are 2 options to solve this problem:

1. Convert r_objnr into an internal table and use "for all entries"

2. There is another option I have seen in one of standard SAP program, where the r_objnr is split into several chunks and select is called repeatedly..

PERFORM prepare_sel TABLES r_objnr

r_sel_objnr

USING l_index

CHANGING l_subrc.

WHILE l_subrc EQ 0.

SELECT

objnr

kstar "Cost Element

rbest "Reference Document Number

....

....

INTO CORRESPONDING FIELDS OF TABLE i_covp PACKAGE SIZE 1000

FROM covp

FOR ALL ENTRIES IN i_kstar

WHERE lednr EQ c_ledger

AND objnr IN r_objnr

.....

.....

ADD 1 TO l_record_counter.

IF sy-batch IS INITIAL AND

sy-binpt IS INITIAL.

PERFORM flash_records_read(sapfgrws)

USING l_record_counter.

ENDIF.

endselect.

ADD 1 TO l_index.

PERFORM prepare_sel TABLES r_objnr

r_sel_objnr

USING l_index

CHANGING l_subrc.

ENDWHILE.

    • Where subroutine prepare_Sel basically picks one record from r_objnr and populates r_sel_objnr.

I wanted to know which of these method is better??

Regards

2 REPLIES 2
Read only

Former Member
0 Likes
446

Hi Samir,

IF I were you, I would have used the second approach, i.e., splitting the data into chunks and executing the selects multipletimes.

Regards,

Anand Mandalika.

Read only

0 Likes
446

Thanks,