Stock transfer and activation  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Stock transfer and activation

Postby indikad » Wed Dec 02, 2015 10:30 pm

IT WILL BE A GREAT HELP IF Scott or Mike can help me here.
This is a bit of code that I wrote on 6.5.13 ( that works fine ) that needs to be converted to Jiwa7.
If you can help that will save me heaps of time.

All I need to achieve here is
1. Create a stock transfer to a different Jiwa database to which we are logged on.
2. Next Activate that Stock Transfer created in the step above

I did this in 6513 by creating a Stock trasnsfer object for the transfer and activation.
I need some Jiwa 7 comparison code please.

Stock transfer code
Code: Select all
   '------------------------------------------------------------------------------------------
         '--- stock transfer object
          Set stCreate = CreateObject("JiwaStockTransfer.clsStockTransfer")         
          '---reference the current database to a local variable
          Set oCreateDatabase = JiwaDatabaseObjectCreate         
          '--- set the warehouse id for the creatign warehouse
          oCreateDatabase.CurrentLogicalWareHouseID = sLogicalWarehouseIdCreate         
          Set stCreate.Database = oCreateDatabase         
          Set stCreate.JiwaCommLib = JiwaCommonLibObjectCreate 'SalesOrderObject.JiwaCommLib
          Set stCreate.JLib = JiwaLibObjectCreate ' SalesOrderObject.JLib
          Call stCreate.Setup         
         '---adding lines
         RetCodeCreate = stCreate.Lines.AddLine("", "", sInventoryIDCreate) '--- only fill ToPart Inventory ID
          stCreate.Lines(iLineNoCreate).TransferQuantity = QuantityTrf
         '---set header reference
         stCreate.Reference = sHeaderRef
         RetCodeCreate = stCreate.SaveRecord()
           If RetCodeCreate <> 0 Then
               bSuccessCreate = True
           End If
         stCreate.CleanUp
         oCreateDatabase.CurrentLogicalWareHouseID = CurrentLogicalWareHouseID
         
         '----------------------------------------------------------------------------------


ACTIVATING THE STOCK TRASNFER
Code: Select all
'----------------------------------------------------------------------------------------------------
      '--- set the detabase object to the databse we need
       Set oActivateDatabase = JiwaDatabaseObjectAct
       '--- set the warehouse id for the activating warehouse
       oActivateDatabase.CurrentLogicalWareHouseID = sLogicalWhsIdActivate

       Set stActivate = CreateObject("JiwaStockTransfer.clsStockTransfer")
       Set stActivate.Database = oActivateDatabase
       Set stActivate.JiwaCommLib = JiwaCommonLibObjectAct
       Set stActivate.JLib = JiwaLibObjectAct
       Call stActivate.Setup

       iActivateResult = stActivate.ReadRecord(0, 1, , sTrfNoToActivate)
       iActivateResult = 0 '--- reset
       iActivateResult = stActivate.ActivateRecord
       If iActivateResult = -1 Then
           bRet = True
       End If
       If iActivateResult = 0 Then
           bRet = False
       End If
       stActivate.CleanUp
       Set stActivate = Nothing         
       'MsgBox "activatestock trf before reset " & oActivateDatabase.CurrentLogicalWareHouseID
       oActivateDatabase.CurrentLogicalWareHouseID = CurrentLogicalWareHouseID
       'MsgBox "activatestock trf after reset " & oActivateDatabase.CurrentLogicalWareHouseID
       Set oActivateDatabase = Nothing
      '-----------------------------------------------------------------------------------------------

indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Stock transfer and activation  Topic is solved

Postby Scott.Pearce » Thu Dec 03, 2015 8:39 am

This should get you off and running:

Code: Select all
      'Grab a copy of the sessionid that is for the currently logged in database
      Dim databaseSessionID As String = JiwaFinancials.Jiwa.JiwaApplication.Session.Instance.SessionID
      
      'Generate a new sessionid to use to identify the connection to the remote jiwa database
      Dim remoteDatabaseSessionID = System.Guid.NewGuid().ToString
      Try
         'Switch sessions (to a new one)
         JiwaFinancials.Jiwa.JiwaApplication.Session.Instance.SessionID = remoteDatabaseSessionID
         Try
            'Logon to remote database
            JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Logon("JiwaScott", "JiwaTest", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password")
            
            'Create a stock transfer
            Dim stockTransferObject As JiwaStockTransfer.StockTransfer
            stockTransferObject = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaStockTransfer.StockTransfer)(Nothing)
            stockTransferObject.CreateNew
            
            'Add a line
            Dim someInventoryID As String = "000000000K00000000BQ"
            stockTransferObject.Lines.AddLine("", "", someInventoryID)
            stockTransferObject.Lines(stockTransferObject.Lines.Count).TransferQuantity = 1
            
            'Save
            stockTransferObject.Save
            
            'Re-read after the save
            stockTransferObject.Read(stockTransferObject.RecID)
            
            'Activate
            stockTransferObject.ActivateRecord
         Finally
            'Logoff from remote database
            JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.LogOff
         End Try
      Finally
         'Set our session back to the currently logged in database
         JiwaFinancials.Jiwa.JiwaApplication.Session.Instance.SessionID = databaseSessionID
      End Try


I'll also wrap that code up into a plugin and post it in the samples area shortly.

EDIT: Sample plugin using the above code is now available here.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Stock transfer and activation

Postby indikad » Thu Dec 03, 2015 9:28 am

Thanks. I will give it a test.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests