× 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.



Thanks for the replies - I will bear all the comments in mind.
I just changed the packed fields to zoned which is the easiest solution
that works ok.


-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of
java400-l-request@xxxxxxxxxxxx
Sent: 05 August 2011 18:00
To: java400-l@xxxxxxxxxxxx
Subject: JAVA400-L Digest, Vol 9, Issue 95

Send JAVA400-L mailing list submissions to
java400-l@xxxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
http://lists.midrange.com/mailman/listinfo/java400-l
or, via email, send a message with subject or body 'help' to
java400-l-request@xxxxxxxxxxxx

You can reach the person managing the list at
java400-l-owner@xxxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of JAVA400-L digest..."


Today's Topics:

1. Using an AS400Structure as a program parameter (Eric Lee)
2. RE: Using an AS400Structure as a program parameter
(Mike Cunningham)
3. Re: Using an AS400Structure as a program parameter (David Gibbs)


----------------------------------------------------------------------

message: 1
date: Fri, 5 Aug 2011 17:09:48 +0530
from: "Eric Lee" <eric.lee@xxxxxxxxxxxxx>
subject: Using an AS400Structure as a program parameter

Hi,



I'm trying to call an RPG program with a Data structure as a program
parameter, but the data doesn't come in formatted as I have defined
them.

When I debug the RPG, the 70 long datastructure isn't formatted as I
expected.





I have a table of data, which is weights, lengths and countries and
postcodes etc....

I want to pass it as an array of data structures so the RPG can deal
with it easily by mapping the datastructure.



I would have thought the first 27 characters would contain the first 3
lots of packed decimals.The next 3 and next 9 the two text fields, then
the last lot, 9, 11 and 11 representing the last 3 packed fields.



But, the packed decimal fields don't get put into the data structure
with the right lengths. The decimal fields are truncated, and corrupt
all the data.



Can you define an array of data structures in this way, and can you mix
text and decimals as I have tried to do?







// Data structure containing values for each line of data :

AS400DataType[] clioDS = new AS400DataType[]{

new AS400PackedDecimal(9,2),

new AS400PackedDecimal(9,3),

new AS400PackedDecimal(9,2),

new AS400Text(3),

new AS400Text(9),

new AS400PackedDecimal(9,2),

new AS400PackedDecimal(11,2),

new AS400PackedDecimal(11,2)

};





AS400Structure struc = new AS400Structure(clioDS);

AS400Array ar = new AS400Array(struc, 99);



// Fill each line from the arrays of values

Object[] o = new Object[99];

for (int i = 0; i < 99; i++) {

o[i] = new Object[]{

new BigDecimal(clweights[i].toString()),

new BigDecimal(clvolumes[i].toString())

new BigDecimal(clloads[i].toString())

clcountries[i].toString(),

clpostcodes[i].toString(),

new BigDecimal(cltaxweights[i].toString()),

new BigDecimal(clfreightprices[i].toString()),

new BigDecimal(clsurcharges[i].toString())};

}



byte[] b = new byte[6930];

b=ar.toBytes(o);





ProgramParameter[] parms=new ProgramParameter[33];

parms[0]=new ProgramParameter(NXRSTS.toBytes(""),2);

parms[1]=new ProgramParameter(NXUSER.toBytes(user),10);

.........

parms[30]=new ProgramParameter(NXPALL.toBytes(pallets),2);

parms[31]=new
ProgramParameter(NXPALT.toBytes(pallettype),3);



// Clio array set parms



parms[32]=new ProgramParameter(b);









RPG code :



* CliO Data which is the entry paramter

E CLCH 99 70 CliO Charges



* CliO Charges

ICLCHRG DS

I 1 92CLGRSW

I 10 183CLCUBE

I 19 272CLFLAT

I 28 36 CLPOST

I 37 39 CLCTRY

I 40 482CLTAXW

I 49 592CLPRCE

I 60 702CLSURC



Then later on, read through the array and extract the data.



C DO 99 X

C MOVE CLCH,X CLCHRG

C CLGRSW IFEQ *ZERO

C CLCUBE ANDEQ*ZERO

C CLFLAT ANDEQ*ZERO

C CLPOST ANDEQ*BLANKS

C CLCTRY ANDEQ*BLANKS

C LEAVE

C ENDIF

C Z-ADDX CLTAXW

C Z-ADDX CLPRCE

C Z-ADDX CLSURC

C MOVE CLCHRG CLCH,X

C ENDDO



Best regards,

Eric Lee

Four Soft UK Limited

Ground Floor

Gladstone House

Redvers Close

Lawnswood Business Park

Leeds

LS16 6QY

UK





DISCLAIMER:?The information in this email (and any attachments) is
legally privileged and confidential. If you are not the intended
recipient, you must not use or disseminate the information. If you have
received this email in error, please immediately notify the sender by
"Reply" command and permanently delete the original and any copies or
printouts thereof. Although this email and any attachments are believed
to be free of any virus or other defect that might affect any computer
system into which it is received and opened, it is the responsibility of
the recipient to ensure that it is virus free and no responsibility is
accepted by Four Soft Limited or its subsidiaries or affiliates either
jointly or severally for any loss or damage arising in any way from its
use or incompleteness or any delay in its receipt".

------------------------------

message: 2
date: Fri, 5 Aug 2011 11:59:32 +0000
from: Mike Cunningham <mike.cunningham@xxxxxxx>
subject: RE: Using an AS400Structure as a program parameter

Explicitly define the numeric data in the DS as packed (P) data type.
Default in a data structure is unpacked. Or change the calling app to
define the numeric data as zoned



-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Eric Lee
Sent: Friday, August 05, 2011 7:40 AM
To: java400-l@xxxxxxxxxxxx
Subject: Using an AS400Structure as a program parameter

Hi,



I'm trying to call an RPG program with a Data structure as a program
parameter, but the data doesn't come in formatted as I have defined
them.

When I debug the RPG, the 70 long datastructure isn't formatted as I
expected.





I have a table of data, which is weights, lengths and countries and
postcodes etc....

I want to pass it as an array of data structures so the RPG can deal
with it easily by mapping the datastructure.



I would have thought the first 27 characters would contain the first 3
lots of packed decimals.The next 3 and next 9 the two text fields, then
the last lot, 9, 11 and 11 representing the last 3 packed fields.



But, the packed decimal fields don't get put into the data structure
with the right lengths. The decimal fields are truncated, and corrupt
all the data.



Can you define an array of data structures in this way, and can you mix
text and decimals as I have tried to do?







// Data structure containing values for each line of data :

AS400DataType[] clioDS = new AS400DataType[]{

new AS400PackedDecimal(9,2),

new AS400PackedDecimal(9,3),

new AS400PackedDecimal(9,2),

new AS400Text(3),

new AS400Text(9),

new AS400PackedDecimal(9,2),

new AS400PackedDecimal(11,2),

new AS400PackedDecimal(11,2)

};





AS400Structure struc = new AS400Structure(clioDS);

AS400Array ar = new AS400Array(struc, 99);



// Fill each line from the arrays of values

Object[] o = new Object[99];

for (int i = 0; i < 99; i++) {

o[i] = new Object[]{

new BigDecimal(clweights[i].toString()),

new BigDecimal(clvolumes[i].toString())

new BigDecimal(clloads[i].toString())

clcountries[i].toString(),

clpostcodes[i].toString(),

new BigDecimal(cltaxweights[i].toString()),

new BigDecimal(clfreightprices[i].toString()),

new BigDecimal(clsurcharges[i].toString())};

}



byte[] b = new byte[6930];

b=ar.toBytes(o);





ProgramParameter[] parms=new ProgramParameter[33];

parms[0]=new ProgramParameter(NXRSTS.toBytes(""),2);

parms[1]=new ProgramParameter(NXUSER.toBytes(user),10);

.........

parms[30]=new ProgramParameter(NXPALL.toBytes(pallets),2);

parms[31]=new
ProgramParameter(NXPALT.toBytes(pallettype),3);



// Clio array set parms



parms[32]=new ProgramParameter(b);









RPG code :



* CliO Data which is the entry paramter

E CLCH 99 70 CliO Charges



* CliO Charges

ICLCHRG DS

I 1 92CLGRSW

I 10 183CLCUBE

I 19 272CLFLAT

I 28 36 CLPOST

I 37 39 CLCTRY

I 40 482CLTAXW

I 49 592CLPRCE

I 60 702CLSURC



Then later on, read through the array and extract the data.



C DO 99 X

C MOVE CLCH,X CLCHRG

C CLGRSW IFEQ *ZERO

C CLCUBE ANDEQ*ZERO

C CLFLAT ANDEQ*ZERO

C CLPOST ANDEQ*BLANKS

C CLCTRY ANDEQ*BLANKS

C LEAVE

C ENDIF

C Z-ADDX CLTAXW

C Z-ADDX CLPRCE

C Z-ADDX CLSURC

C MOVE CLCHRG CLCH,X

C ENDDO



Best regards,

Eric Lee

Four Soft UK Limited

Ground Floor

Gladstone House

Redvers Close

Lawnswood Business Park

Leeds

LS16 6QY

UK





DISCLAIMER:?The information in this email (and any attachments) is
legally privileged and confidential. If you are not the intended
recipient, you must not use or disseminate the information. If you have
received this email in error, please immediately notify the sender by
"Reply" command and permanently delete the original and any copies or
printouts thereof. Although this email and any attachments are believed
to be free of any virus or other defect that might affect any computer
system into which it is received and opened, it is the responsibility of
the recipient to ensure that it is virus free and no responsibility is
accepted by Four Soft Limited or its subsidiaries or affiliates either
jointly or severally for any loss or damage arising in any way from its
use or incompleteness or any delay in its receipt".
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing
list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/java400-l.


------------------------------

message: 3
date: Fri, 05 Aug 2011 08:19:27 -0500
from: David Gibbs <david@xxxxxxxxxxxx>
subject: Re: Using an AS400Structure as a program parameter

On 8/5/2011 6:39 AM, Eric Lee wrote:
I'm trying to call an RPG program with a Data structure as a program
parameter, but the data doesn't come in formatted as I have defined
them.

Use PCML to call the program ... VERY easy to define data structures.

<pcml version="3.0">

<program name="SymbolicProgramEntryPointName"
path="/QSYS.LIB/%LIBL%.LIB/SRVORPGM.srvpgm"
entrypoint="HOST_PROGRAM_ENTRYPOINT">
<struct name="parms" usage="output">
<data name="subfield1" type="char" length="120"
/>
<data name="subfield2" type="int" length="4"
precision="31" />
<data name="subfield3" type="char" length="10"
/>
<data name="subfield4" type="char" length="32"
/>
<data name="subfield5" type="char" length="32"
/>
<data name="subfield6" type="char" length="10"
/>
<data name="subfield7" type="char" length="1" />
</struct>
</program>

</pcml>

david



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.