The Butter Connection

aka "stanguru.com" and "themargerums.com"

Computer Tips & Help
AS400
PC
Hardware
Programming
Web Development
Virus
Spyware/Malware
Spam
Hoax Don't Spread It
Sports
Multiple Sclerosis
Election Stuff
Photography
Handy Links
Interesting
Cool Things
Gamer Stuff
Gallery
RPG Dates · RPG snippets

 

AS400 aka iSeries

 

Sub-menu at top for different sections on code snippets.

Here are some tips and code snippets that I have done to figure stuff out, because you know that the IBM book has every other kind of example but NEVER what you are looking for...ha. I love IBM books and the web site, seriously I figure out 5 other things in the process of trying to look up my immediate problem...very easy to get sidetracked reading and playing with some other functionality.

 

This page is a "work in progress", so a few things might be incomplete.

 

The code snippets are here to cut and paste as you please(they are formatted from position 1). They are by no means "working", they are just here to give you ideas on what and how things work.

 

Sections (for now until this page grows outta hand)


QDLS delete problem

I initially wasn't gonna put anything on my site about this problem, but after an upgrade and realizing that IBM wasn't gonna include it into an accum pack...I will give some info on it. I had already posted in on newsgroups and had solution.

 

Here is the problem:

When trying to delete a file from Win2k/XP that is under QDLS, it will error out saying:

ERROR: "Error deleting File or Folder" - "There is a sharing violation.
The source or destination file may be in use.

So here is what happened:

  • Win2k - You probably never really noticed the problem if you never did any automatic updates then you finally did. Win2k Hotfix KB867778 has never been included with a service pack...but now its in the KB885835 hotfix.
  • XP - You never noticed the problem until you loaded SP2. XPP(SP2) has the same problem with "Windows XP Hotfix Q812937" which was included with SP2

Conclusion:
XP - your hosed
Win2k - don't install the 885835 (hit details and uncheck it)
-OR-
convert all your stuff over to ROOT...ha good luck

looks like "Convert all them CPYTOPCD's to CPYTOSTMF's" is on your todo

-OR-

install PTFs (which IBM released)

 

 


Spoolfile to email PDF

There are a couple ways to send a spool file as a PDF in email. The 2 easiest ways I have time to figure out is:

  • Ops Nav - "Basic Operations, Printer Output", right-mouse on spoolfile and "Convert to PDF", "send as electronic mail", "To:" fill in your qualified email address. Note if the "Device for Conversion" is not filled in then you must set-up a PSF configuration, hit the Help key to walk you through setting up everything.
  • Outq (that is attached to a PSF configuration) - put something in the outq that you create and change the spoolfile attribute:
    USRDFNDTA('MAILTAG(someone@somewhere.net)')

key things you need

  • install product "5722IP1  V5R2M0    5050    IBM Infoprint Server for iSeries"
  • setup a "PSF configuration" (through Ops Nav) (below)
  • setup an "IPDS files to PDF" printer device (below)

CL snippet to override the printer file to the outq and send it...you build the email address

OVRPRTF FILE(QSYSPRT198) OUTQ(PDFIPDS) +
USRDFNDTA(&EADDRESS) SPLFNAME(SOMEREPORT)

CALL PGM(somepgm)

 

Create PSF config and IPDS (for emailing spoolfiles as PDFs from OpsNav)

Basically you print to a prtdev that is setup as an IPDS and it uses the PSF configuration to do the conversion.

 

PSF (straight from Ops Nav help)

Create a PSF configuration object that generates a PDF file

A PSF configuration object lets you specify parameters for an AFP printer that are not supported on the Create Device Description, Printer (CRTDEVPRT) command. You can create a PSF configuration object that instructs PSF and Infoprint Server to generate one or more PDF files and then do any combination of these with the PDF file: spool it to an output queue as a printer output file, store it as a stream file, or send it as e-mail.

You must have system configuration authority (*IOSYSCFG) to create a PSF configuration object. Generating PDF output requires Infoprint Server for iSeries.

To create a new PSF configuration object that causes a PDF file to be generated, follow these steps:

Note: These steps require Version 5, Release 3. If you have Version 5, Release 2 or earlier, follow the steps in Create a PSF configuration object that generates a PDF file (Version 5, Release 2 and earlier)

  1. In iSeries Navigator, expand My Connections (or your active environment).
  2. Expand AFP Manager.
  3. Right-click the PSF configuration objects container and select New.
  4. On the General page, specify a name for the PSF configuration object. The name cannot exceed 10 characters and must meet OS/400 name requirements.
  5. On the PDF Destinations page specify what you want done with the generated PDF files:
    1. Select Generate PDF.
    2. Select Store as printer output if yout want the PDF files spooled to an output queue. You must also specify the library-qualified output queue. Click Browse... to search for an output queue.
    3. Select Store as stream file if you want the PDF files stored as a stream file in the Integrated File System. You must also specify the stream file directory where you want the PDF file stored.
    4. Select Send as electronic mail if you want the PDF files sent as e-mail.
    5. For Administrator address, specify the e-mail address of the PDF administrator. Any PDF files that are not distributed properly are attached (if possible) to an e-mail that is sent to this address. Your iSeries must be set up to send e-mail to use this option. If the specified address is on an iSeries, that iSeries must be set up to receive e-mail. For instructions about setting up your iSeries to send and receive e-mail, refer to 

this is incomplete...my webpage tool had a little problem and i had to recreate everything below this, so i dont know what is correct in "straight from Ops Nav" section...i will recreate later


Transfer data to/from PC/AS400

There are 1,001 ways to get data in and out. Whichever way you figure out/use is up to you. Every situation is different, so I always follow the easiest(less code)/fail safe way to do it.

 

FROM - is getting data "from" AS400

TO - is putting data "to" AS400 (make sure you play with a test file, before doing it to production...it will bite you)

 

Program source

  • Ad-hoc
    • FROM - use Client Access Express "Data transfer from iSeries"
      • "LIBRARY/SOURCE(MEMBER)" remember all CAPS if you type it in
      • display it to the screen to "cut and paste" into a pc doc
    • TO - use CA Express, but save your FDF file from a "from" (previous tip) and use it to define the upload.
  • Automated (don't know if you would need to automate)

Data to a CSV (comma separated variable)

  • QShell - strqsh or qsh this is AWESOME!!!  )
    • change environment to output as ASCII - export QIBM_CCSID=437
    • db2 "SELECT field1||','||field2 from library.file where field3 = var" | sed -n '/,/p'  >> /public/filename.csv
      • the pipe sed removes the interactive headers/footers
  • Ad-hoc
    • FROM - use Client Access Express "Data transfer from iSeries"
      • "LIBRARY/FILE(*FIRST)" remember all CAPS and you can do "*FIRST" for member
      • change to FILE, hit DETAILS and select CSV
        • note - this will follow the CSV standards as in quoting strings so it will follow you file description that is defined on the 400
    • TO - use CA Express, but save your FDF file from a "from" (previous tip) and use it to define the upload.
  • Automated
    • FROM -
      key things - STMFCODPAG(*PCASCII) if you miss this, you won't be able to read the file
                   RCDDLM(*CR) it will barf telling you it needs some kind of record delimiter
      
      CPYTOIMPF FROMFILE(LIBRARY/FILE *FIRST) TOSTMF('/home/filename.txt') 
      STMFCODPAG(*PCASCII) RCDDLM(*CR)
      
    • TO -
      key things - command - FLDDLM(',')
      file - make sure you put in default of blanks, 
             because RPG can't handle null see I got a "null" problem
           A            AFIELD        20A         COLHDG('Field 1') 
           A                                      DFT('') VARLEN(20)             
          ---OR---
             be careful because if a field is blank your gonna get a null field
           A            AFIELD        20A         COLHDG('Field 1') 
           A                                      ALWNULL
      
      CPYFRMIMPF FROMSTMF('/home/filename.txt') +  
                   TOFILE(LIBRARY/FILE) MBROPT(*REPLACE) + 
                   RCDDLM(*CRLF) STRDLM(*NONE) FLDDLM(',') + 
                   RPLNULLVAL(*FLDDFT)                        
      

