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

linking VBAP and PRPS..

former_member192432
Participant
0 Likes
3,272

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,149

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

10 REPLIES 10
Read only

Former Member
0 Likes
2,149

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"

Read only

0 Likes
2,149

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

Read only

Former Member
0 Likes
2,149

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.

Read only

Former Member
0 Likes
2,150

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

Read only

0 Likes
2,149

Hi Vinod ,

I am not using VBAK table before VBAP select statement.

Regards

Chetan

Read only

0 Likes
2,149

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

Read only

Former Member
0 Likes
2,149

First Check if GT_VBAP1 is not initial.

Secondly for using primary index your query should contain the key fields of VBAP

Read only

Former Member
0 Likes
2,149

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.

Read only

Former Member
0 Likes
2,149

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.

Read only

former_member192432
Participant
0 Likes
2,149

This message was moderated.