cancel
Showing results for 
Search instead for 
Did you mean: 

EDI - Outbound Accounting Posting Journals to External System

Former Member
0 Kudos

Hi Experts,

I have a requirement in which I have to outbound

Accouting Journals to an external system...

Does standard SAP support such a functionality.

I looked at the outbound process code and was unable

to find anything on accounting. (which does make sense...) I also noticed that journal entry transactions such as FB01 do not have output controls like SD or MM.

Would I not be able to utilize standard idocs in this case?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

Hi Rolmega,

Please refer the OSS note 616804 .That is exactly matching your requirement and guide you through out the development.

OSS note 616804.

Create a BAPI which can be used to create cash journal documents.

To do this, carry out the steps specified below in your system, or import the relevant Support Package.

1. In Transaction SE37, select the menu option 'Goto' -> 'Function Groups' -> 'Create group'. Create function group SAPLFCJ_BAPI with the short text 'BAPI for FI cash journal' and save it.

2. In Transaction SE37, create function module BAPI_CASHJOURNALDOC_CREATE in function group SAPLFCJ_BAPI in package CAJO with the short text 'Save FI cash journal documents' as a remote-enabled module.

a) Create the following function module documentation for the function module:

With BAPI BAPI_CASHJOURNALDOC_CREATE, you can save a document when you execute in the FI cash journal, in the same way as when you make an entry via the Interface Transaction FBCJ.

If the TESTRUN field is set, the system only carries out the checks and not the actual backup process when the database is updated.

If you want to save a cash journal document, the program that calls the BAPI has to execute the COMMIT WORK to update the document.

A document can contain several split rows.

You can post either expenses or receipts for each document. In other words, either the ITEMS-P_PAYMENTS or the ITEMS-P_RECEIPTS field has to be filled in all line items.

If the document contains several line items or entries in the control table, assigned net or tax base amounts are deleted.

The initiator has to assign the item number (ITEMS-POSITION_NUMBER) for all line items or for none.

If the initiator assigns one-time data, the item numbers (CPD_ITEMS-POSITION_NUMBER) have to correspond to the respective line item (ITEMS-POSITION_NUMBER). The same item number may be used in one one-time line item only.

If the extended withholding tax is active in the company code used, you can create only one line item and no split document for vendors or customers that are relevant for withholding tax.

The vendor has to be filled for all assigned rows of the withholding tax information (table WTAX_ITEMS).

If withholding tax information is to be assigned, the indicator for withholding tax type (WTAX_ITEMS-WTAXTYPE) has to be filled with a value that is defined in the vendor master record. In addition, the same indicator for the withholding tax type may be assigned in one line of the ITEMS table only. The system does not take into account the external item number for withholding tax information.

In the TAX_ITEMS table, the same tax code may be assigned in only one line.

If there are entries in the TAX_ITEMS table, every tax code or jurisdiction code of this table has to be assigned in at least one line of the ITEMS table or be able to be derived from the Customizing for the business transaction.

If, in Customizing, there are accounts and tax codes for interface transactions that are flagged as not ready for input, then the BAPI derives values that are transferred in the ITEMS table again and overwrites them if necessary.

A check recognizes that field HEADER-CHECK_NUMBER is filled when the BAPI is called.

You cannot use the BAPI to save a document in a cash journal if this cash journal is simultaneously blocked by another interface user or another BAPI initiator. When you execute the BAPI, the system also sets a block for other users.

The initiator of the BAPI can transfer additional field values via the EXTENSION_IN table and can process them further in a BADI called in the customer_function subroutine.

You cannot change saved documents or deposit checks.

a) Enter the following import parameters:

Parameter Name Type Associated Type Opt Pass Value Short text

HEADER LIKE BAPI_CJ_HEADER X Document header

Long text:

In the HEADER structure, you can assign the document header information of the cash journal document to be saved. Basically, the structure corresponds to the fields of the TCJ_DOCUMENTS table that are ready for input on the cash journal interface and which contain header information only.

TESTRUN LIKE BAPI2021_HELP X X Indicator for test run

TESTRUN without update

Long text:

If the TESTRUN field is set, the external structures transferred when the BAPI is called are assigned to the internal cash journal structures. The relevant checks are also carried out. However, no update occurs to save the document on the database.

b) Enter the following export parameters:

Parameter Name Type Associated Type Pass Value Short text

COMPANY_CODE LIKE BAPI_CJ_HEADER X Company code

-COMP_CODE

Long text:

The COMPANY_CODE parameter contains the company code of the saved cash journal document.

CASH_JOURNAL_NUMBER LIKE BAPI_CJ_HEADER Cash journal number

-CAJO_NUBMER

Long text:

The CASH_JOURNAL_NUMBER parameter contains the cash journal of the saved cash journal document.

FISCAL_YEAR LIKE BAPI_CJ_KEY X Fiscal year

-FISC_YEAR

Long text:

The FISCAL_YEAR parameter contains the fiscal year of the saved cash journal document, but it is only filled for check totals documents.

CASH_JOURNAL_DOC_NO LIKE BAPI_CJ_KEY X Document number

-POSTING_NUMBER cash journal document

Long text:

The CASH_JOURNAL_DOC_NO parameter contains the internal document number of the saved cash journal document.

c) Enter the following table parameters:

Parameter Name Type Associated Type Optional Short text

ITEMS LIKE BAPI_CJ_ITEMS Cash journal documentitems

Long text:

In the ITEMS table, you can assign the information for the line items of the cash journal document to be saved. Basically, the spaces in the table fields correspond to the fields of the TCJ_POSITIONS table that are ready for input on the cash journal interface and which contain item information only. You can assign several line items per document, in the same way as for the split lines that can be entered via the interface transaction.

TAX_ITMES LIKE BAPI_CJ_TAX_ITEMS X Cash journal tax items

Long text:

In the TAX_ITEMS table, you can assign tax information for the cash journal document to be saved. In this way, you can for example affect tax amounts derived from the system, in the same way as tax information is changed on the split window of the interface transaction.

CPD_ITEMS LIKE BAPI_CJ_CPD_ITEMS X One-time data

Long text:

In the CPD_ITEMS table, you can assign information for one-time customers or vendors that are contained in line items of the ITEMS table. Basically, the table fields correspond to the fields of the TCJ_CPD table, which are ready for input on the one-time window.

WTAX_ITEMS LIKE BAPI_CJ_WTAX_ITEMS X Withholding tax in the

cash journal document

Long text:

In the WTAX_ITEMS table, you can assign information on the extended withholding tax for a vendor that is contained in a line item of the CJ_ITEMS table. Basically, the table fields correspond to the fields of the TCJ_WTAX_ITEMS table, which can be changed the withholding tax window.

EXTENSION_IN LIKE BAPIPAREX X Container for

'Customer Exit'

Long text:

In the EXTENSION_IN parameter, you can transfer parameters that can be processed further in the BADI CJ_DOCUMENT, which the user of the BAPI BAPI_CASH_JOURNAL_CREATE has to implement.

For example, you can assign data to the TCJ_POSITIONS table in the form of Include CI_COBL or information profitability segments or real estate.

RETURN LIKE BAPIRET2 Return parameter

Long text:

In Table RETURN, the messages of the program are returned to the initiator of the BAPI.

d) Save and activate the changes.

1. Using Transaction SE11, create data type (structure) BAPI_CJ_HEADER in Package CAJO with the short description 'Cash journal document header for transfer to a BAPI'.

a) Via the 'Extras' menu option, select 'Cannot Be Enhanced' as the enhancement category.

b) Create the following fields:

Field Data element

COMP_CODE BUKRS

CAJO_NUMBER CJNR

CURRENCY WAERS

CURRENCY_ISO WAERS_ISO

DOC_DATE BLDAT

PSTNG_DATE BUDAT

REF_DOC_NO XBLNR1

BP_NAME CJBPNAME

ALLOC_NMBR DZUONR

TEXT1 CJDOCTEXT100

TEXT2 CJDOCTEXT30

CHECK_NUMBER SCKNR_EB

CHECK_ISSUER CJCHECKISSUER

BANK_KEY BANKK

BANK_ACCT BANKN

BANK_CTRY BANKS

BANK_CTRY BANKS

BANK_CTRY_ISO BANKS_ISO

SCBANK_IND LZBKZ

SUPCOUNTRY LANDL

SUPCOUNTRY_ISO LANDL_ISO

c) Save and activate the changes.

2. In Transaction SE11, create data type (structure) BAPI_CJ_ITEMS in Package CAJO with the short description 'Cash journal line item for transfer to a BAPI'.

a) Via the 'Extras' menu option, select 'Cannot Be Enhanced' as enhancement category.

b) Create the following fields:

Field Data element

POSITION_NUMBER CJBUZEI

TRANSACT_NUMBER CJTRANSNUMB

P_RECEIPTS BAPIWRBTR

