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

database table access

Former Member
0 Likes
379

hi iam using a select command in which iam selecting from besg table . but the problem is that around 4000 record are getting selected so it takes a lot of time to execute as well as it is giving a time out error for another object that is also using the same exit. can u plss suggest me how to overcome this problem?

MY SAMPLE CODE:

SELECT hkont

FROM bseg

INTO

TABLE gi_cstctr

WHERE

kostl = bseg-kostl AND prctr = bseg-prctr.

IF sy-subrc EQ 0. "if rows are returned

SORT gi_cstctr BY hkont. "sorting the internal table.

ENDIF.

*if cost centers are there in the internal table then loop the internal table into corresponding work area and if the G/L account matches any costcenter in the table

CLEAR gw_cstctr.

IF NOT gi_cstctr[] IS INITIAL.

LOOP AT gi_cstctr INTO gw_cstctr.

IF gw_cstctr-hkont EQ lv_hkont.

lv_flag = gc_x. "set the flag to x

EXIT.

ENDIF.

CLEAR gw_cstctr.

ENDLOOP.

ENDIF.

IF lv_flag = space. "if the flag is not set

MESSAGE s031(yd01) WITH lv_hkont gw_cstctr-kostl . "display the message

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
358

hi,

try to hit the table BSEG by primary keys or else secondary indexes..

It will grow up ur rperformance

rewards if useful

regards,

nazeer

Read only

Former Member
0 Likes
358

YOur select query seems to be really bad as far as performance is concerned. Firs of all , until and unless required, you should never select data from a DB table without use of primary keys as selection criteria. Make sure your selection criteria is complete and as specific as possible...

You have written in where clause " kostl = bseg-kostl AND prctr = bseg-prctr.

"..what does this mean?? you are comparing 'kostl' value with bseg-kostl value? that doesnt make sense.check your selection criteria again.

Revert if you have any issues.

Pls pls mark helpful answers.

Cheers,

Karan