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

The Server threw an exception from HRESULT: 0x80010105 (RPC_E_SERVER_FAULT)

Dear Friend,

I am doing following Posting in Our Form using SAP B1 9.0

when reach the Goods Issue Posting method then automaically SAP threw following Exception then stop totally

The Server threw an exception from HRESULT: 0x80010105 (RPC_E_SERVER_FAULT)

The above error came only for One entry only

I am using following Code

Function Posting()

GC.Collect()

Try

Dim v_StockEntry As SAPbobsCOM.Documents = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)

Dim v_StockEntryOperation As SAPbobsCOM.Documents = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)

Dim v_StockExit As SAPbobsCOM.Documents = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenExit)

' Dim rs1 As SAPbobsCOM.Recordset

Dim stockEntryStatus = False, StockExitPosting As Boolean = False

Dim stockExitStatus = False, StockEntryPosting As Boolean = False

Dim dblPrice As String = 0

Dim intStockRowCount As Integer = 0

Dim WithoutRmCost1 As Double = 0

Dim RWCost1 As Double = 0

Dim OpCode As String = frmOperationTransfer.Items.Item("t_ProCode").Specific.Value.ToString.Trim()

Dim Post As String = getSingleValue("select top 1 U_ConsAu from [@SHJ_WIP_OGNS] ").Trim

If Post = "N" Then Return True

oMatrix1.FlushToDataSource()

Dim proNo As String = frmOperationTransfer.Items.Item("t_ProCode").Specific.Value.ToString.Trim

' Dim IndentNo As String = frmOperationTransfer.Items.Item("t_IndNo").Specific.Value.ToString.Trim

Dim WipNo As String = frmOperationTransfer.Items.Item("t_WIPNo").Specific.Value.ToString.Trim

Dim AccCode As String = ""

Dim IssueNo As String = ""

Dim auto = ""

Dim issueFlag As Boolean

Dim time As String = Date.Now

Dim SelecttheIssueNoSDate As Date = Date.Now

OpeCost = 0

'----- Check for Raw Inventory Transfer for Material Indent------------

'CheckMatrialIssue(IndentNo, proNo, IssueNo, auto, issueFlag)

' If issueFlag = False Then

'LogInfo("Material Need to be Issued..", "E")

'Return False

' End If

'--------- Check Inv Tran -end---------------------------------

LogInfo("Whs. Allocation Start : " & Date.Now, "E")

Dim WhsDate As Date = Date.Now

Dim intPosting As Integer = 0

Dim oCmb As SAPbouiCOM.ComboBox = frmOperationTransfer.Items.Item("c_Type").Specific

'Dim Type As String =

' Dim RecordCound = getSingleValue("select count(*) from [@SHJ_OT_OTMP] where U_ProCode='" & frmOperationTransfer.Items.Item("t_ProCode").Specific.value.ToString.Trim & "'")

'---------OPERATION TRANSFER TYPE - REGULAR ---------------

If oCmb.Value.Trim = "RE" Then

Try

GC.Collect()

Dim RmCost As Double = 0

Dim Stime As Date

Stime = Date.Now

LogInfo("RM Issue Header Declaration Start : " & Date.Now, "E")

V_StockExit.Comments = "Stock Exit For Operation-Transfer (RM) Production-Order No: " & proNo & " and Indent-No: " & IndentNo & ""

Dim str_PostDocDate As String = getSingleValue("Select convert(varchar,convert(date,'" & frmOperationTransfer.Items.Item("t_Date").Specific.value.ToString.Trim & "'),111)")

V_StockExit.DocDueDate = str_PostDocDate

V_StockExit.DocDate = str_PostDocDate

V_StockExit.TaxDate = str_PostDocDate

'V_StockExit.DocDueDate = Now.Date

V_StockExit.Reference2 = frmOperationTransfer.Items.Item("t_DocNum").Specific.Value.ToString.Trim

V_StockExit.UserFields.Fields.Item("U_DocTypflg").Value = "OPT"

LogInfo("RM Issue Header Declaration Complete : " & Date.Now, "E")

LogInfo("Duration : " & (CDate(Date.Now) - CDate(Stime)).ToString, "E")

