Updating Batches via BOI

SOLVED

Hello all!

I'm working on a script to auto approve batches but I am running into some issues.  I looked through the BOI course and there is an example in there that updates the SalesOrder so I adapted my code from that.  I'm not sure if I'm setting it to the right module or not.  I'm a little confused on if I should be updating the Receipt Register or the GL.

We run SAGE 100 MAS 90.

Below is the code I currently have. 

oGLPost=""
Set oScript = CreateObject("ProvideX.Script")
oScript.Init("C:\sage\Sage 100 Advanced\MAS90\Home")
Set oSS = oScript.NewObject("SY_Session")

retVal = oSS.nLogon()
If retVal = 0 then 
    retVal = oss.nSetUser("user","password")
End If

retVal = oss.nSetCompany("TST")
retVal = oSS.nSetDate("P/O""20200715")
retVal = oSS.nSetModule("P/O")

oGLUI = oSS.nSetProgram(oSS.nLookUpTask("PO_ReceiptRegister_UI"))

WScript.Echo oSS.sLastErrorMsg & "Line 17 PO UPDATE UI set"
Set oGLPost = oScript.NewObject("PO_ReceiptRegister_upd", oSS)

WScript.Echo "Line 20 PO UPD set"

' WScript.Echo "oGLPost set to new object"

If retVal = 0 Then 
  WScript.Echo oSS.sLastErrorMsg
    'MessageBox.Show(oSS.sLastErrorMsg)
End If 

retVal = oGLPost.nSelectBatch("07864")
WScript.Echo "Batch number set"
 
If CBool(oGLPost.nProcessReport("DEFERRED")) Then
   retVal = oGLPost.nUpdate()
   Select Case retVal 
     Case 0 
     WScript.Echo oGLPost.sLastErrorMsg
       'MessageBox.Show(oGLPost.sLastErrorMsg)
     Case 1 
       'MessageBox.Show("GL Updated Successfully!")
       WScript.Echo "GL Updated Successfully!"
   End Select
Else
  'MessageBox.Show(oGLPost.sLastErrorMsg)
  WScript.Echo oGLPost.sLastErrorMsg & "nProcessReport Else Statement Fired!"
End If

oGLPost.DropObject()
Any help pointing me in the right direction is greatly appreciated!
  • 0

    I forgot to mention we're on SAGE 100c 2018 v6.00.6.0

  • 0 in reply to js-goose
    SUGGESTED

    Before nProcessReport, you need nSetPostingDate.

    Make sure that the pvxwin32.exe.config file has been copied from the server's MAS90\Home directory to the workstation running the script's C:\Program Files (x86)\Common Files\Sage\Common Components directory as well as the server's C:\Program Files (x86)\Common Files\Sage\Common Components directory, then rename it from pvxwin32.exe.config to pvxcom.exe.config.

    If you want to leverage paperless office instead of DEFERRED, copy the [Paperless] section from the server's MAS90\Launcher\SOTA.ini to the workstation running the script's MAS90\Home\PVX.ini file and it wouldn't hurt to also copy it to the server's MAS90\Home\PVX.ini.

    You can search the forum for "_upd" and "*_upd" for more examples.

    Here are two notable posts.

    https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-business-object-interface/152114/error-0-in-method-updateint/398520#398520

    https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-business-object-interface/111925/boi-upd-object---paperless-office/329553#329553

  • 0 in reply to David Speck

    Hello David and thank you for your response!  We're running this script on the server to ensure it works there first before moving to workstations.  Thank you for the heads up about copying the files over.

    I'll be honest in that I don't know the difference in using DEFERRED / Paperless.

    I did make some headway in my script though.  I added the posting date and commented out the the nProcessReport section (since I'm not sure how to use it) and got the error "The register must be printed prior to posting" so I'm researching how to do that.

    Thank you again for the in-depth response and I'll post any progress I make :)

  • 0 in reply to js-goose

    You still need the nProcessReport.

    Deferred means the register will be sent to the deferred printing queue and if someone needs to view it, they'll need to go through File > Deferred printing.

    Paperless office means it will have a pdf created and a record logging it in the pdf log file where it can be review via the journal and register viewer.

  • 0 in reply to David Speck

    Thank you for the clarification David.  I feel like a lot of the mystery surrounding SAGE (at least for me) has to do with the vocabulary.  When I see the word print I assume physical printing.  But after your explanation I know think I understand it as printing to the Deferred printing log or to the Paperless Office. 

    Are those the only 2 destinations possible? 

    I'll have to get more info from stakeholders but as far as I know they just want the batches to "auto approve" based on certain criteria.  This approval is the same as printing to Deferred or Paperless?

    Thank you again for all of the awesome information and all of your help!

  • 0 in reply to js-goose

    You can also use either "Print" or "Export" as the argument to nProcessReport. 

    Use "Print" if you have configured Paperless Office for the register and journals or if you want to send the register/journal to a physical printer. For printing to a physical printer, you must make sure that the Windows user that the script will be running under has a default printer assigned or you need to select the target printer prior to calling nProcessReport and i don't recall how this is done at the moment so it is easier to just set a default printer for the Windows user. 

    Use "Export" if you want to define you own export path, filename, and type. See this post for more details on Export.

    https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-personalization-customization-and-productivity-tools/145148/sage-100-reporting-object/383031#383031

  • 0 in reply to David Speck

    That makes much more sense now, awesome info!

    I went to the server to copy over the pvxwin32.exe.config file but only found pvxwin32.exe

    Is this the same file? 

    As I test I copied it over to my local machine in the C:\Program Files (x86)\Common Files\Sage\Common Components and renamed it to the pvxcom.exe.config but still get this error:

    "Error: 0 in Method PROCESSREPORT Code: 80020009"

    Here is a snipped of my updated script for reference:

    Thank you in advance for all of your help again David!

  • 0 in reply to js-goose

    I got "Batching is not enabled for this data entry type" when I put an sLastErrorMsg above the line that is giving me the issue. 

    Am I in the wrong class to be updating receipt of goods batches?

  • 0 in reply to js-goose
    SUGGESTED

    Is batching enabled for PO Receipts?

    Usually, you'll want to check the nBatchEnabled property, if 1, it is enabled and you should use nSelectBatch, if 0, it is not enabled and you should not use nSelectBatch.

    Check if paperless office is set up for the PO journals/registers specifically or for all journals/registers for the target company, if it is enabled, you will need to copy the [Paperless] section from MAS90\Launcher\SOTA.ini to all instances of the PVX.ini file which should be found in MAS90\Home

  • +1 in reply to David Speck
    verified answer

    Hello David!  Batching is enabled but that wasn't the issue.

    We found the issues was in part, that we were missing some files from the 2018 version.  Copying over the pvxwin32.config.exe and renaming it ending up solving the issue. 

    The other developer (much more experienced in SAGE than I am) said it had something to do with the Crystal Reports viewer version we were using.

    Thank you again for all of your help and patience.  It is greatly appreciated!