Create PO via dll

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

Create PO via dll

Postby Riyaz » Thu Aug 24, 2017 5:33 pm

Hi There

Am using JIWA 6 dlls on VB.net code to automate creation of PO based on the items from the CSV file. Using code as below, which runs successfully but wont create any PO on JIWA. Am sure am checking the correct database. Pls let me know what am I doing wrong.

JiwaCommonLib = New JiwaCommonLib.stdFunctions
JiwaCommonLib.Database = JiwaDatabase
JiwaLib = New JiwaLib.StdFunctions
JiwaLib.Database = JiwaDatabase
JiwaSysProfile = New JiwaSysProfile.clsSysProfile
JiwaSysProfile.Load(Parameter("JiwaSysProfile").ToString)

PurchaseOrder = New JiwaPurchaseOrder.clsPorder

With PurchaseOrder
.Database = JiwaDatabase
.JLib = JiwaLib
.SystemProfile = JiwaSysProfile
.Reference = "1003670"
.CreditorID = strDebtorID
.AddNonInventoryItem("81643-001", newKey)


'With .OrderLines(newKey)

' .Quantity = 10
' .PartNo = "81643-001"

'End With


If .SaveOrder() Then
Throw New Exception(.ErrorModule)
End If

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

Re: Create PO via dll

Postby Scott.Pearce » Thu Aug 24, 2017 5:35 pm

Have you got that entire code block wrapped in a TRY CATCH?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 748
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 225

Re: Create PO via dll

Postby Riyaz » Fri Aug 25, 2017 9:43 am

Hi Scott

Yes its inside a try catch block and it executes fine without any errors
Riyaz
Kohai
Kohai
 
Posts: 239
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Create PO via dll

Postby Scott.Pearce » Fri Aug 25, 2017 10:34 am

Try this code:

Code: Select all
JiwaCommonLib = New JiwaCommonLib.stdFunctions
JiwaCommonLib.Database = JiwaDatabase
JiwaLib = New JiwaLib.StdFunctions
JiwaLib.Database = JiwaDatabase
JiwaSysProfile = New JiwaSysProfile.clsSysProfile
JiwaSysProfile.Load(Parameter("JiwaSysProfile").ToString)

PurchaseOrder = New JiwaPurchaseOrder.clsPorder

With PurchaseOrder
.Database = JiwaDatabase
.JLib = JiwaLib
.SystemProfile = JiwaSysProfile
If PurchaseOrderObject.NewOrder(strDebtorID, JiwaPurchaseOrder.eumCreditor) = False Then
  Throw New Exception(.ErrorMessage)
End If
.Reference = "1003670"
.AddNonInventoryItem("81643-001", newKey)


'With .OrderLines(newKey)

' .Quantity = 10
' .PartNo = "81643-001"

'End With


If .SaveOrder() Then
Throw New Exception(.ErrorModule)
End If

End With


Note the call to "NewOrder" - this sets up the object for a new record. Let me know how it goes.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 748
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 225

Re: Create PO via dll

Postby Riyaz » Fri Aug 25, 2017 12:14 pm

Thanks Scott

It complaints on JiwaPurchaseOrder.eumCreditor as below

enumCreditor is not a member of JiwaPurchaseOrder
Riyaz
Kohai
Kohai
 
Posts: 239
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Create PO via dll

Postby Mike.Sheen » Fri Aug 25, 2017 12:16 pm

Riyaz wrote:It complaints on JiwaPurchaseOrder.eumCreditor as below

enumCreditor is not a member of JiwaPurchaseOrder


What version of Jiwa is this?
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: 2486
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 770

Re: Create PO via dll

Postby Scott.Pearce » Fri Aug 25, 2017 12:22 pm

Use

Code: Select all
JiwaPurchaseOrder.eumJiwaPurchseSupplierType.eumCreditor


instead of

Code: Select all
JiwaPurchaseOrder.eumCreditor
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 748
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 225

Re: Create PO via dll

Postby Riyaz » Fri Aug 25, 2017 12:24 pm

Its 6.5.12 , have also attached the PO dll , pls rename the .txt to .dll
Attachments
Interop.JiwaPurchaseOrder.txt
(180 KiB) Downloaded 260 times
Riyaz
Kohai
Kohai
 
Posts: 239
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Create PO via dll

Postby Riyaz » Fri Aug 25, 2017 12:28 pm

Thanks Scott

Finally got the error as below, is there any documentation for this which I can follow so I can feed all required parameters?

[JiwaPurchaseOrder:clsPorder]
[NewOrder]
Unable to read the Warehouse details, WarehouseID =
Riyaz
Kohai
Kohai
 
Posts: 239
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Create PO via dll

Postby Scott.Pearce » Fri Aug 25, 2017 12:40 pm

I'm afraid there is no documentation for v6.

You need to set the current warehouse on the database object:

Code: Select all
Database.CurrentPhysicalWarehouseID = "ZZZZZZZZZZ0000000000"
Database.CurrentLogicalWarehouseID = "ZZZZZZZZZZ0000000000"


"ZZZZZZZZZZ0000000000" is usually the id of the default warehouse. See IN_Physical and IN_Logical for other possible values. Normally, these should be initially set by your code as part of your logon-to-Jiwa routine. Below is some standard logon and logoff code you can use in your projects, *but* it is in c# (use telerik convert or similar to convert the code to VB .NET):

Code: Select all
        private void LogonToJiwa(string ServerName, string DatabaseName, string SQLLogin, string SQLPassword, string JiwaLogin, string JiwaPassword, string INIFile)
        {
            Database = new JiwaODBC.database();
            string connectionString = string.Format("Driver={{SQL Server}};Server={0};Database={1};UID={2};PWD={3}", ServerName, DatabaseName, SQLLogin, SQLPassword);

            Database.set_UseConnectionScrollCursor(true);
            Database.set_UseConnectionWriteData(true);
            Database.set_UseConnectionReadData1(true);
            Database.set_UseConnectionReadData2(true);
            Database.set_UseConnectionReadData3(true);
            Database.IniFile = INIFile;
            Database.ConnectionDetails = connectionString;

            if(Database.MakeConnections(0))
                if(Database.DoLogOn(JiwaLogin,JiwaPassword) == false)
                {
                    Database.JiwaLoginUserID = "";
                    Database.BreakConnections();
                    throw new Exception(Database.ErrorMessage);
                }
                else
                    SetWarehouse();
            else
                throw new Exception(Database.ErrorMessage);

            CommonLib = new JiwaCommonLib.stdFunctions();
            CommonLib.set_Database (Database);
            JLib = new JiwaLib.StdFunctions();
            JLib.Database = Database;
        }

        private void SetWarehouse()
        {
            Database.CurrentPhysicalWarehouseID = "ZZZZZZZZZZ0000000000";
            Database.CurrentLogicalWarehouseID = "ZZZZZZZZZZ0000000000";
        }

        private void LogoffFromJiwa()
        {
            if (JLib != null)
                JLib = null;

            if (CommonLib != null)
                CommonLib = null;

            if (Database != null)
            {
                Database.BreakConnections();
                Database = null;
            }
        }
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 748
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 225

Next

Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 2 guests