Data to a flat file (aka "Fixed Length Record", "ASCII Text", "Columned")

  • Ad-hoc
    • FROM -
      • "LIBRARY/FILE(*FIRST)" remember all CAPS and you can do "*FIRST" for member
      • change to FILE, hit DETAILS and select "ASCII Text"
        • note - watch for date formats and negative signs
    • TO -
  • Automated
    • FROM -
      key things - STMFCODPAG(*PCASCII) if you miss this, you won't be able to read the file
                   RCDDLM(*CR) it will barf telling you it needs some kind of record delimiter
                   DTAFMT(*FIXED) makes it fixed, default on this command is CSV
      
              CPYTOIMPF FROMFILE(LIBRARY/FILE *FIRST) 
              TOSTMF('/home/filename.txt')
              STMFCODPAG(*PCASCII) RCDDLM(*CR) 
              DTAFMT(*FIXED)
      
    • TO -
      key things - command - file - must be exact length 
              CPYFRMIMPF FROMSTMF('/home/file.txt') +                  
              TOFILE(LIBRARY/FILE) MBROPT(*REPLACE) +               
              RCDDLM(*CRLF) DTAFMT(*FIXED) + 
              STRDLM(*NONE) +
              FLDDFNFILE(LIBRARY/FILE)                                                 
               


SQL - 400 based Stuff

I am certainly not an expert on SQL...yet...so there might be easier ways than what I have posted

 

Examples and snippets are now on own page listed under programming page

 

 

Books

 

Tools to use and get started with:

  • STRSQL - Start SQL Interactive Session - good tool to test your select statements before entering them somewhere else ie: before you put them in RPG or MS Query.
  • STRQM - Start Query Manager for AS/400(Start DB2 UDB Query Manager) - if your familiar with Queries (WRKQRY), this is a very similiar interface that you can display the SQL statement once you have defined what you want.
  • MS Query - Microsoft Query - it's kinda hidden(well MS Office installs don't put an icon on the start menu), but it runs from your Excel or Word when you hit the get data.
    • To get to it directly search for "MSQRY32.EXE" (in MSO97 its located here "C:\Program Files\Microsoft Office\Office\MSQRY32.EXE").
    • This needs to have an ODBC data source created (you figure out that part).
    • This is a very good tool to use if someone needs to put it into a spreadsheet.
    • Once inside MS Query ways to get started:
      • visually(which is time consuming)
      • type it in via the "View, SQL" command/button
      • paste it in via the "View, SQL" command/button with code you got from STRSQL or STRQM (you might have some syntax changing). Using the 400 interfaces to figure out exactly what you want is less time consuming than going through the ODBC connection.
  • convert a QRYDFN to SQL - if you used to WRKQRY (OS400 Query), create query and convert
    key thing is the ALWQRYDFN to *ONLY
    RTVQMQRY QMQRY(lib/queryname) SRCFILE(yourlib/source) ALWQRYDFN(*ONLY)
  • Utility - http://www.innovativesys.net/index.php?pagename=frog&content=frog

 


ABA Bank Routing Number aka ACH Routing Number

 

