Page 1 of 2

Create PO via dll

PostPosted: Thu Aug 24, 2017 5:33 pm
by Riyaz
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

Re: Create PO via dll

PostPosted: Thu Aug 24, 2017 5:35 pm
by Scott.Pearce
Have you got that entire code block wrapped in a TRY CATCH?

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 9:43 am
by Riyaz
Hi Scott

Yes its inside a try catch block and it executes fine without any errors

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 10:34 am
by Scott.Pearce
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.

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 12:14 pm
by Riyaz
Thanks Scott

It complaints on JiwaPurchaseOrder.eumCreditor as below

enumCreditor is not a member of JiwaPurchaseOrder

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 12:16 pm
by Mike.Sheen
Riyaz wrote:It complaints on JiwaPurchaseOrder.eumCreditor as below

enumCreditor is not a member of JiwaPurchaseOrder


What version of Jiwa is this?

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 12:22 pm
by Scott.Pearce
Use

Code: Select all
JiwaPurchaseOrder.eumJiwaPurchseSupplierType.eumCreditor


instead of

Code: Select all
JiwaPurchaseOrder.eumCreditor

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 12:24 pm
by Riyaz
Its 6.5.12 , have also attached the PO dll , pls rename the .txt to .dll

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 12:28 pm
by Riyaz
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 =

Re: Create PO via dll

PostPosted: Fri Aug 25, 2017 12:40 pm
by Scott.Pearce
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;
            }
        }