Skip to Content
0
Former Member
Dec 19, 2006 at 01:53 PM

To increase performance of report

10 Views

Hi Experts,

Can anyone help me to to increase performance by changing the Select stmnts?

Bit of code is attached here.

Really appreciate your response.

  • lookup vendor from bseg

LOOKUP_BUKRS LIKE BSIS-BUKRS,

LOOKUP_BELNR LIKE BSIS-BELNR,

LOOKUP_GJAHR LIKE BSIS-GJAHR,

LOOKUP_BUZEI LIKE BSIS-BUZEI,

PARAMETERS: SEL_DATE LIKE BSIS-BUDAT OBLIGATORY DEFAULT SY-DATUM.

SELECT-OPTIONS: SEL_COMP FOR BSIS-BUKRS OBLIGATORY DEFAULT 'SD01'.

SELECT-OPTIONS: SEL_VEND FOR BSEG-LIFNR.

SELECT-OPTIONS: SEL_COST FOR BSIS-PRCTR.

SELECT-OPTIONS: SEL_ACCT FOR BSIS-HKONT OBLIGATORY DEFAULT '0000210301'.

SELECT * FROM BSIS WHERE BUKRS IN SEL_COMP AND

KOSTL IN SEL_COST AND

HKONT IN SEL_ACCT AND

BUDAT <= SEL_DATE.

PERFORM PROCESS_1_BSIS_RECORD.

ENDSELECT.

*

SELECT * FROM BSIK WHERE BUKRS IN SEL_COMP AND

KOSTL IN SEL_COST AND

HKONT IN SEL_ACCT AND

BUDAT <= SEL_DATE.

*

SELECT SINGLE * FROM BSIS WHERE

BUKRS = BSIK-BUKRS AND

HKONT = BSIK-HKONT AND

AUGDT = BSIK-AUGDT AND

AUGBL = BSIK-AUGBL AND

GJAHR = BSIK-GJAHR AND

BELNR = BSIK-BELNR AND

BUZEI = BSIK-BUZEI.

CHECK SY-SUBRC NE 0.

MOVE-CORRESPONDING BSIK TO BSIS.

PERFORM PROCESS_1_BSIS_RECORD.

ENDSELECT.

*

CHECK SEL_DATE < SY-DATUM.

SELECT * FROM BSAS WHERE BUKRS IN SEL_COMP AND

KOSTL IN SEL_COST AND

HKONT IN SEL_ACCT AND

BUDAT <= SEL_DATE AND

AUGDT > SEL_DATE.

PERFORM PROCESS_1_BSAS_RECORD.

ENDSELECT.

*

SELECT * FROM BSAK WHERE BUKRS IN SEL_COMP AND

KOSTL IN SEL_COST AND

HKONT IN SEL_ACCT AND

BUDAT <= SEL_DATE AND

AUGDT > SEL_DATE.

*

SELECT SINGLE * FROM BSAS WHERE

BUKRS = BSAK-BUKRS AND

HKONT = BSAK-HKONT AND

AUGDT = BSAK-AUGDT AND

AUGBL = BSAK-AUGBL AND

GJAHR = BSAK-GJAHR AND

BELNR = BSAK-BELNR AND

BUZEI = BSAK-BUZEI.

CHECK SY-SUBRC NE 0.

MOVE-CORRESPONDING BSAK TO BSAS.

PERFORM PROCESS_1_BSAS_RECORD.

ENDSELECT.

*

ENDFORM. " load_all_gr_aging

----


  • Form process_1_bsis_record.

----


FORM PROCESS_1_BSIS_RECORD.

*

  • if debit, change sign.

IF BSIS-SHKZG = 'H'. "H-credit, S=debit.

MULTIPLY BSIS-WRBTR BY -1.

ENDIF.

  • calculate aging and move to both tables.

PERFORM CALC_BSIS_AGING.

  • If aging cutoff selected...

IF PRT_AGE = ' ' OR

( PRT_AGE = 'X' AND DAYS_AGED >= AGE_DAYS ).

  • get vendor from bseg

IF BSIK-LIFNR IS INITIAL.

MOVE BSIS-BUKRS TO LOOKUP_BUKRS.

MOVE BSIS-BELNR TO LOOKUP_BELNR.

MOVE BSIS-GJAHR TO LOOKUP_GJAHR.

MOVE BSIS-BUZEI TO LOOKUP_BUZEI.

PERFORM GET_VENDOR_FROM_BSEG.

ELSE.

BSEG-LIFNR = BSIK-LIFNR.

ENDIF.

  • if in vendor selection.

