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
  • 0

    Greetings,

    If you look in the Object Reference for Sy_ReportCommom under Public Methods, the ProcessReport method shows the values that can be used for the output destination: PREVIEW, PRINT, DEFERRED, EXPORT, EXPORTDATA

    I don't recall ever using EXPORT or EXPORTDATA through BOI and there might be an issue with the UI that allows the user to select the export format but that may just display and let the user process the report.

    Thanks,

    Kent Mackall

  • 0 in reply to Kent Mackall

    Should have included this in my original response.  You will need to call the SetExportOptions() method (see Object Reference) to actually set the export format and not have the UI display. So there may be more to it than just setting the destination.

    Thanks,

    Kent Mackall

  • 0 in reply to Kent Mackall

    Thanks a lot for the info Kent.  I'll give it a try.

  • 0 in reply to Justin K

    The only problem is what kind of variable/object the SetExportOptions() method is expecting as its first argument.  According to the object reference, it isn't a string.

    The example in the object reference shows this:

    retVal = _obj'SetExportOptions(crEFTCrystalReport,cDeferredPath$+cDeferredFile$)

    Is crEFTCrystalReport an object that needs to be created before passing it to the method?

  • 0 in reply to Justin K

    Greetings,

    The crEFTCrystalReport variable is used in Sage 100 only when printing deferred and it has a preset value of 1.  

    I don't currently have any information on other format types that might be used.

    Unless someone elase has an example using BOI to do an export, we will need to research this and work up an example to see what is possible.  Not sure when we would get to that but I will put it on our list.

    Thank you,

  • 0 in reply to Kent Mackall

    Greetings,

    I ran a quick test of a simple BOI script to print the G/L Trial Balance and specified EXPORT as the option in the ProcessReport call.  It did bring up the UI to specify then output format and destination so the user can select them.  So, at least that part works.  Still need to work out if this can be done without the UI.

    Thanks,

    Kent

  • 0 in reply to Kent Mackall

    Thanks for the update Kent. I also was able to perform the above, however I was hoping to run this report unattended, so if you find anything about the procedure for exporting without the UI, I would really appreciate it.

  • 0 in reply to Justin K

    Just to throw in my 2 cents...THIS WOULD BE HUGE IF YOU CAN GET THESE TO RUN UNATTENDED!!!

  • 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!

Reply Children
  • 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.