Render Telerik Report from my ABL program - Forum - OpenEdge Development - Progress Community

Render Telerik Report from my ABL program

 Forum

Render Telerik Report from my ABL program

This question has suggested answer(s)

Hi!

I choose now software for reporting. This software must print bills, invoices, contract forms (and so on) on corporate paper form.

I have downloaded Telerik Reporting trial. I have designed small report using .Net OpenClient, small dataset and classic Appserver. I can run and print this report form TelerikReporting Designer. But how can I, for example, render PDF silently from my 4GL program?

I found only one KB Article (How to run a telerik report from ABL #000080061) but cannot reproduce this solution.

I have 11.5/win32 (planned to upgrade on 11.7 later this year). I don't have Developer Studio, but I have a little of expierence in .Net objects.

All Replies
  • Hi Dmitry,

    sorry I'm not able to answer your question directly.

    I am using Telerik but not for printing and reporting. Most of my customers and myself use combit List & Label since ever.

    Looking at your requirements it should fit perfectly. In my opinion telerik reporting is quite powerful, but only makes sense if you have a .net or abl.net app.

    It's propably useful, if you already have the data in .Net objects / forms. But telerik doesn't care about an openedge db or prodatasets where your data is. The KB you mentioned uses ODBC to connect to a progress db. That's propably not the way you want to access your data. An you don't seem to use Winforms in the moment, so it doesn't make sense to start with it just for printing and reporting.

    So, if you don't succeed with Telerik Reporting I recommend the following.

    - Download a trial for List & Label from www.combit.com/.../

    I have written the OpenEdge DataProvider for List&Label (.Net DLL). It's included in the samples directory of the LL distribution.

    C:\Program Files (x86)\combit\LL24\Samples\Progress\OpenEdge.

    - Download the source code including c# for everything from here www.taste-consulting.de/.../. Get the software an documentation.

    Then I recommend that you first try to run the Sports2000 Sample App. You should do this with OpenEdge Developer Studio. A classroom edtion is enough.

    Some features:

    - ABL Clients, classic or Winforms.Net, with or without Appserver. In memory data (Temp-Tables, Datasets) or direct db access. Normal wait-for or .Net wait-for.

    - .Net OpenClients an Appserver to access OpenEdge data.

    - Powerful designer also for End-User.

    - Print, Preview, Export i.e. as PDF.

    - Export on client or silently on appserver.

    - simple or complex an nested documents. Images, Barcode ... almost everything.

    List & Label also incudes a powerful report server with a browser based frontend.

    Feel free to ask addional questions ...

    Best regards,

    Thomas

  • Hi Dmitry, thanks for trying out the Telerik Reporting product!

    Once you have a working report in the Report Designer tool, you need the snippet from this article to export to PDF programmatically (it is a .NET code, so I am not confident you can execute it in your environment): docs.telerik.com/.../programmatic-exporting-report

    To directly print you need this (You will pass UriReportSource, as your report is in declarative trdx/trdp format): docs.telerik.com/.../faq-hide-print-dialog

    Write back with any additional questions that may arise!

  • Thanks for replying.

    I've tried also Telerik Report Server. He has REST API and should be simple in comparison with .Net/DLL call.

    But how I can get auth token? Link Javascript code found in documentation.

    How I can do this with OpenEdge? I got HTTP 400, Bad Request

    USING OpenEdge.Net.HTTP.*.
    USING OpenEdge.Net.Uri.
    USING Progress.Json.ObjectModel.*.
    USING OpenEdge.Core.STRING.
    
    SESSION:DEBUG-ALERT=YES.
    log-manager:logfile-name = 'c:\dev\get_applications.log'.
    log-manager:logging-level = 6.
    log-manager:clear-log().
    
    DEF VAR crJson       AS Progress.Json.ObjectModel.JsonObject NO-UNDO.
    DEF VAR oRequest     AS IHttpRequest                         NO-UNDO.
    DEF VAR oResponse    AS IHttpResponse                        NO-UNDO.
    DEF VAR oURI         AS URI                                  NO-UNDO.
    
    crJson = NEW JsonObject(). 
    crJson:add('grant_type',"password"). 
    crJson:add('username',"dmi"). 
    crJson:add('password',"1123"). 
    
    oURI = NEW URI('http','armor',83).  /* http://armor:83 - report server instance */
    oURI:Path = 'Token'.
    
    oRequest = RequestBuilder:Build('POST', oURI)
                    :AcceptJson() 
                    :WithData(crJson) 
                    :Request.
                     
    oResponse = ClientBuilder:Build():Client:Execute(oRequest).
    
    IF oResponse:StatusCode <> 200 THEN
         MESSAGE 'Request Error: ' + STRING(oResponse:StatusCode).
       ELSE
         CAST(oResponse:Entity, JsonObject):WriteFile('c:\dev\response.json', TRUE).
    

    My request is 

    POST /Token HTTP/1.1
    User-Agent: OpenEdge-HttpClient/0.4.0 (WIN32/64) OpenEdge/11.7.4.0.1685 Lib-ABLSockets/0.5.0
    Host: armor:83
    Content-Type: application/json
    Content-Length: 74
    Accept: application/json

    {
    "grant_type": "password",
    "username": "dmi",
    "password": "1123"
    }

    and answer

    ================================
    NEW CHUNK (8192)
    BYTES READ (272)
    ================================
    HTTP/1.1 400 Bad Request
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Type: application/json;charset=UTF-8
    Expires: -1
    Server: Microsoft-IIS/10.0
    X-Powered-By: ASP.NET
    Date: Wed, 08 May 2019 17:38:06 GMT
    Content-Length: 34

    {"error":"unsupported_grant_type"}

    Can anybody provide to me curl example to get token?
  • Sample code to get token and get report list from server

    USING OpenEdge.Net.HTTP.*.
    USING OpenEdge.Net.Uri.
    USING Progress.Json.ObjectModel.JsonObject.
    USING Progress.Json.ObjectModel.*.
    USING OpenEdge.Core.STRING.
    USING PROGRESS.Lang.OBJECT.
    
    &GLOBAL-DEFINE username dmi
    &GLOBAL-DEFINE password pwd
                               
    /******* debug **********/
    log-manager:logfile-name = 'c:\dev\get_applications.log'.
    log-manager:logging-level = 6.
    log-manager:clear-log().
    /******* debug **********/
    
    DEF VAR oURI          AS URI               NO-UNDO.
    DEF VAR oRequestBody  AS STRING            NO-UNDO.
    DEF VAR oRequest      AS IHttpRequest      NO-UNDO.
    DEF VAR oResponse     AS IHttpResponse     NO-UNDO.
    DEF VAR oClient       AS IHttpClient       NO-UNDO.
    DEF VAR oEntity       AS Object            NO-UNDO.
    DEF VAR oJResponse    AS JsonObject        NO-UNDO.
    DEF VAR chToken       AS CHAR              NO-UNDO.
    
    ASSIGN
     oURI         = NEW URI('http','armor',83)
     oURI:Path    = 'Token'
     oRequestBody = new String('grant_type=password&username={&username}&password={&password}')
     oRequest     = RequestBuilder:Post(oUri, oRequestBody)
                                  :ContentType('application/x-www-form-urlencoded')
                                  :AcceptJson()
                                  :REQUEST
     oResponse    = ResponseBuilder:Build():Response
     oClient      = ClientBuilder:Build():KeepCookies(CookieJarBuilder:Build():CookieJar):Client
    .                 
    
    oClient:EXECUTE(oRequest, oResponse) NO-ERROR.
    
    
    IF oResponse:StatusCode <> 200 THEN DO:
      MESSAGE 'Request Error: ' + STRING(oResponse:StatusCode).
      RETURN ERROR.
    END.
    
    oEntity = oResponse:Entity.
    IF TYPE-OF(oEntity, JsonObject)
        THEN oJResponse = CAST(oEntity, JsonObject).
        ELSE DO:
            MESSAGE 'ERROR: Cannot understand response from service' VIEW-AS ALERT-BOX.
            RETURN ERROR.
        END.
    
    
    oJResponse:WriteFile('c:\dev\response.json', TRUE).
    chToken  = oJResponse:getJsonText('access_token').       
    
    MESSAGE chToken VIEW-AS ALERT-BOX.
    
    /************ Now we have a token ***********/
    
    ASSIGN
     oURI:Path    = 'api/reportserver/v2/reports'
     oRequest     = RequestBuilder:GET (oUri)
                                  :AcceptJson()
                                  :AddHeader("Authorization", "Bearer " + chToken)
                                  :REQUEST
     oResponse    = ResponseBuilder:Build():Response
     oClient      = ClientBuilder:Build():KeepCookies(CookieJarBuilder:Build():CookieJar):Client
    .                 
    
    oClient:EXECUTE(oRequest, oResponse) NO-ERROR.