Topic
16 replies Latest Post - ‏2015-01-13T19:44:22Z by RickMerlini
Matteo_Ceriani
Matteo_Ceriani
6 Posts
ACCEPTED ANSWER

Pinned topic Rpg open access handler example

‏2012-11-30T10:45:26Z |
I want to share with the community an example that I wrote on the use of handler.
In this program i have overlay the operation of open/write/close of a file for creating a CSV on IFS.
Hoping it will be a welcome.
Updated on 2012-12-17T18:55:27Z at 2012-12-17T18:55:27Z by SystemAdmin
  • barbara_morris
    barbara_morris
    383 Posts
    ACCEPTED ANSWER

    Re: Rpg open access handler example

    ‏2012-11-30T14:20:11Z  in response to Matteo_Ceriani
    Thanks Matteo. That will be a nice example for people to study.
  • PWConner
    PWConner
    20 Posts
    ACCEPTED ANSWER

    Re: Rpg open access handler example

    ‏2012-11-30T14:39:34Z  in response to Matteo_Ceriani
    Matteo,

    Can you post the command you use to create the handler? Also, can you post a program that uses the handler?

    Thank you
    • Matteo_Ceriani
      Matteo_Ceriani
      6 Posts
      ACCEPTED ANSWER

      Re: Rpg open access handler example

      ‏2012-11-30T15:15:54Z  in response to PWConner
      I tried to write this example that writes a printer file or you can download the example written from Barbara from this link:

      https://www.ibm.com/developerworks/mydeveloperworks/blogs/b542d3ac-0785-4b6f-8e53-f72051460822/entry/open_access_to_be_available_to_all_rpg_programmers15?lang=en
      • Matteo_Ceriani
        Matteo_Ceriani
        6 Posts
        ACCEPTED ANSWER

        Re: Rpg open access handler example

        ‏2012-11-30T15:26:32Z  in response to Matteo_Ceriani
        For compile Handler program:

        CRTBNDRPG PGM(*CURLIB/CSVHDLR) SRCFILE(*LIBL/QROUSRCE)SRCMBR(CSVHDLR) REPLACE(*YES)

        For compile test program and printer file:

        CRTPRTF FILE(*CURLIB/TESTPRTF) SRCFILE(*LIBL/QROUSRCE) SRCMBR(TESTPRTF) IGCCDEFNT(*SYSVAL) REPLACE(*YES)
        CRTSQLRPGI OBJ(*CURLIB/TEST) SRCFILE(*LIBL/QROUSRCE) SRCMBR(TEST) OBJTYPE(*PGM) REPLACE(*YES)
  • SystemAdmin
    SystemAdmin
    535 Posts
    ACCEPTED ANSWER

    Re: Rpg open access handler example

    ‏2012-12-14T15:28:54Z  in response to Matteo_Ceriani
    Hi Matteo,

    Thanks for sharing OpenAccessRpg, CSVHDLR, the test program and the printer file are all compiled
    without any changes. When I run in debug mode either in 5250 or in RDP, the write testr1 statement is executed. But there is no output, eventhough I changed the printer file on hold. As a matter of fact,
    when I checked for object( TESTPRTF) usage, the printer file was never used. We are running the IBM-power system at V7R1. Can you guess what may be the problem. At any rate, I thank you very much and wishinging the best for you Matteo.

    Adi Tonangi
    • barbara_morris
      barbara_morris
      383 Posts
      ACCEPTED ANSWER

      Re: Rpg open access handler example

      ‏2012-12-14T15:56:40Z  in response to SystemAdmin
      Adi, the printer file is not used at run time. It is only used for compiling the RPG program.

      The open access handler is writing to a CSV file. In the example, the file is hard-coded as /home/test.csv.

      When you are running in debug, try using Step Into on the WRITE operation in your RPG program, so you can see what the handler is doing.

      • Barbara
    • Matteo_Ceriani
      Matteo_Ceriani
      6 Posts
      ACCEPTED ANSWER

      Re: Rpg open access handler example

      ‏2012-12-14T15:57:18Z  in response to SystemAdmin
      Hi Adi,

      I try to suggest something.

      At first:
      Try to remove from program TEST this statement:
      
      f                                     handler(
      'CSVHDLR')
      

      Recompile and excute TEST program. In this way u should have a spool.
      After you must reinsert the statement.
      
      f                                     handler(
      'CSVHDLR')
      

      After you can try to check your authority on your IFS in CSVHDLR you can reply with an other path:
      
      d path_const      c                   
      
      const(
      '/home/test.csv')
      


      On green screen do you do

      strdbg CSVHDLR
      call TEST

      if do u do wrklnk '/home/test*' there isn't anything?
      • SystemAdmin
        SystemAdmin
        535 Posts
        ACCEPTED ANSWER

        Re: Rpg open access handler example

        ‏2012-12-17T18:55:27Z  in response to Matteo_Ceriani
        Thanks Matteo, the programs work like a magic

        Happy Holidays
  • RickMerlini
    RickMerlini
    3 Posts
    ACCEPTED ANSWER

    Re: Rpg open access handler example

    ‏2015-01-12T20:25:00Z  in response to Matteo_Ceriani

    Rpg open access handler example

    Late to the game.

    Is it possible to download Matteo's  Rpg open access handler example all I'm getting is Void(0) when trying to download.

    Many Thanks

    • JonParis
      JonParis
      113 Posts
      ACCEPTED ANSWER

      Re: Rpg open access handler example

      ‏2015-01-12T20:33:11Z  in response to RickMerlini

      Can't speak for Matteo's example - but I have published several myself.  If you are interested in a CSV handler in particular then this article not only provides a handler but does so by using an OA template that I developed which makes it really easy to develop handlers.

      Article "Open Access Made Easy With Templates" is here: http://www.ibmsystemsmag.com/ibmi/developer/rpg/open-access-templates/

      Download link for the materials is at the end of the article or download from our website

      You'll also find a number of other articles on OA on the IBM Systems Mag web site - just look under "More articles from Jon Paris"

       

      Hope this helps. 

       

      • RickMerlini
        RickMerlini
        3 Posts
        ACCEPTED ANSWER

        Re: Rpg open access handler example

        ‏2015-01-12T21:09:02Z  in response to JonParis

        Jon,

         I'm very grateful for your advice and quick response.

        Thanks,

        Rick

    • barbara_morris
      barbara_morris
      383 Posts
      ACCEPTED ANSWER

      Re: Rpg open access handler example

      ‏2015-01-12T20:56:24Z  in response to RickMerlini

      Rick, I was able to open Matteo's attachment, but only by clicking on it and then clicking on "Ok" to the question about the Developerworks terms of use. When I tried to right click and copy the link location, it gave me "javascript:void(0)".

      • RickMerlini
        RickMerlini
        3 Posts
        ACCEPTED ANSWER

        Re: Rpg open access handler example

        ‏2015-01-13T19:44:22Z  in response to barbara_morris

         

        Hi! Barbara,

        I followed your instructions.

        It worked.

        Thank you.

        Rick