I have a problem in SAP B1 SDK,
Actually I can add employee in employee master data by using SDK like below codes
$oOrder=$mycomp->GetBusinessObject(171);
$oOrder->firstName="Schadrack";
$oOrder->lastName="Rurangwa";
$RetCode=$oOrder->Add;
But now I want to add absence line to the existing employee in SAP B1, how can I add absence or update the table (HEM1) of absence in SAP B1 SDK, I used PHP but I need sample even if it is vb
Please anyone can help me
Vb.net Sample from https://answers.sap.com/questions/3710838/insert-new-records-doesnt-work.html
Dim abs As SAPbobsCOM.EmployeeAbsenceInfo
Dim oei As SAPbobsCOM.EmployeesInfo
oei = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oEmployeesInfo)
abs = oei.AbsenceInfo
abs.Add()
abs.SetCurrentLine(1)
abs.EmployeeID = 2
abs.FromDate = "2008-01-01 12:00:00"
abs.ToDate = "2008-01-01 12:30:00"
abs.Add()
abs.SetCurrentLine(2)
abs.EmployeeID = 2
abs.FromDate = "2008-01-02 10:00:00"
abs.ToDate = "2008-01-02 11:00:00"
abs.Add()
Dim err_code As Integer
Dim err_msg As String
err_msg = ""
err_code = oei.Add()
If err_code <> 0 Then
oCompany.GetLastError(err_code, err_msg)
End If
Related
So I have this problem where I want to get DocEntry in OPCH table so I use the GetByKey(). The problem is that it works in all users except this particular user where GetByKey() returns false when I logged in to this specific user.
here is my code:
Sub SaveTransmit(ByVal tForm As SAPbouiCOM.Form)
Dim tMatrix As SAPbouiCOM.Matrix = Nothing
tMatrix = tForm.Items.Item("3").Specific
Dim MyDoc As SAPbobsCOM.Documents = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices)
Dim mtRow As Integer = tMatrix.RowCount
For xxxt As Integer = 1 To mtRow
tCheckE = tMatrix.Columns.Item("Col0").Cells.Item(xxxt).Specific
tCheckB = tMatrix.Columns.Item("Col1").Cells.Item(xxxt).Specific 'Checkbox
Dim koji As Boolean = tCheckB.Checked
If koji = True Then
If MyDoc.GetByKey(tCheckE.Value) Then
'some codes
End if
End if
Next
End Sub
I don't know if this is a bug in SAP B1 or I need to configure this specific user.
This sounds like some kind of permission issue. Validate license ( prof vs limited ), data owner or general authorization.
What is the name of field Absence Type of HEM1 table of SAP B1 in SDK?
I tried to use type and AbsenceType in SDK but I failed
Please anyone can help me
is reason the field you are interested in?
Dim abs As SAPbobsCOM.EmployeeAbsenceInfo
Dim oei As SAPbobsCOM.EmployeesInfo
Dim objCompany As SAPbobsCOM.Company = Application.SBO_Application.Company.GetDICompany
oei = objCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oEmployeesInfo)
abs = oei.AbsenceInfo
abs.Add()
abs.SetCurrentLine(1)
abs.EmployeeID = 2
abs.FromDate = "2008-01-01 12:00:00"
abs.ToDate = "2008-01-01 12:30:00"
abs.Reason = "Flu"
abs.Add()
abs.SetCurrentLine(2)
abs.EmployeeID = 2
abs.FromDate = "2008-01-02 10:00:00"
abs.ToDate = "2008-01-02 11:00:00"
abs.Add()
Dim err_code As Integer
Dim err_msg As String
err_msg = ""
err_code = oei.Add()
If err_code <> 0 Then
objCompany.GetLastError(err_code, err_msg)
End If
End Sub
The HEM1 table is linked to the PMC5 table that stores the Activity type. Look for the SAP Bobs object that caters to Activity types found in Administration -> Setup -> Project Management -> Activity Types.
The column name is ActType
SAPbobsCOM.Documents actTypes = SboConnection.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oActivityTypes);
I have a table customer in my sql server.
Columns
Distributer_Code
Cust_code
cust_name
cust_add
zip
tel
dl_number
gstin
we receive customer files from the distributor on a monthly basis.
so sometimes they send files with the wrong structuer.. like maybe gstin is missing or dl_number is missing or gstin is in place of dl_number and dl_number is in place of tel...basically, columns could be split..
when we upload those flat files with SSIS it gives error..and data doesn't get uploaded on the server if the structure is wrong.
I want to upload those data with null data if columns are missing or columns are misplaced.
Solution
Based on your comment, you are handling with flat files. To solve this problem, you have to read all columns as one column and retrieve the structure on the go.
Details
First add a Flat file connection manager.
In the flat file connection manager, go to the Advanced Tab, remove all columns and keep only one column (Column0).
Change the column type to DT_WSTR and the length to 4000.
Add a Dataflow task
Inside the Dataflow task add a Flat File source, a script component and an OLEDB destination.
Open the script component, go to Input/Output Tab and and add 8 output columns (Distributer_Code,Cust_code,cust_name,cust_add,zip,tel,dl_number,gstin)
Change the script language to Visual Basic.
Inside the script write the following code.
Dim Distributer_Code as integer = -1
Dim Cust_code as integer = -1
Dim cust_name as integer = -1
Dim cust_add as integer = -1
Dim zip as integer = -1
Dim tel as integer = -1
Dim dl_number as integer = -1
Dim gstin as integer = -1
Dim intRowIndex as integer = 0
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If intRowIndex = 0 then
Dim strfields() as string = Row.Column0.split(CChar("|"))
Dim idx as integer = 0
For idx = 0 To strFields.length - 1
Select case str
Case "Distributer_Code"
Distributer_Code = idx
Case "Cust_code"
Cust_code = idx
Case "cust_name"
cust_name = idx
Case "cust_add"
cust_add = idx
Case "zip"
zip = idx
Case "tel"
tel = idx
Case "dl_number"
dl_number = idx
Case "gstin"
gstin = idx
End Select
Next
Else
Dim strfields() as string = Row.Column0.split(CChar("|"))
If Distributer_Code > -1 Then Row.DistributerCode = strfields(Distributer_Code)
If Cust_code > -1 Then Row.Custcode = strfields(Cust_code)
If cust_name > -1 Then Row.custname = strfields(cust_name)
If cust_add > -1 Then Row.custadd = strfields(cust_add)
If zip > -1 Then Row.zip = strfields(zip)
If tel > -1 Then Row.tel = strfields(tel)
If dl_number > -1 Then Row.dlnumber = strfields(dl_number)
If gstin > -1 Then Row.gstin = strfields(gstin)
End If
intRowIndex += 1
End Sub
Map the output columns to the OLEDB Destination
I've a problem when I run simple add-on into SAP Business One. I've gotten this exception through this snippet of this code :
' After changing the item quantity
If (pVal.ItemUID = "mat") And (pVal.ColUID = "ActQuan") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_VALIDATE) Then
Dim oEditPrice As SAPbouiCOM.EditText ' Item Price
Dim oEditTDTotal As SAPbouiCOM.EditText ' To Date Total
Dim oEditTDQuan As SAPbouiCOM.EditText ' To Date Quan
Dim oEditCuttings As SAPbouiCOM.EditText ' Cuttings
Dim oEditTotal As SAPbouiCOM.EditText ' Total = TDTotal - Cuttings
Dim oEditActQuan As SAPbouiCOM.EditText
' Get the items from the matrix
oEditPrice = colItemPrice.Cells.Item(pVal.Row).Specific
oEditTDTotal = colItemTDTotal.Cells.Item(pVal.Row).Specific
oEditTDQuan = colItemTDQuan.Cells.Item(pVal.Row).Specific
oEditTotal = colItemACuttings.Cells.Item(pVal.Row).Specific
oEditCuttings = colItemCuttings.Cells.Item(pVal.Row).Specific
oEditActQuan = colItemActQuan.Cells.Item(pVal.Row).Specific
' Copy the value of TDQty
Dim tmpInt As Integer
tmpInt = CInt(oEditActQuan.Value)
oEditTDQuan.Value = CInt(tmpInt)
' Copy the value of TDTotal
Dim tmpIn As Integer
tmpIn = CInt(oEditTDQuan.Value) * CInt(oEditPrice.Value)
oEditTDTotal.Value = CInt(tmpIn)
'Calc Total Row - ACuts
Dim tmpTotal As Integer ' temp variable to contain total result
tmpTotal = CInt(oEditTDTotal.Value) - CInt(oEditCuttings.Value)
oEditTotal.Value = CInt(tmpTotal)
' Calc the document total
Dim CalcTotal As Double
Dim i As Integer
CalcTotal = 0
' Iterate all the matrix rows
For i = 1 To oMatrix.RowCount
oEditTotal = colItemACuttings.Cells.Item(i).Specific
CalcTotal += oEditTotal.Value
Next
oDocTotal.Value = CalcTotal
End If
End If
End If
I use VB.Net. I have an issue with ColUID = "ActQuan" . Can anyone help me ?
I changed this column many times and the same error.
Not the exact same thing, but in sap, we get this RPC_E_SERVERFAULT issue when sap scripting settings are not correct. The following changes worked for me:
Open transaction RZ11
Set the following to true:
sapgui/user_scripting
Set the following to false:
sapgui/nwbc_scripting
sapgui/user_scripting_disable_recording
sapgui/user_scripting_force_notification
sapgui/user_scripting_per_user
sapgui/user_scripting_set_readonly
Enable user side scripting.
More detailed documentation can be found here.
I'm executing Oracle procedure, which has three OUTPUT parameters and returns results in table type variable.
Here the limitations are, i should not use ODBC, MSDAORA providers to call the procedure. So I'm planning to using Oracle OLEDB provider.
I'm able to execute the procedure successfully, but when i do check (while dr.Read()) its not returning any records. But I know as per stored procedure results, it should return 66 records.
I doubt about my Vb.net code.... Please suggest something.. Thanks in advance.
Private Sub GetClients()
Dim cmd As New OracleCommand("PKG_HOBS.PRC_HOBS_GET_CLIENTID", FPP1_Connection)
cmd.CommandType = CommandType.StoredProcedure
Dim p1 As New OracleParameter(":obus_grp_id", OracleDbType.Int32, ParameterDirection.Output)
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p1.Size = 100 ' This is the size of items in array in THIS case
cmd.Parameters.Add(p1)
Dim p2 As New OracleParameter(":ostat_c", OracleDbType.Int32, ParameterDirection.Output)
p2.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p2.Size = 100 ' This is the size of items in array in THIS case
cmd.Parameters.Add(p2)
Dim p3 As New OracleParameter(":ostat_msg_x", OracleDbType.Varchar2, ParameterDirection.Output)
p3.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p3.Size = 100 ' This is the size of items in array in THIS case
p3.ArrayBindSize = Enumerable.Repeat(500, 100).ToArray
cmd.Parameters.Add(p3)
cmd.ExecuteNonQuery()
Dim oraNumbers1() As OracleDecimal = CType(p1.Value, OracleDecimal())
Dim myobus_grp_idValues(oraNumbers1.Length - 1) As Integer
For i As Integer = 0 To oraNumbers1.Length - 1
myobus_grp_idValues(i) = Convert.ToInt32(oraNumbers1(i).Value)
Next
Dim oraNumbers2() As OracleDecimal = CType(p2.Value, OracleDecimal())
Dim myostat_cValues(oraNumbers2.Length - 1) As Integer
For i As Integer = 0 To oraNumbers2.Length - 1
myostat_cValues(i) = Convert.ToInt32(oraNumbers2(i).Value)
Next
Dim oraStrings() As OracleString = CType(p3.Value, OracleString())
Dim myostat_msg_xValues(oraStrings.Length - 1) As String
For i As Integer = 0 To oraStrings.Length - 1
myostat_msg_xValues(i) = oraStrings(i).Value
Next
Try
MessageBox.Show(myobus_grp_idValues.ToString)
. . . . .
Package definition
TYPE Tnumber IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE Tmsg_500 IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
PROCEDURE prc_hobs_get_clientid (
obus_grp_id OUT Tnumber,
ostat_c OUT Tnumber,
ostat_msg_x OUT Tmsg_500);
First of all, don't use OleDb, period. Microsoft tells you to use vendor-specific provider. Use Oracle's ODP.NET.
Second, to retrieve recordset from Oracle SP, you need to return refCursor.
Edit: At this time we know that your parameters are tables. To process this you need to add p.CollectionType = OracleCollectionType.PLSQLAssociativeArray to your parameters
Your code is essentially this:
Declare
obus_grp_id PKG_HOBS.Tnumber; -- numeric table value
ostat_c PKG_HOBS.Tnumber; -- numeric table value
ostat_msg_x PKG_HOBS.Tmsg_500; -- string table value
BEGIN
PKG_HOBS.PRC_HOBS_GET_CLIENTID(obus_grp_id, ostat_c, ostat_msg_x);
END;
I see you executing anonymous block - you don't need to do this as this complicates things to you. What you need to do is use vb.net to execute package straight.
Bottom line: your current ORACLE code does nothing to output results to .NET. Remove anonymous block and you're in business.
Here is the code to process your type of procedure (read in comments)
Dim cmd As New OracleCommand("PKG_HOBS.PRC_HOBS_GET_CLIENTID", conn)
cmd.CommandType = CommandType.StoredProcedure
Dim p1 As New OracleParameter(":p1", OracleDbType.Int64, ParameterDirection.Output)
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p1.Size = 100 ' Declare more than you expect
' This line below is not needed for numeric types (date too???)
' p1.ArrayBindSize = New Integer(99) {}
cmd.Parameters.Add(p1)
' Add parameter 2 here - same as 1
Dim p3 As New OracleParameter(":p3", OracleDbType.Varchar2, ParameterDirection.Output)
p3.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p3.Size = 100 ' Declare more than you expect
' for string data types you need to allocate space for each element
p3.ArrayBindSize = Enumerable.Repeat(500, 100).ToArray() ' get 100 elements of 500 - size of returning string
' I don't know why you have problems referencing System.Linq but if you do...
'Dim intA() As Integer = New Integer(99) {}
'For i as integer = 0 to intA.Length -1
' intA(i) = 500
'Next
cmd.Parameters.Add(p3)
conn.Open()
cmd.ExecuteNonQuery()
' Ora number is not compatible to .net types. for example integer is something
' between number(9) and (10). So, if number(10) is the type - you get Long in
' return. Therefore use "Convert"
' Also, you return arrays, so you need to process them as arrays - NOTE CHANGES
Dim oraNumbers() As OracleDecimal = CType(p1.Value, OracleDecimal())
Dim myP1Values(oraNumbers.Length - 1) As Long
For i as Integer = 0 To oraNumbers.Length - 1
myP1Values(i) = Convert.ToInt64(oraNumbers(i).Value)
Next
oraNumbers = CType(p2.Value, OracleDecimal())
Dim myP2Values(oraNumbers.Length - 1) As Long
For i as Integer = 0 To oraNumbers.Length - 1
myP2Values(i) = Convert.ToInt64(oraNumbers(i).Value)
Next
Dim oraStrings() As OracleString= CType(p3.Value, OracleString())
Dim myP3Values(oraStrings.Length - 1) As String
For i as Integer = 0 To oraStrings.Length - 1
myP3Values(i) = oraStrings(i).Value
Next
And this is Most Important part
The most important part is how you fill your declared type. Lets take
TYPE Tnumber IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
v_num Tnumber;
v_num(1) := 1234567890;
v_num(2) := 2345678901;
v_num(3) := 3456789012;
This (above) will work. But this will fail:
v_num(0) := 1234567890;
v_num(1) := 2345678901;
v_num(2) := 3456789012;
And finally, this, will work with one condition
v_num(2) := 1234567890;
v_num(3) := 2345678901;
v_num(4) := 3456789012;
Here we will get 4 members in p1.Value but under index 0 you will have oracle null. So, you would need to deal with it here (if you have such condition)
' instead of this
myP2Values(i) = Convert.ToInt64(oraNumbers(i).Value)
' you will need first to check
If oraNumbers(i).IsNull Then
. . . .
So, the principal thing here is, WHAT is the index of your pl/sql table?! It needs to start from something larger than 0, and preferably from 1. And if you have index with skipped numbers, i.e. 2,4,6,8, all those spaces will be part of returning oracle array and there will be oracle null in them
Here is some reference