Skip to Content
Technical Articles

FBL5N Enhancement Document Date Functionality

Standard  FBL5N fetches the customer line item display based on posting date. When there is a requirement to fetch customer line items based on document date, a custom enhancement needs to be developed.

To make them work according to document date (To fetch records based on BLDAT-Document date) enhancement needs to be developed in the logical database.The logical database holds all the structures. Here we cannot enhance the structures and nodes directly. Only the source code program of the database can only be enhanced.

By using submit functionality (passing vendor,open items date) in  custom z reports ,records based on the posting date will only be fetched. But in order to fetch open items based on document date(BLDAT), enhancement needs to be done. The standard transaction code FBL5N cannot be enhanced to accomodate this functionality. The standard FBL5N fetches the customer line item display based on posting date(key date).

The enhancement has to be done in the logical database.

Go to SE36. For FBL5N(Customer) DDF is the logical database. Go to source code/Database program.

Enhancement spots will be available. Create enhancement implementations. The databases should be enhanced(XBSID , XBSAD). These two structures need to be enhanced to accommodate this functionality as XBSID and XBSAD holds the document date.

Enhancement needs to be applied at 2 areas.

1.Put the below enhancement LOGIC in PERFORM update_xbsid_hdb. (towards the end) Endform.

Find the detailed code snippet .

data: lv_cus type char1.
IMPORT lv_cus to lv_cus from MEMORY ID 'ABC'.
if sy-tcode = 'ZFI_CUSTOMER_AGEING' .
*  or sy-tcode = 'ZFI_CPA' OR
*  ( sy-tcode = 'ZFI_ACCR_AGE' AND LV_CUS IS NOT INITIAL ).
* Variante 1: Offene Posten zu einem bestimmten Stichtag
  if DD_OPOPT = 'X' and DD_APOPT ne 'X'.
    refresh xbsid.
    select (BSID_FIELDS) from BSID
                       into corresponding fields of table XBSID
                       for all entries in K_KUNNR
                       where KUNNR eq K_KUNNR-LOW
                         and BUKRS in DD_BUKRS
*                        AND GJAHR IN DD_GJAHR
*                        AND GJAHR BETWEEN '0001' AND '9999'
                         and BlDAT in DD_BUDAT
                         and BLDAT le DD_STIDA
                         and ZUONR in DD_ZUONR
                         and SHKZG in DD_SHKZG
                         and UMSKZ in DD_UMSKZ
                         and BSCHL in DD_BSCHL
                         and (BSID_WHERE).
  endif.                                                    "Variante 1
* Variante 2: Ausgegl. Posten in einem Datumsintervall
  "- Es erfolgt kein Zugriff auf BSID

* Variante 3: Variante 1 + 2 gleichzeitig
  if DD_OPOPT eq 'X' and DD_APOPT eq 'X'.
*   SELECT * FROM BSID WHERE KUNNR >  KUNNR-BSID
    select (BSID_FIELDS) from BSID
                       into corresponding fields of table XBSID
                       for all entries in K_KUNNR
                       where KUNNR eq K_KUNNR-LOW
                         and BUKRS in DD_BUKRS
*                        AND GJAHR IN DD_GJAHR
*                        AND GJAHR BETWEEN '0001' AND '9999'
                         and BUDAT in DD_BUDAT
                         and BUDAT le DD_STIDA
                         and ZUONR in DD_ZUONR
                         and SHKZG in DD_SHKZG
                         and UMSKZ in DD_UMSKZ
                         and BSCHL in DD_BSCHL
                         and (BSID_WHERE).
  endif.                                                    "Variante 3

* Variante 4 (aus RFITEMAR): AP mit Stichtag und Ausgleichszeitraum
  "- Kein Zugriff auf BSID!

* check projk and imkey range
  if PROJK_ELIMINATED eq 'X' or IMKEY_ELIMINATED eq 'X'.
    loop at XBSID.
      if PROJK_ELIMINATED eq 'X'.
        perform CHECK_INT_EXT(FI_LDB_UTIL) tables PROJK_TAB
                                            using XBSID-PROJK
                                                  'KONPR'
                                         changing CHECK_OK.
        if CHECK_OK = 'N'.
          delete XBSID.
          continue.
        endif.
      endif.

      if IMKEY_ELIMINATED eq 'X'.
        perform CHECK_INT_EXT(FI_LDB_UTIL) tables IMKEY_TAB
                                            using XBSID-IMKEY
                                                  'IMKEY'
                                         changing CHECK_OK.
        if CHECK_OK = 'N'.
          delete XBSID.
        endif.
      endif.

    endloop.
  endif.

  sort XBSID by MANDT KUNNR BUKRS.
  CURSOR-BSID = 1.
ENDIF.

2. Enhance in PERFORM update_xbsad. 

Find the code for enhancement.

DATA: LV_CUS1 TYPE CHAR1.
IMPORT LV_CUS TO LV_CUS1 FROM MEMORY ID 'ABC'.
IF SY-TCODE = 'ZFI_CUSTOMER_AGEING' .

* Variante 1: Offene Posten zu einem bestimmten Stichtag
  if DD_OPOPT = 'X' and DD_APOPT ne 'X'.
 refresh xbsad.
    if B0SG-XNOPL is initial.
      select (BSID_FIELDS) from BSAD
                       into corresponding fields of table XBSAD
                       for all entries in K_KUNNR
                       where KUNNR eq K_KUNNR-LOW
                         and BUKRS in DD_BUKRS
*                        AND GJAHR IN DD_GJAHR
*                        AND AUGDT BETWEEN '00010101'
*                                      AND '99991231'
                         and BLDAT in DD_BUDAT
                         and BLDAT le DD_STIDA
                         and AUGDT gt DD_STIDA
                         and ZUONR in DD_ZUONR
                         and SHKZG in DD_SHKZG
                         and UMSKZ in DD_UMSKZ
                         and BSCHL in DD_BSCHL
                         and (BSID_WHERE).
    endif.
  endif.                                                    "Variante 1
* Variante 2: Ausgegl. Posten in einem Datumsintervall
  if DD_OPOPT ne 'X' and DD_APOPT = 'X'.
    select (BSID_FIELDS) from BSAD
                       into corresponding fields of table XBSAD
                       for all entries in K_KUNNR
                       where KUNNR eq K_KUNNR-LOW
                         and BUKRS in DD_BUKRS
*                        AND GJAHR IN DD_GJAHR
*                        AND AUGDT BETWEEN '00010101'
*                                      AND '99991231'
                         and BUDAT in DD_BUDAT
                         and AUGDT in DD_AUGDT
                         and ZUONR in DD_ZUONR
                         and SHKZG in DD_SHKZG
                         and UMSKZ in DD_UMSKZ
                         and BSCHL in DD_BSCHL
                         and (BSID_WHERE).
  endif.                                                    "Variante 2
* Variante 3: Variante 1 + 2 gleichzeitig
  if DD_OPOPT eq 'X' and DD_APOPT eq 'X'.
    select (BSID_FIELDS) from BSAD
                       into corresponding fields of XBSAD
                       for all entries in K_KUNNR
                       where KUNNR eq K_KUNNR-LOW
                         and BUKRS in DD_BUKRS
*                        AND GJAHR IN DD_GJAHR
*                        AND AUGDT BETWEEN '00010101'
*                                      AND '99991231'
                         and BUDAT in DD_BUDAT
                         and BUDAT le DD_STIDA
*                        AND AUGDT GT DD_STIDA
*                        OR  AUGDT IN DD_AUGDT
                         and ZUONR in DD_ZUONR
                         and UMSKZ in DD_UMSKZ
                         and SHKZG in DD_SHKZG
                         and BSCHL in DD_BSCHL
                         and (BSID_WHERE).
      check XBSAD-AUGDT gt DD_STIDA or XBSAD-AUGDT in DD_AUGDT.
      append XBSAD.
    endselect.
  endif.                                                    "Variante 3
* Variante 4 (aus RFITEMAR): AP mit Stichtag und Ausgleichszeitraum
  if DD_OPOPT ne 'X' and DD_APOPT ne 'X'.
    select (BSID_FIELDS) from BSAD
                       into corresponding fields of table XBSAD
                       for all entries in K_KUNNR
                       where KUNNR eq K_KUNNR-LOW
                         and BUKRS in DD_BUKRS
*                        AND GJAHR IN DD_GJAHR
*                         AND AUGDT BETWEEN '00010101'
*                                       AND '99991231'
                         and BUDAT in DD_BUDAT
                         and AUGDT gt DD_STIDA
                         and AUGDT in DD_AUGDT
                         and ZUONR in DD_ZUONR
                         and UMSKZ in DD_UMSKZ
                         and SHKZG in DD_SHKZG
                         and BSCHL in DD_BSCHL
                         and (BSID_WHERE).
  endif.                               " Variante 4

* check projk and imkey range
  if PROJK_ELIMINATED eq 'X' or IMKEY_ELIMINATED eq 'X'.
    loop at XBSAD.
      if PROJK_ELIMINATED eq 'X'.
        perform CHECK_INT_EXT(FI_LDB_UTIL) tables PROJK_TAB
                                            using XBSAD-PROJK
                                                  'KONPR'
                                         changing CHECK_OK.
        if CHECK_OK = 'N'.
          delete XBSAD.
          continue.
        endif.
      endif.

      if IMKEY_ELIMINATED eq 'X'.
        perform CHECK_INT_EXT(FI_LDB_UTIL) tables IMKEY_TAB
                                            using XBSAD-IMKEY
                                                  'IMKEY'
                                         changing CHECK_OK.
        if CHECK_OK = 'N'.
          delete XBSAD.
        endif.
      endif.

    endloop.
  endif.

  sort XBSAD by MANDT KUNNR BUKRS.
  CURSOR-BSAD = 1.
  ENDIF.

The above attached code snippets and images are screenshots.

In the above 2 enhancements, the sy-tcode should be given. The sy-tcode should be the name of the transaction code of the custom zreport.  Only if  the tcode is executed the enhacements work otherwise FBL5N works as per standard.This can be tested by checking the custom z report and FBL5N. The custom report fetches records by document date and FBL5N fetches records by posting date.

When there is a requirement to fetch records based on document date from FBL5N, such a enhancement needs to be applied.The records from FBL5N will be fetched based on the document date.All the records based on the document date(BLDAT) will be fetched.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.