LogInfo("RM Issue Item Detail Declaration Start : " & Date.Now, "E")

Dim RMIssueHeaderSdate As Date = Date.Now

Dim intStockRowCount = 0

WithoutRmCost1 = 0

For i As Integer = 1 To oMatrix2.VisualRowCount

If (oMatrix2.GetCellSpecific("ItemCode", i).Value = "") Then Continue For

intStockRowCount += 1

If intStockRowCount > 1 Then V_StockExit.Lines.Add()

V_StockExit.Lines.ItemCode = oMatrix2.GetCellSpecific("ItemCode", i).Value

V_StockExit.Lines.Quantity = oMatrix2.GetCellSpecific("Qty", i).Value

V_StockExit.Lines.WarehouseCode = oMatrix2.GetCellSpecific("WarCode", i).Value

'Cost Center Process

Dim ItemGroupCode As String = getSingleValue("select ItmsGrpCod from OITM where ItemCode='" & oMatrix1.GetCellSpecific("OpeCode", 1).Value.ToString.Trim & "'")

If nvOPerations.AllKeys.Contains(ItemGroupCode.ToString.Trim) = True Then

'If (ItemGroupCode.ToString.Trim = lv_str_OperationGroupCode.Trim) Then

Try

accCode = getSingleValue("select u_AccCode from [@SHJ_WIP_OOPE] Where Code='" & oMatrix1.GetCellSpecific("OpeCode", 1).Value.ToString.Trim & "'")

Dim CostingCode = getSingleValue("select U_Dimension from [@SHJ_WIP_OOPE] Where Code='" & oMatrix1.GetCellSpecific("OpeCode", 1).Value.ToString.Trim & "'")

Dim DistRule = getSingleValue("select U_DistRule from [@SHJ_WIP_OOPE] Where Code='" & oMatrix1.GetCellSpecific("OpeCode", 1).Value.ToString.Trim & "'")

If (DistRule.ToString.Trim <> "" And CostingCode.ToString.Trim <> "") Then

If (CDbl(CostingCode) = 1) Then

V_StockExit.Lines.CostingCode = DistRule

ElseIf (CDbl(CostingCode) = 1) Then

V_StockExit.Lines.CostingCode2 = DistRule

ElseIf (CDbl(CostingCode) = 1) Then

V_StockExit.Lines.CostingCode3 = DistRule

ElseIf (CDbl(CostingCode) = 1) Then

V_StockExit.Lines.CostingCode4 = DistRule

ElseIf (CDbl(CostingCode) = 1) Then

V_StockExit.Lines.CostingCode5 = DistRule

End If

End If

Catch ex As Exception

Msg("Cost Center Process Failure : ", "E")

End Try

Else

Try

accCode = getSingleValue("select u_AccCode from [@SHJ_WIP_OOPE] Where Code='" & oMatrix1.GetCellSpecific("OpeCode", 1).Value.ToString.Trim & "'")

Catch ex As Exception

End Try

End If

'*************************************

V_StockExit.Lines.AccountCode = accCode

If nvOPerations.AllKeys.Contains(getSingleValue("select ItmsGrpCod from OITM where ItemCode ='" & oMatrix2.GetCellSpecific("ItemCode", i).Value & "' ").Trim) = True Then

' If lv_str_OperationGroupCode.Trim <> getSingleValue("select ItmsGrpCod from OITM where ItemCode ='" & oMatrix2.GetCellSpecific("ItemCode", i).Value & "' ").Trim Then

'OpeCost = OpeCost + (CDbl(GetItemPrice(oMatrix2.GetCellSpecific("ItemCode", i).Value.ToString.Trim)) _

' * CDbl(oMatrix2.GetCellSpecific("Qty", i).Value))

'OpeCost = OpeCost + (CDbl(getFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value.ToString.Trim, CDbl(oMatrix2.GetCellSpecific("Qty", i).Value))))

'RmCost = (CDbl(getFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value.ToString.Trim, CDbl(oMatrix2.GetCellSpecific("Qty", i).Value))))

'RmCost = getOperationFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value, oMatrix2.GetCellSpecific("Qty", i).Value)

