Skip to Content
author's profile photo Former Member
Former Member

Unable to obtain batchnumber information

Hello,

I'm trying to read the batch numbers corresponding to an existing delivery note in SBO2005 SP1 PL11 with this code:

If vDLN.Lines.BatchNumbers.Count > 0 Then
   For linbatch As Integer = 1 To vDLN.Lines.BatchNumbers.Count()
      If linbatch > 1 Then
          vDLN.Lines.BatchNumbers.SetCurrentLine(linbatch - 1)
      End If
      wFECCAD=vDLN.Lines.BatchNumbers.ExpiryDate, "yyyyMMdd")
      LOTE=vDLN.Lines.BatchNumbers.BatchNumber
      CENV=vDLN.Lines.BatchNumbers.Quantity
      ....
   Next
end If

But my code allways return ExpiryDate = #12/30/1899#, BatchNumber='' and Quantity=0.

I also try to use this other alternative with the same result:

Dim oBatchNumbers As SAPbobsCOM.BatchNumbers = vDLN.Lines.BatchNumbers
....
wFECCAD=oBatchNumbers.ExpiryDate, "yyyyMMdd")
LOTE=oBatchNumbers.BatchNumber
CENV=oBatchNumbers.Quantity
....

Thank you

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Oct 09, 2006 at 12:02 PM

    Hi Blas,

    I know this was the behaviour in 2004 and I think it is also the behaviour in 2005.

    It is regarded an error, but wil not be solved quickly.

    Regards

    Ad

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Here's my workaround.

      My requirement:

      - For each DocumentLine I want to have information about the batches

      - Sometimes the batch information sits on the base document line

      Eg. a batch info for a line that has 20 pcs as quantity:

      [BATCH#: BA116 Q: 1 ED: - MD: - FROM: 01 TO: 01 ]

      [BATCH#: BA117 Q: 2 ED: - MD: - FROM: 01 TO: 01 ]

      [BATCH#: BA118 Q: 3 ED: - MD: - FROM: 01 TO: 01 ]

      [BATCH#: BA119 Q: 4 ED: - MD: - FROM: 01 TO: 01 ]

      [BATCH#: BA120 Q: 5 ED: - MD: - FROM: 01 TO: 01 ]

      [BATCH#: BA127 Q: 3 ED: - MD: - FROM: 01 TO: 01 ]

      [BATCH#: BA128 Q: 2 ED: - MD: - FROM: 01 TO: 01 ]

      My code:

      	Public Function SBOGetDocLineBatchInfo(ByVal sboDoc As SAPbobsCOM.Documents, ByVal l As Integer) As String
      		Dim r As Integer
      		Dim s As String
      		Dim s2 As String
      		Dim strLineINI As String
      		Dim strLine As String
      		Dim strSQL As String
      
      		'[BATCH#: _BatchNumber_ Q: _Quantity_ ED: _ExpiryDate_ MD: _ManufactureDate_ FROM: _FromWHS_ _FromLocation_ TO: _ToWHS_ ]_CrLf_
      		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
      			' we'll query the basedoc
      			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.Lines.BaseType)
      			strSQL = Replace(strSQL, "_BaseEntry_", sboDoc.Lines.BaseEntry)
      			strSQL = Replace(strSQL, "_BaseLinNum_", sboDoc.Lines.BaseLine)
      			gsboRS.DoQuery(strSQL)
      		End If
      
      		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

      Bug fixed:

      When requerying the BaseLinNum was not set correctly:

      - wrong: strSQL = Replace(strSQL, "_BaseLinNum_", l.ToString)

      - fixed: strSQL = Replace(strSQL, "_BaseLinNum_", sboDoc.Lines.BaseLine)

      Message was edited by: Juha Lassila

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.