Calling procedures and service programs with the PHP Toolkit for IBM i

Calling procedures in RPG service programs, including getting the return value, is a powerful feature of the PHP Toolkit. The sample script below demonstrates how it’s done.

Note: Make sure your procedure name is 100% correct. It is case-sensitive. If you get an error, run the following command (replacing LIBNAME/PGMNAME with your library and program names) and look for your procedure name in the output. The command:
DSPSRVPGM SRVPGM(LIBNAME/PGMNAME) DETAIL(*PROCEXP)

The example below includes ‘boilerplate’ code to show best practices for connecting to the toolkit and checking for a successful connection. The illustration of how to call a procedure is in the second half.

For more information on the toolkit, see our toolkit information page or get in touch.

11 replies
  1. Antonio Matteazzi
    Antonio Matteazzi says:

    Hello,
    I just started to use ToolKit to retrieve data from iSeries.
    Ii is easy to use, I call RPG program or CL Command and retrieve parameters correctly.
    Only one problem.
    When instance connection, I pass username and password, but when i try to call program, the call is execute sa QUSER and not with the correctly username of connection.
    Why ?
    Thanks for your answer.

    Reply
      • Antonio Matteazzi
        Antonio Matteazzi says:

        Thank you for your answer.
        I undestand that “CURUSER” is the right field to use, but at work i have an ERP Software that work already in company and we have many programs that use USER for check the users.
        If I try to use an connection stateless = false, the field USER passed correclty but ISERIES display me all time the message CPF1240, the job XTOOLKIT ended abnormally.
        The first calling end fine, from the second error appears.

        Reply
  2. Willian Serpas
    Willian Serpas says:

    Hello, thnks, its a great code, so i have a situation, my pgm its on zendsvr lib, but my database its on another library, so i recieve the code RNX1216, how i can use something like I5_OPTIONS_INITLIBL=>”OTHERLIB” on i5_connect

    Reply
  3. Willian Serpas
    Willian Serpas says:

    Hello, thnks, its a great code, so i have a situation, my pgm its on zendsvr lib, but my database its on another library, so i recieve the code RNX1216

    Reply
    • Willian Serpas
      Willian Serpas says:

      Hello, thnks, its a great code, so i have a situation, my pgm its on zendsvr lib, but my database its on another library, so i recieve the code RNX1216, how i can use something like I5_OPTIONS_INITLIBL=>”OTHERLIB” on ToolkitService like on i5_connect

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.