LoadReport & ProcessReport no longer working

We have a few custom reports that I created button launchers for in various places.  As far as I know, they have always worked until recently.  I would assume the update to 2013 broke these.  Here is the code I was using:

'---------------------------------------------------------------------
'Log on to MAS90
'---------------------------------------------------------------------
Set oScript = CreateObject ("ProvideX.Script")
oScript.Init("S:\Sage 100 Standard ERP\MAS90\Home")
Set oSS = oScript.NewObject("SY_Session")
r = oSS.nLogon()
If r=0 Then
r = oSS.nSetUser("scriptrunner","password")
'msgbox(r)
End If
r = oSS.nSetCompany("MX1")
'---------------------------------------------------------------------
'Run Report
'---------------------------------------------------------------------
retVal = oSS.nSetDate("A/R", "20140101")
retVal = oSS.nSetModule("A/R")
retVal = oSS.nSetProgram(oSS.nLookupTask("SY_REPORTRUNTIME_UI"))
If retVAL = 0 Then
MsgBox(oSS.sLastErrorMsg & vbCRLF & "Report Runtime is not available. Quiting.")
End If
Set oSORpt = oScript.NewObject("SY_REPORTRUNTIME_RPT",oSS)
sCompanyKey = oSS.sCompanyKey
sUserKey = oSS.sUserKey
sReportFile = ""
r = oSORpt.sLoadReport("Customer Statement Report","STANDARD","AR",sCompanyKey,sUserKey, sReportFile)
msgbox(r) <--Returns Nothing
r = oSORpt.nProcessReport("preview")  <--Script bombs here with "Error 712 in method ProcessReport
msgbox(r)

The report being requested is in the Custom Reports menu, though I have also tried a standard report resulting in the same error.  I tried using my admin user for the login, same results.

Suggestions?

