Script to transfer data to secondary company

Is it possible to write data into different company within some Sage 100 company. For Example add a button on Sales Order Entry to copy order to secondary company.

I know how to do it outside of Sage with a script but not sure  if session to different company can be created from UDS.

Thanks

Parents
  • 0

    No 2: It might be possible with UDS (no BOI) since you don't need to also pop the screen for S/O Entry in the secondary company.

    *** You'd have to test this idea thoroughly though. I haven't tried it myself ***

    Let's say you're sitting in in S/O Entry in company 001 and want to duplicate the current order new order to company 002. Assume 002 is setup identically to 001.

    Probably best to run script on Table Post-Write but develop it as a button first. It might have to stay as a button for that matter. Here is the general idea the premise of which is the SetCompany() method.

    ** Again I haven't tested it but seems plausible **

    'Store all your Company 001 values in variables that you want to copy into the 002 order
    'For the Lines in 001 consider creating an array to loop thru to store the fields of data you want to copy over to 002

    'When ready to create order in 002:

    'Switch to 002 company
    rSetDupeCompany = oSession.SetCompany("002")
    If rSetDupeCompany Then

    oSO = oSession.GetObject("SO_SalesOrder_bus") 'can't use oBusObj it belongs to 001
    If oSO <> 0 Then Set oSO = oSession.AsObject(oSO)
    Set oSOLines = oSO.AsObject(oSO.Lines) 'can't use oLines it belongs to 001

    retVal = oSO.GetNextSalesOrderNo(sNextSO) 'this should happen in 002 now
    rVal = oSO.SetKey(sNextSO) 'this should happen in 002 now
    If rVal = 2 Then 'EditState of 2 means ready to create new order in 002

    'Use oSO.SetValue() for necessary Header and Address tab fields you need to set

    'Start a Lines loop array that will copy from the 001 company lines array you created earlier to repetitively do:
    'oSOLines.AddLine()
    'oSOLines.SetValue() on ItemCode, QuantityOrdered, etc
    'even better use SetValues() here instead of individual SetValue()
    'oSOLines.Write()

    'oSO.SetValue() for any Totals tab fields you need to override
    'retVal = oSO.Write()
    'If retVal = 0 Then r=oScript.DebugPrint("Error on 002 Write: " & oSO.LastErrorMsg)

    End If

    'Switch back to 001 company
    rSetDupeCompany = oSession.SetCompany("001")

    End If

Reply
  • 0

    No 2: It might be possible with UDS (no BOI) since you don't need to also pop the screen for S/O Entry in the secondary company.

    *** You'd have to test this idea thoroughly though. I haven't tried it myself ***

    Let's say you're sitting in in S/O Entry in company 001 and want to duplicate the current order new order to company 002. Assume 002 is setup identically to 001.

    Probably best to run script on Table Post-Write but develop it as a button first. It might have to stay as a button for that matter. Here is the general idea the premise of which is the SetCompany() method.

    ** Again I haven't tested it but seems plausible **

    'Store all your Company 001 values in variables that you want to copy into the 002 order
    'For the Lines in 001 consider creating an array to loop thru to store the fields of data you want to copy over to 002

    'When ready to create order in 002:

    'Switch to 002 company
    rSetDupeCompany = oSession.SetCompany("002")
    If rSetDupeCompany Then

    oSO = oSession.GetObject("SO_SalesOrder_bus") 'can't use oBusObj it belongs to 001
    If oSO <> 0 Then Set oSO = oSession.AsObject(oSO)
    Set oSOLines = oSO.AsObject(oSO.Lines) 'can't use oLines it belongs to 001

    retVal = oSO.GetNextSalesOrderNo(sNextSO) 'this should happen in 002 now
    rVal = oSO.SetKey(sNextSO) 'this should happen in 002 now
    If rVal = 2 Then 'EditState of 2 means ready to create new order in 002

    'Use oSO.SetValue() for necessary Header and Address tab fields you need to set

    'Start a Lines loop array that will copy from the 001 company lines array you created earlier to repetitively do:
    'oSOLines.AddLine()
    'oSOLines.SetValue() on ItemCode, QuantityOrdered, etc
    'even better use SetValues() here instead of individual SetValue()
    'oSOLines.Write()

    'oSO.SetValue() for any Totals tab fields you need to override
    'retVal = oSO.Write()
    'If retVal = 0 Then r=oScript.DebugPrint("Error on 002 Write: " & oSO.LastErrorMsg)

    End If

    'Switch back to 001 company
    rSetDupeCompany = oSession.SetCompany("001")

    End If

Children
No Data