Escolar Documentos
Profissional Documentos
Cultura Documentos
3. How we can use EXCEPT Opcode with respect to data base operations.
4. To update particular field in the file using the EXCEPT Opcode
5. If we need a continuation field say of length 250, but after the column 12, then code the
program as follows.
6. iSeries (AS/400) FTP Tips and Techniques
7. How are the indicators accessed in the program?
8. File exception (INFDS) codes for database file.
9. How to look for OUTQ & Printer device for your AS/400 interactive job.
10. How to Debug a Batch Job
11. How to access user ID in RPG.
test
REC1
UF E
DISK
READ
test
IF
not %eof()
Eval
fld1 = '11111'
Except suri
ENDIF
SETON
E
SURI
fld1
LR
5. If we need a continuation field say of length 250, but after the column 12, then code the
program as follows.
DDS
A
DSPSIZ(24 80 *DS3)
A
CA03(03 'EXIT')
A
R CNTFLDA
A
FLD001
250 B 5 3CNTFLD(60)
A 90
DSPATR(UL)
A N90
DSPATR(PR)
RPG
FCNTFLD CF E
WORKSTN
C
EVAL
FLD001 = 'KEANE INDIA LIMITED HYD'
C
EVAL
FLD001 = %TRIM(FLD001) +
C
'KEANE INDIA LIMITED HYD'
C
EVAL
FLD001 = %TRIM(FLD001) +
C
'KEANE INDIA LIMITED HYD'
C
EVAL
FLD001 = %TRIM(FLD001) +
C
'KEANE INDIA LIMITED HYD'
C
DO
C
EXFMT CNTFLDA
C
IF
*IN03 = *ON
C
LEAVE
C
ENDIF
C
ENDDO
C
SETON
LR
As the CNTFLD is not supported for output fields, make use of DSPATR(UL) & DSPATR(PR)
to display the both field as output field.
6. iSeries (AS/400) FTP Tips and Techniques
1.
2.
3.
4.
5.
6.
7.
how?
A. Although you can't do this with Rumba's file transfer, you can easily do it
with FTP. Although FTP's primary function is to perform file transfers, you can
use its RCMD subcommand to execute commands and programs on the AS/400. RCMD is
handy for launching AS/400 jobs that process the transferred files. The
following sample FTP command line shows how you can execute under Windows NT a
batch FTP job that performs a file transfer and calls an AS/400 program.
ftp -n -i -s:ftp400cmd.txt S101AA0A
The ftp command starts the Windows FTP application, and the -n and -i switches
indicate that the program will run in batch mode and won't perform any
interactive prompting. At the end of the line, S101AA0A specifies the name of
the AS/400 host system. The -s: switch specifies a file that contains the FTP
subcommands to be executed.
The contents of the ftp400cmd.txt file are as follows:
USER myID
myPWD
cd QGPL
put myfile.txt
quote rcmd call pgm(mylib/mypgm)
quit
The first line supplies the user ID used to connect to the AS/400, and the
second line supplies the password. Note that by default these values are sent
across the network in clear text. Although this is probably fine for most
internal networks, you shouldn't do this for public Internet access. The cd
subcommand changes the AS/400's current library to QGPL. The put subcommand
sends the file myfile.txt from the Windows NT system to the AS/400's QGPL
library. Next, the quote rcmd subcommands execute AS/400 program mypgm in mylib.
Finally, the quit subcommand terminates the FTP session. -- Michael Otey,
NEWS/400 Senior Technical Editor
4. Batch FTP Between AS/400s
To initiate an automatic batch FTP transfer from an AS/400, first create a
script in a source physical file containing valid FTP commands. To get it to
work in batch (that is, without user input) when you run the FTP session, you
must create a file override on a file called INPUT that tells the AS/400's FTP
client where to retrieve the commands from (instead of from the keyboard, as it
normally would). Thus, you override INPUT to point to your FTP script. If you
want to capture the FTP session's results, you also must override a file called
OUTPUT to a member where the session will be logged.
For example, to transfer member HISMBR in file HISFILE in HISLIB from remote
AS/400 HISAS400 to member MYMBR in file MYFILE in library MYLIB on MYAS400, use
the following script, which I've named FTPCMDS in the source file FTPSRC on the
AS/400 originating the FTP session (MYAS400):
MYUSER PASSIT
GET HISLIB/HISFILE.HISMBR MYLIB/MYFILE.MYMBR
QUIT
This script works for source file members. To use the script, start the FTP
server on the remote system (HISAS400) with the command STRTCPSVR *FTP. Then,
execute the following CL program on the source system (MYAS400):
PGM
OVRDBF FILE(INPUT) TOFILE(FTPSRC) MBR(FTPCMDS)
CLRPFM FTPSRC/OUT
OVRDBF FILE(OUTPUT) TOFILE(FTPSRC) MBR(OUT)
FTP HISAS400
ENDPGM
For this CL program to work, you must create a member called OUT in the FTPSRC
file, which will contain the responses from the remote AS/400. Look in this
member for any messages for debugging/error checking.
Note that the user ID and password must be stored in the FTP command source
member, so be sure to secure that member appropriately.
The above NEWS/400 tip is from Terry Silva.
5. Copy sources from the AS/400 to a PC
You can use the MGET FTP command.
From a DOS prompt on your PC:
ftp as400name
userid
password
prompt
quote site namefmt 1
mget QSYS.LIB/library.LIB/sourcefile.FILE/*.MBR
quit
The "prompt" command keeps FTP from asking you to confirm each transfer. You
could leave out the "quote site namefmt 1" command and use "mget
library/sourcefile.*" instead. Doing it that way will save the members on
the PC as "sourcefile.member". Switching to namefmt 1 as shown above will
save the members on the PC as "member.MBR".
6. File PC to a AS/400 spool file?
This will work for printing a file from a PC via FTP:
ftp as400
Name (as400:klemscot): klemscot
NARRATIVE - This program FTP function transfers ATB summary data (comma
delimited) to the finance shared corporate drive. FTP script instruction used to deliver
data are defined in file ARPFTPS.
PGM
PARM(&RMTSYSNAM)
DCL
VAR(&RMTSYSNAM) TYPE(*CHAR) LEN(30)
CLRPFM FILE(*LIBL/ARPFTPL)
OVRDBF FILE(INPUT) TOFILE(*LIBL/ARPFTPS)
OVRDBF FILE(OUTPUT) TOFILE(*LIBL/ARPFTPL)
FTP
RMTSYS(&RMTSYSNAM)
DLTOVR FILE(ARPFTPS)
MONMSG MSGID(CPF0000)
DLTOVR FILE(ARPFTPL)
MONMSG MSGID(CPF0000)
ENDPGM
Info:- For &RMTSYSNAM we need to pass the IP address or system name.
File ARPFTPS is used for logging the FTP commands to be executed. One such example is
listed below,
FINFTP FINFTP
CD /
CD /SYS2/SHARED/ATBREPT
PUT TARCUST/ARPATBWK HSDATB.XLS
QUIT
Where FINFTP is the Remote User ID and FINFTP is Password.
File ARPFTPL is used for logging the FTP messages. System will take care of logging the
messages in to the file. File is a flat file with 120A length field.
7. How are the
Ans) *IN
*IN(XX)
*INXX
D SPCL_STAT 38 42S 0
* SPECIAL status
D RECORD
*RECORD
* Record name
D MSGID
46 52
* Error MSGID
D SCREEN
*SIZE
* Screen size
D NLS_IN
*INP
* NLS Input?
D NLS_OUT *OUT
* NLS Output?
D NLS_MODE *MODE
* NLS Mode?
Example of Coding an INFDS with File Feedback Information
9. How to look for OUTQ & Printer device for your AS/400 interactive job.
Look for the value in the PRTDEV parameter of the job description is *USRPRF, which tells
the system to look at the PRTDEV parameter in user profile. If the value in the parameter
is *WRKSTN, which tells the system to look at the PRTDEV parameter in the work station
description.
Commands to use,
DSPJOBD, WRKUSRPRF, DSPDEVD DEVD(QPADEV0007)
Ref os/400 Printer device programming V5R1
10. How to Debug a Batch Job
Ans)
1
2
Session 1
3
4
Session 2
Session 1
Session 2
2
3
D USER
254 263
* User name
D JOB_NUM
264 269S 0
* Job number
D JOB_DATE
270 275S 0
* Date (UDATE fmt)
D RUN_DATE
276 281S 0
* Run date (UDATE)
D RUN_TIME
282 287S 0
* Run time (UDATE)
D CRT_DATE
288 293
* Create date
D CRT_TIME
294 299
* Create time
D CPL_LEVEL 300 303
* Compiler level
D SRC_FILE
304 313
* Source file
D SRC_LIB
314 323
* Source file lib
D SRC_MBR
324 333
* Source file mbr
D PROC_PGM 334 343
* Pgm Proc is in
D PROC_MOD 344 353
* Mod Proc is in
Example of Coding a PSDS Program Exception/Errors
17. To convert the contents of the database field from Lower case to Upper case.
In a logical you can use the file-level keyword ALTSEQ(QSYSRTNTBL) to convert the key fields
of the file to all upper case.
To do that to an individual field, you have to map the entire file (that is list all the fields you want in
the logical) and specify the TRNTBL(QSYSTRNTBL) keyword at the field-level
Displayed
Default
UValue
Default
UValue
Default
UValue
Default
UValue
None
UNone
Default
UValue
Default
UValue
Protected
No
No
Yes
Yes
No
No
Yes
Yes
N/A
N/A
No
No
Yes
Yes
Nothing
Marked with
Specified
Default
Value
Default
Value
Default
Default
Default
Default
Default
Value
Default
Default
Default
Default
> Symbol
No
Yes
No
Yes
No
No
No
No
N/A
N/A
No
No
No
No