RmCost = getOperationFIFOCostWHS(oMatrix2.GetCellSpecific("ItemCode", i).Value, oMatrix2.GetCellSpecific("Qty", i).Value, oMatrix2.GetCellSpecific("WarCode", i).Value)

OpeCost = OpeCost + RmCost

Try

If (getSingleValue("select U_JobType from [@SHJ_WIP_PRO1] where Code='" & proNo & "' and U_OpeCode='" & oMatrix1.GetCellSpecific("OpeCode", 1).value.ToString.Trim & "' ") = "J") Then

'WithoutRmCost1 = CDbl(WithoutRmCost1) + getOperationFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value, oMatrix2.GetCellSpecific("Qty", i).Value)

WithoutRmCost1 = CDbl(WithoutRmCost1) + getOperationFIFOCostWHS(oMatrix2.GetCellSpecific("ItemCode", i).Value, oMatrix2.GetCellSpecific("Qty", i).Value, oMatrix2.GetCellSpecific("WarCode", i).Value)

End If

Catch ex As Exception

End Try

Else

' OpeCost = OpeCost + getOperationFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value, oMatrix2.GetCellSpecific("Qty", i).Value)

'RmCost = getOperationFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value, oMatrix2.GetCellSpecific("Qty", i).Value)

' RmCost = (CDbl(getFIFOCost(oMatrix2.GetCellSpecific("ItemCode", i).Value.ToString.Trim, CDbl(oMatrix2.GetCellSpecific("Qty", i).Value))))

RmCost = (CDbl(getFIFOCostWHS(oMatrix2.GetCellSpecific("ItemCode", i).Value.ToString.Trim, CDbl(oMatrix2.GetCellSpecific("Qty", i).Value), oMatrix2.GetCellSpecific("WarCode", i).Value)))

OpeCost = OpeCost + RmCost

End If

Dim ItemPrice = RmCost / CDbl(oMatrix2.GetCellSpecific("Qty", i).Value)

V_StockExit.Lines.UnitPrice = ItemPrice

Dim ManBtchNum = getSingleValue("Select ManBtchNum from OITM Where ItemCode='" & oMatrix2.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_ActQty,0)),0) from [@SHJ_MR_OPT1] where U_OrderNo = '" & frmOperationTransfer.Items.Item("t_ProCode").Specific.value.ToString.Trim & "' and U_OpeCode = '" & oMatrix1.GetCellSpecific("OpeCode", 1).Value & "'"

Dim strSql = "select isnull(Sum(isnull(U_ActQty,0)),0)+isnull(Sum(isnull(U_RewQty,0)),0)+isnull(Sum(isnull(U_RejQty,0)),0) from [@SHJ_MR_OOPT] mas left outer join [@SHJ_MR_OPT1] det on mas.DocEntry =det.DocEntry where mas.U_ProCode = '" & frmOperationTransfer.Items.Item("t_ProCode").Specific.value.ToString.Trim & "'and det.U_OpeCode = '" & oMatrix1.GetCellSpecific("OpeCode", 1).Value & "'"

'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 ='" & oMatrix2.GetCellSpecific("ItemCode", i).Value & "' "

Dim UsedQty = getSingleValue(strSql)

Dim CrrQty = oMatrix2.GetCellSpecific("Qty", i).Value

'Dim rs As SAPbobsCOM.Recordset = DoQuery("Select BatchNum , Quantity from IBT1 where BaseType = 67 and Direction = 0 and BaseEntry in (" & _

' IssueNo & ") and ItemCode= '" & oMatrix2.GetCellSpecific("ItemCode", i).Value & "' ")

