02
Sat, Nov
2 New Articles

TechTalk May 2000

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Don’t Lose Your SEU Changes

Have you ever been in the middle of modifying an existing AS/400 source file, such as an RPG IV program, and deleted or changed lines of code that you didn’t really want to by using SEU? This is a frustrating and common occurrence, but there are a few things you can do to remedy the situation.

You could just press the F3 key to exit and not save any of your changes. That way, at least your original source will remain unchanged. This option will work fine, but it may not be the most desirable, since you will lose all the changes that you made. We all have enough to do without having to redo our own work.

You could exit, save your changes to another member name, edit the new member, and copy the source code you deleted or changed from the original member. This option will also work fine, with the exception of being a minor pain. Of course, you have to remember what you named the new member and then copy the changes back into the original source member. That could turn into a pretty big nightmare in a hurry.

The method that I have found that works best for me is to use the Browse/Copy Options (F15) in SEU to display a copy of the same source member I’m currently editing. Now all I have to do is position the copy to the lines that I accidentally deleted, copy them, and paste them into the current source. You can also use this method to browse the original code to see what it looked like before you made your changes.

— Greg Leister This email address is being protected from spambots. You need JavaScript enabled to view it.

SFLSIZ and SFLPAG Matters

Occasionally, it’s useful to retrieve SFLSIZ and SFLPAG numbers before initializing a subfile. A good example might be if the DDS file were changed and the subfile size or subfile page size were also changed. If you knew ahead of time, your program wouldn’t necessarily need to be recompiled. A subfile can have two sets of these numbers: one set for *DS3 (24 x 80 mode) and another set for *DS4 (27 x 132 mode). This information is not in the open file feedback area but is available in the Retrieve Display File Description (QDFRTVFD) API.

Figure 1 shows Retrieve Subfile Size (RTVSFLSIZE), an RPG IV procedure that accepts two parameters: a 20-byte qualified display file name and a 10-byte subfile control record format name. RTVSFLSIZE calls the QDFRTVFD API and returns an 8-byte


structure of four BIN(2) numbers: the set of SFLSIZ and SFLPAG numbers for *DS3 and *DS4.

A program need call RTVSFLSIZE only once for each subfile after a display file is opened. SFLSIZ and SFLPAG numbers don’t change while a display file is open. If the subfile specifies only *DS3 or *DS4 but not both, RTVSFLSIZE returns the SFLSIZ and SFLPAG numbers in the appropriate *DS3 or *DS4 subfield and returns 0,0 in the other subfields. If the display file or library doesn’t exist or if the record format name isn’t a subfile control record, RTVSFLSIZE returns 0,0,0,0.

Figure 2 shows a program that calls RTVSFLSIZE. This program gets the qualified display file name from the open file feedback area and requests the SFLSIZ and SFLPAG numbers for a subfile control record format named PAY01C.

The code for this tip can be downloaded at www.midrangecomputing.com/mc.

— Gene Gaunt Gene_Gaunt/This email address is being protected from spambots. You need JavaScript enabled to view it.

**********************************************************************************************

* To Create: *

* *

* CRTRPGMOD MODULE(QTEMP/RTVSFLSIZE) SRCFILE(xxx/QRPGLESRC) + *

* SRCMBR(RTVSFLSIZE) *

* *

* CRTSRVPGM SRVPGM(xxx/RTVSFLSIZE) MODULE(QTEMP/RTVSFLSIZE) + *

* EXPORT(*ALL) *

* *

**********************************************************************************************

* Procecure: RTVSFLSIZE (Retrieve Subfile Sizes) *

* *

* Input parameters: PARM FIELD TYPE *

* 1 display file name and library name CHAR(20) *

* 2 subfile control record format name CHAR(10) *

* *

* Return structure: POS FIELD TYPE *

* 1 SFLSIZ number (*DS3 24x80 mode) BIN(2) *

* 3 SFLPAG number (*DS3 24x80 mode) BIN(2) *

* 5 SFLSIZ number (*DS4 27x132 mode) BIN(2) *

* 7 SFLPAG number (*DS4 27x132 mode) BIN(2) *

**********************************************************************************************

