ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Php & RPG ? do they talk (& what do they talk about?)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Php & RPG ? do they talk (& what do they talk about?)

    Is it possible to call a RPG or CL program from a php web program and return variables? I am assuming php is running on iseries. If so, does RPG/CL program have to be written to accommodate CGI/HTML type variables with SQL wrappers or some java-goo, or does something magically interpret the variables for me. I know I get use SQL drivers to get a record or a set or records from as/400 database, however sometimes I would need a RPG program to access data and perform calculations (eg complicated tax calculations) before returning a value or set of values.

    Can the same program (assuming no interactive green screen) run both native and from php web script?

    I have seen examples like the following...

    PHP Code:
    $dbh odbc_connect("Driver={Client Access ODBC Driver (32-bit)};System=ipaddress",'user','pwd'); 
    $sql 'CALL /QSYS.LIB/MYLIB.LIB/EXAMPLECL.PGM(?,?)'
    $stmt odbc_prepare($dbh$sql); 

  • #2
    Re: Php & RPG ? do they talk (& what do they talk about?)

    Let me just say that I know this is possible. There is a guy here that is currently writing a web application in PHP and he has some back end business logic in RPG. I'm not exactly sure how he's connecting the two, but its definitely working I'll see if I can't find out a little bit more for you.
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #3
      Re: Php & RPG ? do they talk (& what do they talk about?)

      I think you are gonna like this one

      first the code....
      Code:
      // Setup parameters in associative array...
      $desc = array (
      
      	array ("name" => "corder", "io" => I5_INOUT, "type" => I5_TYPE_CHAR, "length" => "6"),
      	array ("name" => "line", "io" => I5_INOUT, "type" => I5_TYPE_CHAR, "length" => "3"),
      ); 
      
      // Prepare the program, similar to prototype in ILE...
      $prog = i5_program_prepare("PAC100R", $desc);
      if ($prog === FALSE)
      {
      	$errorTab = i5_error();
      	echo "Program prepare failed <br>";
      	var_dump($errorTab);
      	die();
      }
      You basically set up your parameters into an array and then call the i5_program_prepare(program, parmlist); function.

      This is specific to the i5 and is included with Zend Core for i5, which if your PHP server is on the i5 I think you should have it

      Then you can just have a program that accepts parameters on the iSeries. I would start here, if you have any more questions just ask and I'll try to find out more.
      Your future President
      Bryce

      ---------------------------------------------
      http://www.bravobryce.com

      Comment


      • #4
        Re: Php &amp; RPG ? do they talk (&amp; what do they talk about?)

        I found a very nice summary of these new "i5" php functions here, including the one for program calls. However I have to wonder who's bright idea it was to prefix each function with the version of th OS.

        Zend i5

        PHP Toolkit Functions Categories:
        • Connection Management
        • System Values
        • CL Calls
        • User Spaces
        • Program Calls
        • Job Log List
        • Data Retrieval
        • Active Job List
        • Native File Access
        • Data Areas
        • SQL File Access
        • Spooled File
        • Transactions
        • Object Listing
        • Data Queues

        Comment


        • #5
          Re: Php &amp; RPG ? do they talk (&amp; what do they talk about?)

          I'm guessing it wasn't Zend's idea. They are usually cleaner than that.
          Your future President
          Bryce

          ---------------------------------------------
          http://www.bravobryce.com

          Comment

          Working...
          X