SO creation dll  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

SO creation dll

Postby Riyaz » Mon Nov 11, 2019 4:48 pm

Hi There

Am using the below code for SO creation, but it keeps failing at the enum sections (e_ ...) with object reference not set, error, kindly advise on what I'm doing wrong

Dim SalesOrderType As New JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes
SalesOrderType = JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes.e_NewSalesOrder

.BackOrderMode = JiwaSales.SalesOrder.SalesOrder.SalesOrderBackOrderModes.e_SalesOrderAutomatic
.BillType = JiwaSales.SalesOrder.SalesOrder.SalesOrderBillTypes.e_SalesOrderShipAndBill
.Branch.BranchID = BranchID

.DefaultInvoiceType = JiwaSales.SalesOrder.SalesOrder.SalesOrderTypes.e_SalesOrderNormalSalesOrder
.ExpectedDeliveryDate = CType(Row("RequestDate"), Date)
.InitiatedDate = CType(Row("OrderDate"), Date)
.OrderNo = Row("PONo").ToString
.SalesOrderType = JiwaSales.SalesOrder.SalesOrder.SalesOrderTypes.e_SalesOrderNormalSalesOrder

If Trim(IN_LogicalID) = "ZZZZZZZZZZ0000000000" Then
'.OrderType = JiwaSalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeInvoiceOrder 'commented on 02/03/2015
.OrderType = JiwaSales.SalesOrder.SalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeReserveOrder
ElseIf Trim(IN_LogicalID) <> "ZZZZZZZZZZ0000000000" Then
.OrderType = JiwaSales.SalesOrder.SalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeReserveOrder
End If
.Staff.StaffID = Std.JiwaID("HR_Staff", "Admin")
.WholeSaleInvoice = True
.InvoiceNo = 'test1234'
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: SO creation dll

Postby Mike.Sheen » Mon Nov 11, 2019 4:54 pm

Which line do you first encounter an error on?

You can make my life a lot easier by posting a chunk of code I can run without too much trouble - in your example I can can only assume you are using a With block but I cannot see how that With block variable (the sales order business logic) was created - and this is could be the cause of the error.

If I had some code I could just paste into a project, it would mean a quicker resolution to your problem.

You can also make it easier to help you by using a code block in your forum post formatting.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: SO creation dll

Postby Scott.Pearce » Mon Nov 11, 2019 4:55 pm

Which version of Jiwa and how are you creating the sales order object that you are then manipulating in the code you provided?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: SO creation dll

Postby Riyaz » Mon Nov 11, 2019 4:58 pm

Thanks Mike, yes using With, will send them code chunk.

Thanks Scott, v 7.2
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: SO creation dll

Postby Riyaz » Mon Nov 11, 2019 7:08 pm

Hi Mike

Below is the code chunk, it fails on the BackOrderMode line, if I comment that then it fails on the next one also


JiwaLib = New JiwaLib.StdFunctions
JiwaLib.Database = JiwaDatabase
JiwaLib = New JiwaLib.StdFunctions
JiwaLib.Database = JiwaDatabase
SalesOrder = New JiwaSales.SalesOrder.SalesOrder

With SalesOrder

Dim SalesOrderType As New JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes
SalesOrderType = JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes.e_NewSalesOrder

.BackOrderMode = JiwaSales.SalesOrder.SalesOrder.SalesOrderBackOrderModes.e_SalesOrderAutomatic
.BillType = JiwaSales.SalesOrder.SalesOrder.SalesOrderBillTypes.e_SalesOrderShipAndBill
.Branch.BranchID = BranchID

.DefaultInvoiceType = JiwaSales.SalesOrder.SalesOrder.SalesOrderTypes.e_SalesOrderNormalSalesOrder
.ExpectedDeliveryDate = CType(Row("RequestDate"), Date)
.InitiatedDate = CType(Row("OrderDate"), Date)
.OrderNo = Row("PONo").ToString
.SalesOrderType = JiwaSales.SalesOrder.SalesOrder.SalesOrderTypes.e_SalesOrderNormalSalesOrder

If Trim(IN_LogicalID) = "ZZZZZZZZZZ0000000000" Then
.OrderType = JiwaSales.SalesOrder.SalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeReserveOrder
ElseIf Trim(IN_LogicalID) <> "ZZZZZZZZZZ0000000000" Then
.OrderType = JiwaSales.SalesOrder.SalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeReserveOrder
End If
.Staff.StaffID = Std.JiwaID("HR_Staff", "Admin")
.WholeSaleInvoice = True
.InvoiceNo = Std.NextSysNo("Central")

If Trim(IN_LogicalID) = "ZZZZZZZZZZ0000000000" Then
.Reference = "Awaiting Confirmation"
ElseIf Trim(IN_LogicalID) <> "ZZZZZZZZZZ0000000000" Then
.Reference = "Awaiting Confirmation"
End If

.EDI.EDIAddress ="PartnerID"
.EDI.EDIDeliverNotBeforeDate = GetDeliveryDate("NotBefore", Row)
.EDI.EDIDeliverNotAfterDate = GetDeliveryDate("NotAfter", Row)

