Skip to Content
Technical Articles
Author's profile photo Hongjun Qian

Flow Builder: Using exit to fetch HBKID/HKTID for Accounting Documents missed those information

This post is targeted for Flow Builder 1.0, which still using HAdI as the extensibility. If you already run with Flow Builder Plus, please refer to new post where provides you the same logic for Flow Builder Plus <Flow Builder Plus: extend standard logic for fetching bank account | SAP Blogs>.

 

 

As pointed out in the previous blog <One Exposure: Check Data Quality as the first step>, the storage in One Exposure may contain the data which brings the inconsistent figure in Cash relevant apps, like Cash Position.

Among all those checks I provided in that blog, I think it’s the most common case that flows coming from Accounting documents lack of bank account relevant information. In detail, the table BSEG lack of HBKID/HKTID.

The Flow Builder provides the mechanism to extend our standard logic, which we called it “exit”. Via implemented the exit, we can solve the case above: flows from Accounting documents missing bank account information. In this post, I would like to provide a way to fetch the bank account information from General Ledger (GL) account master data.

First of all, copy the standard sample class CL_FCLM_APAR_HADI_SAMPLE to local namespace one, such as ZCL_FCLM_APAR_HADI_SAMPLE.

Second, copy the codes below to that clas (You shall use ABAP Development Tool instead of the SAPGUI transaction SE24 because it ships the ADMP codes):

class ZCL_FCLM_APAR_HADI_SAMPLE definition
  public
  final
  create public .

public section.

  interfaces IF_AMDP_MARKER_HDB .
  interfaces IF_FCLM_HADI_APAR .
protected section.
private section.
ENDCLASS.

CLASS ZCL_FCLM_APAR_HADI_SAMPLE IMPLEMENTATION.

  METHOD IF_FCLM_HADI_APAR~FLOW_ADJUST BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT USING
  SKB1
  vfclmbamaclvw.

    et_flows =  select
                ORIGIN_TRANS_QUALIFIER,
                FI_DOCUMENT_NUMBER,
                COMPANY_CODE,
                FI_DOCUMENT_LINE_ITEM,
                PLANNING_GROUP,
                PLANNING_LEVEL,
                FI_FISCAL_YEAR,
                FI_ACCOUNT,
                DOCUMENT_DATE,
                BASE_CURRENCY,
                c.CURRENCY,
                CASH_DISCOUNT_PERCENT1,
                CASH_DISCOUNT_DAYS1,
                CASH_DISCOUNT_PERCENT2,
                CASH_DISCOUNT_DAYS2,
                DAYS_DUE,
                BASELINE_DATE,
                PAYMENT_METHOD,
                PAYMENT_BLOCK,
                ASSIGNMENT,
                case when BANK_ACCOUNT_ID <> d.acc_id then d.acc_id
else BANK_ACCOUNT_ID end as BANK_ACCOUNT_ID,
                ASSIGNED_COMPANY_CODE,
                CERTAINTY_LEVEL,
                FLOW_TYPE,
                ORIGIN_DOCUMENT_ID_RL,
                CLEARED,
                ORIGIN_TRANSACTION_ID_RL,
                ORIGIN_DOCUMENT_ID,
                ORIGIN_FLOW_ID,
                BASE_AMOUNT,
                AMOUNT,
                ORIGIN_TRANSACTION_ID,
                TRANSACTION_DATE,
                FI_PURCHSE_DOCUMENT_NUMBER,
                FI_PURCHSE_LINE_ITEM,
                FI_SEQUENTIAL_NUMBER,
                BUSINESS_AREA,
                HOUSE_BANK,
                HOUSE_BANK_ACCOUNT,
                COST_CENTER,
                CUSTOMER_NUMBER,
                VENDOR_NUMBER,
                LIQUIDITY_ITEM,
                MATERIAL,
                PROFIT_CENTER,
                PROJECT,
                c.SEGMENT,
                TRADING_PARTNER,
                CONTRACT_NUMBER,
                CONTRACT_TYPE
                from (  select
                        ORIGIN_TRANS_QUALIFIER,
                        FI_DOCUMENT_NUMBER,
                        COMPANY_CODE,
                        FI_DOCUMENT_LINE_ITEM,
                        PLANNING_GROUP,
                        PLANNING_LEVEL,
                        FI_FISCAL_YEAR,
                        FI_ACCOUNT,
                        DOCUMENT_DATE,
                        BASE_CURRENCY,
                        CURRENCY,
                        CASH_DISCOUNT_PERCENT1,
                        CASH_DISCOUNT_DAYS1,
                        CASH_DISCOUNT_PERCENT2,
                        CASH_DISCOUNT_DAYS2,
                        DAYS_DUE,
                        BASELINE_DATE,
                        PAYMENT_METHOD,
                        PAYMENT_BLOCK,
                        ASSIGNMENT,
                        BANK_ACCOUNT_ID,
                        ASSIGNED_COMPANY_CODE,
                        CERTAINTY_LEVEL,
                        FLOW_TYPE,
                        ORIGIN_DOCUMENT_ID_RL,
                        CLEARED,
                        ORIGIN_TRANSACTION_ID_RL,
                        ORIGIN_DOCUMENT_ID,
                        ORIGIN_FLOW_ID,
                        BASE_AMOUNT,
                        AMOUNT,
                        ORIGIN_TRANSACTION_ID,
                        TRANSACTION_DATE,
                        FI_PURCHSE_DOCUMENT_NUMBER,
                        FI_PURCHSE_LINE_ITEM,
                        FI_SEQUENTIAL_NUMBER,
                        BUSINESS_AREA,
                        case when HOUSE_BANK = '' then coalesce(b.hbkid, '') else HOUSE_BANK end as HOUSE_BANK,
                        case when HOUSE_BANK_ACCOUNT = '' then coalesce(b.hktid, '') else HOUSE_BANK_ACCOUNT end as HOUSE_BANK_ACCOUNT,
                        COST_CENTER,
                        CUSTOMER_NUMBER,
                        VENDOR_NUMBER,
                        LIQUIDITY_ITEM,
                        MATERIAL,
                        PROFIT_CENTER,
                        PROJECT,
                        SEGMENT,
                        TRADING_PARTNER,
                        CONTRACT_NUMBER,
                        CONTRACT_TYPE
                        from :it_flows as a
                        inner join skb1 as b
                        on  b.mandt         = :iv_mandt
                        and a.company_code  =  b.bukrs
                        and a.fi_account    = b.saknr) as c
                left outer join vfclmbamaclvw as d
                on  d.mandt         = :iv_mandt
                and d.linkage_bukrs = c.company_code
                and d.linkage_hbkid = c.house_bank
                and d.linkage_hktid = c.house_bank_account
                and c.transaction_date >= d.linkage_valid_from
                and c.transaction_date <= d.linkage_valid_to;

  ENDMETHOD.
