Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BAPI VB, Column values mismatching in Table Parameter and Database value


I am trying to call a BAPI ZBAPI_EMP_INS_TBL, in which I pass a Table parameter with 2 columns and 2 rows.

The column names are EMPID and DOJ which are of Char (8) and Dats data type.

In my BAPI, I loop through the table which has been passed as a parameter and insert data into the Z-table.

The problem is that my program runs without error and insert data in the corresponding Z-table. But the column values are different in Z-table and the ones passed from VB.

For e.g. If I pass 12345678 as EMPID, In Database the value comes as 45678200.
Similarly for the DOJ field the value comes as “7 - -7112”.

Is there any check or methods to be called while passing a Table parameter?
Because if I call another BAPI to insert single record and the BAPI takes 2 parameters i.e. EMPID and DOJ, the program works fine.

Are there any checks to be made while passing the Table parameter?
Once I call the code from VB, is it possible to debug the code from ABAP side?



  wa_emp type z_emp_dtls,
loop at tbl_emp into wa_emp. "tbl_emp is passed from VB code as a table
insert into z_emp_dtls values wa_emp.
clear wa_emp.

VB code

Public Sub InsTable()
Dim obSapFn As Object
Dim obEmp As Object, obTblEmp As Object
Set obSapFn = CreateObject("SAP.Functions")

obSapFn.Connection.ApplicationServer = CNT_STR_APPLN_SRVR
obSapFn.Connection.SystemNumber = CNT_STR_SYS_NUM
obSapFn.Connection.User = CNT_STR_USR
obSapFn.Connection.Password = CNT_STR_PWD
obSapFn.Connection.Language = CNT_STR_LOGON_LANG
obSapFn.Connection.Client = CNT_STR_CLIENT
obSapFn.LogLevel = CNT_INT_LOG_LEVEL
obSapFn.LogFileName = CNT_STR_LOG_FILE

If obSapFn.Connection.Logon(0, True) = False Then
    MsgBox "R/3 connection failed"
    Exit Sub
End If

Set obEmp = obSapFn.Add("ZBAPI_EMP_INS_TBL")
Set obTblEmp = obEmp.Tables("TBL_EMP") ‘Table Parameter to be passed
‘Add rows to the table which is to be passed
obTblEmp.Value(obTblEmp.RowCount, "EMPID") = CStr("K1009008")
obTblEmp.Value(obTblEmp.RowCount, "DOJ") = Now

obTblEmp.Value(obTblEmp.RowCount, "EMPID") = CStr("M2009008")
obTblEmp.Value(obTblEmp.RowCount, "DOJ") = Now + 1
‘ Below section is to check the data types .
Dim oColumn As Object
For Each oColumn In obTblEmp.Columns
    'MsgBox oColumn.Name & "," & oColumn.TypeName
Next oColumn
‘ End

‘Verify the data before calling Fn.
Dim iCount As Integer, iLoop As Integer
iCount = obTblEmp.RowCount
For iLoop = 1 To iCount
    'MsgBox obTblEmp(iLoop, "EMPID") & " , " & obTblEmp(iLoop, "DOJ")

If obEmp.Call = False Then
    MsgBox "Error in calling fn "
End If

Set obTblEmp = Nothing
Set obEmp = Nothing
Set obSapFn = Nothing
End Sub

Former Member
Not what you were looking for? View more on this topic or Ask a question