Skip to Content
Technical Articles

How to Change Reconciliation Account in MIRO,MIR7,MIRA,MIR4 with using BADI’s

In this blog post, you will be able to add custom fields to MM-IV screens and also you will be able to change reconciliation account via using BTE 1120.

Some of SAP customers need to change reconciliation account while posting invoices due to legal procedures. It is possible to change it in FI t-codes like FB60,FV60, etc. with using special gl indicator.

But if you are using MM-IV for all invoices, you won’t be able to change reconciliation account in MIRO/MIR7/MIRA/MIR4.

In MM-IV tcodes, Reconciliation account is being filled from Vendor master data (XK03) below.

It is seen that G/L account can not be editable in MIR7 above pic. There is also no Special GL indicator field in any tab.

What TO DO? If you need to post to another account, instead of assigned account in vendor master data.

It is possible to change reconciliation acc. from vendor master(XK02) before posting. But, another users will be affected regarding this action. For this reason, it is very dangerous to change reconciliation account from master data.

We will be able to post another accounts by below steps. I have used only BADI’S and Append structure function in this solution (no coding repair!)

1      Add new account field to MIRO/MIR7/MIRA/MIR4 Screen

1.1     Go to SE19 -> Display FI_FDCB_SUBBAS01

Copy to your notepad above called program “SAPLBADI_EXAMPLE_FDCB_BAS”. This program is used for all invoice posting screens (MIRO/MIR7/FB60/FV60..etc) we will copy this program and make a new Z program.

Create a copy of FI_FDCB_SUBBAS01_EX. I did Z1_BADI* below. You can also create BADI from se18

*If you are using Subbas01 for your other requirments, you can use 02,03..,06. Go to SE18 -> Choose “BADI_FDCB_SUBBAS0*”

1.2     Go to SE38 -> Create a copy of “SAPLBADI_EXAMPLE_FDCB_BAS”

New function group is your z badi’s name. Click “Copy” system will create a new program automatically.

The screen 0100 is coming from standard program which is used in IV(Invoice verification) screens. We will create a new screen through coping 0100, it will be 0900 for my new field. Delete 0100, after creating 0900.

The Screen(0900) is created, we will write some simple abap codes to make validations and better functions for our new reconciliation account field.

2      Add new field to structures and tables

After debugging MIRO, i have recognised that we need to add our new custom field to releated structures and tables below.

The structures :

  • BKPF_SUBST (After saving for FI document Header, we will use BTE 1120)
  • BSEG_SUBST (After saving and simulation mode for FI document item, we will use BTE 1120)
  • INVFO (Screen fields structure)
  • ACMM_VENDOR_COMP (Necessary)
  • RBKP_V (Necessary for MIR7)
  • VBKPF (Optional for FV60-FV65)

The Tables :

  • BKPF
  • RBKP (Necessary for Header, we keep new field in the header)

My new field is ZZAKONT.

 

3      ABAP Coding Part of Screen

After implementations of my new field, now we can add our field to MM-IV screens. Go to SE19 -> Change “Z1_BADI_FDCB_SUBBAS” and Screen “900”.

3.1     Screen coding

I would like to make a search help for my new field and i want to display my field only MIRA,MIR4,MIR7,MIRO screens not FV60-FV65..etc.

Thus, I make some diffrences in the coding of screen.

Below, You can find abap codes what i wrote for my requirement for the screen.

The field will be only visible and editable for MIR7, MIRO, MIRA, MIR4.

MODULE modify_screen OUTPUT. “ONLY MM-IV”

IF NOT ( sy-tcode = ‘MIR7’
OR    sy-tcode = ‘MIRO’
OR    sy-tcode = ‘MIRA’
OR    sy-tcode = ‘MIR4’ ).
LOOP AT SCREEN.
IF screen-group1 = ‘ZZ1’.
screen-input = ‘0’.
screen-invisible = ‘1’.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.

ENDMODULE.

—–

MODULE fill_zzakont INPUT.

Validation for incorrect accounts! Only, Vendor reconciliation accounts can be chosen.

DATA : LV_SAKNR TYPE SAKNR.

IF invfo-zzakont IS NOT INITIAL.
CLEAR LV_SAKNR.
SELECT SINGLE saknr FROM skb1 INTO LV_SAKNR
WHERE saknr EQ invfo-zzakont
AND bukrs EQ invfo-bukrs
AND mitkz EQ ‘K’
AND ( xloeb NE ‘X’
OR xspeb  NE ‘X’) .
IF sy-subrc IS INITIAL.
EXPORT invfo-zzakont TO MEMORY ID ‘BKPF-ZZAKONT’.
ELSE.
MESSAGE ‘Incorrect account assingment!'(001) TYPE ‘E’.
ENDIF.
ENDIF.

