PreviousNext
Help > Easycom .NET > Easycom namespace > EacXML > Example 5
Example 5

 

This is a simple RPG program:

 

D   PARM1         S             10a                

D   PARM2         S             20a                

                                                   

C     *entry        plist                          

C                   PARM                    PARM1  

C                   PARM                    PARM2  

                                                   

 /free                                             

    PARM2 = PARM1;                                 

    return;                                        

                                                   

 /end-free               

 

This RPG has been compiled using these commands:

 

CRTRPGMOD MODULE(EASYCOMXM3/SAMPLEPG1) SRCFILE(EASYCOMXM3/QRPGLESRC) SRCMBR(SAMPLEPG1) PGMINFO(*PCML) INFOSTMF('/tmp/SAMPLEPG1_easycomxm3.pcml')                            

CRTSRVPGM SRVPGM(EASYCOMXM3/SAMPLEPG1) EXPORT(*ALL) ACTGRP(SAMPLEPG1)

CRTPGM PGM(EASYCOMXM3/SAMPLEPG1) MODULE(EASYCOMXM3/SAMPLEPG1) 

The generated PCML file has been modified by adding the “path” attribute into the “program” tag:

 

<pcml version="6.0">

   <!-- RPG module: SAMPLEPG1  -->

   <!-- created: 2020-03-16-10.14.34 -->

   <!-- source: EASYCOMXM3/QRPGLESRC(SAMPLEPG1) -->

   <program name="SAMPLEPG1" path="/QSYS.lib/EASYCOMXM3.lib/SAMPLEPG1.pgm">

    <data name="PARM1" type="char" length="10" usage="inputoutput" />

    <data name="PARM2" type="char" length="20" usage="inputoutput" />

   </program>

</pcml>

                         

There is 2 ways to call SAMPLEPG1 program:

 

1) Use RPG description:

 

     EacXML oXml = new EacXML(ConnectionIBM);

 

     oXml.XmlBindSrv("SAMPLEPG1");

 

     oXml.XmlLoadDefinition("RPG", "EASYCOMXM3/QRPGLESRC,SAMPLEPG1");

 

     string result = oXml.XmlCallProgram("SAMPLEPG1", "<PARM1>Aura</PARM1>");

 

 

     XElement root = XElement.Parse(result);

     //< ParameterList > 

     //< PARM1 Type = "Char" > Aura </ PARM1 >

     //< PARM2 Type = "Char" > Aura </ PARM2 >

     //</ ParameterList >

 

     string displayResult = "";

     foreach (XElement el in root.Descendants())

     {

         displayResult = displayResult + el.Name + " = " + el.Value + " - ";

     }

     MessageBox.Show(displayResult);

 

 

2) Use PCML on IFS:

 

     EacXML oXml = new EacXML(ConnectionIBM);

     oXml.XmlLoadDefinition("PCML", "/tmp/SAMPLEPG1_easycomxm3.pcml");

     string result = oXml.XmlCallProgram("SAMPLEPG1", "<PARM1>Aura</PARM1>");

 

 

     XElement root = XElement.Parse(result);

 

     string displayResult = "";

     foreach (XElement el in root.Descendants())

     {

         displayResult = displayResult + el.Name + " = " + el.Value + " - ";

     }

     MessageBox.Show(displayResult);