Export Report using BOI?

SOLVED

I'm printing a report via a BOI script (SO Customer Sales History).  I can print/preview it, but I was just wondering if the report object has a method to export the report to file?  (Excel or PDF)?  Thanks in advance.

Parents Reply Children
  • 0 in reply to connex
    verified answer

    Greetings,

    I spent some time this morning working out how to export reports silently through BOI.

    My testing was done using Sage 100 ERP 2014 ABC Demo Data on a Windows 7 x64 Virtual Machine.  I did not do exhaustive testing of all reports.  I just used the example code I am sharing that prints the G/L Trial Balance and tested the various output formats.  This code is not intended to be production level.

    If you run into instances where this doesn't work for a particulalr report or export format, please report that to Customer Support and not on Sage City so that it can be submitted to development for investigation.

    Below is a sample VBS with comments for the necessary logic to export the report:

          Set oScript = CreateObject ("ProvideX.Script")

          oScript.Init("C:\Sage\Sage 100 Standard ERP\MAS90\Home")

          Set oSS = oScript.NewObject("SY_Session")

          retVAL = oSS.nSetUser("Kent","")

          retVAL = oSS.nSetCompany("ABC")

          retVAL = oSS.nSetDate("G/L","20140529")

          retVAL = oSS.nSetModule("G/L")

          retVAL = oSS.nSetProgram(oSS.nLookupTask("GL_TrialBalance_ui"))

          Set oGLReport = oScript.NewObject("GL_TrialBalance_rpt", oSS)

          options = "SORTREPORTBY$=""A"";DB_TYPEOFBALANCE$=""E"";

          DB_FISCALYEAR$="""";DB_STARTPERIOD$="""";DB_ACCOUNTINGPERIOD$="""";

          DB_ENDPERIOD$="""";CB_ZEROBALANCE$=""Y"";CB_CONDENSEDPRINT$=""N"""

           r = oGLReport.nSetOptions(options)

    'BEGIN EXPORT SPECIFIC LOGIC

    ‘The following options and methods are the keys to exporting the  report.

    ‘nReportType is used to suppress the Export Selection dialogue (UI) that displays when exporting a

    'report in Sage 100.  This must always be set to 6 in order to suppress the selection dialogue.  This must be

    'set prior to calling the nProcessReport() method.  Do not set this value at all if you want the export selection

    'dialogue to display.

           oGLReport.nReportType = 6

    ‘nInitReportEngine() is called to create the report object that is required in order to set the export options.

    'This must be called before the call to nSetExportOptions()

            retval = oGLReport.nInitReportEngine()

    ‘nSetExportOptions(nOuptutFormat, sOuputPath) is called to set the output format and path.  

    'nOuputFormat is a numeric value and can be one of the following values/export types:

    '  Ouput Format Values/Types

    '  2 Rich Text

    '  3 Microsoft Word

    '  4 Microsoft Excel

    '  5 PDF

    '  9 Text

    '  10 CSV

    '  11 Tab Separated

    '  12 Editable Rich Text

    '  13 XML

    'nOuputPath is the path where the file will be exported/created. This should be the full path and filename

    '(i.e. "C:\temp\GL_TrialBalance.pdf"). This was tested using an existing path.

            nOuputFormat = 5

            sOuputPath = "C:\temp\GL_TrialBalance.pdf"

            retval = oGLReport.nSetExportOptions(nOutputformat, sOutputPath)

    ‘nProcessReport(sDestination) is called with “EXPORT” as the destination which will export the report in the format and to the location specified in the nSetExportOptions() call above.

             retVal = oGLReport.nProcessReport("EXPORT")

    'END EXPORT SPECIFIC LOGIC

             oSS.nCleanup()

             oSS.DropObject()

             Set oSS = Nothing

             Set oScript = Nothing

    Thank you,

    Kent Mackall

    Sage

  • 0 in reply to Kent Mackall

    This worked for me.  Thanks so much for looking into this Kent!

  • 0 in reply to Justin K

    Thank you Kent. I'll be working with this as well and will report back (and/or to support).

  • 0 in reply to connex

    Just FYI to whomever else comes across this post. There is a typo, and if you copy and paste this script you'll get Error: 548 in Method SETEXPORTOPTIONS, and it might take you a bit to find it, at least it did for me.

    The first "t" is missing in sOutputPath.

    Should be:

    sOutputPath = "C:\temp\GL_TrialBalance.pdf"

    Also, in my testing the SetExportOptions didn't work properly when using the variables, even when resetting them to 0 and "" before calling them. Hard coding the values, nSetExportOptions(5, "C:\temp\GL_TrialBalance.pdf"), worked fine.

  • 0 in reply to Kent Mackall

    We recently changed to version 2018 and after the change I am getting an Error 200 back from the line that says 

          retval = oGLReport.nInitReportEngine()

    Are there any changes to this script that are needed to be compatible with V2018?

  • +1 in reply to Mike Wodarczyk
    verified answer

    Greetings,

    This is an issue with Crystal and COM (BOI) for the Sage 100 2018 Release. To correct this, copy the pvxwin32.exe.config from the Sage 100 2018 installs ..\mas90\home folder to the C:\Program Files (x86)\Common Files\Sage\CommonComponents folder and then RENAME the file to pvxcom.exe.config.

    Thank you,

    Kent Mackall

  • 0 in reply to Kent Mackall
    SUGGESTED

    Thanks!  That Worked!!!