PreviousNext
Help > API Functions > Program and Procedure calls > i5_program_prepare_PCML
i5_program_prepare_PCML

 

 Opens a Program or Procedure using a PCML description and prepares it to be run.

 

 resource i5_program_prepare_PCML (string description [, resource connection])

 

 

 

Parameters

 

 

description

PCML file's program and parameters information.
This parameter string can contain the PCML description itself, or the path to a text file containing the PCML description.

connection

Result of i5_connect

 

 

Return

Resource if open succeeded, false if open failed.

 

I5_ERR_DESC_WRONG_DATAOP

41

Wrong operation on a data field of a description

I5_ERR_PARSEXML

42

Internal error; please contact Aura Equipements.

error number 42

I5_ERR_PHP_OPTIONSTYPE

259

The type of " I5_OPTIONS_ALIAS" option must be x

and not x

I5_ERR_PHP_OPTIONSNUMBER

260

Option number -1 is unknown.

I5_ERR_PHP_TYPEPARAM

262

Type of element x in parameter -1 must be y.

Type z was provided.

I5_ERR_PHP_NO_DS_VALUE

307

You cannot set a value for 'Data Structure' x.

 

 

Detail

 

The program information file (in PCML format) can be created by compiling the RPG

program.

 

Example:

 

CRTBNDRPG PGM(EACDEMO/TEST) SRCFILE(EACDEMO/QRPGLESRC)

SRCMBR(TESTSTRUC) PGMINFO(*PCML)

INFOSTMF('/www/zendcore/htdocs/test.pcml')

 

The PCML file will contain the program parameters info. There are two ways you can assign the program parameters to i5-program_prepare_PCML description:

 

- Copy the content of PCML file to you PHP script and assign the i5_program_prepare_PCML description array to the PCML content. See PCML example in PCML Example 1

- Assign i5_program_prepare description array to the PCML file located in the same PHP program directory. See PCML example in figure 2

 

Example 1

 

 

$description = "<pcml version=\"4.0\">

<!-- RPG module: TEST -->

<!-- created: 2006-10-12-11.46.56 -->

<!-- source: EACDEMO/QRPGLESRC(TEST) -->

<!-- 5 -->

<struct name=\"S2\">

<data name=\"ZOND2\" type=\"zoned\" length=\"10\" precision=\"5\"

usage=\"inherit\" />

<data name=\"PACK2\" type=\"packed\" length=\"19\" precision=\"5\"

usage=\"inherit\" />

<data name=\"PACK3\" type=\"packed\" length=\"19\" precision=\"5\"

usage=\"inherit\" />

<data name=\"ALPH2\" type=\"char\" length=\"20\" usage=\"inherit\" />

</struct>

<!-- 1 -->

<struct name=\"S1\">

<data name=\"ZOND\" type=\"zoned\" length=\"10\" precision=\"5\"

usage=\"inherit\" />

<data name=\"PACK1\" type=\"packed\" length=\"19\" precision=\"5\"

usage=\"inherit\" />

<data name=\"ALPH1\" type=\"char\" length=\"10\" usage=\"inherit\" />

</struct>

<program name=\"TEST\" path=\"/QSYS.LIB/EACDEMO.LIB/TEST.PGM\">

<data name=\"CODE\" type=\"char\" length=\"10\" usage=\"output\" />

<data name=\"S1\" type=\"struct\" struct=\"S1\" usage=\"inputoutput\" />

<data name=\"S2\" type=\"struct\" struct=\"S2\" usage=\"inputoutput\" />

<data name=\"PACK\" type=\"packed\" length=\"1\" precision=\"1\"

usage=\"output\" />

<data name=\"CH10\" type=\"char\" length=\"19\" usage=\"output\" />

<data name=\"CH11\" type=\"char\" length=\"20\" usage=\"output\" />

<data name=\"CH12\" type=\"char\" length=\"29\" usage=\"output\" />

<data name=\"CH13\" type=\"char\" length=\"33\" usage=\"output\" />

</program>

</pcml>

";

 

 

                $hdlPgm = i5_program_prepare_PCML($description);

                if (is_bool ( $hdlPgm ) && $hdlPgm == FALSE)

                {

                               print_r("i5_program_prepare_PCML error : ".i5_errormsg().'<br/>');

                }

 

Example 2

               $description ='

                       <pcml version="4.0">

                       <program name="RPCSAMPLE" path="/QSYS.LIB/EASYCOMXMP.LIB/RPCSAMPLE.PGM" >

                                               <data name="OP1" type="packed" length="5" precision="2" usage="input" />

                                               <data name="STR1" type="char" length="20" usage="input" />

                                               <data name="OP2" type="packed" length="5" precision="2" usage="inputoutput" />

                                               <data name="STR2" type="char" length="30" usage="inputoutput" />

                                               <data name="OP3" type="packed" length="10" precision="4" usage="output" />

                       </program>

                       </pcml>';

               

                $hdlPgm = i5_program_prepare_PCML($description);

                if (is_bool ( $hdlPgm ) && $hdlPgm == FALSE)

                {

                               print_r("i5_program_prepare_PCML error : ".i5_errormsg().'<br/>');

                }

                else

                {

 

                $parameterIn = Array("OP2"=> 20.2, "STR2"=>"test", "STR1"=>"Hello", "OP1"=>                                                                                                                                                   10.1);

                $parameterOut = array("OP2"=>"parmOperator2", "STR2"=> "parmString2");

                $ret = i5_program_call($hdlPgm, $parameterIn, $parameterOut);

                if (!$ret)

                {

                                print_r("i5_execute error : ".i5_errormsg().'<br/>');

                }

                else

                {

                                echo "Parameter 3(P1+ P3, 10.1 + 20.2) : $parmOperator2<BR>";

                                echo "Parameter 4(P2), Hello : $parmString2<BR>";

                }

                }