‎2010 May 07 9:01 AM
Hi friends ,
I am doing performance tuning for one report in that select stmt is written as below which is taking more time , i want change it so that it should use primary index ,. Is there any way to tune below statement
SELECT VBELN PS_PSP_PNR FROM VBAP INTO TABLE GT_VBAP1
FOR ALL ENTRIES IN GT_PRPS1
WHERE PS_PSP_PNR = GT_PRPS1-PSPNR.
Regards
Chetan
‎2010 May 07 9:12 AM
Hi,
Hope your first selection is on VBAK Table. Select the data from VBAP for all entries in VBAK
Try Below coding
Select <fields> from VBAP
into table GT_VBAP1
for all entries in IT_VBAK
where vbeln = it_vbak-vbeln.
data : l_tabix type sy-tabix.
loop at gt_vbap1 into wa_vbap1.
move sy-tabix to l_tabix.
read table gt_prps1 into wa_prps1 with key pspnr = wa_vbap1-ps_psp_pnr.
if sy-subrc ne 0.
delete gt_vbap1 index l_tabix.
endif.
endloop.Regards
Vinod
‎2010 May 07 9:09 AM
Hi,
IF not GT_PRPS1[] is initial. ---> Add condition
SELECT VBELN PS_PSP_PNR FROM VBAP INTO TABLE GT_VBAP1
FOR ALL ENTRIES IN GT_PRPS1
WHERE PS_PSP_PNR = GT_PRPS1-PSPNR.
endif.
your only passing item number in where conditon if possible can you please let me know what are the fiels in internal table "GT_PRPS"
‎2010 May 07 9:49 AM
Hi Sudheer ,
GT_PRPS1 contains below fields..
SELECT PSPNR PSPHI STUFE OBJNR
FROM PRPS INTO TABLE GT_PRPS1
FOR ALL ENTRIES IN GT_PROJ
WHERE PSPHI = GT_PROJ-PSPNR.
Regards
Chetan
Edited by: chetan teli on May 7, 2010 10:50 AM
‎2010 May 07 9:09 AM
Primary index: then you need the full key of VBAP in the WHERE clause. Unless you make sure the VBAP key is included in GT_PRPS1 there's no way to get it to use the primary index.
‎2010 May 07 9:12 AM
Hi,
Hope your first selection is on VBAK Table. Select the data from VBAP for all entries in VBAK
Try Below coding
Select <fields> from VBAP
into table GT_VBAP1
for all entries in IT_VBAK
where vbeln = it_vbak-vbeln.
data : l_tabix type sy-tabix.
loop at gt_vbap1 into wa_vbap1.
move sy-tabix to l_tabix.
read table gt_prps1 into wa_prps1 with key pspnr = wa_vbap1-ps_psp_pnr.
if sy-subrc ne 0.
delete gt_vbap1 index l_tabix.
endif.
endloop.Regards
Vinod
‎2010 May 07 9:52 AM
Hi Vinod ,
I am not using VBAK table before VBAP select statement.
Regards
Chetan
‎2010 May 07 10:02 AM
Hi,
If you want to use the Primary key for VBAP, then the flow of data selection should come from VBAK to VBAP. If you are not using VBAK, then performance improvement on VBAP with reference to the field PS_PSP_PNR can be done by creating a seconday index on this field.
Regards
Vinod
‎2010 May 07 9:14 AM
First Check if GT_VBAP1 is not initial.
Secondly for using primary index your query should contain the key fields of VBAP
‎2010 May 07 9:14 AM
Try with below code
GT_PRPS1_tmp[] = GT_PRPS1[].
sort GT_PRPS1_tmp by PSPNR.
delete adjacent duplicates from GT_PRPS1_tmp comparing PSPNR.
SELECT VBELN PS_PSP_PNR FROM VBAP INTO TABLE GT_VBAP1
FOR ALL ENTRIES IN GT_PRPS1_tmp
WHERE PS_PSP_PNR = GT_PRPS1_tmp-PSPNR.
‎2010 May 07 9:19 AM
GT_PRPS1_tmp] = GT_PRPS1[.
sort GT_PRPS1_tmp by PSPNR.
delete adjacent duplicates from GT_PRPS1_tmp comparing PSPNR.
delete GT_PRPS1_tmp where PSPNR EQ 0.
IF not GT_PRPS1_tmp[] is initial.
SELECT VBELN PS_PSP_PNR FROM VBAP INTO TABLE GT_VBAP1
FOR ALL ENTRIES IN GT_PRPS1_tmp
WHERE PS_PSP_PNR = GT_PRPS1_tmp-PSPNR.
endif.
‎2010 Sep 23 2:07 PM