Running report from Progress 4GL language

2 posts, 0 answers
  1. Dariusz
    Dariusz avatar
    1 posts
    Member since:
    Dec 2019

    Posted 17 Dec 2019 Link to this post

    Hi all,

    I'm looking for example code to call/render report stored at Report Server from Progress 4GL language (Progress v.11.5, AIX box) and save it somewhere as .PDF file.

    Hope what I want is possible.

    Thanks.

  2. Neli
    Admin
    Neli avatar
    252 posts

    Posted 20 Dec 2019 Link to this post

    Hello Dariusz,

    You can utilize the RS web API to request and get the reports from any environment. For further information, visit the following articles:

    - POST api/reportserver/v2/documents;

    - GET api/reportserver/v2/documents/{documentId};

    - HOW TO RUN A TELERIK REPORT FROM ABL?

    You can use the code below:

    const string REPORT_NAME = "ExampleReport1";
    static void Main()
    {
        ExecuteSampleScenario();
    }
    
    public static void ExecuteSampleScenario()
    {
        var settings = new Settings()
        {
            BaseAddress = "http://reportserver:83"
        };
    
        using (var client = new ReportServerClient(settings))
        {
            client.Login("admin", "111111");
            var documentBytes = ExportDocument(client);
            File.WriteAllBytes($@"C:\temp\{REPORT_NAME}.pdf", documentBytes);
            System.Diagnostics.Process.Start($@"C:\temp\{REPORT_NAME}.pdf");
        }
    }
    
    /// <summary>
    
    /// Creates a single-format document and gets its bytes
    
    /// </summary>
    
    /// <param name="client"></param>
    
    /// <returns></returns>
    
    static byte[] ExportDocument(ReportServerClient client)
    {
        var existingReport = client.GetReportInfos().Single(r => r.Name == REPORT_NAME);
        var model = new CreateDocumentData
        {
            DeviceInfo = new Dictionary<string, object>(),
            Format = "PDF",
            ParameterValues = new Dictionary<string, object>(),
            ReportId = existingReport.Id,
        };
        var documentId = client.CreateDocument(model);
        return client.GetDocument(documentId);
    }
    }

     

    Regards,
    Neli
    Progress Telerik

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top