Skip to Content

SAP Cash Management provides the possibility to let you assign Flow Type to G/L account, you can use the IMG path: Financial Supply Chain Management > Cash and Liquidity Management > Cash Management > Flow Types > Assign Flow Types to G/L Accounts

As this maintenance view allow you input a range of G/L account to specify the Flow Types, it could happen that there are more than one Flow Types have been assigned to one single G/L account.

For instance, the following setting will make G/L account 113101, 113102, … 113109 double assigns:

  • G/L 00113100 – 00113109 FT1
  • G/L 00113101 – 00113110 FT2

Those kinds of multiple-assigns shall be avoid during the configuration. And it can be checked via a local program easily.

Please be aware that the program provided below using lots of ABAP new feature, and it has been tested under SAP_BASIS version 753 and SAP_ABA version 75D. You may need rewrite it to fit your ABAP version.

REPORT zac_clear_flowtypecust.

START-OF-SELECTION.

DATA lt_bseg_ft TYPE TABLE OF FQM_BSEG_FT.
TYPES: BEGIN OF ts_flowtypecust,
    BUKRS type bukrs,
    hkont type hkont,
    shkzg like bseg-shkzg,
    flow_type like fqm_bseg_ft-flow_type,
    end of ts_flowtypecust.
TYPES ty_flowtypecust TYPE TABLE OF ts_flowtypecust.
DATA lt_flowtypecust type ty_flowtypecust.

" Read DB.
select b~company_code as bukrs,
    a~ktopl,
    a~hkont_l,
    a~hkont_h,
    a~flow_type,
    a~flow_type_dec
    into CORRESPONDING FIELDS OF TABLE @lt_bseg_ft
    FROM fqmc_activation as b
    left outer join fqm_bseg_ft as a
    on ( a~bukrs = b~company_code or a~bukrs = '' )
    and b~origin_application = 'FI'
    and b~activation_status = '1'.

" Filter by company code
DATA lt_t001 type table of t001.
select bukrs, ktopl into CORRESPONDING FIELDS OF table @lt_t001
    from t001.

DATA lt_t001_2 like lt_t001.
LOOP AT lt_bseg_ft INTO DATA(ls_bseg_ft)
    GROUP BY ( bukrs = ls_bseg_ft-bukrs ktopl = ls_bseg_ft-ktopl ) ASCENDING.

    READ TABLE lt_t001 TRANSPORTING NO FIELDS
        WITH KEY bukrs = ls_bseg_ft-bukrs
            ktopl = ls_bseg_ft-ktopl.
    IF sy-subrc NE 0.
        APPEND VALUE #( bukrs = ls_bseg_ft-bukrs ktopl = ls_bseg_ft-ktopl ) TO lt_t001_2.
    ENDIF.
ENDLOOP.

LOOP AT lt_t001_2 ASSIGNING FIELD-SYMBOL(<fs_t001>).
    DELETE lt_bseg_ft WHERE bukrs = <fs_t001>-bukrs AND ktopl = <fs_t001>-ktopl.
ENDLOOP.

CLEAR: lt_t001, lt_t001_2.

DATA lt_skb1 TYPE TABLE OF skb1.

" Filter by GL account: Only have hkont_l
LOOP AT lt_bseg_ft INTO ls_bseg_ft
    WHERE hkont_h = ''
    GROUP BY ( bukrs = ls_bseg_ft-bukrs saknr = ls_bseg_ft-hkont_l ) WITHOUT MEMBERS
    INTO DATA(key).

    APPEND VALUE #( bukrs = key-bukrs saknr = key-saknr )
        TO lt_skb1.
ENDLOOP.

SELECT * FROM skb1
    INTO TABLE @DATA(lt_skb1_2)
    FOR ALL ENTRIES IN @lt_skb1
    WHERE bukrs = @lt_skb1-bukrs
      AND saknr = @lt_skb1-saknr.

LOOP AT lt_skb1 ASSIGNING FIELD-SYMBOL(<fs_skb1>).
    READ TABLE lt_skb1_2 TRANSPORTING NO FIELDS
        WITH KEY bukrs = <fs_skb1>-bukrs
                saknr = <fs_skb1>-saknr.
    IF sy-subrc NE 0.
        DELETE lt_skb1.
    ENDIF.
ENDLOOP.
CLEAR: lt_skb1_2.

LOOP AT lt_bseg_ft INTO ls_bseg_ft
    WHERE hkont_h = ''  .

    READ TABLE lt_skb1 TRANSPORTING NO FIELDS
        WITH KEY bukrs = ls_bseg_ft-bukrs
                 saknr = ls_bseg_ft-hkont_l.
    IF sy-subrc EQ 0.
        APPEND VALUE #(
            bukrs = ls_bseg_ft-bukrs
            hkont = ls_bseg_ft-hkont_l
            shkzg = 'S'
            flow_type = ls_bseg_ft-flow_type
            )
            TO lt_flowtypecust.
        APPEND VALUE #(
            bukrs = ls_bseg_ft-bukrs
            hkont = ls_bseg_ft-hkont_l
            shkzg = 'H'
            flow_type = ls_bseg_ft-flow_type_dec
            )
            TO lt_flowtypecust.
    ENDIF.
ENDLOOP.

" Filter by GL account: Have hkont_l and hkont_l both
DATA lt_bseg_ft2 LIKE lt_bseg_ft.
LOOP AT lt_bseg_ft INTO ls_bseg_ft
    WHERE hkont_h IS NOT INITIAL.
    APPEND ls_bseg_ft TO lt_bseg_ft2.
ENDLOOP.

CLEAR: lt_skb1_2.
DATA ls_skb1_2 LIKE LINE OF lt_skb1_2.
SELECT * FROM skb1
    INTO TABLE @lt_skb1_2
    FOR ALL ENTRIES IN @lt_bseg_ft2
    WHERE bukrs = @lt_bseg_ft2-bukrs
      AND saknr >= @lt_bseg_ft2-hkont_l
      AND saknr <= @lt_bseg_ft2-hkont_h.

LOOP AT lt_bseg_ft2 INTO ls_bseg_ft.

    LOOP AT lt_skb1_2 INTO ls_skb1_2
        WHERE bukrs = ls_bseg_ft-bukrs
              AND saknr >= ls_bseg_ft-hkont_l
              AND saknr <= ls_bseg_ft-hkont_h.

        APPEND VALUE #(
            bukrs = ls_bseg_ft-bukrs
            hkont = ls_skb1_2-saknr
            shkzg = 'S'
            flow_type = ls_bseg_ft-flow_type
            )
            TO lt_flowtypecust.
        APPEND VALUE #(
            bukrs = ls_bseg_ft-bukrs
            hkont = ls_skb1_2-saknr
            shkzg = 'H'
            flow_type = ls_bseg_ft-flow_type_dec
            )
            TO lt_flowtypecust.
    ENDLOOP.
ENDLOOP.
CLEAR: lt_bseg_ft2, lt_skb1_2.

LOOP AT lt_flowtypecust ASSIGNING FIELD-SYMBOL(<fs_ftcust>)
    GROUP BY ( bukrs = <fs_ftcust>-bukrs hkont = <fs_ftcust>-hkont shkzg = <fs_ftcust>-shkzg index = GROUP INDEX size = GROUP SIZE ) WITHOUT MEMBERS
    INTO DATA(key3).

    IF key3-size > 1.
      WRITE / key3-bukrs.
      WRITE key3-hkont.
      WRITE key3-shkzg.
      WRITE key3-size.
    ENDIF.
ENDLOOP.

 

 

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply