cancel
Showing results for 
Search instead for 
Did you mean: 

Batchnumbers in goodsreceipt lines

AdKerremans
Active Contributor
0 Kudos
88

Hi,

If I use the code below I get a blank for my batchnumber.

I know for 100% sure that the batch is filled and If I look at my goodsreceipt the batchnumber is showing

Is this a bug in the DI or am I doing anything wrong

We run SBO004A pl32

Dim delivery As SAPbobsCOM.IDocuments = oCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)

If delivery.GetByKey(GetDocEntryForDocument(DocNum, SAPbobsCOM.BoObjectTypes.oDeliveryNotes)) Then

With delivery.Lines

For i As Integer = 0 To .Count - 1

.SetCurrentLine(i)

With .BatchNumbers

For j As Integer = 0 To .Count - 1

.SetCurrentLine(j)

Console.WriteLine(".BatchNumber: " + .BatchNumber)

(ors.Fields.Item(0).Value, itemcode)

Next

End With

Next

End With

End If

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

We do have such problems too, with both serials and batches. In some document-objects serials and batches are not in somehow, even if they should.

As already said, an SQL-query solves the problem.

I was hoping that it would be solved in 2004A as well..

Edit: At the moment, I use following code to get all batch numbers for a stock transfer line (assume to have such a fancy Hashmap in VB6 like me ;-):

Private Function HackGetBatchesForStockTransferLine( _
    objSTransfer As SAPbobsCOM.StockTransfer) As Hashmap
    
    Dim objRecSet As SAPbobsCOM.Recordset
    Set objRecSet = vCmp.GetBusinessObject(BoRecordset)
    objRecSet.DoQuery "SELECT BatchNum, Quantity FROM IBT1 WHERE " & _
        "(BaseType = 67) AND (BaseLinNum = " & _
        objSTransfer.lines.lineNum & ") AND (BaseEntry = " & _
        objSTransfer.DocEntry & " AND (Direction = 1))"

    If objRecSet.EOF Then
        Log LL_SEVERE, GetS(1330, _
        	objSTransfer.lines.lineNum & "|" & _
        	objSTransfer.docNum)
        Exit Function
    End If
    
    Dim map As Hashmap
    Set map = New Hashmap
    
    While Not objRecSet.EOF
        map.SetValue _
        	objRecSet.fields.Item(0).value, _
        	objRecSet.fields.Item(1).value
        objRecSet.MoveNext
    Wend
    
    Set HackGetBatchesForStockTransferLine = map
    
End Function

Of course, I know that I have only one stock transfer line in this document, this function covers only one special case, thats why it has the "Hack"-Prefix. Maybe someone can adopt it's idea to solve own problems.

Message was edited by: Florian Zeller

Former Member
0 Kudos

AFAIK, there's an "issue" or a "feature" with Batch and Serial Numbers. I deal the issue with the following Function:

	Public Function SBOGetDocLineBatchInfo(ByVal sboDoc As SAPbobsCOM.Documents, ByVal l As Integer)
		Dim r As Integer
		Dim s As String
		Dim s2 As String
		Dim strLineINI As String
		Dim strLine As String
		Dim strSQL As String

		strLineINI = INIRead(XPR.xprFilesINI.XMLXPRT_SPEX_INI, "LineInfo", "LineBatchInfo")

		strSQL = "SELECT T0.BatchNum, T1.Quantity, T0.ExpDate, T0.PrdDate,  T0.WhsCode, T0.Located, T1.WhsCode  FROM OIBT T0 INNER JOIN IBT1 T1 ON T1.ItemCode = T0.ItemCode  AND T1.BatchNum = T0.BatchNum  AND  T1.WhsCode = T0.WhsCode INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode WHERE (T2.ItemCode = N'_ItemCode_') AND (T1.BaseType = _BaseType_ ) AND (T1.BaseEntry = _BaseEntry_) AND (T1.BaseLinNum = _BaseLinNum_) AND T2.InvntItem = N'Y'  AND  T2.Canceled <> N'Y' "
		strSQL = Replace(strSQL, "_ItemCode_", sboDoc.Lines.ItemCode)
		strSQL = Replace(strSQL, "_BaseType_", sboDoc.DocObjectCode)
		strSQL = Replace(strSQL, "_BaseEntry_", sboDoc.DocEntry.ToString)
		strSQL = Replace(strSQL, "_BaseLinNum_", l.ToString)

		gsboRS.DoQuery(strSQL)
		If gsboRS.RecordCount >= 1 Then
			For r = 0 To gsboRS.RecordCount - 1
				strLine = strLineINI
				strLine = Replace(strLine, "_BatchNumber_", gsboRS.Fields.Item(0).Value)
				strLine = Replace(strLine, "_Quantity_", gsboRS.Fields.Item(1).Value)

				s2 = Format(gsboRS.Fields.Item(2).Value, "yyyy.MM.dd")
				If s2 = "1899.12.30" Then s2 = "-"
				strLine = Replace(strLine, "_ExpiryDate_", s2)

				s2 = Format(gsboRS.Fields.Item(3).Value, "yyyy.MM.dd")
				If s2 = "1899.12.30" Then s2 = "-"
				strLine = Replace(strLine, "_ManufactureDate_", s2)

				strLine = Replace(strLine, "_FromWHS_", gsboRS.Fields.Item(4).Value)
				strLine = Replace(strLine, "_FromLocation_", gsboRS.Fields.Item(5).Value)
				strLine = Replace(strLine, "_ToWHS_", gsboRS.Fields.Item(6).Value)
				strLine = Replace(strLine, "_CrLf_", vbCrLf)
				s = s & strLine
				gsboRS.MoveNext()
			Next
		End If
		Return (s)
	End Function

HTH

Juha

AdKerremans
Active Contributor
0 Kudos

Hi Juha,

I have posted this question to support and it looks like it is a bug in SBO 2004, they will check if it is solved in 2005.

Ad