IF BSEG-LIFNR IN SEL_VEND.

  • add to detail table.

IF ( MATCH_GR = 'X' ).

PERFORM LOAD_GR_IR_ITABS_FROM_BSIS.

ELSE.

REC_CNT = REC_CNT + 1.

MOVE BSEG-LIFNR TO ITAB_GR_IR_DOC-LIFNR.

MOVE BSIS-KOSTL TO ITAB_GR_IR_DOC-COSTCENTER.

MOVE BSIS-BELNR TO ITAB_GR_IR_DOC-BELNR.

MOVE BSIS-BLART TO ITAB_GR_IR_DOC-BLART.

MOVE BSIS-BUDAT TO ITAB_GR_IR_DOC-BUDAT.

MOVE BSIS-XBLNR TO ITAB_GR_IR_DOC-XBLNR.

MOVE BSIS-ZUONR TO ITAB_GR_IR_DOC-ZUONR.

MOVE DAYS_AGED TO ITAB_GR_IR_DOC-DAYS_AGED.

APPEND ITAB_GR_IR_DOC.

ENDIF.

CLEAR ITAB_GR_IR_DOC.

ENDIF.

ENDIF.

*

ENDFORM. " process_1_bsis_record.

----


  • Form process_1_bsas_record.

----


FORM PROCESS_1_BSAS_RECORD.

  • if debit, change sign.

IF BSAS-SHKZG = 'H'. "H-credit, S=debit.

MULTIPLY BSAS-WRBTR BY -1.

ENDIF.

  • calculate aging and move to both tables.

PERFORM CALC_BSAS_AGING.

  • If aging cutoff selected...

IF PRT_AGE = ' ' OR

( PRT_AGE = 'X' AND DAYS_AGED >= AGE_DAYS ).

  • get vendor from bseg

IF BSAK-LIFNR IS INITIAL.

MOVE BSAS-BUKRS TO LOOKUP_BUKRS.

MOVE BSAS-BELNR TO LOOKUP_BELNR.

MOVE BSAS-GJAHR TO LOOKUP_GJAHR.

MOVE BSAS-BUZEI TO LOOKUP_BUZEI.

PERFORM GET_VENDOR_FROM_BSEG.

ELSE.

BSEG-LIFNR = BSAK-LIFNR.

ENDIF.

  • if in vendor selection.

IF BSEG-LIFNR IN SEL_VEND.

  • add to detail table.

IF ( MATCH_GR = 'X' ).

PERFORM LOAD_GR_IR_ITABS_FROM_BSAS.

ELSE.

REC_CNT = REC_CNT + 1.

MOVE BSEG-LIFNR TO ITAB_GR_IR_DOC-LIFNR.

MOVE BSAS-KOSTL TO ITAB_GR_IR_DOC-COSTCENTER.

MOVE BSAS-BELNR TO ITAB_GR_IR_DOC-BELNR.

MOVE BSAS-BLART TO ITAB_GR_IR_DOC-BLART.

MOVE BSAS-BUDAT TO ITAB_GR_IR_DOC-BUDAT.

MOVE BSAS-XBLNR TO ITAB_GR_IR_DOC-XBLNR.

MOVE BSAS-ZUONR TO ITAB_GR_IR_DOC-ZUONR.

MOVE DAYS_AGED TO ITAB_GR_IR_DOC-DAYS_AGED.

APPEND ITAB_GR_IR_DOC.

SORT ITAB_GR_IR_DOC BY LIFNR

COSTCENTER

BELNR

BLART

BUDAT

XBLNR

ZUONR

DAYS_AGED.

ENDIF. "match_gr='X'

CLEAR ITAB_GR_IR_DOC.

ENDIF. "bseg-lifnr in sel_vend

ENDIF. " if selected, days_aged >= age_days

ENDFORM. " process_1_bsas_record.

----


  • Form get_vendor_from_bseg

----


FORM GET_VENDOR_FROM_BSEG.

SELECT SINGLE * FROM BSEG

WHERE BUKRS = LOOKUP_BUKRS AND

BELNR = LOOKUP_BELNR AND

GJAHR = LOOKUP_GJAHR AND

BUZEI = LOOKUP_BUZEI.

IF BSEG-LIFNR = ' '.

SELECT * FROM BSEG

WHERE BUKRS = LOOKUP_BUKRS AND

BELNR = LOOKUP_BELNR AND

GJAHR = LOOKUP_GJAHR.

IF BSEG-LIFNR <> ' '.

EXIT.

ENDIF.

ENDSELECT. "bseg

ENDIF.

ENDFORM. " get_vendor_from_bseg

Thanks,

AKumar.