What is the name of field Absence Type of HEM1 table of SAP B1 in SDK? - sapb1

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);

Related

How to retrieve the Custom Text (Assignment) Field value based on a Custom Number value in MS Project VBA?

I can get to the values I am after by hardcoding, for example assignment.Text8 but can't get it to work when I create a variable and try to include it like: "if i = 8 then show me what is in assignment.Texti"
Could be a syntax thing but can't figure it out.
Sub TransferAsgnTextX_to_AsgnTCC_viaNumberedMeans()
Dim t As Task
Dim a As Assignment
Dim nr, i As Integer
i = 1
For Each t In ActiveProject.Tasks
nr = ActiveProject.Tasks(i).Number1
If nr > 0 Then
For Each a In t.Assignments
Select Case a.ResourceName
Case "Productivity"
a.Units = "a.Text" & nr
End Select
Next a
End If
i = i + 1
Next t
End Sub
Above code gives a run-time error 1101, but if I hardcoded say a.Units = a.Text8 then the code runs. But I want to find the custom text field based on the (separate) custom number.
The MS Project API doesn't have a good way to do what you are trying to do for Assignments (it does for Tasks and Resources), so I would recommend creating a function that you can call whenever you want to get the data:
Public Function GetAssignmentTextInfo(a As Assignment, fieldNumber As Integer) As String
If fieldNumber = 1 Then
GetAssignmentTextInfo = a.Text1
End If
If fieldNumber = 2 Then
GetAssignmentTextInfo = a.Text2
End If
If fieldNumber = 3 Then
GetAssignmentTextInfo = a.Text3
End If
If fieldNumber = 4 Then
GetAssignmentTextInfo = a.Text4
End If
'... so on through 30 (for the 30 text fields)
Now you could just call this in your code block:
Sub TransferAsgnTextX_to_AsgnTCC_viaNumberedMeans()
Dim t As Task
Dim a As Assignment
Dim nr, i As Integer
i = 1
For Each t In ActiveProject.Tasks
nr = ActiveProject.Tasks(i).Number1
If nr > 0 Then
For Each a In t.Assignments
Select Case a.ResourceName
Case "Productivity"
'call our function instead of hard coding
a.Units = GetAssignmentTextInfo(a, i) & nr
End Select
Next a
End If
i = i + 1
Next t
End Sub
As an added bonus to enhance the method, you could create an Enum called "FieldType" or something like that and include that as an argument in the GetAssignmentTextInfo function so it could retrieve data from other fields aside from just Text1-30.
Public Enum FieldType
Text = 1
Number = 2
Flag = 3
OutlineCode = 4
'etc...
End Enum
Public Function GetAssignmentInfo(a As Assignment, fieldNumber As Integer, fType As FieldType) As String
If fType = FieldType.Text Then
If fieldNumber = 1 Then
GetAssignmentTextInfo = a.Text1
End If
If fieldNumber = 2 Then
GetAssignmentTextInfo = a.Text2
End If
'... so on through 30 (for the 30 text fields)
End If
If fType = FieldType.Number Then
If fieldNumber = 1 Then
GetAssignmentTextInfo = CStr(a.Number1)
End If
If fieldNumber = 2 Then
GetAssignmentTextInfo = CStr(a.Number2)
End If
'... so on through 20 (for the 20 number fields)
End If
Stephen, if I follow what you are trying to do, you want to change the assignment units for the "Productivity" resource to whatever value is in the Task Number1 field. If so then just do that, i.e.
a.Units = nr
For the Assignment object, there is no way around getting properties other than accessing them directly. So the solution is to use a Select Case statement.
FWIW this would be much simpler if the values were stored at the task level as the Task object offers the GetField method that takes a field ID parameter and returns the variable field value. See I can't access columns in MS Project VSTO Add-In and Can FieldNameToFieldConstant be used with the TaskDependency Object for examples.

GetByKey() not working in some users in SAP B1

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.

How to update absence table of employee master data in SDK?

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

how to check column structure in ssis?

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

How to convert textbox year date value to check if it has only 2 digits?

The problem that I have is related to only being possible to insert 2 digit's on the field year and I was wondering if it was possible to have a string with a value 2017 and only inserting 17 when I press a button.
I have tried to use the CONTAINS property to check if it only has numbers, but now I'm kind of stuck.
You could use regex.
Private Function returnLastTwo(input As Integer) As Integer
Dim matchYearString As String = "(?:(\d\d)(?:(\d\d))?)"
Dim output As Integer
If CStr(input).Length = 4 Then
output = Text.RegularExpressions.Regex.Match(CStr(input), matchYearString).Groups(2).Value
ElseIf CStr(input).Length = 2 Then
output = Text.RegularExpressions.Regex.Match(CStr(input), matchYearString).Groups(1).Value
Else
Throw New Exception("Check input")
End If
Return output
End Function
You can use a string/substring concept;
Module DateSplit
Sub Main()
Dim literal As String = "2017"
Dim substring As String = literal.Substring(2)
Console.WriteLine("Substring: {0}", substring)
End Sub
End Module
I did not test this code but should output 17
Another approach would be casting your date as a string and create a char array, then you can have access to the element and convert them back to numbers if you like
Dim dateToSplit As Integer = 2017
Dim strDate As String = dateToSplit.ToString()
Dim charArr() AS Char = strDate.ToCharArray()
Assuming your user enters a date like this: 01/01/2017, into the textbox:
dim dateFromTextbox = yourTextbox.Text ' ==> 01/01/2017
dim lastTwoDigits = Right(dateFromTextbox, 2) ' ==> 17