Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BSID and BSAD tables.

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.

Tags:
Not what you were looking for? View more on this topic or Ask a question