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



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.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.