ENDMODULE.

Search help for my new reconciliation account field.

MODULE help_lfb1-akont INPUT.

DATA: akont LIKE lfb1-akont.
DATA:    BEGIN OF dynpfields OCCURS 1.
INCLUDE STRUCTURE dynpread.
DATA:    END   OF dynpfields.
DATA:             char1(1)       TYPE c.

*—— Inhalt des Feldes ‘LFB1-AKONT’ vom Dynpro besorgen ————-
CLEAR   dynpfields.
REFRESH dynpfields.
dynpfields-fieldname = ‘INVFO-ZZAKONT’.
APPEND dynpfields.
CALL FUNCTION ‘DYNP_VALUES_READ’
EXPORTING
dyname     = ‘SAPLMR1M’ ” ‘SAPMF02K’
dynumb     = ‘0900’     “‘0210’
TABLES
dynpfields = dynpfields
EXCEPTIONS
OTHERS     = 4.
IF sy-subrc = 0.
READ TABLE dynpfields INDEX 1.
invfo-zzakont = dynpfields-fieldvalue.
TRANSLATE invfo-zzakont TO UPPER CASE.                       “#EC TRANSLANG
ENDIF.

*——- Feld ‘LFB1-AKONT’ Eingabe- oder Anzeigefeld? ——————
PERFORM feldstatus_ermitteln USING ‘INVFO-ZZAKONT’ char1.

*—— Abstimmkonten anzeigen —————————————–
CALL FUNCTION ‘FI_F4_AKONT’
EXPORTING
i_bukrs = ‘YOUR COMPANY CODE‘ “invfo-bukrs’
i_mitkz = ‘K’
i_akont = invfo-zzakont
i_xshow = char1
IMPORTING
e_akont = invfo-zzakont.
IF NOT invfo-zzakont IS INITIAL.
invfo-zzakont = invfo-zzakont.
ENDIF.
ENDMODULE.

Form of above marked Perform.

FORM feldstatus_ermitteln USING fname xshow.
LOOP AT SCREEN.
CHECK screen-name = fname.
IF screen-input = 0.
xshow = ‘X’.
ELSE.
xshow = space.
ENDIF.
EXIT.
ENDLOOP.
ENDFORM.

4      Coding in FI BTE (Bussiness Transaction Event) 1120.

You have to use (SAMPLE_PROCESS_00001120). I will not be decribing how to activate BTE 1120 in this document. There are many helpful documents for activating BTE’s in BLOG’s. Thanks to Borja Federico Muro Berdasco (https://blogs.sap.com/2013/01/07/btes-business-transaction-events/#)

After activating BTE 1120. You need to write below codes.

DATA : ls_bkpf    TYPE bkpf,

DATA : invfo    TYPE invfo,
lv_index TYPE i.
IMPORT invfo-zzakont FROM MEMORY ID ‘BKPF-ZZAKONT’.
FREE MEMORY ID : ‘BKPF-ZZAKONT’.
IF invfo-zzakont IS NOT INITIAL.
ls_bkpf-zzakont = invfo-zzakont.
LOOP AT t_bseg REFERENCE INTO DATA(ls_tempbseg) WHERE lifnr IS NOT INITIAL.
lv_index = sy-tabix.
t_bsegsub-hkont = ls_tempbseg->hkont = invfo-zzakont.
t_bsegsub-saknr = ls_tempbseg->saknr = invfo-zzakont.
MODIFY t_bsegsub INDEX lv_index TRANSPORTING hkont saknr.
ENDLOOP.
ENDIF.

5      Activation New BADI

Go to se18 -> BADI_FDCB_SUBBAS01 -> Overview.

Your implementation must be marked below or your implementation will not work.

6      Test

When you simulate without choosing new recon.account, the system executes standart behavior that assigned account in master data (Below).

If you fill our new custom reconciliation account. The system will reckon it .

Simulation after filling the custom field.

FI posted document is seen below.

In conclusion, it is possible to post to another reconciliation account in MM-IV by applying steps above. But it is not standart solution, therefore you have to test your all cases, FM integration and other impacts what modules you use in SAP.

Good Luck,

Mehmet Akif Ak

 

 

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