MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » May 2014

Re: Reading source files in RPGLE



fixed

I'm not sure at this point whether you got an answer. It appears that the thread wondered off-course.

If you're open to an SQL solution, just create an ALIAS for the member and read the alias instead:

1. CREATE ALIAS YourLib.YourAlias FOR YourLib.YourSRCPF (member_name)

2. SELECT * FROM YourLib.YourAlias

3. DROP ALIAS YourLib.YourAlias

For example, if you have a source member PRODLIB.QRPGLESRC.PROG001,

CREATE ALIAS PRODLIB.TempAlias FOR PRODLIB.QRPGLESRC (PROG001);
SELECT * FROM PRODLIB.TempAlias;
DROP ALIAS PRODLIB.TempAlias;


Of course, you could create the alias in QTEMP and then the DROP statement might not be necessary as QTEMP would be destroyed when the job ends.

HTH,
Robert

"Contrariwise, if it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic."--Tweedledee

On 05/19/2014 2:19 PM, Rob Dixon wrote:
I haven't needed to read a source file for about 24 years and didn't have
any problems reading them with OPM RPG.

Now I need to do it again and am using RPGLE. I can open the file and read
records but the fields are all empty. I must be doing something pretty
dumb. I am on V5R1. Can anyone help please? I have tried with both
externally described and program described files.

The code below is for the program described version

The file is defined in the program with

0001.10 FERPGLESRC IF F 112 DISK
0001.11 F USROPN

It is a full procedural file

The Input fields are

0248.39 IERPGLESRC DS
0248.40 I 1 6 2SRCSEQ
0248.41 I 7 12 SRCDAT
0248.42 I 13 112 SRCDTA

and the file statements are

0496.32 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * *
0496.33 C/SPACE
1
0496.34 C FNPEXT
BEGSR
0496.35 C/SPACE
1
0496.36 C Read ERPGLESRC
5152
0496.37 C/SPACE
1
0496.38 C
ENDSR
0496.39 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
0496.40 C/SPACE
1
0496.41 C FNP#1O
BEGSR
0496.42 C/SPACE
1
0496.43 * This subroutine opens the source
file
0496.44 C OPEN ERPGLESRC
51
0496.45 C MOVE 'Y'
OPNSRC
0497.08 C/SPACE
1
0497.09 C
ENDSR
0497.10 C/SPACE
1
0497.65 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*


I then do an override before calling the program

OVRDBF FILE(ERPGLESRC) TOFILE(E290PRDSRC/QRPGLESRC) MBR(E29RPP)
POSITION(*START)


I do a debug after the read statement and all the fields are empty but the
correct file member is open - I have checked the job using WRKACTJOB

I shall probably be embarrassed by the simplicity of the answer

Many thanks.








Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact