No matching records found (ODBC -2028) in SAP DI Service Call - sapb1

When I try to make a new service call I get a No matching records found (ODBC -2028) here is my code:
Dim sC = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oServiceCalls)
sC.CustomerCode = recordSet.Fields.Item(2).Value Logging(sC.CustomerCode)
sC.Subject = recordSet.Fields.Item(3).Value
sC.Description = recordSet.Fields.Item(5).Value
sC.InternalSerialNum = recordSet.Fields.Item(11).Value
sC.ItemCode = recordSet.Fields.Item(11).Value
Dim ret = sC.Add()
If ret <> 0 Then company.GetLastError(ErrCode, ErrMsg)
Logging("Error in service call: " + ErrCode.ToString() + " : " + ErrMsg)
End If
Every value is valid. When I remove the InternalSerialNum line. it is working. The InetrnalSerialNum is valid too. And on the other machine, this code is working.
How can I solve that problem?

Related

VBA Function to connect to WHOIS server and return availability of a .com.au domain

I'm creating a template for a client who wishes to quickly check the availability of dozens of domains at a time. The template must remain as an excel file.
I've installed and used the SEOToolsForExcel which permitted me to query a server and check whether particular domains are available using the isdomainregistered() function. Unfortunately however, the function will always return 'true' (i.e. domain is taken) for all Australian ('.com.au') domains that are thrown at it. I've tried changing the TLD lookup in the xml config file as suggested in this page : http://seotoolsforexcel.com/how-to-setup-tlds-in-seotools-config-xml/
I tried with the following:
<Tld Name="au" WhoIsServer="whois.aunic.net" WhoIsNotFoundRegex="(no match)|(no data found)|(not found)|(no entries found)|(error for)|(invalid pattern)|(illegal question)" WhoIsCreatedRegex="" WhoIsUpdatedRegex="(?:Last Modified:\s*(\d{2}-[A-z]{3}-)\d{4})" WhoIsExpiresRegex="" WhoIsDelayMs="1000" />
and this one:
<Tld Name="au" WhoIsServer="whois-check.ausregistry.net.au" WhoIsNotFoundRegex="is free" WhoIsCreatedRegex="" WhoIsUpdatedRegex="" WhoIsExpiresRegex="" WhoIsDelayMs="1000" />
But neither seemed to have worked. I've checked with other services that clearly show that the domains are available, yet the SEOTool keeps returning false results (only on '.com.au' domains, '.com' domains work fine).
Thus, my next attempt is to code a custom function in excel to take the domain and send it through to the Ausregistry.com.au server's domain-availability tool.
Ausregistry explains how this can be done in their page here:http://www.ausregistry.com.au/tools/domain-availability
They explain:
The service will then respond with either the string 'Available' or 'Not Available' depending upon the availability of the Domain Name.
For Example
To check the availability of ausregistry.net.au follow these steps:
Connect to: Address: whois-check.ausregistry.net.au, Port: 43
Send the string `ausregistry.net.au\r\n' to the server
The server will respond with `Not Available' and then close the connection.
The above procedure is compatible with standard WHOIS protocol; hence any reseller interface that is built to use WHOIS will be able to use this system as well.
Alternatively, the standard *nix whois command can be used as follows:
whois -h
I've coded plenty in VBA before but I do not know how to implement this connection to the server and how to throw it the domain string and then read the result. I'd appreciate any information on how to achieve this using VBA.
Update. I solved this issue months ago and figured I would post my solution in case anyone stumbles across this. #Lumigraphics, thankfully I didn't have to learn PERL. I used the OstroSoft Winsock Component (you can get it here).
And the following UDF:
Function AusRegDomainAvailable(DomainUrl As String) As Boolean
Dim sPage As String
Dim sServer As String
Dim nPort As Long
Dim AusRegistryServer As String
Dim ReturningData As String
Dim wsTCP As OSWINSCK.Winsock
Dim FixedDomain As String
Dim Timelimit As Date
QueryTimeOut = False
FixedDomain = Replace(DomainUrl, "www.", "")
FixedDomain = Replace(FixedDomain, "http://", "")
FixedDomain = Replace(FixedDomain, "https://", "")
AusRegistryServer = "whois-check.ausregistry.net.au"
nPort = 43
sServer = Trim(AusRegistryServer)
If InStr(sServer, "://") > 0 Then sServer = Mid(sServer, InStr(sServer, "://") + 3)
If InStr(sServer, "/") > 0 Then
sPage = Mid(sServer, InStr(sServer, "/") + 1)
sServer = Left(sServer, InStr(sServer, "/") - 1)
End If
If InStr(sServer, ":") > 0 Then
nPort = Mid(sServer, InStr(sServer, ":") + 1)
sServer = Left(sServer, InStr(sServer, ":") - 1)
End If
If sServer = "" Then Err.Raise 12001, , "Invalid URL"
Set wsTCP = CreateObject("OSWINSCK.Winsock")
wsTCP.Connect sServer, nPort
Do Until wsTCP.State = 7
DoEvents
If wsTCP.State = sckError Then
Exit Function
End If
Loop
wsTCP.SendData FixedDomain & vbCrLf
Timelimit = (Now + TimeValue("0:00:02"))
Do Until wsTCP.Status = "Data Arrival" Or Now > Timelimit
DoEvents
If wsTCP.State = sckClosed Then
QueryTimeOut = True
Exit Function
End If
Loop
wsTCP.GetData ReturningData
ReturningData = Replace(ReturningData, vbLf, "")
ReturningData = Replace(ReturningData, vbCr, "")
ReturningData = Trim(ReturningData)
If ReturningData = "Available" Then
AusRegDomainAvailable = True
ElseIf ReturningData = "Not Available" Then
AusRegDomainAvailable = False
Else
QueryTimeOut = True
AusRegDomainAvailable = Null
End If
DoEvents
Debug.Print FixedDomain & " " & ReturningData
wsTCP.CloseWinsock
Exit Function
ErrHandler:
AusRegDomainAvailable = "Error " & Err.Number & ": " & Err.Description
End Function

