RPG/36 or RPG II or RPG/400 sample program

35 pts.
RPG II program-defined disk output file
RPG/400 program-defined disk output file
Hi I need to write an RPG program that reads a program-defined file; does not use the program cycle, and outputs to a program-defined Disk file using either a WRITE or EXCPT. I am a 30-year RPG programmer who knows RPGIV, but I have forgottem how to code program-defined output files. Thanks, Stoney

Software/Hardware used:
AS/400 Vv5R3

Answer Wiki

Thanks. We'll let you know when a new response is added.

Code the output to the disk file the same way as if you were coding to a Printer file.
“O” spec with filename and and EXCEPT name
Follow that with the fields you want to output.


I don’t know if this program will work or not, but it’s close. I didn’t have any “OPM RPG but don’t use the Cycle” examples. I converted an old program to avoid the Cycle and it was harder than I expected. Man… I hadn’t realized how much has changed!<pre>
I 1 256 SAVF1
I 257 512 SAVF2
I 513 528 SAVF3
O SAVF1 256
O SAVF2 512
O SAVF3 528</pre>This simply takes a savefile and copies its records into a 528-byte PF. I think.

It’s quite a bit shorter using the Cycle in ILE RPG.

Good luck.


Discuss This Question: 8  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Stoney903
    Thanks Tom. That was a "Lotta" help! (Pun intended, Sorry.) I agree that a lot more has changed in what used to be a simple Report Program Generator. I liked your use of the LR as the READ EOF indicator. (I used 99 and then had to SETON LR after the ENDDO. I guess I should have put more detail: The Input file is 80 chars. and the Outfile has to be 92 chars. - a 12 digit sequential number (not a key) with the 80 chars from the Input record appended, which is the reason for this program. In case you are interested, the current application (circa 1996) is a PC which receives Telxon orders via a modem and FTP's a CSV extfile.dat file to an RS/6000 (AIX) which strips to commas; insert the 12 leading digits and renames it to orders.txt. The As/400 then FTP's the now unformatted file from the RS/6000 into a AS/400 PF Orders MBR Txt which is processed by a vendor's ERP software. The RS/6000 is on its last legs and the client wants it removed from the loop. So, I was hired to FTP the extfile.dat direct from the PC to the AS/400 without changing the vendor's ERP software (except changing the FTP client IP address); so, I need this silly two program-defined files program. (Luckily, the AS/400 FTP makes my job easier cause it not only changes the PC files from ASCII to EBCDIC, but also automatically puts a file.ext into an AS/400 PF file MBR ext.
    35 pointsBadges:
  • Stoney903
    CharlieBrowne: Are you there? Guess not! I received a "resume" from CharlieBrowne along with his picture and ALL of his postings. WOW! He sure claims a lot of postings, but when I tried to link to his answer, all I got was a loop back to my original question; Tom Lotta's answer, .and my reply to Tom Lotta. So, while I thank both gemtlemen for their prompt responses, I must say that in my view Tom Lotta's response was extremely helpful and CharlieBrownes was ... well - Sorry Charlie.
    35 pointsBadges:
  • TomLiotta
    In that case, my example might add 1 to a counter and simply include the counter in the O-spec for the output file. I had to break the 528-bytes apart because the field size limit used to be 256. Sheesh! Who could live that way? You know, it almost sounds as if this could be done with a pretty simple SQL statement. What OS version/release? Tom
    125,585 pointsBadges:
  • TomLiotta
    And CharlieBrowne has done a lot of good here. I've been away for a few years and just came back a month or two ago. CharlieBrowne has been about the best available here for quite a while. I wouldn't be surprised if he gets tired sometimes after as much as he's tried to do here. Everybody deserves to take a few breaks, eh? Tom
    125,585 pointsBadges:
  • Stoney903
    Tom You are a true gentleman and I, again, thank you for your response and opinions. The AS/400 version is V5R3. I first started computer programming when I worked for Time, Inc in Chicago, IL in 1962 (47 years ago.) I grew up with RPG and COBOL (...and PL/1 back then). I have taught college level courses in everything from Intro. to Computers 101 to HTML and JAVA (1982-2004). I am 68 years young; semi-retired and in addition to doing niche legacy consulting & programming for small AS/400 firms in North Central and South Central Wisconsin at rates that are less than half of that charged IT temp staffing firms; I own & run 3 other growing businesses and a R&D operation, and I have a not for profit small and startup business consulting office and have a 98% success rate. So, I am sorry I offended you, but I do not your appreciation for those you - unlike you - blow their own horns via the Internet (which I did not invent!) but used back in 1977 when it wasn't the WWW and had merely bulletin boards and not websites; and its backbone was connected to less than 500 government and university mainframes, and not to millions of ISP's and billions of PC's as it is today! So, it is fine to give credit to those that openly give needed advice to others (and are awarded points!), but please remember for very 100 of them, there are ones like me who actually go on the road and average less and $25 per hour, stay in cheap, small town motels (like Wille Loma travelling salesmen of the '40s) because there are those you need us, and we have a gift for analyzing business problems and solving those problems with computers. Yesterday, it was our career, but today, it is what we want and need to do. BTW: with your input, I signon to my long-standing Web-based AS/400 account at John Ross' Netshare400.com and actually got the program to compile; saved it to a CD, and will install it on my client's AS/400 on Dec. 30th and have the RS/6000 removed before the end of the year. (I have never missed a client deadline in the 15 years I have been a consultant.) By now, you and others are probably thinking, "What an arrogant S.O.B!" and, maybe, also wonder if I could have figured it out by myself? The answer is very likely: Yes; however, it is the week before Christmas and (thinking like a tthe teacher I am) I thought it would be fun to give a nice person like you not just a chance - but a challenge - to do something nice for someone else. You see, a part of being unselfish, is also giving others the chance to be unselfish, too. And, Tom, you ARE the hero in this story. The End.
    35 pointsBadges:
  • CharlieBrowne
    In respnse to Stoney903. I have no odea what you are talking about regarding sending you a 'resume' I have a profile setup on this system as most do, and when you click on someones name, that will appear along with their recent activity. If you got a automatic email from ITKE and that link did not take you to my response, I'm sorry, but I have no control over that. I'm guessing Tom and I responded about the same time. This has happened before. I would agree that Tom did go into much more detail that I did as to how to resolve your issue. I was inbetween meetings and did not thave the time to go in depth, but wanted to at least give you something to go on. I'm sorry if my response or the email situation caused you concern.
    62,385 pointsBadges:
  • TomLiotta
    I first started ... I first started wiring old logic boards -- interpreters, collators, "accounting" machines -- moved into 1401 machine language and then Autocoder (IOCS macros, etc.), COBOL next, then RPG, onto 360s and 370s, PL/1, BAL, and then a System/3. A number of years away from IBM -- DEC PDPs, HP 1000s/2000s/3000s, some Pick OS systems, and around to S/32 & S/34, before running across the S/38. After experiencing Pick, the S/38 coming from IBM was impressive to me. (The S/32-34 series was almost enough to keep me away from IBM.) I made the choice to stick with S/38 the rest of my career, at least to see if IBM would let it survive. I come here to give basic bits of things I've learned back to the community. For a while, I've chosen to use this site as my focus in my free time. This site is advertised as an 'Answer Wiki'. One of its characteristics is that the last person to contribute to an answer is the one whose name/icon is displayed, regardless of merit. This comment is separate from the "answer". It's listed under the "discussion" section. If my name is showing more often in recent months, it's because I'm generally the last one to add to the answer section. I'm on the west coast and I tend to be late in the day. I have an advantage of seeing what's already been written and choosing to add more detail during later hours. Others may have less time to dedicate, but be able to give a quicker answer that might be sufficient. It's not necessarily fair. It's just the way it is. Somebody else will have the spare time in a few months. I suspect that CharlieBrowne will continue as he usually has at a more steady pace, appropriate to the time he has. We all have our histories and our futures. Tom
    125,585 pointsBadges:
  • stemindiebos
    RPG stands for Report Program Generator. It originated from plug board programming where you selected steps by plugging in an wire in one hole and the other end went some where else on the board. I first came across it on a animal called an UNIVAC 1004. The on a project at ICL where on the 2903 and 2904 they had RPG2 which Escom ported from System 3.
    10 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: