BAPI to clear posting

作者:郑德鼎 约 5 分钟阅读 更新日期:2024-02-22 2 年前更新 标签:ABAP, 开发
目录

FB05 through FM, POSTING_INTERFACE_CLEARING

6350,204

Posting Clearing document through function module POSTING_INTERFACE_CLEARING

*** Header and line item diffrentiation

LCF_STYPE_K            TYPE  STYPE_PI           VALUE ‘K’, ” HEADER Line

LCF_STYPE_P            TYPE  STYPE_PI           VALUE ‘P’, ” Line Item

*** Populate and map FTCLEAR  to POSTING_INTERFACE_CLEARING

LDS_FTCLEAR–AGKOA  = ‘K’ or ‘D’ ( based on account type, Vendor or Customer for Out Going / Incoming Payments.

LDS_FTCLEAR–AGBUK  =  <company_code>.

LDS_FTCLEAR–XNOPS  = ‘X’.

LDS_FTCLEAR–SELFD  = <referece_document_number>

LDS_FTCLEAR–SELVON = <reference_field> ” SELFD is value of the filed assigned here.

APPEND LDS_FTCLEAR TO P_LDT_FTCLEAR.

*** FTPOST sample filling data

LDS_FTPOST–STYPE = P_LCF_STYPE.

LDS_FTPOST–COUNT = P_LDF_COUNT.

LDS_FTPOST–FNAM = P_LCF_FNAM.

LDS_FTPOST–FVAL = P_FVAL.

APPEND LDS_FTPOST TO P_LDT_FTPOST.

Call the below function modules in following order.

POSTING_INTERFACE_START

POSTING_INTERFACE_CLEARING

POSTING_INTERFACE_END

POSTING_INTERFACE_START

CALL FUNCTION ‘POSTING_INTERFACE_START’

EXPORTING

I_CLIENT           = SY–MANDT

I_FUNCTION         = ‘C’ ( Function: BDC, Call Trans. Using, internal interface)

I_MODE             = MODE ( N – no screen, A – all screen, E – Error –> Mode we use in Call transaction)

I_USER             = SY–UNAME

EXCEPTIONS

CLIENT_INCORRECT   = 1

FUNCTION_INVALID   = 2

GROUP_NAME_MISSING = 3

MODE_INVALID       = 4

UPDATE_INVALID     = 5

OTHERS             = 6.

IF SY–SUBRC <> 0.

MESSAGE ID SY–MSGID TYPE SY–MSGTY NUMBER SY–MSGNO

WITH SY–MSGV1 SY–MSGV2 SY–MSGV3 SY–MSGV4.

ENDIF.

POSTING_INTERFACE_CLEARING

CALL FUNCTION ‘POSTING_INTERFACE_CLEARING’

EXPORTING

I_AUGLV      =      ‘AUSGZAHL’ ” Follow below mentioned table

I_TCODE      =     ‘FB05’

I_SGFUNCT      =      ‘C’

IMPORTING

E_MSGID         =      LDS_RETURN–ID

E_MSGNO         =      LDS_RETURN–NUMBER

E_MSGTY         =      LDS_RETURN–TYPE

E_MSGV1         =      LDS_RETURN–MESSAGE_V1

E_MSGV2         =      LDS_RETURN–MESSAGE_V2

E_MSGV3         =      LDS_RETURN–MESSAGE_V3

E_MSGV4         =      LDS_RETURN–MESSAGE_V4

*             E_SUBRC        =      SY-SUBRC

TABLES

T_BLNTAB     =      LDT_BLNTAB

T_FTCLEAR    =      LDT_FTCLEAR

T_FTPOST     =      LDT_FTPOST

T_FTTAX      =      LDT_FTTAX

EXCEPTIONS

CLEARING_PROCEDURE_INVALID       = 1

CLEARING_PROCEDURE_MISSING       = 2

TABLE_T041A_EMPTY                = 3

TRANSACTION_CODE_INVALID         = 4

AMOUNT_FORMAT_ERROR              = 5

TOO_MANY_LINE_ITEMS              = 6

COMPANY_CODE_INVALID             = 7

SCREEN_NOT_FOUND                 = 8

NO_AUTHORIZATION                 = 9

OTHERS                           = 10.

Note the following

The data is marked with a record type (header, code = K; item, code = P) and counter. –  LCF_STYPE_K  and  LCF_STYPE_S

Up to 950 line items can be transferred.

The data is transferred with the field name and field value.

The data must be transferred in the following sequence

Document header data ( K 1)

Document item 1 ( P 1)

Document item 2 ( P 2)  etc.

The field names are the same as those used on the entry screen (e.g. ‘BKPF-WAERS’, ‘BSEG-WRBTR’, ‘COBL-GSBER’…).

Suppose if it Cost Center / Profit Center – its COBL-KOSTL and COBL-PRCTR

Posting key:        RF05A-NEWBS or BSEG-BSCHL

Account number:     RF05A-NEWKO or BSEG-KONTO

or BSEG-KUNNR (for customer accounts)

or BSEG-LIFNR (for vendor accounts)

or BSEG-HKONT (for G/L accounts)

Special G/L indicator: RF05A-NEWUM or BSEG-UMSKZ

Company code (for intercompany posting)

RF05A-NEWBK or BSEG-BUKRS.

The field names are analyzed by the function module so that the data can be assigned to the right screens. Field names for one-time data or data for an alternative payer must start with ‘BSEC-‘, for example (see screen SAPLFCPD 0100).

Processing with ‘Call Transaction … Using ‘

If processing takes place with ‘Call Transaction .. Using’, the initiator can see whether processing was successful by looking at the export parameter’SUBRC’.

SUBRC = 0 means that the document was posted. The document number is stored in table T_BLNTAB. For intercompany documents, several document numbers are stored here.

SUBRC <> 0 means that the document could not be posted. Information concerning the error which has arisen is returned via the message fields MSGID, MSGNO, etc.

Support of transaction ‘FBB1’

If you want to access transaction FBB1, you should note the following

Enter the foreign currency key in field BKPF-WAERS.

In this transaction you should enter the local currency amount in field BSEG-WRBTR for each document item.

POSTING_INTERFACE_END

CALL FUNCTION ‘POSTING_INTERFACE_END’

EXPORTING

I_BDCIMMED              = ‘X’

EXCEPTIONS

SESSION_NOT_PROCESSABLE = 1

OTHERS                  = 2.

FollowLikeRSS Feed

Alert Moderator

Assigned Tags

FIN (Finance)

clearing

code

document

fb05

payment

posting interface

View more...

Similar Blog Posts

How to activate Invoice Receipt Date in document header for any company

By Marek TurczynskiJun 16, 2020

Change financial document using function module FI_DOCUMENT_CHANGE

By Jonathan EemansJan 27, 2020

Extending BKPF Table by adding custom or ZZ Fields in SAP

By Divya MunnuruJun 18, 2018

Related Questions

Can FM POSTING_INTERFACE_CLEARING be used just for clearing?

By Likitha GopalApr 21, 2022

clear vendor down payment

By madjid khanevadegiDec 11, 2018

error F8 006 Transaction code FB1K is invalid in BAPI POSTING_INTERFACE_CLEARING

By KAPIL MEHTAFeb 14, 2018

6 Comments

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

Former Member

June 20, 2013 at 5:12 pm

Notes are very helpful.

Like 0

Share

Former Member

July 30, 2013 at 9:16 pm

Hello Ramkrishna,

This is very helpful. I am in the process of writing one such program where I am posting a few entries and clearing some open items at the same time. But, the requirement here is a little unique where the clearing is not based on just one field but based on two fields (BELNR and XREF3 ) with an AND condition between them. Is this even possible to do ?

If yes, can you please suggest me a way to do this ?

Thank you once again for the information you have posted here.

Like 0

Share

Former Member

Blog Post Author

July 31, 2013 at 2:23 am

Hi Santosh,

Don't think this is possible through FB05. The reason am saying this is we can have only one additional selection (its radio button).

Just to give a try, do the following

Alternatively, please use Assignment field. But before that your assignment filed should hold both BELNR + XREF3 values then you can use the field for selection. This is just an alternative, you can think of it.

And, Try to add two values to FTCLEAR internal table in FM and see whats happening. May you can simulate as sample code and try.

*** Populate and map FTCLEAR  to POSTING_INTERFACE_CLEARING

LDS_FTCLEAR-AGKOA  = 'K' or 'D'

LDS_FTCLEAR-AGBUK  =  <company_code>.

LDS_FTCLEAR-XNOPS  = 'X'.

LDS_FTCLEAR-SELFD  = 'BELNR'

LDS_FTCLEAR-SELVON = 'BELNR' value

APPEND LDS_FTCLEAR TO P_LDT_FTCLEAR.

LDS_FTCLEAR-AGKOA  = 'K' or 'D'

LDS_FTCLEAR-AGBUK  =  <company_code>.

LDS_FTCLEAR-XNOPS  = 'X'.

LDS_FTCLEAR-SELFD  = 'XREF3' " you may not have this filed in selection, use OTHERS.

LDS_FTCLEAR-SELVON = 'XREF3' value

APPEND LDS_FTCLEAR TO P_LDT_FTCLEAR.

Once you try this, leave the results here. It may be helpful for others; even me.

Thanks

Like 0

Share

Former Member

September 20, 2016 at 8:36 pm

There is an error.

I wonder why noone didn't catch it yet.

SELFD = Field Name from the Document Index

SELVON = Input Field for Search Criterion for Selecting Open Items.

Just need to swap these two values.

Like 0

Share

Himmel P

September 26, 2016 at 7:04 am

Hi All,

Using these FMs i am able to successfully post/clear the document against each open document. ( one clear document generated for one open document )

But my requirement is to create only one clear document against all open documents of the same customer .

Would some one help me in this case how to fill these FTPOST and FTCLEAR tables.

Appreciate your valuable inputs .

Thank you.

Like 0

Share

chedva Ankava

July 31, 2022 at 6:52 am

Hi,

I would like to use the POSTING_INTERFACE_CLEARING FM for  large amount of items to be cleared (over 950)

Is there a solution to this?

(besides split the posting and create multiple documents )

Thank you for your help,

Chedvi

Atif Mukhtar

April 21, 2020 14 minute read

Implementing Clearing Interface using POSTING_INTERFACE_CLEARING in s4 Hana 1709.

027,208

SAP has provided a clearing process using tcode FB05 which is not very user friendly in order to perform clearing a new module is created in SAP using provided interface for the convenience of users.

Create a screen using below interface

2.Upon save event call below subroutines in sequence.

3. Source code provided below

*&---------------------------------------------------------------------*

*& Include LZFIBRF01

*&---------------------------------------------------------------------*

*----------------------------------------------------------------------*

• INCLUDE TABLECONTROL_FORMS *

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Form USER_OK_TC *

*&---------------------------------------------------------------------*

FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM

P_TABLE_NAME

P_MARK_NAME

CHANGING P_OK LIKE SY-UCOMM.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

DATA: L_OK TYPE SY-UCOMM,

L_OFFSET TYPE I.

...

郑德鼎

关于作者:郑德鼎

企业信息化与 SAP 技术顾问,长期专注 SAP ABAP、FI/CO、MM、SD 等模块的技术分享与实战经验总结。查看更多介绍

来源说明:本文内容由「BAPI to clear posting.docx」整理生成,仅用于内部技术分享与学习交流。