FileInfo returning wrong value?

Okay, so I'm working in VB.NET, manually writing error logs to log files (yes, I know, I didn't make the call). Now, if the files are over an arbitrary size, when the function goes to write out the new error data, it should start a new file with a new file name.
Here's the function:
Dim listener As New Logging.FileLogTraceListener
listener.CustomLocation = System.Configuration.ConfigurationManager.AppSettings("LogDir")
Dim loc As String = DateTime.UtcNow.Year.ToString + DateTime.UtcNow.Month.ToString + DateTime.UtcNow.Day.ToString + DateTime.UtcNow.Hour.ToString + DateTime.UtcNow.Minute.ToString
listener.BaseFileName = loc
Dim logFolder As String
Dim source As String
logFolder = ConfigurationManager.AppSettings("LogDir")
If ex.Data.Item("Source") Is Nothing Then
source = ex.Source
Else
source = ex.Data.Item("Source").ToString
End If
Dim errorFileInfo As New FileInfo(listener.FullLogFileName)
Dim errorLengthInBytes As Long = errorFileInfo.Length
If (errorLengthInBytes > CType(System.Configuration.ConfigurationManager.AppSettings("maxFileSizeInBytes"), Long)) Then
listener.BaseFileName = listener.BaseFileName + "1"
End If
Dim msg As New System.Text.StringBuilder
If String.IsNullOrEmpty(logFolder) Then logFolder = ConfigurationManager.AppSettings("LogDir")
msg.Append(vbCrLf & "Exception" & vbCrLf)
msg.Append(vbTab & String.Concat("App: AppMonitor | Time: ", Date.Now.ToString) & vbCrLf)
msg.Append(vbTab & String.Concat("Source: ", source, " | Message: ", ex.Message) & vbCrLf)
msg.Append(vbTab & "Stack: " & ex.StackTrace & vbCrLf)
listener.Write(msg.ToString())
listener.Flush()
listener.Close()
I have this executing in a loop for testing purposes, so I can see what happens when it gets (say) 10000 errors in all at once. Again, I know there are better ways to handle this systemically, but this was the code I was told to implement.
How can I reliably get the size of the log file before writing to it, as I try to do above?
Well, as with many things, the answer to this turned out to be "did you read your own code closely" with a side order of "eat something, you need to fix your blood sugar."
On review, I saw that I was always checking BaseFileName and, if it was over the arbitrary limit, appending a character and writing to that file. What I didn't do was check to see if that file or, indeed, other more recent files existed. I've solved the issue be grabbing a directory list of all the files matching the "BaseFileName*" argument in Directory.GetFiles and selecting the most recently accessed one. That ensures that the logger will always select the more current file to write to or -if necessary- use as the base-name for another appended character.
Here's that code:
Dim directoryFiles() As String = Directory.GetFiles(listener.Location.ToString(), listener.BaseFileName + "*")
Dim targetFile As String = directoryFiles(0)
For j As Integer = 1 To directoryFiles.Count - 1 Step 1
Dim targetFileInfo As New FileInfo(targetFile)
Dim compareInfo As New FileInfo(directoryFiles(j))
If (targetFileInfo.LastAccessTimeUtc < compareInfo.LastAccessTimeUtc) Then
targetFile = directoryFiles(j)
End If
Next
Dim errorFileInfo As New FileInfo(listener.Location.ToString() + targetFile)
Dim errorLengthInBytes As Long = errorFileInfo.Length

Check if each line from a text file contains a certain string, and add the ones that do to a listbox?

