cancel
Showing results for 
Search instead for 
Did you mean: 

How to Auto select Batch Through SDK Code ?

former_member183246
Participant
0 Kudos

Hi Experts,

How to Auto select Batch Through SDK Code ? my stock is managed by batch i need to set autoselect batch while Issue  from production.

SAPbobsCOM.Documents oIssue;

oIssue = clsAddOn.LDNA_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenExit);

oIssue.Lines.SetCurrentLine(0);

oIssue.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;

while (!ldna_Rec.EoF)

{

     if (ldna_Rec.Fields.Item("ItemCode").Value == oMat3.Columns.Item("V1").Cells.Item(i).Specific.value)

     {

         BubbleEvent = false;

         VaccQnty = Convert.ToDouble(oMat3.Columns.Item("V5").Cells.Item(i).Specific.value);

         oIssue.Lines.BaseEntry = ldna_Rec.Fields.Item("DocEntry").Value;

         oIssue.Lines.BaseType = 202;

         oIssue.Lines.BaseLine = ldna_Rec.Fields.Item("LineNum").Value;

         oIssue.Lines.Quantity = VaccQnty;

         oIssue.Lines.Add();

         break;

     }

     ldna_Rec.MoveNext();

}

oIssue.Add()

- Thanks and regards

Vikas

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member183246
Participant
0 Kudos

Hi,

My Items is manual  Not BackFlush. so i need to set batch via code. please tell me how to do through SDK code.

- Thanks

Vikas

Former Member
0 Kudos

Hi,

you can use query to get the batch number for particular item and particular warehouse. I think last time I have given that query.

Then you can use those batch numbers in sdk

Regards,

Amrut Sabnis

Former Member
0 Kudos

Hai,

           Herewith with I have mentioned the Sample Code for this, Please Check it.

     Dim ManBtchNum = getSingleValue("Select ManBtchNum  from OITM Where ItemCode='" & oMatrix4.GetCellSpecific("ItemCode", i).Value & "'")

                LogInfo("RM " & i & " Batch No Declaration Start : " & Date.Now, "E")

                If ManBtchNum.Trim <> "N" Then

                    Dim strSql = "select isnull(SUM(isnull(U_Qty,0)),0) Qty from [@SHJ_MR_OPT2] OPT2, " & _
                                 " [@SHJ_MR_OOPT] OOPT where OOPT.DocEntry = OPT2.DocEntry  " & _
                                 " and OOPT.U_IndNo ='" & IndentNo & "' and OPT2.U_ItemCode ='" & oMatrix4.GetCellSpecific("ItemCode", i).Value & "' "

                    Dim UsedQty = getSingleValue(strSql)
                    Dim CrrQty = oMatrix4.GetCellSpecific("Qty", i).Value
                    'If (IssueNo = "") Then
                    'IssueNo = "''"

                    'End If
                    Dim rs As SAPbobsCOM.Recordset = DoQuery("Select BatchNum , Quantity from IBT1 where BaseType = 67  and Direction = 0 and BaseNum in (" & _
                                                           IssueNo & ") and ItemCode= '" & oMatrix4.GetCellSpecific("ItemCode", i).Value & "' ")

                    For k As Integer = 0 To rs.RecordCount - 1

                        Dim n As Double = CDbl(rs.Fields.Item("Quantity").Value)
                        If n >= UsedQty Then
                            n = n - UsedQty
                            UsedQty = 0
                        Else
                            UsedQty = UsedQty - n
                            rs.MoveNext()
                            Continue For
                        End If

                        If n >= CrrQty Then
                            v_StockExit.Lines.BatchNumbers.BatchNumber = rs.Fields.Item("BatchNum").Value
                            v_StockExit.Lines.BatchNumbers.Quantity = CrrQty
                            v_StockExit.Lines.BatchNumbers.Add()
                            Exit For
                        ElseIf n > 0 Then
                            v_StockExit.Lines.BatchNumbers.BatchNumber = rs.Fields.Item("BatchNum").Value
                            v_StockExit.Lines.BatchNumbers.Quantity = n
                            v_StockExit.Lines.BatchNumbers.Add()
                            CrrQty = CrrQty - n
                        End If

                        ''Keep the connection alive by clicking label  - By Parthiban
                        'frmOperationTransfer.Items.Item("t_hid").Specific.value = k.ToString.Trim

                        rs.MoveNext()
                        LogInfo("Detail Item End : " & intStockRowCount, "E")
                    Next

                    rs = Nothing

Regards,

K Sakthivel

former_member183246
Participant
0 Kudos

Hi Sakthivel ,

thanks for reply. VB is not my Domain. can you please elaborate in C#.net.

-regards

Vikas

Former Member
0 Kudos

Hi Vikas,

Have a look at this sample provided by SAP :

C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM DI\CSharp\04.SerialAndBatch

Hope it helps .

Regards

Former Member
0 Kudos

Hi,

On Item master data, there is a setting Issue method, select Backflush.

Then you wont need to provide Batch Number through SDK.

Regards,

Amrut Sabnis