If CType(_drEDIParameters("ConsolidateOrders"), Boolean) = True And Row("Store").ToString = "" Then
.EDI.EDIOrderType = JiwaSales.SalesOrder.EDI.SalesOrderEDIOrderTypes.e_SalesOrderEDIOrderTypeConsolidated
Else
.EDI.EDIOrderType = JiwaSales.SalesOrder.EDI.SalesOrderEDIOrderTypes.e_SalesOrderEDIOrderTypeNormal
End If

.SalesOrderHistorys(.CurrentHistoryNo).DelAddress1 = "add1"
.SalesOrderHistorys(.CurrentHistoryNo).DelAddress2 = "add2"
.SalesOrderHistorys(.CurrentHistoryNo).DelAddress3 = "add3"
.SalesOrderHistorys(.CurrentHistoryNo).DelAddress4 = "add4"
.SalesOrderHistorys(.CurrentHistoryNo).PostCode = "1234"

If Trim(IN_LogicalID) = "ZZZZZZZZZZ0000000000" Then

.SalesOrderHistorys(.CurrentHistoryNo).EDIPickStatus = JiwaSales.SalesOrder.SalesOrder.SalesOrderHistoryEDIPickStatuses.e_SalesOrderHistoryEDIPickStatusReadyToBePicked
ElseIf Trim(IN_LogicalID) <> "ZZZZZZZZZZ0000000000" Then
.SalesOrderHistorys(.CurrentHistoryNo).EDIPickStatus = JiwaSales.SalesOrder.SalesOrder.SalesOrderHistoryEDIPickStatuses.e_SalesOrderHistoryEDIPickStatusReadyToBePicked
End If


.SalesOrderHistorys(.CurrentHistoryNo).CourierDetails = "123"
.SalesOrderHistorys(.CurrentHistoryNo).Notes = "ttest23"

End With
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: SO creation dll

Postby Mike.Sheen » Mon Nov 11, 2019 9:27 pm

It is failing because this looks like VB6 / VB Script code from version 6.

We changed a lot between version 6 and 7 (the most recent version 6 release is now over 10 years old) - we now use the .NET framework and also our own framework requires our objects to be instantiated using our factories - in this case the sales order object needs to have been created using our BusinessLogic factory.

There is a bit of work to convert the code you provided to work in version 7 - is this part of a larger body of work you need converting? If so you may want to engage us to do it for you - but to get you started, these lines:

Code: Select all
JiwaLib = New JiwaLib.StdFunctions
JiwaLib.Database = JiwaDatabase
JiwaLib = New JiwaLib.StdFunctions
JiwaLib.Database = JiwaDatabase
SalesOrder = New JiwaSales.SalesOrder.SalesOrder


Are to be replaced with:

Code: Select all
SalesOrder = Manager.BusinessLogicFactory.CreateBusinessLogic(Of JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)(Nothing)


You may or may not have a Manager instance available - depending on the context of the application. Is this a plugin, or stand-alone application / service? If it is a stand-alone application you need to have created an instance of the Manager class and logged on first.

And then, as from what I can tell, you are creating a new sales order, so you want to invoke the CreateNew() method of the SalesOrder.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: SO creation dll

Postby Riyaz » Mon Nov 11, 2019 9:37 pm

Thanks Mike

This helps, I will go through and let you know, also is there reference online for these things, I found the below link as reference for now, which matches with your guidance

https://help.jiwa.com.au/Jiwa7/7.00.78/ ... 664043.htm
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: SO creation dll

Postby Scott.Pearce » Tue Nov 12, 2019 8:44 am

That help page is for v7.0.78. Things have changed a bit since then, namely the singleton "instance" property is no longer used as it can cause problems. Read https://docs.jiwa.com.au/display/J7UG/H ... 0+or+later for information regarding "instance", why we no longer use it, and what you should instead be using to instantiate Jiwa objects (factories).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: SO creation dll

Postby Riyaz » Tue Nov 12, 2019 9:58 am

Thanks Scott

I've progressed quite a bit after the guidance from you guys, am getting stuck at this this line now(.SalesOrderHistorys(.CurrentHistoryNo).DelAddress1), is this is correct way? for the sales order

Private SalesOrder As JiwaSales.SalesOrder.SalesOrder
Dim manager As New JiwaFinancials.Jiwa.JiwaApplication.Manager()
manager.Logon("MyServer", "JiwaDemo", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", password)

SalesOrder = manager.BusinessLogicFactory.CreateBusinessLogic(Of JiwaSales.SalesOrder.SalesOrder)(Nothing)

With SalesOrder

.SalesOrderHistorys(.CurrentHistoryNo).DelAddress1 = "add1"
.SalesOrderHistorys(.CurrentHistoryNo).DelAddress2 = "add2"
.SalesOrderHistorys(.CurrentHistoryNo).DelAddress3 = "add3"
.SalesOrderHistorys(.CurrentHistoryNo).DelAddress4 = "add4"
.SalesOrderHistorys(.CurrentHistoryNo).PostCode = "1234"

End With
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: SO creation dll

Postby Scott.Pearce » Tue Nov 12, 2019 10:00 am

Looks good to me.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron