2012 Mar 22 10:17 AM
Hi experts,
I would like to ask you for select optimization:
SELECT mandt kokrs objnr belnr buzei gjahr wrttp beknz wkgbtr ebeln ebelp timestmp
FROM coep CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE lt_covp
FOR ALL ENTRIES IN p_gt_outtab
WHERE mandt EQ sy-mandt
AND kokrs EQ g_kokrs
AND objnr EQ p_gt_outtab-objnr
AND ( wrttp EQ '04' OR wrttp EQ '12')
AND beknz NE 'A'
AND gjahr LE p_gjahr.
Generally there can be a lot of data in p_gt_outtab and it results in TSV_TNEW_PAGE_ALLOC_FAILED error. The selection time is very long too. I 'm using MANDT KOKRS OBJNR index. Thank you in advance.
Best regards
Paul Smuda
2012 Mar 22 10:43 AM
Pawel,
Technical Setting of the table shows Size Category as
| 4 | Data records expected: 31,000 to 120,000 |
so it is assumed to have maximum .12 million records.
The key u have used seems fine. Try to have maximum fields on selection that can reduce the selection.
try following as well.
1. remove CORRESPONDING FIELDS by matching the selection field and internal table structure
2. Sort table p_gt_outtab in the sequence of where clause and use delete ADJACENT DUPLICATES using the same key
3. check the empty table p_gt_outtab. if it is empty, will return the entire data from coep.
4. if still you get the error you can distribute data in multiple internal table using select * UP TO 1000 rows into table lt_covp.
Hope this would help.
2012 Mar 22 10:25 AM
2012 Mar 22 10:43 AM
Pawel,
Technical Setting of the table shows Size Category as
| 4 | Data records expected: 31,000 to 120,000 |
so it is assumed to have maximum .12 million records.
The key u have used seems fine. Try to have maximum fields on selection that can reduce the selection.
try following as well.
1. remove CORRESPONDING FIELDS by matching the selection field and internal table structure
2. Sort table p_gt_outtab in the sequence of where clause and use delete ADJACENT DUPLICATES using the same key
3. check the empty table p_gt_outtab. if it is empty, will return the entire data from coep.
4. if still you get the error you can distribute data in multiple internal table using select * UP TO 1000 rows into table lt_covp.
Hope this would help.
2012 Mar 22 10:50 AM
Hi Pawel,
to work around the alloc. failed issue. Use the PACKAGE SIZE addition to the SELECT statment.
SELECT mandt kokrs objnr belnr buzei gjahr wrttp beknz wkgbtr ebeln ebelp timestmp
FROM coep
CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE lt_covp
FOR ALL ENTRIES IN p_gt_outtab
PACKAGE SIZE 10000
WHERE mandt EQ sy-mandt
AND kokrs EQ g_kokrs
AND objnr EQ p_gt_outtab-objnr
AND ( wrttp EQ '04' OR wrttp EQ '12')
AND beknz NE 'A'
AND gjahr LE p_gjahr.
* process your data here.
ENDSELECT.
Also do you really need the CLIENT SPECIFIED OPTION. If you only want data from the current client then drop that option the ABAP kernel will take of it for you.
Cheers
Adi
2012 Mar 22 12:03 PM
2012 Mar 22 1:52 PM
Hi Adi,
this solution (Package size) will not work here.
Kind regards,
Hermann
p.s.: saw Raymonds answer to late...
2012 Mar 22 7:18 PM
2012 Mar 22 10:58 AM
First remove the mandt field and client specified. (not required)
The problem may come from the FOR ALL ENTRIES which is definitively not an accelerator (interpreted as a long list of FETCH for some values) also the data will be stored by the system before deletion of duplicate records (Note 634263 - Selects with FOR ALL ENTRIES)
You could try some parallelization, create a RFC enabled FM which will receive a subset of the p_gt_outtab and be executed STARTING NEW TASK and PERFORMING subroutine or CALLING method at END. IN this FM, if you create not-too large subset, you could replace the FOR ALL ENTRIES by a WHERE IN clause in the called FM. > Best performance and less memory consumption, but more programming...
Regards,
Raymond
2012 Mar 25 10:54 AM
Several points
Cheersy Cheers
Paul
2012 Mar 26 3:53 PM
There are two problems here - the memory allocation and the long run time.
The long run time can be solved quite easily by adding LEDNR to the WHERE. If you check the domain, you'll see that the only possible value is '00'.
No need to create an index on OBJNR.
Rob