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



Hi Marco



One thing you can do in Java to emulate your data structures is to create a new Class with getters and setters to hold the data structure information. This way is a little more work but is used a lot in Java.



You first create your class with setter methods and getter methods.

You use the setter methods to put in the values you want in the class.

When you want your information out you use the getter methods.



As I said this is a little more work than we are used to with RPG but you can then instantiate multiple versions of the same class and use it like we do the LikeDS and you can pass the object around to other objects and methods.



I jump back and forth between Java and RPG and spend most of my time in RPG so my Java terms are not always the best so I hope this makes sense to you.



Below is a sample I just grabbed from the internet.



public class Printer {

private String name;

private String salutation;



public String setSalutation(String salutation) {

this.salutation = salutation;

}



public String getSalutation() {

return salutation;

}



public void setName(String name) {

this.name = name;

}



public String getName() {

return name;

}

}

Printer myPrinter = new Printer();

Printer yourPrinter = new Printer();



myPrinter. setName(“my printer”);

yourPrinter.setName(“your printer”);



String myPrinterName = myPrinter.getName();



Also you cannot use the equals in java for strings like you showed in RPG. This does not work with Strings.

You must use the following.

If (myPrinter.getName().equals("myPrinter")) {

}



I hope that helps



Ron







-----Original Message-----
From: JAVA400-L [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Wednesday, December 02, 2015 7:06 AM
To: Java Programming on and around the IBM i
Subject: Re: Reading RPG style record in Java



Hi Marco



I'm not sure you need to declare something like an externally-defined DS

- when you use JDBC I believe you have a result set, which has a collection (probably the wrong word) of the columns. ODBC has this kind of thing - the resutlset.Fields() collection. There are ways to get all the attributes, too.



Now you should look at jt400 - I have to think that there are constructs for handling data sets as you want.



HTH

Vern



On 12/2/2015 1:58 AM, Marco Facchinetti wrote:

Hi Jon, I'm sure I can read the file without problems, both using

record level access or via Sql (jdbc).



The problem I can see is how to emulate what I ordinary do in RPG:

transfer a string into an externally desrcibed DS:



dow not %eof();

read af2wk;

if %eof();

leave;

endif;

Select;

When AWDSOPE = 'Ds_w_StampaTesto';

Ds_w_StampaTesto = AWFLD;

When AWDSOPE = 'Ds_w_StampaBox';

Ds_w_StampaBox = AWFLD;

Ds_w_StampaBoxExtended = AWFLDEX;

....

endsl;

enddo;



How do I declare an external defined DS in Java?



TIA



--

Marco Facchinetti



Mr S.r.l.



Tel. 035 962885

Cel. 393 9620498



Skype: facchinettimarco



2015-12-01 19:55 GMT+01:00 Jon Paris <jon.paris@xxxxxxxxxxxxxx<mailto:jon.paris@xxxxxxxxxxxxxx>>:



It is not clear to me why you think you need to worry about column

positions etc.



Any externally described file on the IBM i can be treated as a

database table. So as a minimum you could perform data retrieval via

a JDBC connection.



Your best bet is probably to get the JT400 toolbox *

http://jt400.sourceforge.net/) and that gives you both record level

and SQL access to the table.



Is there a reason why that won’t work?





On Dec 1, 2015, at 4:55 AM, Marco Facchinetti <

marco.facchinetti@xxxxxxxxx<mailto:marco.facchinetti@xxxxxxxxx>> wrote:

Hi, as implied by the title I have to read (and use) this file (and

cannot

modify it) in a Java program:



A R AF2WK TEXT('Afpds: workfile')

A*

A AWIDDOC 5 0 TEXT('Id doc')

A AWIDPAG 10 0 TEXT('Id page')

A AWIDOPE 14 0 TEXT('Id')

A AWNMOPE 20 TEXT('Operation')

A AWDSOPE 40 TEXT('Ds name')



A AWFLD 256 VARLEN(30) CCSID(1144)

A AWFLDEX 32000 VARLEN(1) ALWNULL DFT('')

A CCSID(1144)

A*

A K AWIDDOC

A K AWIDPAG

A K AWIDOPE



I use in RPG programs AWFLD and AWFLDEX as DS:



dDs_w_StampaTesto...



d ds qualified



d h like(Ubase)

Pos. Hor.

d v like(Ubase)

Pos. Ver.

d punti 4s 1

Punti, serve?

d font 8

Font

d codepage 8

Code page

d Orientamento 3s 0

0/90/180/270

d Lunghezza 3s 0

Len testo stampa

d Colore 3s 0

Colore testo



so the code is very easy:



Select;

When AWDSOPE = 'Ds_w_StampaTesto';

Ds_w_StampaTesto = AWFLD;

...

Endsl;



So my question is: how to do the same in Java with hardcoding

positions, names and types?



TIA



--

Marco Facchinetti



Mr S.r.l.



Tel. 035 962885

Cel. 393 9620498



Skype: facchinettimarco

--

This is the Java Programming on and around the IBM i (JAVA400-L)

mailing

list

To post a message email: JAVA400-L@xxxxxxxxxxxx<mailto: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<mailto:JAVA400-L-request@xxxxxxxxxxxx> Before posting, please take

a moment to review the archives at

http://archive.midrange.com/java400-l.



Jon Paris



www.partner400.com<http://www.partner400.com>

www.SystemiDeveloper.com<http://www.SystemiDeveloper.com>



--

This is the Java Programming on and around the IBM i (JAVA400-L)

mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx<mailto: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<mailto:JAVA400-L-request@xxxxxxxxxxxx> Before posting, please take

a moment to review the archives at

http://archive.midrange.com/java400-l.







--

This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx<mailto: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<mailto: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 ...

Follow-Ups:
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.