Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jigang_Zhang
Active Contributor
7,080

Customizing SAPF124 for Automatic Clearing of Open Items

cover.png

1. Overview of SAPF124
  • It automatically clears open items from customer, vendor, and G/L accounts (particularly GR/IR clearing accounts). It selects all accounts specified in the value sets with debit and credit postings.
  • For the final clearing of the open items, SAPF124 makes a CALL TRANSACTION ‘FB1S’ (G/L Account) or ‘FB1D’ (Customer) or ‘FB1K’ (Vendor), thus avoiding double coding for the clearing itself. 
2. Key objects of SAPF124
  • The main internal table for item display is GT_DLIST;
  • Include F124_DETAIL_LIST will fill the item table and output by writing the list;
  • The key routine Routine for account data populating is ACC_APPEND_DATA;
  • Jigang_Zhang_1-1730792809630.png

  • Include F124_MERGE, which contains logic for selecting tables from the main table: BSID/BSIK/BSIS and further data consolidation.
  • Jigang_Zhang_2-1730793325066.png
3. Tips when customizing SAPF124

3.1 About table TF123(Additional Rules for Running Program SAPF124)

SAPF124 selects all accounts specified in the value sets with debit and credit postings according to customizing for SAP table TF123 via SAP transaction OB74. 

Jigang_Zhang_5-1730793815428.png

The defaulted Clearing Criteria/Rule for Additional Rules For Automatic Clearing are:

  • Criterion 1 = Technical Field ZUONR for Assignment Number.

  • Criterion 2 = Technical Field GSBER for Business Area.

  • Criterion 3 = Technical Field VBUND for Trading Partner. 

Be cautious that the criteria field from BEDG1 to BEDG5 has a limit of 30 characters. For example, trying to use Item Text (BSEG-SGTXT) as one of the criteria will lead to incorrect clearing because the SGTXT is 50 characters long.

Jigang_Zhang_6-1730794043992.png

Besides, the definition of the criteria field BEDGX only supports 24 characters long less than 30 of TF123!

Jigang_Zhang_7-1730795245410.png

To support longer fields like SGTXT as criteria then have to customize the following places for SAPF124 (better create Z one and its include program):

  1. Create a new Z table ZTF123 refer to TF123 and extend the length of BEDG fields from 30 to 50;
  2. Update the length for the definition of field BEDG from 24 to 50 at types like ys_xbsis/ ys_dlist/ xbsidgr/ xbsik, etc;
  3. Recalculate the position of criteria fields after the length extension, and update all related write-list routines like Record_document_neu/RECORD_DOCUMENT_LG. 

Check every place criteria field has been used including definition/populating/displaying. Dozens of places need to be adjusted after this length extension. May take some time but it will work.

Jigang_Zhang_8-1730796049046.png

3.2 About archived documents during clearing items

SAPF124 will encounter a termination popup (with Error F1 800-Clearing: Document & & & does not exist) while trying to post any archived documents and terminate the whole process.

Jigang_Zhang_1-1730796864987.png

We can use BSIS-XARCH as an archived indicator to separate from the normal FI documents.

Jigang_Zhang_0-1730796787881.png

Remember to add an XARCH check for all data fetching toward table BSID/BSIS/BSIK.

Related notes:

196118 - Automatic clearing with tolerance - SAPF124