Application Development 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: 

Run time error in select from bkpf

0 Kudos

Hi

i create a report that i have to select  BUDAT MONAT FROM table BKPF   with where condition. but run time error occured in this line.i create a view whit 4 required fields but selection from that view raise runtime error also. how i can change my program to fix thise runtime error ?


Regards.

Mahtab

8 REPLIES 8

nishantbansal91
Active Contributor
0 Kudos

Hi,

Can you please paste your select query,

Please check the sequence of the field you have written and match the sequence with VIEW field.

Thanks

Nishant

raymond_giuseppi
Active Contributor
0 Kudos

Execute a SQL trace and then analyze the access plan (some full scan table ?) or post more information (the where criteria) to get more help.

Regards,

Raymond

0 Kudos

Hi

"DATA is an internal table from Bseg with more than 90000 record

LOOP AT DATA INTO WA.

PERFORM GET_PERIOD USING WA-BELNR CHANGING XPERIOD.

FORM GET_PERIOD USING XBELNR CHANGING XPERIOD.

  CLEAR XPERIOD.

  SELECT  single MONAT FROM BKPF INTO XPERIOD WHERE BELNR = XBELNR and gjahr       eq xyear.

ENDFORM.

Regards

Mahtab

0 Kudos

Hi,

Please use the for all entries instead of using the select in loop statement.

Please mention the type of the XPERIOD in changing parameters.

CHANGING XPERIOD

Thanks

Nishant

0 Kudos

Check declaration of XPERIOD. It should in sync with selection fields for Select Single.

0 Kudos
  • SINGLE SELECT in a LOOP has never given good result if table is not buffered
  • You also forget the BUKRS first primary key of BKPF (after client)

So you may be executing 90K full scan of table ?

Are you able to read BKPF information in previous SELECT of data using some JOIN, else can you use some FOR ALL ENTRIES OF or subquery to read BKPF using BUKRS, BELNR and GJAHR in a sorted type table and then update the internal table with some // LOOP or optimized READ TABLE ?

Regards,

Raymond

Former Member
0 Kudos

Hi Mahtab,

1. As per the best practice we should not write a Select Statement in a  LOOP to improve Performance.

2.As we our aware that BKPF is the Header Table and BSEG is the Item Table for Accounting Documents.

a} Fetch all the BELNR's from BKPF for all entries in the BSEG validating with  BELNR,BUKRS,GJAHR.

b) Sort the BKPF with BUKRS BELNR GJAHR.

Now by Looping BSEG values , read the table BKPF and do the validation which you need to process.

Thanks & Regards,

S.Rajendranath

former_member458055
Participant
0 Kudos

Hi Mahtab,

You might have got the solution as I think almost all the above replies are perfect. But if not, i would suggest you an addition field in where clause as BUKRS and instaid of select single try using select up to 1 rows.


Regards -

MT