H nomain

D RtvSflSize PR 8A

D 20A const

D 10A const

P RtvSflSize B export

D RtvSflSize PI 8A

D FileLib 20A const

D Record 10A const

D ReturnValue DS

D SubfileSize3 5I 0 inz(0) *DS3

D SubfilePage3 5I 0 inz(0)

D SubfileSize4 5I 0 inz(0) *DS4

D SubfilePage4 5I 0 inz(0)

D Qdff_Base DS based ( Qdff_Base@ ) base file section

D Wdff_Inof 5I 0 overlay( Qdff_Base : 9 )

D Wdff_Rcs 5I 0 overlay( Qdff_Base : 11 )

D Wdff_Scr 5I 0 overlay( Qdff_Base : 14 )

D Wdff_Scrs 5A overlay( Qdff_Base : 20 ) dim(2)

D Wdff_Scia 1A overlay( Wdff_Scrs : 1 )

D Qdff_Info DS based ( Qdff_Info@ ) file header section

D Wdff_Dflo 10I 0 overlay( Qdff_Info : 1 )

D Qdfa_Rfte DS based ( Qdfa_Rfte@ ) record format table

D Wdfa_Rfte 16A overlay( Qdfa_Rfte : 1 ) dim(2000)

D Wdfa_Rfnm 10A overlay( Wdfa_Rfte : 1 )

D Wdfa_Rfof 10I 0 overlay( Wdfa_Rfte : 13 )

D Qdff_Rinf DS based ( Qdff_Rinf@ ) record headr section

D Wdff_Rflg 1A overlay( Qdff_Rinf : 13 )

D Wdff_Raof 5I 0 overlay( Qdff_Rinf : 29 )

D Qdff_Sfcr DS based ( Qdff_Sfcr@ ) subfile control

D Wdff_Sfpm 24A overlay( Qdff_Sfcr : 55 ) dim(2)

D Wdff_Sfsz 5I 0 overlay( Wdff_Sfpm : 1 )

D Wdff_Sfpg 5I 0 overlay( Wdff_Sfpm : 3 )

D GET PR extpgm(‘QDFRTVFD’)

D 27A dummy length here


D 10I 0 const receiver’s length

D 8A const API format name

D 20A const display file name

D 10I 0 const API error code

D Test DS 27

D 4A

D SizeNeeded 10I 0

C callp GET( Test : 8 : ‘DSPF0100’ : FileLib : 0 ) get size needed

C alloc SizeNeeded Qdff_Base@

C callp GET( Qdff_Base: SizeNeeded : base file section

C ‘DSPF0100’ : FileLib : 0 )

C eval Qdff_Info@ = Qdff_Base@ + Wdff_Inof file header section

C eval Qdfa_Rfte@ = Qdff_Info@ + Wdff_Dflo record format table

C 1 do Wdff_Rcs X 5 0 scan record table

C Record ifeq Wdfa_Rfnm(X) if record name found

C eval Qdff_Rinf@ = Qdff_Info@ + Wdfa_Rfof(X) record headr section

C testb X’20’ Wdff_Rflg 21 (EQ)

C N21 iter not subfile control

C eval Qdff_Sfcr@ = Qdff_Rinf@ + Wdff_Raof subfile control rcrd

C 1 do Wdff_Scr Y 5 0 scan screen sizes

C select

C X’03’ wheneq Wdff_Scia(Y) if *DS3 size

C z-add Wdff_Sfsz(Y) SubfileSize3

C z-add Wdff_Sfpg(Y) SubfilePage3

C X’04’ wheneq Wdff_Scia(Y) if *DS4 size

C z-add Wdff_Sfsz(Y) SubfileSize4

C z-add Wdff_Sfpg(Y) SubfilePage4

C endsl

C enddo

C endif

C enddo

C dealloc Qdff_Base@

C return ReturnValue

P RtvSflSize E **************************************************************

* To Compile:

* CRTRPGMOD MODULE(QTEMP/PAY01R) +

* SRCFILE(xxx/QRPGLESRC) SRCMBR(PAY01R)

*

* CRTPGM PGM(xxx/PAY01R) MODULE(QTEMP/PAY01R) +

