Wednesday 16 January 2019

Add fields to ALV in FINT

Introduction


I have shown how email sending with Smartforms can be archived. This feature is not the only enhancement that can be applied to FINT.

In this blog I will show how ALV of FINT can be enhanced by new fields that will ease the work with interest processing.

FINT Enhancement Possibilities


The selection screen as well as ALV output and ALV Functions can be enhanced by customer fields via program RFINTITUSEREXT.

The usage of functions added by above mentioned program can be archived with BADI FI_INT_CUS01.

FINT Sending: Enhance Screen


The ALV output will be enhanced by 3 fields:  business partner name (custom data element not used in any other table), email address and country (both already used in different tables).

Function of adding/ deleting fields in calculation and display structure of enhancement program RFINTITUSEREXT will be used

There are two ways to archive the ALV fields enhancement in FINT:

◈ Append in structure INTIT_EX

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Afterwards the display structure INTIT_EXTF is regenerated automatically and the new field is added:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

◈ The field is already used in a different table:

Run the extension report only and specify the field name that suld be visible in the interest structure and also the name of the field in the source table:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Display structure is extended:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

In the same way country is added:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

After adding all fields structure is enhanced and ready to be filled in by BADI.

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

FINT Field Addition: Method used


In your implementation of BADI FI_INT_CUS01 ALV fields are available in method INT_CHANGE_ITEMS which is triggered before the actual calculation is done. It is advisable to use this method because during calculation the interest can be split into more line item when there are many percentages used for calculation. Fields filled in before this is done are taken over to newly created lines.

FINT Field Addition: INT_CHANGE_ITEMS


Method INT_CHANGE_ITEMS contains all data about the interest calculated, business partners and selection option.

This method is called for every business partner separately. Meaning if we have 3 business partners selected – it will be called 3 times.

We are going to select the fields from KNA1 and ADR6 tables to fill it in the output:

"select data from tables for a single customer
    "and add it to display structure

    IF ct_items IS NOT INITIAL.

      SELECT kna1~kunnr, kna1~name1, kna1~name2 , kna1~land1, adr6~smtp_addr, adr6~flgdefault
        FROM kna1
        LEFT OUTER JOIN adr6
        ON adr6~addrnumber = kna1~adrnr
        INTO TABLE @DATA(lt_master_data)
        FOR ALL ENTRIES IN @ct_items
        WHERE kna1~kunnr = @ct_items-account.
      IF sy-subrc EQ 0.

        SORT lt_master_data BY kunnr flgdefault DESCENDING.
        LOOP AT ct_items ASSIGNING FIELD-SYMBOL(<fs_single_item>).

          READ TABLE lt_master_data WITH KEY kunnr = <fs_single_item>-account
                                    ASSIGNING FIELD-SYMBOL(<fs_found_md>).
          IF sy-subrc EQ 0.

            <fs_single_item>-zzbpname = |{ <fs_found_md>-name1 }{ <fs_found_md>-name2 }|.
            <fs_single_item>-zzland1 = <fs_found_md>-land1.
            IF <fs_found_md>-flgdefault EQ abap_true. "Address is marked as an standard email address
              <fs_single_item>-zzsmtp_addr = <fs_found_md>-smtp_addr.
            ENDIF.

          ENDIF. "on master data read

        ENDLOOP. "on selected items

      ENDIF. "on master data selection

    ENDIF. "on check if any item is provided

Dependent on your needs the coding can be adjusted ( for example FAE can be deleted by single read of the customer number and CONCAT option can be used to already concatenate the names during the selection) in any possible way.

To show how the solution works 3 customers were defined of which 2 only has email addresses updated (same as in previous FINT blog post).

FINT calculation is executed:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

In the layout the fields were added and are available in the display:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Further usage of the fields added


Adding a field in a display structure can also trigger filling it in the posted interest document. Some fields are not visible here but quite important for dunning/ credit control area. The transfer from original invoice to interest document can either happen via an user-exit or by means of the display structure extension.

Once a field that is available in original document (based on BSID table) it can be added to display structure, like Credit Control area:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

or Dunning Area:

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Using customizing options you can indicate which of the fields available in original document should be transferred to interest document.

IMG: Financial Accounting (New)  –> Accounts Receivable and Accounts Payable –> Business Transactions –>  Interest Calculation –> Interest Calculation Global Settings

Transaction: Prepare Item Interest Calculation

Once the option ‘Transfer of Account Assignment Info’ is marked the fields to be transferred from original posting (additionally to all fields transport by standard) are moved to interest document.

SAP ABAP Tutorial and Material, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

No comments:

Post a Comment