I often need to copy source code from an AS/400 source file member to a PC file. To facilitate this process, I created a utility called Copy To Folder (CPYTOFLR) shown in 7. The CPP for the command, FLR001CL, is shown in 8. It uses the Copy to PC Document (CPYTOPCD) command to copy a member to a PC file in an AS/400 folder. From there, the file is accessible to the PC through PC Support's shared folders function (the PC organizer is not required). For example, it can be copied to a PC drive such as C: or imported directly from the shared folder into a PC word processor.
I often need to copy source code from an AS/400 source file member to a PC file. To facilitate this process, I created a utility called Copy To Folder (CPYTOFLR) shown in Figure 7. The CPP for the command, FLR001CL, is shown in Figure 8. It uses the Copy to PC Document (CPYTOPCD) command to copy a member to a PC file in an AS/400 folder. From there, the file is accessible to the PC through PC Support's shared folders function (the PC organizer is not required). For example, it can be copied to a PC drive such as C: or imported directly from the shared folder into a PC word processor.
I created this utility because of the difference in naming conventions for an AS/400 member name and a DOS file name. An AS/400 member name can be up to 10 characters, whereas a DOS file name can contain only eight characters (plus a three-character extension). By default, the CPYTOPCD command gives the PC file the same name as the AS/400 member. This works fine as long as the member name is eight characters or less. However, if the member name is longer than eight characters, the CPYTOPCD command fails unless you supply it with a new name in the To Document (TODOC) parameter.
The CPYTOFLR utility solves this problem by reformatting the AS/400 member name to comply with the DOS file-naming convention. (The default TODOC parameter value of *CALC causes this to happen.) It uses the first eight characters of the member as the PC file name and the last two characters as the extension. This means that the CPYTOFLR command will work for any AS/400 member name, regardless of the length. You can also place a specific document name in the TODOC parameter.
To make this utility even more useful, it can be executed from a PDM user- defined option such as the one shown in 9. You'll need to supply the folder name that you want to copy the member to in the TOFLR parameter. Using this method, you can easily copy a member from a source file to a PC file by typing the option (PC) next to the member name on the Work with Members Using PDM (WRKMBRPDM) screen. This way you can be sure that the newly created file has a valid PC file name.
To make this utility even more useful, it can be executed from a PDM user- defined option such as the one shown in Figure 9. You'll need to supply the folder name that you want to copy the member to in the TOFLR parameter. Using this method, you can easily copy a member from a source file to a PC file by typing the option (PC) next to the member name on the Work with Members Using PDM (WRKMBRPDM) screen. This way you can be sure that the newly created file has a valid PC file name.
Simple File Transfer
Figure 7 Command CPYTOFLR
/*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/CPYTOFLR) PGM(XXX/FLR001CL) + */ /* SRCFILE(XXX/QCMDSRC) PRDLIB(QIWS) */ /* */ /*===============================================================*/ CMD PROMPT('Copy To Folder') PARM KWD(FROMFILE) TYPE(QUAL1) MIN(1) + PROMPT('From file') PARM KWD(TOFLR) TYPE(*NAME) LEN(80) MIN(1) + PROMPT('To folder') PARM KWD(FROMMBR) TYPE(*NAME) DFT(*FIRST) + SPCVAL((*FIRST)) PROMPT('From member') PARM KWD(TODOC) TYPE(*NAME) LEN(12) DFT(*CALC) + SPCVAL((*CALC)) PROMPT('To document') PARM KWD(REPLACE) TYPE(*CHAR) LEN(4) RSTD(*YES) + DFT(*NO) VALUES(*NO *YES) PROMPT('Replace + document') QUAL1: QUAL TYPE(*NAME) QUAL TYPE(*NAME) DFT(*LIBL) SPCVAL((*LIBL) + (*CURLIB)) PROMPT('Library')
Simple File Transfer
Figure 8 CL Program FLR001CL
/*===============================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/FLR001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===============================================================*/ FLR001CL: + PGM PARM(&QFILE &TOFLR &FROMMBR &TODOC &REPLACE) DCL VAR(&QFILE) TYPE(*CHAR) LEN(20) DCL VAR(&TOFLR) TYPE(*CHAR) LEN(80) DCL VAR(&FROMMBR) TYPE(*CHAR) LEN(10) DCL VAR(&TODOC) TYPE(*CHAR) LEN(12) DCL VAR(&REPLACE) TYPE(*CHAR) LEN(4) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) /* Send all errors to error handling routine */ MONMSG MSGID(CPF0000 IWS0000) EXEC(GOTO CMDLBL(ERROR)) /* Split out qualified file name */ CHGVAR VAR(&FILE) VALUE(%SST(&QFILE 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&QFILE 11 10)) /* Format PC file name */ IF COND(&TODOC *EQ '*CALC') THEN(DO) IF COND(%SST(&FROMMBR 9 2) *NE ' ') THEN(DO) CHGVAR VAR(&TODOC) VALUE(%SST(&FROMMBR 1 8) *TCAT '.' *CAT + %SST(&FROMMBR 9 2)) ENDDO ELSE CMD(CHGVAR VAR(&TODOC) VALUE(&FROMMBR)) ENDDO /* Copy member to folder */ CPYTOPCD FROMFILE(&LIB/&FILE) TOFLR(&TOFLR) FROMMBR(&FROMMBR) + TODOC(&TODOC) REPLACE(&REPLACE) /* Send completion message */ RCVMSG MSGTYPE(*COMP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*COMP) /* Branch around error handling routine */ GOTO CMDLBL(ENDPGM) /* Error handling routine */ ERROR: + RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) + MSGF(&MSGF) MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM: + ENDPGM
Simple File Transfer
Figure 9 User-Defined PDM Option
Option Command PC CPYTOFLR FROMFILE(&L/&F) TOFLR(folder_name) FROMMBR(&N)
LATEST COMMENTS
MC Press Online