Skip to Content
0
Jul 31, 2007 at 12:48 AM

BSAK link to BSIS and BSAS...

597 Views

Hello Experts,

I am doing 2 FOR ALL ENTRIES to get records from BSIS and BSAS based on the records

that I got in BSAK. Currently, I only know of 3 fields to link which is BUKRS, BELNR, AND GJAHR

but I is still any more fields that I can link to BSAK from BSIS and BSAS? Because we are

experiencing performance issues in my program. I am using index for the 3 tables but still it gives us

performance issues. Below is my code:

*   Get previous year
    lv_year = p_gjahr - 1.

*   Get records from PAYR
    SELECT zbukr vblnr gjahr lifnr zaldt
      FROM payr
      INTO TABLE gt_payr
     WHERE zbukr = p_bukrs
       AND gjahr IN (lv_year, p_gjahr).

    DELETE gt_payr WHERE zaldt+4(2) > p_monat.
    SORT gt_payr BY zbukr vblnr gjahr lifnr zaldt.
    DELETE ADJACENT DUPLICATES FROM gt_payr COMPARING zbukr vblnr gjahr lifnr zaldt.

    IF NOT gt_payr[] IS INITIAL.
*     Get records from BSAK
      SELECT bukrs blart gjahr monat belnr lifnr dmbtr shkzg
        FROM bsak
        INTO TABLE gt_bsak
         FOR ALL ENTRIES IN gt_payr
        WHERE lifnr = gt_payr-lifnr
          AND bukrs = gt_payr-zbukr
          AND augdt = gt_payr-zaldt
          AND augbl = gt_payr-vblnr
          AND gjahr = gt_payr-gjahr.
    ENDIF.

    DELETE gt_bsak WHERE monat > p_monat.
    DELETE gt_bsak WHERE shkzg <> 'H'.
    gt_payments[] = gt_bsak[].

    IF NOT gt_payments[] IS INITIAL.
*   Get records from BSIS(Open items)
    SELECT bukrs blart gjahr monat dmbtr hkont
      FROM bsis
      INTO TABLE gt_bsis
       FOR ALL ENTRIES IN gt_payments
     WHERE bukrs = gt_payments-bukrs
       AND belnr = gt_payments-belnr
       AND gjahr = gt_payments-gjahr
       AND blart IN (lc_su, lc_px).

*   Get records from BSAS(Cleared items)
    SELECT bukrs blart gjahr monat dmbtr hkont
      FROM bsas
      INTO TABLE gt_bsas
       FOR ALL ENTRIES IN gt_payments
     WHERE bukrs = gt_payments-bukrs
       AND belnr = gt_payments-belnr
       AND gjahr = gt_payments-gjahr
       AND blart IN (lc_su, lc_px).
    ENDIF.


Hope you can help me guys. Thank you and take care!