* BNDSRVPGM(xxx/RTVSFLSIZE)

***************************************************************

FPay01d CF E workstn infds(WsInfo)

F sfile(PAY01L:SfileRecno)

D WsInfo DS

D FileLib 83 102A

D Get PR 8A extproc('RTVSFLSIZE')

D 20A const

D 10A const

D SfileRecno S 5S 0

D Sizes DS

D SFLSIZ_3 5I 0 inz(0) *DS3

D SFLPAG_3 5I 0 inz(0)

D SFLSIZ_4 5I 0 inz(0) *DS4

D SFLPAG_4 5I 0 inz(0)

C eval Sizes = Get( FileLib : 'PAY01C' )

* now use subfile numbers for something ...

C move *on *INLR

Figure 1: RTVSFLSIZE returns subfile and page sizes.

Figure 2: This program calls the RTVSFLSIZE procedure.

Cleaning Up the AS/400 IFS

I’ve written several RPG IV applications that create files in the AS/400 Integrated File System (AS/400 IFS) on our AS/400. Too often during testing, I’ll miskey something, and the file name I’ve created in the AS/400 IFS contains invalid characters such as a file name containing slashes or quote marks: a definite no-no.

You’d think that I could use the Work with Links (WRKLNK) command to go into that directory and delete these files, but that’s not the case. The Remove (delete) function of


WRKLNK needs a valid AS/400 IFS file name as a parameter to locate the file and remove it. Since the misnamed files I created contain invalid characters, the Remove function fails.

There is a way around this problem, however: using FTP to delete the misnamed files in the AS/400 IFS. To accomplish this, do the following:

1. Start an FTP session on your AS/400 by typing FTP on any command line.

2. Change the Name Format to 1 using the namefmt 1 FTP command. This tells FTP that you are using a directory naming structure rather than a library naming structure.

3. Either change the directory to the AS/400 IFS directory where your misnamed files reside by using the FTP Change Directory (CD) command, or enter a fully qualified path name on the next step.

4. Enter the FTP command DEL YourFileName to delete the file. Remember that, if you didn’t use the CD command to set the directory to the location of the misnamed file, you need to enter the fully qualified path name on the DEL command. Also keep in mind that directory and file names are case-sensitive in some AS/400 filing systems, so take care when typing.

Now you know how to clean up all those misnamed files before anyone else finds

A Better Way to CSV

Looking for a way to create a comma-separated value (CSV) containing AS/400 physical file data? There are several methods for doing this, but here’s a couple you may not have considered. The first uses a CL program and a REXX program to build the CSV. The second uses a simple Java program to accomplish the same thing. The Java program is a bit more flexible, but, for those of you not as familiar with Java as you might like to be or for those of you wanting to explore the benefits of REXX (which comes free on every AS400), the first method may prove just as useful.

In the first solution, you create a list of AS/400 PTFs and build the CSV file from that data. The CL program shown in Figure 3 overrides the standard input and output files to a couple of work files, runs the Display PTF (DSPPTF) command to build the list, and outputs the results to a work file. It then calls the REXX procedure shown in Figure 4. The REXX program builds the CSV in the QTEMP library. Notice that the first record created contains nothing but the file’s column headers. This is useful if you want to import this file into a spreadsheet that requires headers for identification.

Once the REXX procedure is finished, the CL program executes the Copy to Stream File (CPYTOSTMF) command to move the CSV to the /Home directory of the AS/400 Integrated File System (AS/400 IFS). You can modify this procedure to work with any file on your system and move it to any directory your AS/400 has access to. The downside to this program is that it uses hardcoded column header and field names. To avoid this, you may want to use the Java program CvtToCSV, which you can download from the MC Web site at www.midrangecomputing. com/mc. CvtToCSV generates a CSV file from any AS/400 physical file, and you can include column headers if you need them. Keep in mind that the data may not load correctly in some spreadsheets without some formatting on your part.


them!

— Shannon O’Donnell Senior Technical Editor

Midrange Computing

To use this program, execute it from a PC DOS prompt or from an AS/400 command line or CL program, passing into it the following:

