... this question is related to AppServer4RPG and was also posted to it.comp.as400 and answered there. For those who might be interested my answer there:
Hi Dario,
the data is sent by call fireEventP, wich is using QSNDDTAQ sending the Data
as an array of binary data. I'm using so called PORDS2POJO Objects looking
to one side like an RPG DS and to the other side as a Java Bean.
This bean should extend de.bender_dv.as400.datastructure.DataStructure or
de.bender_dv.as400.datastructure.Converter wich has some Convinience methods
to convert binary Data to Java data types and vice versa. (AS400Record is a
little bit outdated, I should set it deprecated).
All Conversion Metods are implemented in Converter and are named like
aS400TextToString and stringToAS400Text...
the conversion object would look like (untested):
package it.dario.pords2pojo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import de.bender_dv.as400.datastructure.DataStructure;
public class MailDS extends DataStructure {
private static final Log log = LogFactory.getLog(MailDS.class);
private byte[] huddle;
private String[] toAddr;
private String fromAddr;
public MailDS(byte[] huddle, int ccsid) {
super(ccsid);
this.huddle = huddle;
this.toAddr = new String[10];
this.setHuddle(huddle);
}
String[] getToAddr() {
return toAddr;
}
String getFromAddr() {
return fromAddr;
}
void setHuddle(byte[] huddle) {
byte[] work = new byte[10];
this.huddle = huddle;
System.arraycopy(huddle, 0, work, 0, 10);
fromAddr = this.aS400TextToString(work);
for(int i = 0; i < 10; i++){
System.arraycopy(huddle, (i+1) * 10, work, 0, 10);
toAddr[i] = this.aS400TextToString(work);
}
}
}
This way is much more flexible than using AS400RecordFormat, wich can't
handle data with variable length and nested data, as it was a requirement to
implement the ARDPGM interface. In the example your data is coming from
AS/400 and needed in Java, so that the other setter and getter methods are
not needed.
Dieter
"Dario" <carnevaledario@xxxxxxxxx> schrieb im Newsbeitrag
news:0de77b6a-423d-49c6-9813-7075665fd9f1@xxxxxxxxxxxxxxxxxxxxxxxxxxxx...
Hi Dieter,
Yes , it's an extension of
de.bender_dv.as400.datastructure.AS400Record.
I want send a this datastructor like in your Kunde example :
d MailDs ds
d qualified
D FROMaddr 64A
D ToAddr 64A DIM(10)
INZ(*blanks)
D BODY_FILE 20A
D BODY_MEMBER 10A
D SUBJECT 64A
D ATTACHMENTDS 64A DIM(10)
INZ(*blanks)
D SMTPHOST 64A
On 30 Dic, 14:23, "Dieter Bender" <dieter.ben...@xxxxxxxxxxx> wrote:
Hi Dario,
looks a little bit like an extension of
de.bender_dv.as400.datastructure.AS400Record, isn't it? . I wouldn't use
RecordFormat and AS400Array. What you get out of the DataQ is an array of
byte consisting of some well defined chunks of data. If you would provide
some details, it would be more easy to provide the code you would need.
Looking to your Snippet
format.addFieldDescription(new ArrayFieldDescription(new
AS400Array(new AS400Text(1, 280), 3), "CICCIO2"));
}
you are defining an Array of 3 Alpha Fields with length 1, you name it
CICCIO2 and you are expecting the data with CCSID 280. In RPG it would
like:
d CICCIO2 s 1a dim(3)
is this what you want???
D*B
As an Amazon Associate we earn from qualifying purchases.