P_PAYMENTS BAPIWRBTR

P_NET_AMOUNT BAPIWRBTR

H_NET_PAYMENT_WT BAPIWRBTR

GL_ACCOUNT HKONT

TAX_CODE MWSKZ

TAXJURCODE TXJCD

VENDOR_NO LIFNR

CUSTOMER KUNNR

POSITION_TEXT CJPOSTEXT

BUS_AREA GSBER

TR_PART_BA PARGB

TRADE_ID RASSC

CS_TRANS_T RMVCT

FUNC_AREA FKBER

CO_AREA KOKRS

COSTCENTER KOSTL

ACTTYPE LSTAR

ORDERID AUFNR

ORDER_ITNO CO_POSNR

CALC_MOTIVE BEMOT

COSTOBJECT KSTRG

CO_BUSPROC CO_PRZNR

PROFIT_CTR PRCTR

PART_PRCTR PPRCTR

WBS_ELEM PS_POSID

NETWORK NPLNR

ACTIVITY VORNR

ASSETMAINO BF_ANLN1

ASSETSUBNO BF_ANLN2

VALUEDATE BF_BZDAT

ASSETTRTYP BF_ANBWA

PLANT WERKS_D

VAL_TYPE BWTAR_D

MATERIAL MATNR

SALES_ORD KDAUF

SCHED_LINE KDEIN

S_ORD_ITEM KDPOS

FM_AREA FIKRS

FUNDS_CTR FISTL

CMMT_ITEM FIPOS

FUND BP_GEBER

FUNDS_RES KBLNR_FI

RES_ITEM KBLPOS

PERSON_NO PERNR_D

BUPLA BUPLA

SECCO SECCO

c) Save and activate the changes.

3. In Transaction SE11, create the data type (structure) BAPI_CJ_TAX_ITEMS in Package CAJO with the short description 'One-time data of cash journal line items for transfer to a BAPI'.

a) Via the 'Extras' menu option, select 'Cannot Be Enhanced' as the enhancement category.

b) Create the following fields:

Field Data element

TAX_CODE MWSKZ

AMT_TAX BAPITXBTR

AMT_BASE BAPIFWBAS

TAXJURCODE TXJCD

c) Save and activate the changes.

4. In Transaction SE11, create the data type (structure) BAPI_CJ_CPD_ITEMS in Package CAJO with the short description 'One-time data of cash journal line items for transfer to a BAPI'.

a) Via the 'Extras' menu option, select 'Cannot Be Enhanced' as the enhancement category

b) Create the following fields:

Field Data element

POSITION_NUMBER CJBUZEI

ANRED ANRED

NAME NAME1_GP

NAME_2 NAME2_GP

NAME_3 NAME3_GP

NAME_4 NAME4_GP

SOLE_PROP STKZN

REP_NAME REPRES

STREET STRAS_GP

POSTL_CODE PSTLZ

CITY ORT01_GP

COUNTRY LAND1_GP

COUNTRY_ISO LAND1_ISO

PO_BOX PFACH

POBX_PCD PSTL2

REGION REGIO

POBK_CURAC PSKTO

BANK_ACCT BANKN

BANK_NO BANKL

BANK_CTRY BANKS

BANK_CTRY_ISO BANKS_ISO

CTRL_KEY BKONT

BANK_REF BKREF

INSTR_KEY DTAWS

DME_IND DTAMS

TAX_NO_1 STCD1

TAX_NO_2 STCD2

TAX_NO_3 STCD3

TAX_NO_4 STCD4

SLS_PUR_TX STKZU

FITYP J_1AFITP_D

TAX_NO_TY J_1ATOID

EQUAL_TAX STKZA

SPRAS CHAR_LG_01

LANGU_ISO LAISO

BUS_TYPE GESTYP

IND_TYPE INDTYP

c) Save and activate your changes.

5. In Transaction SE11, create the data type (structure) BAPI_CJ_WTAX_ITEMS in Package CAJO with the short description 'Withholding tax in cash journal document for transfer to a BAPI'.

a) Via the 'Extras' menu option, select 'Cannot Be Enhanced' as the enhancement category.

b) Create the following fields:

Field Data element

POSITION_NUMBER CJBUZEI

VENDOR_NO LIFNR

WTAXTYPE WITHT

WT_WITHCD WT_WITHCD

W_TAX_BASE BAPIQSSHB

WI_TAX_AMT BAPIQBSHB

c) Save and activate the changes.