Parents
  • 0 in reply to dlevasseur

    Dan,

    I had a few minutes to look at this today and I don't see how the code you shared could work.  Maybe I missing something or there is more to your setup.  If you can replicate this using a standard report in a prior version then please contact Customer Support with details so that they can create a case.

    In a standard Sage 100 installation, there is no task for SY_ReportRunTime_UI in the system so the SetProgram method being used would always fail. Another issue is that the first argument being passed to the LoadReport method is not correct.  It should be the UI for the report printing program (i.e. AR_StatementPrinting_UI).

    Is the intent of this script just to print the customer statements?  If so, this is not the way we would reccomend going about that.  There are other posts on the forum that deal with printing that you should refer to for information.

    Thanks

    Kent Mackall

  • 0 in reply to Justin K

    That thread is extremely hard for me to follow.  So is this unsupported in 2013?  It works as long as you upgraded from 4.4?  There's at least 3 different code examples in there.

  • 0 in reply to dlevasseur

    Basically, as of Sage 2013, you can no longer create an object of 'CrystalRuntime.Application' in vbscript, because Crystal no longer includes the necessary dll (with the version of Crystal included with Sage 2013, Sage 2014).  They mention that if you are working on a computer that already had a Sage version < 2013, the necessary dll will be there and you can use the 'CrystalRunTime.Application' object....you can run any crystal report with this..there are many examples online.

    If you are using a workstation that only contains Sage 2013 or greater, you need to use the "Sage100ERP.Reporting.Report' object in your script.

    In order to use it, you need to register the DLL on the workstation running the script, using the below command (I pointed this to the Sage workstation's home folder since I am running Advanced, not Standard.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm "C:\Sage\Sage 100 Standard ERP\MAS90\Home\Sage100ERP.Reporting.dll" /codebase

    Once this dll is registered, the script is pretty straightforward (unless you need to pass parameters, but I believe this is not too complex).  This is the example included by the Sage rep on that post, and it should work simply by populating your connection string (using the Sage DSN) and the crystal report you want to run.

    Set report = CreateObject("Sage100ERP.Reporting.Report")

    report.Load("C:\Sage\Sage 100 Standard ERP\MAS90\Reports\GL_ChartOfAccounts.rpt")

    connectionString = "Driver={MAS 90 4.0 ODBC Driver};UID=all;PWD=all;Company=ABC;Directory=C:\Sage\Sage 100 Standard ERP\MAS90;Prefix=C:\Sage\Sage 100 Standard ERP\MAS90\SY\, C:\Sage\Sage 100 Standard ERP\MAS90\==\;ViewDLL=C:\Sage\Sage 100 Standard ERP\MAS90\HOME;CacheSize=4;DirtyReads=1;BurstMode=1;StripTrailingSpaces=1"

    report.SetConnection connectionString

    ' report.Preview()

    report.PrinterName = "HP on NULL"

    'Parameters: copies, collate, fromPage, toPage, reformatReportPageSettings

    report.PrintToPrinter 1, 0, 0, 0, 0

     

  • 0 in reply to Justin K

    Justin,  Thank you for posting back that you got your script working.

    Dan, If you are still having issues, please post back and also open a case with Customer Support.

    Thank you,

    Kent

  • 0 in reply to Kent Mackall

    I would love to see if Justin - you or anyone was ever were able to load a custom report via UDS script (and not with the Crystal runtime). I too am having an issue with your updated script at the "LoadReport" method  It returns 0 whether the receiving variable is initialized as a string or zero.

    I am not clear on the parameters. Specifically "Report$" and "ReportSetting$". For "Report$" I've tried the menu name as well as the file name with and without the path. For "ReportSetting$" I've tried "STANDARD". Anyone???

    FUNCTION LoadReport$(Report$ ,\
    
                         ReportSetting$ ,\
    
                         ModuleCode$ ,\
    
                         CompanyKey$ ,\
    
                         UserKey$ , \
    
                         ReportFile$)

  • 0 in reply to connex

    The above example is meant for custom reports and not for canned Sage 100 reports where you can specify a form code, apply filters, etc.  For those its a bit more involved.  The below post may help you out with that:

    https://www.sagecity.com/us/sage100_erp/f/sage-100-business-object-interface/41913/how-to-use-boi-to-print-a-sales-order

  • 0 in reply to Justin K

    Justin, Thanks for the reply, you are correct that the above example is meant for "Custom Reports" and that's exactly what I'm trying to do.

    The link you gave above is for running a standard form with BOI.  Dlevesseru indicates that his UDS script (above) with the "LoadReport" method used to work with "Custom Reports".

    This is the relevant code snippet from above:

    '---------------------------------------------------------------------
    'Run Report
    '---------------------------------------------------------------------
    retVal = oSS.nSetDate("A/R", "20140101")
    retVal = oSS.nSetModule("A/R")
    retVal = oSS.nSetProgram(oSS.nLookupTask("SY_REPORTRUNTIME_UI"))
    If retVAL = 0 Then
    MsgBox(oSS.sLastErrorMsg & vbCRLF & "Report Runtime is not available. Quiting.")
    End If
    Set oSORpt = oScript.NewObject("SY_REPORTRUNTIME_RPT",oSS)
    sCompanyKey = oSS.sCompanyKey
    sUserKey = oSS.sUserKey
    sReportFile = ""
    r = oSORpt.sLoadReport("Customer Statement Report","STANDARD","AR",sCompanyKey,sUserKey, sReportFile)
    msgbox(r) <--Returns Nothing
    r = oSORpt.nProcessReport("preview")  <--Script bombs here with "Error 712 in method ProcessReport
    

  • 0 in reply to connex

    Justin - Were you ever able to get a "Custom Report" to run from a script (UDS)?

  • 0 in reply to connex

    Are you referring to a script within the context of Sage (i.e. from a button link on a panel)?  Or completely outside of Sage (via the Providex Script Object)?  I believe I have only done it from within Sage in which case the below worked perfectly for me:

    Set report = CreateObject("Sage100ERP.Reporting.Report")
    
    report.Load("C:\Sage\Sage 100 Standard ERP\MAS90\Reports\GL_ChartOfAccounts.rpt")
    
    connectionString = "Driver={MAS 90 4.0 ODBC Driver};UID=all;PWD=all;Company=ABC;Directory=C:\Sage\Sage 100 Standard ERP\MAS90;Prefix=C:\Sage\Sage 100 Standard ERP\MAS90\SY\, C:\Sage\Sage 100 Standard ERP\MAS90\==\;ViewDLL=C:\Sage\Sage 100 Standard ERP\MAS90\HOME;CacheSize=4;DirtyReads=1;BurstMode=1;StripTrailingSpaces=1"
    
    report.SetConnection connectionString
    
    ' report.Preview()
    
    report.PrinterName = "HP on NULL"
    
    'Parameters: copies, collate, fromPage, toPage, reformatReportPageSettings
    
    report.PrintToPrinter 1, 0, 0, 0, 0

  • 0 in reply to Justin K

    Thanks again for your response. This thread is about running "Custom Reports" using a script inside Sage. What version does this script work with? I've tried it on 2020 and 2021 and I get the attached message that indicates "Sage100ERP.Reporting.Report" is not registered(?)

    If I try to register it I get a message that it is "Unable to locate...one of its dependencies" (the "Sage100ERP.Reporting.dll" is present in "..\Home").

  • 0 in reply to connex

    Interesting, I don't believe I've ever tried it with Standard.  I would try registering it directly on the 'server' computer via local drive path rather than from the workstation via share.

Reply Children
  • 0 in reply to Justin K

    That worked! Thank you Justin. I was running that from the server, but using the drive letter worked.

    I still need to get the methods of the "SY_ReportRuntime_rpt" object working that are the original title of this post (i.e. LoadReport, ProcessReport). that  said used to work. Anyone?  @kent-mackall (either as a UDS or a BOI script)

  • 0 in reply to connex

    , this does work for me on 2021.   I just ran this from a button script but did have success, granted my report isn't very sophisticated.

    oRpt = oSession.GetObject("SY_ReportRuntime_rpt")
    Set oRpt = oSession.AsObject(oRpt)
    
    sCompKey = oSession.CompanyKey
    sUserKey = oSession.UserKey
    
    sReportRet = ""
    sCrystalRpt = ""
    
    sReportRet = oRpt.LoadReport("TestReport", "STANDARD", "A/P", sCompKey, sUserKey, sCrystalRpt)
    
    ' note that the first argument is the ReportID from SY_ReportWizardMain
    
    retVal = oRpt.ProcessReport("PREVIEW")
    

    Let me know if that works

    E

  • 0 in reply to jepritch

    Thanks  for the example, but I'm finding that even though I have many custom reports the ..\MAS_System\SY_ReportWizardMain file doesn't include any records. I found an archived system that has a few records in it, but none are for its custom reports.

    File "Sy_ReportSetting.m4T" has entries for my custom report (including "ReportSetting=STANDARD", but the ReportID there (the file name including the extension) didn't work either. I also tried it w/o the extension. I checked all other MAS_System files modified since the custom report was added and could not find anything that worked. I am testing as a button script on Sage 100 Std Version 2021 Version 7.00.2.0.

  • 0 in reply to connex

    The above report I did through Business Insights Reporter, which uses a wizard to define the report and then add it to the menu. This also adds it to SY_ReportWizardMain.   The SY_ReportRuntime_rpt requires the report to be setup in that SY_ReportWizardMain.     Did you use Report Manager to create your report?  

    I'll have to review how to do that via scripting (if possible).  I assume you want this to run without a UI?  

    E

  • 0 in reply to jepritch

    Thanks again. Yes, I need it for reports added to the  Custom Reports menu with Report Manager and without the UI if possible.

  • 0 in reply to connex

    The report manager uses a different object to run everything through, so I just modified your script above, and this seems to work for me here.

    retVal = oSS.nSetDate("A/R", "20140101")
    retVal = oSS.nSetModule("A/R")
    retVal = oSS.nSetProgram(oSS.nLookupTask("SY_Listing_ui"))
    If retVal = 0 Then
        MsgBox(oSS.sLastErrorMsg & vbCRLF & "Report Runtime is not available. Quiting.")
    End If

    Set oSORpt = oScript.NewObject("SY_ReportManagerGeneratedListing_rpt", oSS, "AR_whateverCustom.rpt", "Report Caption")
    r = oSORpt.nProcessReport("preview")

    Give that a try.

    E

  • 0 in reply to jepritch

    Thanks  Testing this now, in a UDS what is the equivalent of this for in a UDS?

    Set oSORpt = oScript.NewObject("SY_ReportManagerGeneratedListing_rpt", oSS, "AR_whateverCustom.rpt", "Report Caption")

    I tried both of these statements below but get the same error message "Error 88 Invalid/unknown property name, Wrong number of arguments or invalid property assignment: 'oSession.NewObject'

    Set oSORpt = oScript.NewObject("SY_ReportManagerGeneratedListing_rpt", oSession, "GL_My_Custom.rpt", "My Caption")
    Set oSORpt = oSession.NewObject("SY_ReportManagerGeneratedListing_rpt", oSession, "GL_My_Custom.rpt", "My Caption")

  • 0 in reply to connex

    That's kind of the kicker.  In a user-defined script there really isn't a way to instantiate an object with multiple arguments.  However, you should be able to write it as a vbs script and then connect it to either a button script or an event script.  For an event script you'll have to define it as a user-defined script, but I think it should still work.

    E

  • 0 in reply to jepritch

     Thanks again for the response. This does clear things up. I don't want to use a BOI script because I can't leave the credentials in clear text and don't want to have to compile it to every time they need to be changed.