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: 

BSID and BSAD tables.

Former Member
0 Kudos

Hi Gurus,

Please solve this.

i want to fetch the lastest date for which amount credited by customer for the documnet types zl and dz.

I written code for the same.

but it takes 10 minutes time to run so how can i reduce this to execute within 1 minute can anyone please tell me.

please verify my code and give me solution.

&----


*& Form GET_CASHA

&----


  • for the fields Last Payment Date (BUDAT) and amount (WRBATR).

----


FORM GET_CASHA.

SORT TAB BY KUNNR.

DELETE ADJACENT DUPLICATES FROM TAB.

R_BLART-SIGN = 'I'.

R_BLART-OPTION = 'EQ'.

R_BLART-LOW = 'ZL'.

APPEND R_BLART.

R_BLART-SIGN = 'I'.

R_BLART-OPTION = 'EQ'.

R_BLART-LOW = 'DZ'.

APPEND R_BLART.

CLEAR R_BLART.

R_SHKZG-SIGN = 'I'.

R_SHKZG-OPTION = 'EQ'.

R_SHKZG-LOW = 'H'.

APPEND R_SHKZG.

CLEAR R_SHKZG.

IF NOT TAB[] IS INITIAL.

SELECT BUKRS

KUNNR

GJAHR

BELNR

BUDAT

BLART

WRBTR

FROM BSID

INTO TABLE it_BSIAD

FOR ALL ENTRIES IN TAB

WHERE KUNNR = TAB-KUNNR

AND BLART IN R_BLART

AND SHKZG IN R_SHKZG.

SELECT BUKRS

KUNNR

GJAHR

BELNR

BUDAT

BLART

WRBTR

FROM BSAD

APPENDING TABLE it_BSIAD

FOR ALL ENTRIES IN TAB

WHERE KUNNR = TAB-KUNNR

AND BLART IN R_BLART

AND SHKZG IN R_SHKZG.

ENDIF.

SORT it_BSIAD BY KUNNR BELNR ASCENDING GJAHR BUDAT DESCENDING.

LOOP AT it_BSIAD INTO WA_BSIAD.

MOVE WA_BSIAD-BUKRS TO WA_AMT-BUKRS.

MOVE WA_BSIAD-KUNNR TO WA_AMT-KUNNR.

MOVE WA_BSIAD-BUDAT TO WA_AMT-BUDAT.

MOVE WA_BSIAD-WRBTR TO WA_AMT-WRBTR.

COLLECT WA_AMT INTO it_AMT.

CLEAR WA_BSIAD.

CLEAR WA_AMT.

ENDLOOP.

SORT it_AMT BY KUNNR ASCENDING BUDAT DESCENDING.

ENDFORM. "GET_CASHA

Thanks/Radhakrishna.

4 REPLIES 4

Former Member
0 Kudos

Radhakrishna

What is the count for Customer Table ?? If it is less than 3000 records then remove for all entries and use IN by putting all customers in the Range Table.

Thanks

Amol Lohade

0 Kudos

Great, and once the customer count exceeds 3000, the program bombs out, or what?

As for the actual problem of the original poster, include BUKRS in the selects on BSID and BSAD to speed things up.

Thomas

0 Kudos

Hi Thomas,

In this program we don't have company code as selection screen parameter.

it is not given any dump but it takes 10 minutes of time to execute.

my problem is how to reduce time to execute it in less than 10 minutes of time.

please give me solution.

Thanks/Radhakrishna.

0 Kudos

I strongly suggest you include BUKRS as selection parameter, since the data you are evaluating here is separated by company codes.

If there is only one company code in your landscape, then at least add BUKRS = <value> to WHERE-conditions, altough hard coding literals is extremely bad programming style.

If you don't add BUKRS to the selection you will not be able to select the data any quicker

Thomas