• The IP address of the AS/400 where the physical file resides

• A valid AS/400 user ID and password

• The name of the library where the physical file is stored

• The name of the physical file

• The name and path on the PC where the resulting CSV file should be placed

• A value of TRUE or FALSE that indicates whether or not to trim trailing blanks

• A value of TRUE or FALSE that indicates whether or not the first row of the CSV file should include column headers, such as in the following: When the Java program runs, it will connect to your AS/400, retrieve the database information, and build the CSV file in the directory you specified. By adding the AS/400 TCP/IP address (or host name) to the AS/400 constructor in the Java class, you can modify this program so it doesn’t require as many parameters to be passed to it. And if you don’t want any user interaction at all, you can hardcode all the parameters in the Java class and build either a DOS batch file or an AS/400 command and a CL program to execute the Java program. This is useful for those situations where you want the user to be able download AS/400 data without bugging you. If the user needs the flexibility of being able to enter any file name and library and you want to make this procedure more user-friendly, you can also build a Java GUI on this class to prompt the user for the parameters as required.

— Alex Garrison This email address is being protected from spambots. You need JavaScript enabled to view it.

/****************************************************************************/

/* */

/* To compile: */
/* */

/* CRTCLPGM PGM(XXX/PTFLISTC) SRCFILE(XXX/QCLSRC) */
/* */

/* */

/****************************************************************************/

/* PGM : PTFLISTC */
/* DESC: LIST PTFS ON SYSTEM AND CALL REXX PROCEDURE TO BUILD COMMA */
/* SEPERATED FILE IN USER'S HOME DIRECTORY */
/****************************************************************************/

PGM

/* ATTEMPT TO CREATE THE WORK FILES IN QTEMP */

CRTPF FILE(QTEMP/PTFLIST) RCDLEN(132) SIZE(*NOMAX)

MONMSG MSGID(CPF0000)

/* OVERRIDE STANDARD INPUT AND OUTPUT FILES TO WORK FILES */

OVRDBF FILE(STDOUT) TOFILE(QTEMP/PTFLIST)

OVRDBF FILE(STDIN) TOFILE(QTEMP/PTFWRK)

/* DUMP THE LIST OF PTFFS TO A WORK FILE */

DSPPTF OUTPUT(*OUTFILE) OUTFILE(QTEMP/PTFWRK)

/* STARTS A REXX PROCEDURE */

STRREXPRC SRCMBR(PTFLISTR) SRCFILE(*LIBL/QREXSRC)

/* COPY THE PHYSICAL FILE TO A COMMA SEPARATED FILE IN THE IFS */

CPYTOSTMF +

FROMMBR('QSYS.LIB/QTEMP.LIB/PTFLIST.FILE/PT+

java CvtToCSV 111.222.333.444 MYUSRPRF MYPASSWORD LIBNAME FILENAME
C:FILENAME.TXT TRUE TRUE


FLIST.MBR') TOSTMF('HOME/PTFLIST.CSV') +

STMFOPT(*REPLACE) STMFCODPAG(*PCASCII)

DLTOVR FILE(*ALL)

DLTF FILE(QTEMP/PTFLIST)

MONMSG MSGID(CPF0000)

DLTF FILE(QTEMP/PTFWRK)

MONMSG MSGID(CPF0000)

ENDPGM /****************************************************************************/

/* To Compile: NO COMPILING REQUIRED. PROGRAM WILL BE INTERPRETED. */
/* */

/****************************************************************************/

/* pgm : ptflistr */
/* desc: Builds Comma Separated File of PTFs */
/****************************************************************************/

/* output column headers */

say '"System","LicPgm","PTFid","Status","Date"'

/* output specific columns of file */

do until scptfid = ''

parse linein 2 scdate 8 ,

51 scppid 58 ,

58 scptfid 65 ,

71 scstatus 91 ,

202 scsysnm 210

if (scptfid '') then

do

say '"'scsysnm'","'scppid'","'scptfid'","'scstatus'","'scdate'"'

end

end

exit

Figure 3: This CL program executes a REXX procedure to build a CSV file.

Figure 4: This REXX procedure builds the CSV file.


BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: