× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello everybody,

I am using PCML to call C/400 Program from my Java program.
The C Program gets 2 arguments in the main's argv[] argument , and set the processed value back into argv[1].
When I run my java program and send the excepted arguments, the C program is executed but I can not get the returned value.
I set the usage in the PCML file to be inputoutput.
Is there a way to get the value that set back in argv[1] ?

Regards,
Tomer S.


Attached the C Progam, the PCML file and the Java Program

The C Program:
void main(int argc,char *argv[]) {
// Geting 3 string values as arguments in argv[]
// and return a processed string in argv[1]
{

My PCML file: (MyCProgPcml.pcml)
<pcml version="1.0">
<program name="myCProg" path="/QSYS.LIB/MyLib.LIB/MyC_Porg.PGM">
<data name="argv" type="char" length="100" usage="inputoutput"/>
</program>
</pcml>


My Java Program:
public static void main(String argv[]) throws IOException, PropertyVetoException {
String systemIp = "xxx.yyy.zzz.www";
String userName = "myUserName";
String password = "myPass";
String pcmlFile = "as400.pcml.sample1.MyCProgPcml";

System.out.println("Connecting to iSeries...");

AS400 as400 = new AS400(systemIp, userName, password);
boolean isLoginOk = as400.authenticate(userName, password);
if (!isLoginOk) return;

// Run the program
runPcml(as400Object, pcmlFile);

as400.disconnectAllServices();
}

public static void runPcml(AS400 as400Object, String pcmlFile) {
ProgramCallDocument pcml;
boolean rc = false;

try {
String programName = "myCProg";

// Instantiate the Objects (assign the variables)
pcml = new ProgramCallDocument(as400Object, pcmlFile);
String myArgs = "Hello World";

pcml.setValue("myCProg.argv", myArgs);

String valueStr = (String) pcml.getValue("myCProg.argv");

System.out.println("------------------------ Before Executing ---------------------------");
System.out.println("InputParameters: valueStr: " + valueStr);
System.out.println("--------------------------------------------------------------------");

// Debug statement...
com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true);

// Call the Program
System.out.println("Calling the program...");
rc = pcml.callProgram(programName);

// If return code is false, get messages from the iSeries
if (rc == false) {
String msgId, msgText;
// Retrieve list of AS/400 messages
AS400Message[] msgs = pcml.getMessageList(programName);

// Loop through all messages and write them to standard output
for (int m = 0; m < msgs.length; m++) {
msgId = msgs[m].getID();
msgText = msgs[m].getText();
System.out.println(" " + msgId + " - " + msgText);
}
System.out.println("Call to TEST failed. See messages listed above");
System.exit(0);
}

// Return code was true, call to PROGRAM succeeded - woo-hoo!

else {
// Process the returned Data
valueStr = (String) pcml.getValue("myCProg.argv");

System.out.println("------------------------ After Executing ---------------------------");
System.out.println("InputParameters: valueStr: " + valueStr);
System.out.println("--------------------------------------------------------------------");

System.exit(0);
}
} catch (PcmlException e) {
System.out.println(e.getLocalizedMessage());
e.printStackTrace();
System.out.println("Call to PROGRAM failed");
System.exit(0);
}
}


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.