Lingo

  • ABA - American Bankers Association
  • ACH - Automated Clearing House (mechanism or system name)
  • NACHA - National Automated Clearing House Association (government agency over ACH)
  • TFP - Thompson Financial Publications (responsible for tracking and assigning new ABAs(routing numbers)

Links to information

The Number

It's 9 digits. like DDBBXXXXC

  • D= Federeal Reserve District, 0-12 b/c there are 12 districts or 21-32 if thrift institution(done away with in 1985)
  • B = branch within the district
  • X = Financial Institutions number
  • C = check digit based on algorithm below
The Checksum Algorithm

Example:

7 8 9 4 5 6 1 2 4

 

Multiply the first digit by 3, the second by 7, the third by 1, the fourth by 3, the fifth by 7, the sixth by 1, etc., and add them all up.

 

(7 x 3) + (8 x 7) + (9 x 1) +
(4 x 3) + (5 x 7) + (6 x 1) +
(1 x 3) + (2 x 7) + (4 x 1) = 160

 

If this sum is an integer multiple of 10 (e.g., 10, 20, 30, 40, 50,...) then the number is valid, as far as the checksum is concerned.

 

If you want to validate the correct check digit, leave out the last number(the actual check digit) out of the summation, take the sum and subtract it from the next multiple of 10 and that is your check digit. In the example above the sum would be 156, so 160-156=4

Some Code

the link above has some Java script

 

RPGIV example on snippets link above

 


CL Stuff

 

  • Produce Job log in a CL
    • CHGJOB     OUTQ(QPRINT) LOG(4 0 *SECLVL) LOGCLPGM(*YES) +
                   INQMSGRPY(*SYSRPYL)
                              

 


IFS (Integrated File System)

  • cannot remove a file with a '\' in filename
    • file was created with a CPYTOIMPF and was supposed to go in the home directory located off the root, but the file was created in the root and looks like so: "\home\filename.txt"
    • You can use QSH to do it.  
      • CD to the directory
      • then enter:   rm logs\\file.txt
      • Explanation - the first '\' is an "escape" character.  It means: consider the following character (the second '\') as a simple character in the name, not as a special character denoting a subdirectory.


RCLSTG Information

 

this article taken from "The Four Hundred"

page http://www.itjungle.com/tfh/tfh092903-story04.html ...just in case it gets moved

 

Admin Alert: Tips on Running RCLSTG


 

by Joe Hertvik

Every once in a while, OS/400 system administrators should run a Reclaim Storage (RCLSTG) command on their system in order to fix and validate damaged objects. But the unfortunate thing about RCLSTG is that people sometimes don't understand how best to use it. This week, I'll look at what RCLSTG is and provide some tips on the best way to run it.

True to its name, RCLSTG attempts to validate and reclaim orphaned, damaged, and incompletely updated objects on an iSeries or AS/400 box. It also deletes unusable objects or fragments, so it's helpful for a system cleanup. But IBM isn't quite as enthusiastic about recommending RCLSTG as you might think. Big Blue states in its technical document on RCLSTG that the command should not be run "unless there is a warranted reason." While IBM may be a little dramatic with its verbiage here, you might want to think hard about using RCLSTG, because, among other things, it does the following for an auxiliary storage pool:

  • It checks every single object in the auxiliary storage pool and validates all the headers and pointers used by that object.
  • It locates orphaned objects and isolates them.
  • Whenever possible, it corrects objects that were incompletely updated.
  • It deletes any unusable objects or fragments.

The problem is that RCLSTG could produce some unpredictable results after it runs, and that's probably why IBM is more conservative in recommending it.

RCLSTG is easy to run, but the real trick lies in knowing how to set up your iSeries machine or partition for running it and then knowing what to do after it has run. Here's a sequence of commands I put together for successfully running RCLSTG.

Before Running the Command

  1. If you're reclaiming storage from the system and basic auxiliary storage pools, RCLSTG requires that your iSeries or AS/400 be in restricted mode in order to run the command. For an example of how to put your system into restricted mode, see "Getting In and Out of Restricted State." Since you have to run in restricted mode, you'll have to schedule RCLSTG to run during off-hours, when no production is running. There isn't a way to estimate how long it will take for RCLSTG to run, and sometimes it can run for very long time. Generally, the more often you run RCLSTG, the quicker it will complete. But if you've run RCLSTG before, you may be able to check the results of the last run by viewing the QRCLSTG data area in library QUSRSYS. QRCLSTG contains the start and stop times of the last RCLSTG run, your system name and serial number, and some messages about the last run.
  2. In addition to running in restricted mode, IBM also suggests that, if possible, you perform an IPL before running RCLSTG. With V5R1 and later versions of OS/400, you could satisfy this requirement and the restricted mode requirement by IPLing your system directly into restricted state. To learn how to do this, see "You Can Re-IPL into Restricted State."
  3. If you don't IPL your iSeries or AS/400 very often, you may want to take a snapshot of your system, in case you run into trouble after the command finishes. A large number of companies never take down their iSeries, and after they inevitably IPL the box, their administrators may find that many critical server jobs were not started after the IPL. To provide some hints in case of trouble, run the Work with Active Jobs (WRKACTJOB) command before you run RCLSTG and redirect the WRKACTJOB output to a printer file. (This printout can be helpful in pin-pointing what servers may need to be restarted after you run the system's startup program.) Do this by running WRKACTJOB in the following way:
WRKACTJOB OUTPUT(*PRINT)

Running the Command

RCLSTG is shipped with *EXCLUDE authority for public users, so sign on to your iSeries as a security-officer-equivalent user to run the command. If you're running RCLSTG on the primary auxiliary storage pool, go to the operator's console after the system enters restricted mode and type in the following command:

RCLSTG

For the primary auxiliary storage pool, it's fine to use the default parameters. But if you're running the command to reclaim storage on a non-system auxiliary storage pool, see IBM's technical note on running RCLSTG.

As I mentioned, it's impossible to estimate how long it will take to run RCLSTG. The unfortunate part is that, because it runs in restricted mode, you can't remotely check the command's progress, because all communications are shut down while RCLSTG is running. This means you'll have to be on-site to monitor this command (so bring lunch and a portable TV, especially if it's football season).

During the command execution, there are a few scenarios to be aware of. First, if the command detects a damaged user library, RCLSTG processing will stop. To recover, you'll need to restore a clean copy of the library from a previous successful save and then run the command again.

You should also understand that IBM says that you can cancel RCLSTG processing by using system request option 2. However, if RCLSTG is cancelled or can't be restarted after an error--such as trying to process a damaged user library--the database cross-reference files associated with the auxiliary storage pool you ran RCLSTG on may also be damaged. You can fix these files by running RCLSTG again with the database cross-reference table reclaim function, as follows:

RCLSTG SELECT(*DBXREF)

This will fix your cross-reference tables so you can restart your system without problems.

After Running the Command

Check for messages in the operator console job log, the history log, and in the QSYSOPR message queue. Correct any errors.

If RCLSTG finds any incomplete updated objects, OS/400 puts these objects in the following places: OS/400 library-based objects go into the QRCL library, and AS/400 Integrated File System (IFS) objects go into the /QReclaim or /QopenSys/Qreclaim directory.

You should examine these locations after running RCLSTG and deal with the items they contain as needed. IBM has some tips for handling items in the QRCL library in its technical document. If needed, you should also make a backup copy of the QRCL library and the /Qreclaim and /QopenSys/Qreclaim folders, in case you need to reference these objects later.

If RCLSTG finds any objects that were secured by an authorization list that was damaged or destroyed, OS/400 assigns those objects to a new authorization list called QRCLAUTL. You can obtain a list of objects secured by QRCLAUTL by using the Display Authorization List Object (DSPAUTLOBJ) command:

DSPAUTLOBJ AUTL(QRCLAUTL)

For orphaned objects where the user profile is damaged or destroyed, RCLSTG will assign object ownership to QDFTOWN, the default owner. RCLSTG generates messages when it transfers object ownership to another user. To display and manipulate all objects owned by QDFTOWN, you can use the Work with Objects by Owner (WRKOBJOWN) command, as follows:

WRKOBJOWN USRPRF(QDFTOWN)

If RCLSTG encounters any duplicate objects, it will rename those objects. The original object name can be found in the text description.

When you restart your system by using the OS/400 startup program, carefully check the QSTRUPJD job log to see if there are any messages that may have resulted from missing fixed or relocated objects. For more information on viewing the QSTRUP job log, see "Where's My QSTRUP Job Log?" and "Readers' Insights on Inactive Jobs and QSTRUPJD Job Logs."

So you can relax, because RCLSTG isn't as intimidating as it seems if you follow IBM's directions and some of the common-sense suggestions I have listed here.

 


ACCUM pack determination

 

Q.

How do I determine which Cumulative Fix package is installed?

A.

Use the DSPPTF command. For example, on V5R1, use the following command:

DSPPTF LICPGM(5722SS1)

After executing DSPPTF, you'll see the Display PTF Status screen. Cumulative Fix package identifiers begin with the letters TC. The topmost entry that begins with these letters and shows a status indicating the package has been applied determines your current Cumulative Fix level. Following the TC prefix is a five-digit number representing the Cumulative package's date. The first two digits indicate the year, and the last three digits indicate the Julian Date excluding the year.

For example: on a V5R1 system, Fix TC02134 would represent Cumulative Fix package C2134510. On V5R2, Fix TC02211 represents Cumulative Fix package C2211520.

 

To Order Accum Pack:

GO PTF

#6 - Order a program temporary fix

PTF Identifier = SF9xVRM

x=

  • 8=cover letter to tell you what latest is
  • 9=order cum pack delivered to your door

V= version

R= release

M= mod

 

Example: SF98520, would order cover letter for latest accum pack for v5r2m0

SF99520, would order the actual cum pack, airborne expressed on CD

 

http://www-912.ibm.com/s_dir/sline003.nsf/ALLPSPS?OpenView&Start=1&Count=30&Expand=1#1

 

display cover letters - just use PDM and goto QGPL/QAPZCOVER and look at the member names.

 


Backup source code

Get

400 step 1- CRTSAVF FILE(MY_LIBR/MY_SAVF)
400 step 2- SAVOBJ OBJ(MY_OBJECTS) LIB(MY_LIBR) DEV(*SAVF) SAVF(MY_SAVF) TGTRLS(V5R1M0)

 

PC

(from DOS prompt) cd C:\

ftp 10.2.3.4 (this should be the IP address of your AS/400)

enter your user ID

enter your password

ftp> cd /

ftp> bin

ftp> get qsys.lib/mylib.lib/mysavf.file

ftp> quit

 

OR

CPYTOSTMF FROMMBR('/qsys.lib/your_lib.lib/save_file.file') 

           TOSTMF('/home/myhome/savefile.savf')
           STMFOPT(*REPLACE)
           CVTDTA(*NONE)

 

Copy to

FTP  (target system)
(signon)
cd /some/where   (on the target system)
namefmt 1   (if using AS400-FTP, or QUOTE SITE NAMEFMT 1)
lcd /my/source   (on the target system)
bin   (binary transfer)
put mylib.savf   mylib.savf   (twice stated, save file does not need to
exist on target system)
exit

 

FTP

The library file system is NAMEFMT 0

From AS400 to PC

---issue the command NAMEFMT 0

From PC to AS400

---issue the command QUOTE SITE NAMEFMT 0

 

After that, issue the usual FTP commands.

 


Restore Objects from SAVF

 


RSTOBJ OBJ(*ALL)
SAVLIB(SAVEDFROM)
DEV(*SAVF)
OBJTYPE(*ALL)
SAVF(ACTSAVFLIB/ACTSAVFNAM)
MBROPT(*ALL) ALWOBJDIF(*ALL) FRCOBJCVN(*YES)
RSTLIB(RESTORTOLI)

- what objects
- where objects were saved FROM
- coming from a save file
- type being restored
- name of actual save file
- this is to force everything to restore no matter what
- where your gonna restore TO

 

 

 


 


You are here: Home-Computer Tips & Help-AS400

Next Topic: PC

Subtopics: RPG Dates RPG snippets