Sebastian Wey,

FS-CD Payment Plan Interface

The upstream system can transfer a posting date to FS-CD via the FS-CD payment plan interface. However, if the posting period in FS-CD is already closed, the debit entry terminates with an error message and the document cannot be posted. In this blog post I describe how in a customer enhancement the posting date can be overridden to the next open posting period so that the debit entry can be executed.

Checking the Posting Date

FS-CD contains the function module FKK_BUDAT_CHECK, which can be used to check whether the posting period for the transferred posting date is open or not. The check must be carried out both for the reconciliation account of the business partner item and for the G/L account of the general ledger item. It should also be noted that the company codes for the two items can be different. It makes sense to check and, if necessary, override the posting date in event V016, since FS-CD has already determined the G/L accounts at this point.

FUNCTION z_cd_zpp_v016.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_PAYPLAN) TYPE  SVVSCPOS_DI
*"  EXPORTING
*"     REFERENCE(E_PAYPLAN) TYPE  SVVSCPOS_DI
*"  TABLES
*"      T_ERROR STRUCTURE  SVVSCMSG_X
*"----------------------------------------------------------------------

  e_payplan = i_payplan.

  lcl_service=>adjust_budat( CHANGING cs_scpos = e_payplan ).

ENDFUNCTION.
*----------------------------------------------------------------------*
***INCLUDE LZCD_ZPPD01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&       Class lcl_service
*&---------------------------------------------------------------------*
*        Text
*----------------------------------------------------------------------*
CLASS lcl_service DEFINITION ABSTRACT FINAL.

  PUBLIC SECTION.

    CLASS-METHODS adjust_budat
      CHANGING
        cs_scpos TYPE svvscpos_di.

ENDCLASS.               "lcl_service
*----------------------------------------------------------------------*
***INCLUDE LZCD_ZPPP01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&       Class (Implementation)  lcl_service
*&---------------------------------------------------------------------*
* If the posting period of the posting date of the payment plan item is
* closed, the posting date is overridden to the start of the next open 
* posting period.
*----------------------------------------------------------------------*
CLASS lcl_service IMPLEMENTATION.

*    CLASS-METHODS adjust_budat
*      CHANGING
*        cs_scpos TYPE svvscpos_di.
  METHOD adjust_budat.

    DATA lv_ccode_op TYPE bukrs.
    DATA lv_budat    TYPE d.
    DATA lv_year(4)  TYPE n.
    DATA lv_month(2) TYPE n.
    DATA lv_closed   TYPE abap_bool.

    lv_budat = cs_scpos-budat.

    " Determine correct company code for partner item
    IF cs_scpos-opccode IS INITIAL.
      lv_ccode_op = cs_scpos-ccode.
    ELSE.
      lv_ccode_op = cs_scpos-opccode.
    ENDIF.

    " Determine posting period
    CALL FUNCTION 'FI_PERIOD_DETERMINE'
      EXPORTING
        i_bukrs = cs_scpos-ccode
        i_budat = lv_budat
      IMPORTING
        e_gjahr = lv_year
        e_monat = lv_month.


    DO.
      lv_closed = abap_false.

      " Check posting date for partner item
      IF cs_scpos-bltyp = '20' OR cs_scpos-bltyp = '22'.
        CALL FUNCTION 'FKK_BUDAT_CHECK'
          EXPORTING
            i_bukrs       = lv_ccode_op
            i_budat       = lv_budat
          EXCEPTIONS
            error_message = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
          lv_closed = abap_true.
        ENDIF.
      ENDIF.

      " Check posting date for general ledger item
      IF cs_scpos-bltyp = '20' OR cs_scpos-bltyp = '23'.
        CALL FUNCTION 'FKK_BUDAT_CHECK'
          EXPORTING
            i_bukrs       = cs_scpos-ccode
            i_budat       = lv_budat
            i_hkont       = cs_scpos-h_hkont
          EXCEPTIONS
            error_message = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
          lv_closed = abap_true.
        ENDIF.
      ENDIF.


      IF lv_closed = abap_false.
        " Period is open: Set posting date
        cs_scpos-budat = lv_budat.
        RETURN.
      ENDIF.


      " Period closed: Check next month
      ADD 1 TO lv_month.

      IF lv_month > 12.
        lv_month = 1.
        ADD 1 TO lv_year.

        " Check termination - max. current and following year
        IF lv_year + 0 > sy-datlo(4) + 1.
          RETURN. " Do not change posting date
        ENDIF.
      ENDIF.

      lv_budat = lv_year && lv_month && '01'.

    ENDDO.

  ENDMETHOD.                    "adjust_budat

ENDCLASS.               "lcl_service

Translated with DeepL


Back to list Context Menu in ALV-Based Account Balance >