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

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
    385 Posts

    Re: Rpg open access handler example

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

    Re: Rpg open access handler example

    ‏2012-11-30T14:39:34Z  
    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

    Re: Rpg open access handler example

    ‏2012-11-30T15:15:54Z  
    • PWConner
    • ‏2012-11-30T14:39:34Z
    Matteo,

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

    Thank you
    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

    Re: Rpg open access handler example

    ‏2012-11-30T15:26:32Z  
    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
    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

    Re: Rpg open access handler example

    ‏2012-12-14T15:28:54Z  
    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
    385 Posts

    Re: Rpg open access handler example

    ‏2012-12-14T15:56:40Z  
    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
    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

    Re: Rpg open access handler example

    ‏2012-12-14T15:57:18Z  
    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
    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

    Re: Rpg open access handler example

    ‏2012-12-17T18:53:36Z  
    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
    Thanks very much Barbara, The handler and the test program work like a charm.

    Happy Holidays
  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: Rpg open access handler example

    ‏2012-12-17T18:55:27Z  
    Hi Adi,

    I try to suggest something.

    At first:
    Try to remove from program TEST this statement:
    <pre class="jive-pre"> f handler( 'CSVHDLR') </pre>
    Recompile and excute TEST program. In this way u should have a spool.
    After you must reinsert the statement.
    <pre class="jive-pre"> f handler( 'CSVHDLR') </pre>
    After you can try to check your authority on your IFS in CSVHDLR you can reply with an other path:
    <pre class="jive-pre"> d path_const c const( '/home/test.csv') </pre>

    On green screen do you do

    strdbg CSVHDLR
    call TEST

    if do u do wrklnk '/home/test*' there isn't anything?
    Thanks Matteo, the programs work like a magic

    Happy Holidays
  • NancyMKannel
    NancyMKannel
    1 Post

    Re: Rpg open access handler example

    ‏2015-01-12T14:49:34Z  
    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

    I am having trouble locating the library QOAR.  Is this still available? 

  • barbara_morris
    barbara_morris
    385 Posts

    Re: Rpg open access handler example

    ‏2015-01-12T15:59:38Z  

    I am having trouble locating the library QOAR.  Is this still available? 

    Nancy, if you are on release 6.1 or 7.1, you need PTFs to get library QOAR.

    Here's the information about all the PTFs needed for Open Access. Many of the PTFs have been superseded, so you should get the latest supersedes.

    https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/We13116a562db_467e_bcd4_882013aec57a/page/Open%20Access%20announcement

    Here's the short URL for that page: http://tinyurl.com/rpg-oar-ptfs

    If you are on 7.2, QOAR should have been installed as part of installing the 7.2 version of 5770WDS.

  • RickMerlini
    RickMerlini
    3 Posts

    Re: Rpg open access handler example

    ‏2015-01-12T20:25:00Z  

    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
    115 Posts

    Re: Rpg open access handler example

    ‏2015-01-12T20:33:11Z  

    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

    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. 

     

  • barbara_morris
    barbara_morris
    385 Posts

    Re: Rpg open access handler example

    ‏2015-01-12T20:56:24Z  

    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

    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

    Re: Rpg open access handler example

    ‏2015-01-12T21:09:02Z  
    • JonParis
    • ‏2015-01-12T20:33:11Z

    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. 

     

    Jon,

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

    Thanks,

    Rick

  • RickMerlini
    RickMerlini
    3 Posts

    Re: Rpg open access handler example

    ‏2015-01-13T19:44:22Z  

    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)".

     

    Hi! Barbara,

    I followed your instructions.

    It worked.

    Thank you.

    Rick