6. In Transaction SE11, create the data type (structure) BAPI_CJ_KEY in Package CAJO with the short description 'Key fields for cash journal documents'.

a) Via the 'Extras' menu option, select 'Cannot Be Enhanced' as the enhancement category.

b) Create the following fields:

Field Data element

FISC_YEAR GJAHR

POSTING_NUMBER CJBELNR

c) Save and activate the changes.

7. Using Transaction SE91, create the following messages for message class FCJ and select the 'Self-explanatory' field for each one:

a) 011: 'Document & & & was saved successfully.'

b) 012: 'Enter a gross amount.'

c) 013: 'Enter only the disbursement or incoming payment amount for each document.

d) 014: 'Enter the item numbers for all items or for none of them.'

e) 015: 'The number of tax items may not be larger than the number of items.'

f) 016: 'Only one tax item allowed per tax code/jurisdiction code.'

g) 017: 'Enter the item number for one-time items.'

h) 018: 'With several line items (split), do not enter any withholding tax items.'

i) 019: 'Business transaction without G/L account or tax code.'

j) 020: 'No line item with tax code/jurisdiction code of the tax item.'

k) 021: 'In company code & taxes without jurisdiction code.'

l) 022: 'Do not enter any tax item for posting indicator '3' (T007B-STBKZ)'

m) 023: 'Document could not be saved. Correct the errors listed'

n) 024: 'Business place + section code only with extended withholding tax.

o) 025: 'Net/tax base is deleted for several items or tax items'

p) 026: 'No line item corresponds to one-time item &.'

q) 027: 'Do not enter any withholding tax info if customer not w.tax-relevant'

r) 028: 'Do not enter any withholding tax info if vendor not w.tax-relevant'

s) 029: 'Do not enter any withholding tax info for G/L account posting.'

t) 030: 'Vendor in withholding tax information is not in line item.'

u) 031: 'Only one one-time item is allowed per item number.'

v) 032: 'Only one withholding tax item is allowed per withholding tax type.'

w) 033: 'Number of assigned withholding tax items deviates from master data.'

x) 034: 'No vendor required for business transaction.

y) 035: 'No customer required for business transaction.'

z) 036: 'Enter only receipts for checks.'

8. In Transaction SE37, call the FCJ_SAVE and FCJ_SAVE_DOCUMENT function modules in change mode.

a) Add import parameter I_XBAPI of TYPE BOOLEAN to these function modules. Select the Optional and Pass Value fields and enter the short text 'Indicator whether the call occurs from a BAPI'.

b) Also add the import parameters I_POSTING_NUMBER, LIKE, ISCJ_POSTINGS-POSTING_NUMBER for the function module FCJ_SAVE_DOCUMENT. Select the Optional and Pass Value fields.

c) Save and activate the changes.

9. In Transaction SE37, create the function module FCJ_SAVE_DOCUMENT_BALANCE_BAPI in the function group SAPLFCJ_PROCESS_MANAGER in Package CAJO with the short text 'Save cash journal document and balances for BAPI' as an update module with 'Start immed'.

a) Enter the following import parameters:

Parameter Name Type Associated Type Opt Pass Value

I_COMP_CODE LIKE TCJ_C_JOURNALS-COMP_CODE X

I_CAJO_NUMBER LIKE TCJ_C_JOURNALS-CAJO_NUMBER X

I_CURRENCY LIKE TCJ_DOCUMENTS-CURRENCY X

I_TYP TYPE CJTRANSTYP X

I_DISPLAY_PERIOD_LO LIKE SY-DATUM X

I_DISPLAY_PERIOD_HI LIKE SY-DATUM X

I_POSTING LIKE ISCJ_POSTINGS X

I_POSTING_NUMBER LIKE ISCJ_POSTINGS-POSTING_NUMBER X

b) Enter the following tables:

Parameter Name Type Associated Type

ITCJ_POSTINGS LIKE ISCJ_POSTINGS

ITCJ_WTAX_ITEMS LIKE TCJ_WTAX_ITEMS

ITCJ_SPLIT_POSTINGS LIKE ISCJ_POSTINGS

ITCJ_CPD LIKE TCJ_CPD

10. In Transaction SE18, define the BADI CJ_DOCUMENT. The corresponding interface is IF_EX_CJ_DOCUMENT.

The method has the following 'Changing' parameter: Parameter Type Associated Type

C_ITCJ_SPLIT_POSTINGS Type ISCJ_POSTINGS

C_ITCJ_SPLIT_TAXES Type ISCJ_POSTINGS

C_ITCJ_CPD Type TCJ_CPD

C_ITCJ_WTAX_ITEMS Type TCJ_WTAX_ITEMS

C_EXTENSION2 Type BAPIPAREX

C_RETURN Type BAPIRET2

You can use an implementation of this BADI to change the cash journal structures before the data check is processed.

1. Implement the attached corrections in your system.

2. In Transaction SE37, release the function module BAPI_CASHJORUNAL_DOC_CREATE via the menu path 'Function module' -> 'Release' -> 'Release'.

3. In Transaction SWO1, create the object type BUS2023.

a) Create the following key fields for the object type:

Key field Name Data type reference

CompanyCode Company Code TCJ_DOCUMENTS

-COMP_CODE

CashJournalNumber Cash Journal Number TCJ_DOCUMENTS

-CAJO_NUMBER

FiscalYear Fiscal Year TCJ_DOCUMENTS

-FISC_YEAR

CashJournalDocNo Cash Journal TCJ_DOCUMENTS

Document Number -POSTING_NUMBER

b) Create the 'Create' method synchronously and instance-independent as an 'API function' with the name BAPI_CASHJOURNALDOC_CREATE.

Create the following parameters for the method: Parameter Obj Type Imp. Man. Exp.

Header BUS2023 X X

Testrun BUS2023 X

CompanyCode BUS2023 X

CashJournalNumber BUS2023 X

FiscalYear BUS2023 X

CashJournalDocNo BUS2023 X

Items BUS2023 X X

TaxItems BUS2023 X

CPDItems BUS2023 X

WTaxItems BUS2023 X

ExtensionIn BUS2023 X

Return BUS2023 X

a) Create the 'ExistenceCheck' method synchronously and define the following source code:

begin_method existencecheck changing container.

DATA: l_mandt TYPE sy-mandt.

SELECT SINGLE mandt INTO l_mandt

FROM tcj_documents

WHERE comp_code = object-key-companycode

AND cajo_number = object-key-cashjournalnumber

AND fisc_year = space

AND posting_number = object-key-cashjournaldocno.

check sy-subrc <> 0.

exit_object_not_found.

end_method.

a) Under the menu option 'Goto' -> 'Documentation', define the following text for object type BUS2023:

A cash journal document is assigned to a cash journal and a company code.

It contains a unique document number from a company code-dependent number range interval that is independent of the number range interval of the G/L document. Cash journal documents are also numbered sequentially per company code and cash journal.

A cash journal document contains the offsetting entries for the G/L account of the cash journal in which G/L or person accounts are posted to for the business transaction.

You can save, delete, post or reverse a cash journal document. In the two last cases, there is a corresponding G/L document. This can be a receipt, a disbursement of cash, or the receipt of checks.

1. In Transaction BDBG, set up the IDOC processing for the object type BUS2023 and the method CREATE.

The function module for ALE outbound processing with data refining is ALE_CASHJOURNALDOC_CREATE.

The function module for ALE inbound processing is called IDOC_INPUT_CAJODOC_CREATE.

1. In Transaction 'SALE', maintain the ALE distribution. Here, maintain the steps generally required for a distribution process. Take into account the existing documentation of the operation. Execute the following steps for the BAPI used to save cash journal documents.

a) Maintain the distribution model under the path 'Model and Implement Business Processes' -> 'Maintain Distribution Model and Distribute Views'. The object name is 'CashJournalDoc' and the method name is 'Create'.

b) Execute the menu option 'Edit' -> 'Model view' -> 'Distribute' for the selected model view.

c) Select the path 'Model and Implement Business Processes' -> 'Partner Profiles and Time of Processing' -> 'Generate Partner Profiles'. (See corresponding documentation in document OALE_AUTOPARTN_BD82.) Enter the selected model view in the distribution model and the selected target system as the partner system.

2. To monitor the distribution of the IDOCs, use Transaction BD87 in both the sender system and the receiver system, and you can reach it via the path 'Tools' -> 'ALE' -> 'ALE Administration' -> 'Monitor' -> 'Status Monitor'. The relevant message type is CASHJOURNALDOC_CREATE.

Former Member
0 Kudos

Hi Karun,

Thanks for the valuable information. I am currently setting it up.

I am have setup up the bapi, business object, etc. confirmed that all the settings are correct.

I am wondering how to trigger the bapi from the standard program. I am sure the business object should take care of it. But I am struggling to find how to activate the business object so that it is called from standard.

Any advice or help is greatly appreciated.

Thanks once again.