2009 Mar 21 7:38 PM
Dear SAPians,
I am trying to find best way of fetching some perculiar entries from a DB table. The scenario is explianed below:
1. If the values/entries in column C1 equal to value 'b' for a given key number in column T1, then it should be selected. (Duplicate keys are possible. )
2. If there is anyother entry/value in column C1 along with value 'b' for a given key number (T1) it should be discarded.
3. There are millions of entries in DB table, hence we want to cursor logic which fetches only 1000 at a time.
4. For a given Key number (in T1) there could be entries more than 1000.
(example:
Consider the following TABLE entries With T1 and C1 as two coloumns/fields
T1 C1
-
-
9866 b
9866 b
9877 a
9877 b
9877 c
9899 a
9899 b
9900 b
The problem is to retrieve the numbers whose C1 values are only b.In the above example 9877 and 9899
should not be retrieved as they have a C1 value other than b.[this step is done]
The database may contain million records.Due to performance reasons we cannot take more than 1000 entries at a time from the database.Now consider the following case
Case:
T1 C1
-
-
9866 b
9866 b
9877 a------3
9877 c
9877 b-------5
9877 b
9877 b
9877 b
'
'
'
9877 b------1000
'
'
9877 b-------1500
In the above case consider the number 9877 for which more than 1000 entries exits and from 5 th entry to 1500 entry the c1 value is 'b', in this case for the first 1000 entries 9877 will not satisfy the given condition hence will be retrieved, but during the second run 9877 is retrieved which is incorrect.There may be thousands of entries for a single T1 number and more possible C1 values and th table is not sorted.
)
Dear SAPians,
I am trying to find best way of fetching some perculiar entries from a DB table. The scenario is explianed below:
1. If the values/entries in column C1 equal to value 'b' for a given key number in column T1, then it should be selected. (Duplicate keys are possible. )
2. If there is anyother entry/value in column C1 along with value 'b' for a given key number (T1) it should be discarded.
3. There are millions of entries in DB table, hence we want to cursor logic which fetches only 1000 at a time.
4. For a given Key number (in T1) there could be entries more than 1000.
(example:
Consider the following TABLE entries With T1 and C1 as two coloumns/fields
T1 C1
-
-
9866 b
9866 b
9877 a
9877 b
9877 c
9899 a
9899 b
9900 b
The problem is to retrieve the numbers whose C1 values are only b.In the above example 9877 and 9899
should not be retrieved as they have a C1 value other than b.[this step is done]
The database may contain million records.Due to performance reasons we cannot take more than 1000 entries at a time from the database.Now consider the following case
Case:
T1 C1
-
-
9866 b
9866 b
9877 a------3
9877 c
9877 b-------5
9877 b
9877 b
9877 b
'
'
'
9877 b------1000
'
'
9877 b-------1500
In the above case consider the number 9877 for which more than 1000 entries exits and from 5 th entry to 1500 entry the c1 value is 'b', in this case for the first 1000 entries 9877 will not satisfy the given condition hence will be retrieved, but during the second run 9877 is retrieved which is incorrect.There may be thousands of entries for a single T1 number and more possible C1 values and th table is not sorted.
)
2010 Mar 10 7:53 AM
Sorry to give you the reply so late, never the less what you want is to use the the
DATA: packsize TYPE i VALUE 1000.
SELECT (tab_fields) FROM glpca
PACKAGE SIZE packsize
APPENDING CORRESPONDING FIELDS OF TABLE i_glpca_i
WHERE rldnr IN rldnr
AND rrcty IN rrcty
AND rvers IN rvers
AND kokrs IN kokrs
AND rbukrs IN rbukrs
AND ryear IN ryear
AND racct IN racct
AND rprctr IN prctr
AND sprctr IN pprctr.
ENDSELECT.
As you might notice the logig to pick up records 1000 at a time the PACKAGE SIZE addition is used. Because this kind of selection loops it allows for you to get records in chunks of 1000 if there are less than 1000 they are also taken up, this allows for you to manage the allocation memory and exit the selection once you have taken your desired number of records!
Regards
Tatenda Chaibva
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |