Skip to Content

Previously, I wrote a blog to find out Bank Statement flows which existed in table FQM_FLOW however the original bank statement records have been archived. Please check the detail via the link <One Exposure: Find out the flows coming from Bank statement but bank statement is not exist any more>

Let’s enhance that program a little bit, by adding one more check: find out the bank statement flows shall be deleted.

By default, bank statement flows shall be deleted after the relevant accounting documents got posted. The accounting document posting will trigger Flow Builder to build flows for accounting documents.

There various reasons why bank statement flows haven’t been delete:

  1. Trigger mechanism of Flow Builder; You can switch off automatic trigger of Flow Builder to process the accounting document;
  2. Interval of Flow Builder execution; You can set the delay seconds for starting Flow Builder; And the Flow Builder cost times to execution. Before the Flow Builder delete relevant BS flows, those flows are still existed;
  3. There could be some other reasons where Flow Builder failed to execute.

This blog’s purpose is not figure out the root reason of bank statement flows existence, but provide a way to find out those flows out.

First of all, let’s add two parameter to control which check shall be performed. One is for the bank statement flows’ existence but without original bank statement, the other is for the bank statements’ existence but relevant accounting document number found bank statement line item.

PARAMETERS: p_cknko TYPE xfeld AS CHECKBOX.
PARAMETERS: p_ckeep TYPE xfeld AS CHECKBOX.

Then, add the logic to process the second check (the first check has been implemented in the previous blog):

  IF p_ckeep EQ 'X'.
    SELECT DISTINCT origin_document_id, origin_transaction_id FROM fqm_flow
      INTO TABLE @DATA(lt_bsflows_bsi)
      WHERE company_code = @p_bukrs
        AND deleted = ''
        AND FLG_ACTUAL = 'X'
        AND origin_application = 'BS'.
    TYPES: BEGIN OF ts_bsi_key,
             kukey TYPE kukey_eb,
             esnum TYPE esnum_eb,
           END OF ts_bsi_key.
    DATA lt_bsi_key TYPE SORTED TABLE OF ts_bsi_key WITH UNIQUE KEY kukey esnum.

    LOOP AT lt_bsflows_bsi ASSIGNING FIELD-SYMBOL(<fs_bsflows_bsi>).
      MOVE <fs_bsflows_bsi>-origin_document_id TO lv_kukey.
      DATA lv_lens TYPE i.
      lv_lens = strlen( lv_kukey ).
      DATA lv_esnum TYPE esnum_eb.
      MOVE <fs_bsflows_bsi>-origin_transaction_id+lv_lens(5) TO lv_esnum.

      READ TABLE lt_bsi_key TRANSPORTING NO FIELDS
        WITH TABLE KEY kukey = lv_kukey esnum = lv_esnum.
      IF sy-subrc EQ 0.
        " Do nothing
      ELSE.
        DATA ls_bsi_key TYPE ts_bsi_key.
        ls_bsi_key-kukey = lv_kukey.
        ls_bsi_key-esnum = lv_esnum.
        INSERT ls_bsi_key INTO TABLE lt_bsi_key.
      ENDIF.
    ENDLOOP.

    DATA lt_febep TYPE TABLE OF febep.
    SELECT b~kukey, b~esnum, b~belnr, b~ak1bl
      FROM febep AS b
      INNER JOIN febko AS a ON b~kukey = a~kukey
      INTO CORRESPONDING FIELDS OF TABLE @lt_febep
      FOR ALL ENTRIES IN @lt_bsi_key
      WHERE b~kukey = @lt_bsi_key-kukey
      AND b~esnum = @lt_bsi_key-esnum
      AND ( b~vb1ok = 'X' OR b~vb2ok = 'X' )
      AND ( ( b~belnr <> '' AND b~belnr <> '-' AND b~belnr <> '*' )
          OR ( b~ak1bl <> '' AND b~ak1bl <> '-' AND b~ak1bl <> '*' ) ).

    IF lines( lt_febep ) > 0.
      WRITE 'FQM flows but bank statement but FI doc exists: '.
      LOOP AT lt_febep ASSIGNING FIELD-SYMBOL(<fs_febep>).
        NEW-LINE.
        DATA lv_msg TYPE string.
        CONCATENATE <fs_febep>-kukey '-' <fs_febep>-esnum '-' <fs_febep>-belnr '-' <fs_febep>-ak1bl INTO lv_msg.
        WRITE lv_msg.
      ENDLOOP.
    ENDIF.
  ENDIF.

You shall update the selection text to make the program easy to understand:

Then, let’s run it!

And you got the finding.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    Hello,

    very useful, I am in a customer where I can see that the BS is not delete, therefore I don’t have a good cash position, How could I delete ( or mark to deleted) to those entries?. and How to avoid that this error still continues?

    Regards and thanks in advanced,

     

     

    (0) 
    1. Former Member Post author

      Hello Diana,

      As I explained, this blog is not target to solve those BS flows. And I had listed several possible reasons why those BS flows got no deleted yet.

      Thank you, Hongjun

      (0) 

Leave a Reply