Help with AS/400 array

235 pts.
Tags:
AS/400
iSeries RPG programming
Java
Java classes
RPG ILE
RPG IV
V5R4
hi evryone,

i'm a beginner with Java and i try this:

try{

AS400Array txtarr =new AS400Array(AS400PackedDecimal(55,0),100);

parmList[0] = new ProgramParameter(txtarr.toBytes(new BigDecimal(0)),55);

ProgramCall pgm =

new ProgramCall(sistem,"/qsys.lib/xxx.lib/....pgm",parmList);

in my RPG program i have this:

D numcli       s          55 0  dim(100)

C           parm       numclie  

i need get this array from rpg, how can i make this happening, i know that i need a ( for )instruction in java, to cacth the value from this array.

but anyone give me a example code for this kind of instructions?

thanks in advanced.

 



Software/Hardware used:
V5R4 OS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

This is a test sample where a service program procedure expects a DS DIM() parameter

RPG prototype :

<pre>

d modDs ds template qualified
d fieldA 10a
d fieldB 10a

d setDs pr
d myDs likeds(modDs) dim(100)
</pre>

The call from java :

<pre>
ServiceProgramCall service = new ServiceProgramCall(as400);

// define the parameter
AS400DataType[] types = new AS400DataType[]{
new AS400Text(10),
new AS400Text(10),
};

AS400Structure struc = new AS400Structure(types);
AS400Array ar = new AS400Array(struc, 100);

Object[] o = new Object[100];
for (int i = 0; i < o.length; i++) {
o[i] = new Object[]{“A”, “B”};
}

byte[] b = ar.toBytes(o);
ProgramParameter p1 = new ProgramParameter();

try {
as400.connectService(AS400.COMMAND);
service.setProgram(QSYSObjectPathName.toPath(“MYLIB”, “MYSRVPGM”, “SRVPGM”));

service.setMessageOption(AS400Message.MESSAGE_OPTION_ALL);
p1.setInputData(b);
p1.setParameterType(ProgramParameter.PASS_BY_REFERENCE);

service.setParameterList(new ProgramParameter[] {p1});
service.setProcedureName(“SETDS”);
service.setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);

boolean ran = service.run();
/….
</pre>

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    I'm not clear exactly what you're looking for. Please review the comments for How to prevent parameter 2 from getting into parm 1 in iSeries. There is an example program there that uses FOR to loop through a parm that carries an array. If that isn't quite what you're looking for, please describe differences. Tom
    125,585 pointsBadges:
    report
  • BUG68
    what i need is the code for java program, when i need use AS400Array class how i make, and how i define this kind of instructions for AS400Array(AS400PackedDecimal(55,0),. Is this the right way for what i have imn my RPG program or not? Before i put this question i travel across WEB, principally in IBM but i don't any friendly code for my doubt. thanks again for everybody
    235 pointsBadges:
    report
  • TomLiotta
    I might be more of a novice than you are for this question. Nevertheless, I'd look first at the toDouble() method of the AS400PackedDecimal() class. And with 55-digit numbers going to BigDecimals, you might instead need to use the toObject() method of AS400PackedDecimal. I'm pretty sure it'll be a while before I find example code that helps you. But maybe you can make progress just by having a suggestion. Tom
    125,585 pointsBadges:
    report
  • BUG68
    HI, again, i think i discovered a first step: String parme1 =""; AS400PackedDecimal x1=new AS400PackedDecimal(9,0); AS400Array nume1 =new AS400Array(x1,50); AS400Text y1=new AS400Text(40); AS400Array txt1 =new AS400Array(y1,50); parmList[0] = new ProgramParameter(x1.toBytes(0),50); parmList[1] = new ProgramParameter(y1.toBytes(parme1),50); i want now see de output, what i need for GET instructions? thanks Tom, for your first help.
    235 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following