ENDCLASS.

The sample code snippets show you the way to fetch bank account based on house bank/house bank account which defined in GL master data, and it will use the newly found bank account to overwrite the existing bank account if there is a mismatch.

 

After the activation of this class, you need re-generate the loading class for Flow Builder, using t-code: FCLM_FB_UTIL, input the following parameter and press F8 to regenerate the loading class.

 

 

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Alvarez Victor
      Alvarez Victor

      Amazing and very instructive job. I am facing some problems due to the standard derivation in FQM_FLOW using Bill of Exchange functionality and for sure your post will help me a lot.

      Keep on with the good work!

      Author's profile photo Hongjun Qian
      Hongjun Qian
      Blog Post Author

      Glad to hear this post brings help to you.

      Please let me know your further suggestion or comment, thank you.

      Author's profile photo Service itelli Itelligence
      Service itelli Itelligence

      Hi, really great & clear instructions. One issue however. Everything works as per your instructions, but after I Generate the loading classes and Assign, I come out of FCLM_FB_UTIL & go back in & every time my Exit Class for FI reverts back to the standard CL_FCLM_APAR_HADI_SAMPLE rather than my new ZCL_FCLM_APAR_HADI_SAMPLE. The loading class remains as ZCL_FCLM_BSEGFLOW_SAMPLE.

      Many thanks

      Ben

      Author's profile photo Former Member
      Former Member

      Hi Hongjun Qian,

      Thanks in advance for this detailed explanation, i am facing the problem that i need to complete always the fields HBKID/HKTID with the GL account Master Data. We did all the configuration but it seems the method is not being called. (tested by debug)

      there is any additional activation that should i have to do?

      Thanks a lot.

       

      Author's profile photo Hongjun Qian
      Hongjun Qian
      Blog Post Author

      Hi Andiran Boiero,

      The sample code I provided here, will fetch the HBKID/HKTID during Flow Builder building flows from accounting documents (BKPF/BSEG).

      Once you implemented the exit, you need:

      1. Re-generate the loading class
      2. Re-assign the loading class, it's optional if the loading class already assigned;

      And then you need rebuild the flows to make the exit work.

      Hope the answer above helps.

       

      Author's profile photo Former Member
      Former Member

      Hi Hongjun Qian,

      I re-generate and re-assign the loading class and now is working.

      Thanks a lot

      Author's profile photo Hongjun Qian
      Hongjun Qian
      Blog Post Author

      Glad to hear the loading class now working. Enjoy it.

      Author's profile photo Jacques Otto
      Jacques Otto

      Hi There,

      First of all, thank you for the blog.  I am however experiencing an issue.  I have followed your steps exactly, and double checked that as well, when I try to run the transaction to re-generate the loading class I get a short dump:

      shortdump

      shortdump

       

      I investigated and it seemed to be related to the fact that method IF_FCLM_HADI_APAR~SEL_REL_DOC does not have an implementation.  I then tried to add just an empty implementation of the method, but that then leads to syntax errors during generation of ZCL_FCLM_BSEGFLOW_SAMPLE.

      Any idea why this would be?  We are on HANA 1909

      Author's profile photo Marna Heater
      Marna Heater

      Hi Hongjun Qian,

      Would it be possible for you to update this code to be compatible with version 2021 OP?

      Thank you!

      Author's profile photo Hongjun Qian
      Hongjun Qian
      Blog Post Author

      Please refer to Flow Builder Plus: extend standard logic for fetching bank account | SAP Blogs