Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

SAP VBA interfacing - error: FI/CO interface: Inconsistent FI/CO document header data for updating

$
0
0

Hello,

 

Currently I'm working with excel SAP interfacing. For this I am using VBA to call different BAPI functions.

I have already some interface scripts working, however I have also one which I cannot discover what I'm missing.

The VBA code is to reach BAPI_ACC_DOCUMENT_POST

 

My error is ---> FI/CO interface: Inconsistent FI/CO document header data for updating

 

So I'm appealing to you SAP bapi VBA gurus whether you have any ideas how to fix my issue.

 

I'm attaching below my code for you to review:

 

Option Explicit

' Declaration for the necessary objects

Dim objBAPICortrol, objConnection, objCreateMaterial, objReturn As Object

Dim objPRFCT, objNTXT, objDTXT As Object

Dim vLastRow, vRows As Integer

Dim objMaterial1, objMaterial2, retMess As Object

 

 

Sub Batch()

' Getting the last filled Row in Column

vLastRow = Cells(Rows.Count, "A").End(xlUp).Row

' Setting the necessary variables for R/3 connection

Set objBAPICortrol = CreateObject("SAP.functions")

Set objConnection = objBAPICortrol.Connection

objConnection.System = "SYSTEM NAME"

objConnection.Client = "Client number"

objConnection.user = "USERNAME"

objConnection.Password = "PASSWORD"

objConnection.Language = "EN"

' Establish a connection

If objConnection.logon(0, False) <> False Then

'MsgBox "Connection Established"

End If

On Error Resume Next

' Assign the Parameters

Set objCreateMaterial = objBAPICortrol.Add("BAPI_ACC_DOCUMENT_POST")

Set objMaterial = objCreateMaterial.Exports.Item("DOCUMENTHEADER")

Set objMaterial1 = objCreateMaterial.Tables.Item("ACCOUNTGL")

Set objMaterial2 = objCreateMaterial.Tables.Item("CURRENCYAMOUNT")

 

'Set Values

objMaterial.Value("USERNAME") = "USERNAME"

objMaterial.Value("HEADER_TXT") = "BAPITEST"

objMaterial.Value("COMP_CODE") = "0001"

objMaterial.Value("PSTNG_DATE") = "20140506"

objMaterial.Value("TRANS_DATE") = "20140506"

objMaterial.Value("DOC_DATE") = "20140506"

objMaterial.Value("FISC_YEAR") = "2014"

objMaterial.Value("DOC_TYPE") = "SA"

objMaterial.Value("REF_DOC_NO") = "BAPITEST"

objMaterial.Value("FIS_PERIOD") = "00"

 

 

objMaterial1.Rows.Add

objMaterial1.Value(1, "ITEMNO_ACC") = "1"

objMaterial1.Value(1, "GL_ACCOUNT") = "0007180000"

objMaterial1.Value(1, "ITEM_TEXT") = "BAPITEST1"

objMaterial1.Value(1, "DOC_TYPE") = "SA"

objMaterial1.Value(1, "COMP_CODE") = "0001"

objMaterial1.Value(1, "PROFIT_CTR") = "AZ1111" ---->'profit center is normally having 10CHARS but as there are letters I'm not using zeros at the beginning

 

 

objMaterial1.Value(1, "ITEMNO_ACC") = "2"

objMaterial1.Value(1, "GL_ACCOUNT") = "0007180000"

objMaterial1.Value(1, "ITEM_TEXT") = "BAPITEST1"

objMaterial1.Value(1, "DOC_TYPE") = "SA"

objMaterial1.Value(1, "COMP_CODE") = "0001"

objMaterial1.Value(1, "PROFIT_CTR") = "AZ1111"

 

 

objMaterial2.Rows.Add

objMaterial2.Value(1, "ITEMNO_ACC") = "1"

objMaterial2.Value(1, "CURRENCY") = "EUR"

objMaterial2.Value(1, "AMT_DOCCUR") = "-1.00"

 

 

objMaterial2.Value(1, "ITEMNO_ACC") = "2"

objMaterial2.Value(1, "CURRENCY") = "EUR"

objMaterial2.Value(1, "AMT_DOCCUR") = "1.00"

 

 

' Function call

objCreateMaterial.call

 

 

Set objReturn = objBAPICortrol.Add("BAPI_TRANSACTION_COMMIT")

objReturn.call

 

Set retMess = objCreateMaterial.Tables.Item("RETURN")

If retMess Is Nothing Then

MsgBox retMess.Value(1, "MESSAGE")

End If

 

 

' Get return parameters & display in excel

Set objReturn = objCreateMaterial.Tables("RETURN")

ActiveSheet.Cells(5, 1) = retMess.Value(2, "MESSAGE")

 

End Sub


Viewing all articles
Browse latest Browse all 3125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>