The following code works, to simply get each line as a line in the listbox.
Reader = IO.File.OpenText(textlocation)
Dim bookmarks() As String = Reader.ReadToEnd.Split(vbNewLine)
Dim i As Integer = 0
Do Until i = bookmarks.Length
lstFavorites.Items.Add(bookmarks(i))
i += 1
Loop
But I don't want every line to go into the text box. I only want the lines that contain the text "Bookmark" to go into the listbox. What can I do to achieve this? I've tried everything I can think of.
Heres some code I tried, I can't see the problem in it, but it seems to just crash my program.
Do Until i = bookmarks.Length
If bookmarks(i).Contains("at") Then
If radBookmarks.Checked Then
If bookmarks(i).Contains("Bookmark") Then
Original = bookmarks(i)
BeginningOfDemoName = Original.Substring(Original.LastIndexOf("(") + 2)
TickWithParenthesis = BeginningOfDemoName.Substring(BeginningOfDemoName.IndexOf(Chr(34)) + 4)
Tick = TickWithParenthesis.Split(" ")(1).Split(")")(0)
DemoName = BeginningOfDemoName.Split(Chr(34))(0)
ToList = DemoName + " at " + Tick
lstFavorites.Items.Add(ToList)
i += 1
Else
i += 1
End If
ElseIf radEverything.Checked Then
Original = bookmarks(i)
BeginningOfDemoName = Original.Substring(Original.LastIndexOf("(") + 2)
TickWithParenthesis = BeginningOfDemoName.Substring(BeginningOfDemoName.IndexOf(Chr(34)) + 4)
Tick = TickWithParenthesis.Split(" ")(1).Split(")")(0)
DemoName = BeginningOfDemoName.Split(Chr(34))(0)
ToList = DemoName + " at " + Tick
lstFavorites.Items.Add(ToList)
i += 1
End If
End If
Loop
Try to change this line
If bookmarks(i).Contains("Bookmark") Then
to
If bookmarks(i).IndexOf("Bookmark",
StringComparison.CurrentCultureIgnoreCase) >= 0 Then
Contains do a case sensitive comparison and your input string contains a lower case 'bookmark'

get ip address from url

I am trying to get country location from the ip address which I am also looking up from actual url. However for certain urls I am getting the following error:
The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
I wanted to use the following code to identify the proxy perhaps but since this is a regular console app I am not sure how to get around it. Here is my code;
For Each prod In querylist
If myfetcher.getHtml(prod, userAgent, page) Then
' The lines below I use to find proxy ip
' but error name 'Request' not declared
' Dim nowip As String
' nowip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
' If nowip = "" Then
'nowip = Request.ServerVariables("REMOTE_ADDR")
'End If
'
If prod.Contains("http://") Then
prod = Regex.Replace(prod, "http://", "")
End If
badHost = prod
Dim ipEntry As IPHostEntry = Dns.GetHostByName(prod)
Dim IPAdd As IPAddress() = ipEntry.AddressList
Dim i As Integer = 0
For i = 0 To IPAdd.GetUpperBound(0)
number = number & "IP Address {0}:{1}" & IPAdd(i).ToString
Next
IPList.Add(prod & " " & number)
number = ""
Else
badList.Add(prod)
number = ""
End If
count = count + 1
Next
Here's a language agnostic way to do it:
do a HTTP GET for
domain2ip.net/:url
like
http://domain2ip.net/www.edresearch.co.jp
is
122.200.237.66
you can even to it from JavaScript
$.getJSON("http://domain2ip.net/google.com", callback);
Disclosure: it's my site, and open source.

Weird strange things happening in repository record!

SubSonic 2.2. I use the repository record pattern, with a table "appointment" with an appointmentId as auto-incrementing int.
I am trying to update it, but when I do update the fields with something totally different, dirty columns are always zero, and I get an exception.
System.NullReferenceException: Object reference not set to an instance of an object. at SubSonic.DataService.ExecuteQuery(QueryCommand cmd) at SubSonic.SubSonicRepository.Update[T](RepositoryRecord1 item, String userName) at janji.Janji.Data.DB.Update[T](RepositoryRecord1 item) in A:\Source\VS2008\Web\Apps\janji\janji\Classes\DAL\AllStructs.vb:line 197 at janji.WebForm4.SaveData() in A:\Source\VS2008\Web\Apps\janji\janji\UI\Appt.aspx.vb:line 343
Here's my code:
Try
If Appointment.AppointmentId > 0 Then
Appointment.AddressName = uxHotel.Text
Appointment.Address = uxAddress.Text
Appointment.AppStartTime = Date.Parse(uxApptDate.SelectedDate.Value.ToShortDateString + " " + uxApptStartTime.SelectedDate.Value.ToShortTimeString)
Appointment.ApptEndTime = Date.Parse(uxApptDate.SelectedDate.Value.ToShortDateString + " " + uxApptEndTime.SelectedDate.Value.ToShortTimeString)
Appointment.Completed = uxCOmpleted.Checked
Appointment.DropNumber = uxDropNum.Text
Appointment.Total = 0
Appointment.EmployeeId = 0
Appointment.Model = uxModel.Text
Appointment.DropAmount = Decimal.Parse(uxDropAmount.SelectedValue)
Appointment.RoomNumber = uxRoom.Text
'If Appointment.DirtyColumns.Count > 0 Then
Janji.Data.DB.Update(Of Janji.Data.Appointment)(Appointment)
'End If
End If
Catch ex As Exception
_ErrorMessage = ex.ToString
RetVal = False
lErrors.Text = _ErrorMessage
lErrors.Visible = True
End Try
You're using the Structs we provide instead of instantiating an Appointment object. Do everything you're doing here, but create an Appointment instance and assign it the values. Then pass that instance to the repo.