Posting Key (BSCHL) and debit/credit indicator (SHKZG) determination logic for IDOC type ACC_DOCUMENT03
Description:
When using the basic type ACC_DOCUMENT03, in order to pass the values of posting key and credit/debit indicator the respective fields are not available. This blog determines how these are being determined automatically and the steps to check those required fields.
Solution:
This can be handled even though we do not pass the credit debit indicator or posting key. The BAPI which we are using for the posting the FI document itself does this.
BAPI_IDOC_INPUT1 is the BAPI used for individual posting.
1. In segment E1BPACCR09 (Currency Item):
We need to pass the amount in AMT_DOCCUR field.
Figure 1: Segment E1BPACCR09 (Currency Item)
In the above segment pass the amount in field AMT_DOCCUR with ‘-’ negative sign for credit and for debit there is no need to attach ‘+’ sign.
Example
In the below snapshot the amount ‘349.9000-’ indicate that amount should be credited and the amount ‘284.4500’ indicate that amount should be debited.
Figure 2: Amount in Segment E1BPACCR09
2. Depending on amount the debit/credit indicator is fetched. The code for the same is written in FORM ‘PROCESS_ACCCR’.
As we know for debit/credit indicator there are two values which are fixed i.e. ’S’ and ‘H’.
S – Debit.
H – Credit.
If amount is greater than ‘0’ then field SHKZG (debit/credit indicator) will hold the ‘S’ Value which indicate debit and if amount is less than zero then field SHKZG (debit/credit indicator) will hold the ‘H’ Value which indicate Credit.
Below snapshot shows the code written in the form routine ‘PROCESS_ACCCR’.
Figure 3: Fetching Debit/Credit Indictor (SHKZG)
3. Once the debit/credit indicator is fetched, the account type should be fetched. Account type is fetched on the basis of parameter field in it_bapi_accit. The IDOC data it is split-ed into 4 internal tables as account_receivable, account_payable, account_gl and Account_tax. These internal tables are checked and then if the data is present in their respective fields then the parameter field is hard-coded with ACCOUNTRECEIVABLE, ACCOUNTPAYABLE, ACCOUNTGL, and ACCOUNTTAX respectively.
Below Snippet shows how the values are getting populated in field parameter. This code is written in form routine ‘FILL_BAPI_ACCIT’.
Figure 4: Filling parameter
Following are the account types which are present in SAP:
- A – Asset
- D – Customer
- K – Vendor
- M – Material
- S – General ledger
Depending on the values in gs_bapi_accit-parameter the account type is chosen.If gs_bapi_accit-parameter is holding value as ‘ACCOUNTGL’ then ‘S’ account type will be hard-coded.
Figure 5: Fetching Account type (KOART)
And for remaining parameters please check the below code which is written in form routine ‘FILL_ACCOUNTTYPE’.
Code:
CASE gs_bapi_accit-parameter.
WHEN ‘ACCOUNTRECEIVABLE’.
IF gs_accit–kunnr IS INITIAL AND
NOT gs_accit–hkont IS INITIAL.
gs_accit–koart = ‘S’.
gs_accit–taxit = ‘ ‘.
ELSE.
gs_accit–koart = ‘D’.
IF gs_bapi_accit–actv_account = ‘2’.
PERFORM koart_v_active(saplfaci) IF FOUND
USING gs_acchd–awtyp
CHANGING l_koart.
IF NOT l_koart IS INITIAL.
gs_accit–koart = l_koart.
ENDIF.
ENDIF.
gs_accit–taxit = ‘ ‘.
gs_accit–xfilkd = ‘X’.
PERFORM check_if_initial
USING gs_bapi_accit–parameter
gs_bapi_accit–tabix:
‘CUSTOMER ‘ gs_accit–kunnr.
IF gs_accit–shkzg = ‘H’ AND “note 1596139
gs_acchd–awtyp <> ‘LOANS’. “note 1596139
gs_accit–rebzg = ‘V’.
ENDIF.
ENDIF.
WHEN ‘ACCOUNTPAYABLE’.
IF gs_accit–lifnr IS INITIAL AND
NOT gs_accit–hkont IS INITIAL.
gs_accit–koart = ‘S’.
gs_accit–taxit = ‘ ‘.
ELSE.
gs_accit–koart = ‘K’.
gs_accit–taxit = ‘ ‘.
gs_accit–xfilkd = ‘X’.
IF gs_acchd–awtyp <> ‘BEBD’ AND
gs_acchd–awtyp <> ‘BERD’ AND
gs_acchd–awtyp <> ‘BERE’ AND
gs_acchd–awtyp <> ‘ENTD’.
PERFORM check_if_initial
USING gs_bapi_accit–parameter
gs_bapi_accit–tabix:
‘VENDOR_NO ‘ gs_accit–lifnr.
ENDIF.
IF gs_accit–shkzg = ‘S’ AND “note 1596139
gs_acchd–awtyp <> ‘LOANS’. “note 1596139
gs_accit–rebzg = ‘V’.
ENDIF.
ENDIF.
WHEN ‘ACCOUNTGL’.
IF gs_accit–koart IS INITIAL.
gs_accit–koart = ‘S’.
ENDIF.
gs_accit–taxit = ‘ ‘.
IF gs_accit–kstat IS INITIAL AND
gs_accit–koart = ‘S’. “Note 1503626
PERFORM check_if_initial
USING gs_bapi_accit–parameter
gs_bapi_accit–tabix:
‘GL_ACCOUNT’ gs_accit–hkont.
ENDIF.
WHEN ‘ACCOUNTTAX’.
PERFORM process_accit_tx
USING gs_bapi_accit–tabix.
WHEN OTHERS.
RAISE wrong_linetyp.
ENDCASE.
4. Based on the debit/credit indicator and account type the posting key is fetched.
Now in this case for account type i.e. KOART we are having value as ‘S’. i.e. GL. And in debit/credit indicator i.e. SHKZG. we are having value as ‘S’ then the posting key is fetched as 40 i.e. Debit.
Figure 6: Fetching Posting Key (BSCHL)
Summary:
- As there are no fields for passing the debit/credit indicator and posting key in IDOC ACC_DOCUMENT03 but this can be handled using the BAPI ‘BAPI_IDOC_INPUT1’, the only thing we need to take care of is ‘just pass the amount with negative sign if it should be credited’. Rest all things are handled by this standard BAPI as mentioned in above steps.
Hope this will help.
Hi Sneha ,
Thanks for this note. It is very helpful indeed.
I am also using the same basic type for conversion of Open AP item from ECC to S/4 system. But it is giving the below two errors . Could you please guide on this how to solve this.
Reference type =
Reference key =
Logical system =
Value field is not defined in the financial statements.
After debugging I got to know that the error is coming the below highlighted perform.( LIne no - 114 in BAPI_ACC_DOCUMENT_POST ).
It is related to segment E1BPACKEV9: Posting in accounting: CO-PA acct assignment value fields . In the code the comp_length = 0 always even if giving values in the segment E1BPACKEV9 .
Is it Mandatory to to give values to this segment while posting?
If you have any idea about this error please let me know .
Thanks & Regards,
Rajashree
If we want to post accounting document without reference to purchase order or sales order can we use same message type