× 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 James,

when I read your program schema "primary processing about 1000 records and then writing values back to some/all of them" i heard a load scream in my head: "SQL"

Modern SQL is more than

EXEC SQL SELECT * INTO :RECFMT FROM FILE WHERE ...

Using SQL window function like OVER(PARTITION BY ...) you can generate running totals, simulate "level breaks", summarize and count over subsets, and and and.

And using embedded SQL has multiple advantages:

1. You can develop, try, test and debug your SQL code interactively, until it works as you like.

2. You can develop complex logic with less code - and less code means less errors.

3. The poor soul, that has to maintain your code in 20 years from now, will probably know SQL, because it was, is and (as far as I can see) will be the Lingua Franca of relational databases.

Don't get me wrong - RPG is a great language - but add SQL and you get a combination, that is very hard to beat.

Just my 2ct.

Kind regards,
Daniel

P.S.: If you need support with wrapping your logic in modern SQL, just drop me a mail with more information, and I will try to help as good as I can.



Von meinem iPad gesendet
Am 03.08.2023 um 16:05 schrieb Hiebert, Chris <chris.hiebert@xxxxxxxxxxxxxx>:

The Cycle is all but deprecated in the **FREE format code.
**FREE is the future.


You can easily open the same file twice in Free format RPGLE.

You can use LIKEFILE and define them both in the mainline.

You can also define the file again in a sub procedure without any special overrides.

**FREE
Dcl-F FOOBAR Keyed block(*No);
Dcl-F BOZBAR LIKEFILE(FOOBAR);
Dcl-ds INFOOBAR EXTNAME('FOOBAR':*INPUT) Qualified End-ds;

Dcl-s key packed(3);

Dou %EOF(FOOBAR);
READ FOOBAR;
IF %EOF(FOOBAR);
LEAVE;
Endif;


SETLL (KEY) BOZBAR;
Dou %EOF(BOZBAR);
READE (KEY) BOZBAR INFOOBAR;
IF %EOF(BOZBAR);
LEAVE;
Endif;


Process( key);
Enddo;
Enddo;
Process( );
*INLR = *ON;
RETURN;


Dcl-Proc PROCESS;
Dcl-Pi *N;
key packed(3) options(*nopass);
End-pi;
// Reduce open/close by coding file as static, then include call to close file.
Dcl-F FOOBAR Keyed Static usropn;
Dcl-ds INFOOBAR EXTNAME('FOOBAR':*INPUT) Qualified End-ds;

If %parms() < %parmnum(key);
If %open(FOOBAR);
close FOOBAR;
Endif;
return;
Endif;

If not %open(FOOBAR);
open FOOBAR;
Endif;
Chain (KEY) FOOBAR INFOOBAR;


End-proc;


--
Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.

From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of James H. H. Lampert via RPG400-L
Sent: Tuesday, August 1, 2023 4:00 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Cc: James H. H. Lampert <jamesl@xxxxxxxxxxxxxxxxx>
Subject: Re: Opening the same file twice in the same program?



It worked. Thanks. I didn't think it would be this simple, but it almost

is. "Almost" because it also needs an EXTDESC and a RENAME, i.e. (note

that spaces are squeezed out for email purposes):



FFOOBAR IP E DISK EXTDESC('FOO/FOOBAR')

F EXTFILE(*EXTDESC)

F RECNO(RRN)

FBOZBAR UF E DISK EXTDESC('FOO/FOOBAR')

F EXTFILE(*EXTDESC)

F RENAME(FOOREC:BOZREC)



(I'm even using an EXTDESC and EXTFILE on the primary, for absolute

LIBL-independence, and there's also a RECNO clause on the primary,

because the PF is unkeyed, and there's no key that's especially useful.)



And Jon, my attitude about riding The Cycle is that you should use any

language feature that you find useful, especially if it's idiomatic

and/or unique to the language. And there's probably nothing in RPG

that's more idiomatic or unique to the language than The Cycle. So why

walk when you can ride?



That's not to say that I've ever found secondary files to be even

remotely useful enough to be worth figuring out how to use them.



--

JHHL
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


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.