Launch Custom Report from UDS

SOLVED

Hi,

I've found a bunch of examples on how to launch MAS custom reports using the PVX object in a vbscript, but does anyone have an example of how to do this from a user defined script?  I tried altering some of the examples for use in a UDS, but I'm not getting very far :(

  • 0

    Post one of the example scripts.

  • 0 in reply to dlech

    Report$ = Name of BIR Report

    ReportSetting$ = report Setting, typically "STANDARD"

    ModuleCode$ = "BIR"

    Companykey$ = Session object CompanyKey property

    UserKey$ = Session object UserKey property

    ReportFile$ = string variable that will return the report file name.

    here is VBS my code.  i setup a BIR Report called TEST that prints A/R Customer information:

    ' standard setup and logon logic above

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

    Set oBIR = oScript.NewObject("SY_ReportRuntime_rpt", oSS)

    sCompanyKey = oSS.sCompanyKey

    sUserKey = oSS.sUserKey  

    sReportFile = ""

    tmp = oBIR.sLoadReport("TEST","STANDARD","BIR",sCompanyKey,sUserKey, sReportFile)

    retVal = oBIR.nProcessReport("print")

  • 0 in reply to Justin K
    verified answer

    In user defined scripting, we already have a session object because the code is being called from within MAS 90. This means get rid of the "standard setup and logon logic above". The variable oSession already exists and you can use it in place of oSS. (oScript already exists as well).

    Also, we don't have oScript.NewObject.

    This means that

    -----

    Set oBIR = oScript.NewObject("SY_ReportRuntime_rpt", oSS)

    -----

    becomes

    -----

    hBIR = oSession.GetObject ("SY_ReportRuntime_rpt")

    Set oBIR = oSession.AsObject(hBIR)

    -----

    hBIR is the handle (integer identifier) to the actual object. AsObject converts the handle to an actual object.

    The next difference is that we need to get rid of all the type prefixes on properties and methods. This is the n/s/o prefix. You can still use them on variable names if you like.

    So you script would be something like this:

    -----

    retVAL = oSession.SetProgram(oSession.LookupTask("SY_ReportRuntime_ui"))

    hBIR = oSession.GetObject ("SY_ReportRuntime_rpt")

    If hBIR = 0 Then

       ' Show error message

       Exit Sub

    End If

    Set oBIR = oSession.AsObject(hBIR)

    sCompanyKey = oSession.CompanyKey

    sUserKey = oSession.UserKey  

    sReportFile = ""

    tmp = oBIR.LoadReport("TEST","STANDARD","BIR",sCompanyKey,sUserKey, sReportFile)

    retVal = oBIR.ProcessReport("print")

    -----

    Each user-defined script is wrapped in "Sub xxx ... End Sub", so the Exit Sub just prevents the rest of the script from running.

  • 0 in reply to dlech

    Thanks so much for the detailed response dlech.  I'll give it a try.

  • 0 in reply to Justin K

    Thanks DLech.  I'm having a problem at the LoadReport, coming back as 0.  Any suggestions?  In my case It's a custom report in AR, so I did change the module code in the LoadReport section to "AR".  I verified the current user could run the report (me).

    Suggestions?

  • 0 in reply to dlech

    The only question I have is what arguments should be passed to LoadReport for a custom report.  The form code ('STANDARD') wouldn't really apply, right?  Should the first parameter be the name of the custom crystal report?  Also, should a proper path/file name be provided in the sReportFile variable?

  • 0 in reply to Justin K

    Trying a bunch of different combinations of arguments, but get 'Report file is not found or does not exist every time :(

  • 0 in reply to dlevasseur

    Dan,

    You can check the value of oBIR.LastErrorMsg to find out what the error is.

  • 0 in reply to Justin K

    Justin,

    I just saw that Dan has another thread about this going with a Sage employee, so hopfully it gets figured out. I don't have any experience with this particular function/object.

    sagecity.na.sage.com/.../74820.aspx