Dim rs As SAPbobsCOM.Recordset = DoQuery(" Select BatchNum , Quantity from IBT1 where BaseType = 67 and Direction = 0 and BaseEntry in " & _

"(select OWTR.DocEntry from OWTR join WTR1 on OWTR.DocEntry = WTR1.DocEntry where U_ProOrdNo = '" & frmOperationTransfer.Items.Item("t_ProCode").Specific.value.ToString.Trim & "' and U_ProOrdNo is not null " & _

") and ItemCode= '" & oMatrix2.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

rs.MoveNext()

Next

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

LogInfo("Duration : " & (CDate(Date.Now) - CDate(Stime)).ToString, "E")

End If

Next

LogInfo("RM Issue Item Detail Declaration Complete : " & Date.Now, "E")

LogInfo("Duration : " & (CDate(Date.Now) - CDate(RMIssueHeaderSdate)).ToString, "E")

LogInfo("RM Issue Posting Start : " & Date.Now, "E")

Dim RMIssuePostingSDate As Date = Date.Now

Catch ex As Exception

LogInfo("RM Posting Details " & ex.Message, "E")

End Try

End If

'...............Scrap matrial Posting........................

' ------------SCRAP - GOODS RECEIPT POSTING -----------------

ScrapReceipt(proNo, AccCode, v_StockEntry, OpCode)

' ............ Scrap matrial Posting - END ...................

'---------OPERATION TRANSFER TYPE - REWORK ---------------

'------- OPeration Posting ------------

' --------- FINISHED GOODS POSTING ----------------------

Dim strQryRE As String = ""

Dim strQryRW As String = ""

Dim strQryFG As String = ""

Dim strQryINQty As String = ""

Dim strQryReqQty As String = ""

FGReceipt(proNo, "", AccCode, WipNo, OpCode, intPosting, v_StockEntryOperation, strQryRE, strQryRW, strQryFG, strQryINQty, strQryReqQty)

If oCompany.InTransaction = False Then

oCompany.StartTransaction()

End If

LogInfo("RM Issue Posting Start : " & Date.Now, "E")

If oCmb.Value.ToString.Trim = "RE" Then

LogInfo("RM Issue Posting Inside Fun. : " & Date.Now, "E")

If oMatrix2.VisualRowCount > 0 Then

If v_StockExit.Add() <> 0 Then 'When Reach this List that Error Happened

StatusBarWarningMsg("Unable To RM Post Stock Document....... " & oCompany.GetLastErrorDescription)

Return False

End If

End If

End If

LogInfo("RM Issue Posting Complete : " & Date.Now, "E")

LogInfo("Scrap Receipt Posting Start : " & Date.Now, "E")

If oMatrix3.VisualRowCount > 0 Then

If v_StockEntry.Add() <> 0 Then

StatusBarWarningMsg("Unable To Scrap Post Stock Document....... " & oCompany.GetLastErrorDescription)

Return False

End If

End If

LogInfo("Operation Receipt Posting Start : " & Date.Now, "E")

If intPosting = 1 Then

If v_StockEntryOperation.Add() <> 0 Then

StatusBarWarningMsg("Unable To Operation Post Stock Document....... " & oCompany.GetLastErrorDescription)

Return False

End If

End If

If strQryINQty.ToString.Trim <> "" Then

' DoQuery(strQryINQty)

End If

LogInfo("REQ Query : " & strQryReqQty, "E")

LogInfo("Updating Production Order- IN, OUT, req Qty End : " & Date.Now, "E")

'Collect Garbage

System.Runtime.InteropServices.Marshal.ReleaseComObject(v_StockEntry)

System.Runtime.InteropServices.Marshal.ReleaseComObject(v_StockEntryOperation)

System.Runtime.InteropServices.Marshal.ReleaseComObject(v_StockExit)

v_StockEntry = Nothing

v_StockEntryOperation = Nothing

v_StockExit = Nothing

Return True

Catch ex As Exception

LogInfo("Stock Posting Method Failed :" & ex.Message, "E")

If oCompany.InTransaction Then oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

Return False

End Try

End Function

Please Help Me.

Regards,

K Skathivel

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 16, 2013 at 07:23 AM

    On what part of your code? Please use breaklines when debugging.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2013 at 12:20 PM

    Hi,

    I think looping on the process at that time , this error happens.

    By debug on each part, then you should know how to resolve that error.

    Thanks & Regards,

    Bowya S S

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2014 at 10:57 AM

    hi.

    Mr.Sakthi vel ..

    Right now i am facing..same above error.

    have solved this one.

    if yes.

    Can u plz explains what are the things giving the error.

    and how did u solve this one..

    Add a comment
    10|10000 characters needed characters exceeded

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.