Quick and easy on the AS/400.
by Art Tostaine, Jr.
If you distribute programs, files, or reports to remote AS/400s, you might mail diskettes to perform that distribution. But if the recipient is waiting for something critical such as a program fix, even express mail is not fast enough. With the utility presented in this article, you can now send objects from AS/400 to AS/400 through the phone lines.
The commands LINK400 and UNLINK400, presented in the November 1989 issue of Midrange Computing (then DataNetwork), allow users to transfer files and source programs between AS/400s through a simple interface which activates the AS/400's communications function, File Transfer Support. Moreover, LINK400/UNLINK400 simplified Display Station pass-through so that users can easily sign on to the other system. The only hardware and software required is that which comes with the system.
But the fact that these programs can't transfer ALL object types, such as programs and libraries, is a major limitation; further, even though it transfers files, it does so only one at a time. Since then, I have written another set of commands and programs that go beyond LINK400/UNLINK400. By configuring your system as part of System Network Architecture Distribution Services (SNADS) as shown in 1, configuring a communication Line, Controller, and Device (2), and creating the SNDOBJ (3) and RCVOBJ (4) commands and programs, you will be able to send or receive all types of objects except documents between AS/400s. In addition, you'll be able to send messages to users on the other AS/400.
But the fact that these programs can't transfer ALL object types, such as programs and libraries, is a major limitation; further, even though it transfers files, it does so only one at a time. Since then, I have written another set of commands and programs that go beyond LINK400/UNLINK400. By configuring your system as part of System Network Architecture Distribution Services (SNADS) as shown in Figure 1, configuring a communication Line, Controller, and Device (Figure 2), and creating the SNDOBJ (Figure 3) and RCVOBJ (Figure 4) commands and programs, you will be able to send or receive all types of objects except documents between AS/400s. In addition, you'll be able to send messages to users on the other AS/400.
Configuration
You must perform a separate one-time configuration for each of the two AS/400s. Because the configurations for each system are slightly different, we must identify each system uniquely. We will name the system originating the call System 1 and the other System 2.
Figures 1 and 2 outline the configuration steps for both systems. You must have *SECADM authority to run the configuration steps. After you have done your configurations, key and compile the programs and commands listed in Figures 3 and 4.
Sending and Receiving
Now you're ready to send an object or message. Most likely you would start by sending a message to the other system to let them know that an object is about to be sent. In order for any system to receive a message, subsystem QSNADS must be active. A message can be sent to any user on the other system providing that the User ID and the User Address are in the directory of the remote system. To add a user and address, use the ADDDIRE command.
In the configuration for System 2 we started QSNADS. If it is not active, just key the following: STRSBS QSNADS. (If your system distributes objects on a regular basis, QSNADS subsystem should always be started along with your other subsystems.)
From System 1, type SNDOBJ on the command line and press F4. Fill in the
parameters as follows:
Object Type (OBJTYP): Enter the type of object you wish to send. This program
groups objects into four types:
*SPOOL (a spool file)
*LIB (an entire library)
*OTHER (any other kind of object such as a file or data area)
*MSG (a message)
If *MSG is entered, you will be prompted for up to 256 characters of message
text.
If *SPOOL is entered, the following three prompts are displayed:
Spool File Name: Enter the spool file name to be sent.
Job Name: The job name which created the spool file. AS/400 interactive job names consist of the Display Station ID, User ID name, and a sequential number assigned by the computer, separated by slashes (i.e., DSP13/JOE/083410). Batch jobs consist of the batch job name, the User ID, and a sequential number separated by slashes (i.e., CUSTLIST/JOE/083422). The job name for spool files can be obtained by using the WRKSPLF command to display the spool entry. Enter Option 8 (attributes) next to the desired spool file.
Spooled File Number: Enter (1-99), *ONLY, or *LAST. Enter *ONLY if there is only one file currently on the spool, *LAST to take the last file spooled, or a number to take a specific file. For most applications, *LAST should be used, because it will always send the most recent file.
If *LIB or *OTHER is entered, three prompts are displayed:
Object Name (or Library Name): Enter the object name to be sent. Generic names can be entered to send more than one object.
Member Name, *FIRST or *ALL: Enter the member name if the object is a file. *FIRST is the default and will send the first member of the file. If the object is not a file, this parameter is ignored.
Library Name: If the object type is *OTHER, then the library name is required. *LIBL can be entered and the system will search the current library list for the object. This library name will also be the target library name.
For all object types, three additional parameters are displayed:
To User ID Name: If sending to System 1, enter USER1. If sending to System 2, enter USER2. The default value is USER2.
To User Address: If sending to System 1, enter ADRS1. If sending to System 2, enter ADRS2. The default value is ADRS2.
Which System: Enter a '1' if you are System 1 (the system originating the call), or a '2' if you are System 2 (the system answering the call). The default value is '1'.
When SNDOBJ is run from System 1, it makes the call, establishes the connection, and sends the object or message. A message goes directly to the user (as long as subsystem QSNADS is active). Objects are sent to Network Files. System 2 must then run RCVOBJ to extract the objects from the Network Files.
Note: Be aware that, as it is set up in Figures 1 and 2, only System 1 can call and only System 2 can answer. If you want to change the calling or answering system, you will need to make some modifications to the communications controllers. Use the CHGCTLAPPC command to change the INLCNN (Initial Connection) parameter to *ANS for the System 1 controller, TEMPLCL. Change the System 2 controller, TEMPRMT, parameter INLCNN, to *DIAL.
References:
Communications: User's Guide (SC21-9601) Programming: Control Language Reference (SC21-9775, 9776, 9777, 9778, 9779)
Object Distribution Utility
Figure 1 One-time configurations for Systems 1 & 2
Figure 1: One-time configurations for System 1 and System 2. Before you start, you must know the system name for each system. Use DSPNETA on both System 1 and System 2 to determine the names. The following configuration must be performed on both System 1 and System 2. The configurations are the same for both systems except for two variables (x and y). Substitute the values shown below for these variables. For example, when configuring System 1, substitute the number 1 for x and TEMPLCL for y. System 1 System 2 w = TEMPRMT TEMPLCL x = 1 2 y = TEMPLCL TEMPRMT z = 2 1 CRTUSRPRF USRPRF(USERx) ADDDIRE USRID(USERx ADRSx) USRD(Local USERx) USER(USERx) + SYSNAME(System x name) ADDDIRE USRID(USERz ADRSz) USRD(Remote USERz) USER( ) SYSNAME(System z + name) Next, enter CFGDSTSRV (Configure Distribution Services). Select Option 1 to configure a Distribution Queue. These Queues contain the information to route objects to another system. Press F6 to add the Distribution Queue Entry Specify SxSYSQ for Queue prompt, and w for the Remote Location Name prompt. Press enter, then F12 twice to return to the Configure Distribution Services display. Select Option 2. Press F6 to add the routing entry in the source system. On the Add Routing Table Entry display, type the System z name for the system name/Group prompt. Type SxSYSQ for all of the following prompts: o Fast Queue Name o Status Queue Name o Data High Queue Name o Data Low Queue Name Press enter and press F12 three times to exit CFGDSTSRV. In order to use QSNADS, a communications entry must be added to the QSNADS subsystem. ADDCMNE SBSD(QSNADS) DEV(*APPC) JOBD(*USRPRF) DFTUSR(QUSER) MODE(*ANY) + MAXACT(*NOMAX) If System 2 start the QSNADS subsystem: STRSBS QSNADS
Object Distribution Utility
Figure 2 Line, controller and device configuration
Figure 2: Line, Controller, and Device Configuration for System 1 and System 2. Create a line, controller, and device for each system, using the following commands and parameters. (This configuration is the same as the one used in the LINK400 program mentioned earlier.) System 1 CRTLINSDLC LIND(TEMPLCL) RSRCNAME(LIN011) ONLINE(*NO) + ROLE(*PRI) CNN(*SWTPP) EXCHID(05600001) NRZI(*YES) + LINESPEED(2400) AUTODIAL(*YES) DIALCMD(*V25BIS) DUPLEX(*FULL) (The LINESPEED parameter must agree with your modem speed.) CRTCTLAPPC CTLD(TEMPLCL) LINKTYPE(*SDLC) ONLINE(*NO) + SWITCHED(*YES) APPN(*NO) SWTLINLST(TEMPLCL) MAXFRAME(521) + RMTNETID(*NONE) EXCHID(05600002) INLCNN(*DIAL) + CNNNBR(target_phone#) ROLE(*SEC) STNADR(01) (The CNNNBR parameter contains phone number of system being called.) CRTDEVAPPC DEVD(TEMPLCL) RMTLOCNAME(TEMPRMT) ONLINE(*NO) + LCLLOCNAME(TEMPLCL) RMTNETID(*NONE) CTL(TEMPLCL) MODE(BLANK) + APPN(*NO) System 2 CRTLINSDLC LIND(TEMPRMT) RSRCNAME(LIN011) ONLINE(*NO) + ROLE(*SEC) CNN(*SWTPP) EXCHID(05600002) NRZI(*YES) + LINESPEED(2400) AUTODIAL(*YES) DIALCMD(*V25BIS) DUPLEX(*FULL) + STNADR(01) (The LINESPEED parameter must agree with your modem speed.) CRTCTLAPPC CTLD(TEMPRMT) LINKTYPE(*SDLC) ONLINE(*NO) + SWITCHED(*YES) APPN(*NO) SWTLINLST(TEMPRMT) MAXFRAME((521) + RMTNETID(*NONE) EXCHID(05600001) INLCNN(*ANS) ROLE(*PRI) + STNADR(01) CRTDEVAPPC DEVD(TEMPRMT) RMTLOCNAME(TEMPLCL) ONLINE(*NO) + LCLLOCNAME(TEMPRMT) RMTNETID(*NONE) CTL(TEMPRMT) MODE(BLANK) + APPN(*NO)
Object Distribution Utility
Figure 3A CL program SNDOBJ
SNDOBJ: + PGM PARM(&OBJTYP &OBJECT &MEMBER &LIB &MSG &SPOOL &JOBNUMBER + &JOBUSER &JOBNAME &SPLNBR &TOUSRID &TOUSRAD &SYSTEM) DCL VAR(&OBJTYP) TYPE(*CHAR) LEN(6) DCL VAR(&OBJECT) TYPE(*CHAR) LEN(10) DCL VAR(&MEMBER) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(256) DCL VAR(&SPOOL) TYPE(*CHAR) LEN(10) DCL VAR(&JOBNUMBER) TYPE(*CHAR) LEN(10) DCL VAR(&JOBUSER) TYPE(*CHAR) LEN(10) DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10) DCL VAR(&SPLNBR) TYPE(*CHAR) LEN(5) DCL VAR(&TOUSRID) TYPE(*CHAR) LEN(10) DCL VAR(&TOUSRAD) TYPE(*CHAR) LEN(10) DCL VAR(&SYSTEM) TYPE(*CHAR) LEN(1) DCL VAR(&CTL) TYPE(*CHAR) LEN(10) IF COND(&SYSTEM *EQ '1') THEN(CHGVAR VAR(&CTL) VALUE('TEMPLCL')) IF COND(&SYSTEM *EQ '2') THEN(CHGVAR VAR(&CTL) VALUE('TEMPRMT')) /* MAKE SURE CONFIGURATIONS ARE VARIED ON */ VRYCFG CFGOBJ(&CTL) CFGTYPE(*LIN) STATUS(*ON) MONMSG MSGID(CPF9999) EXEC(GOTO CMDLBL(ERROR)) VRYCFG CFGOBJ(&CTL) CFGTYPE(*CTL) STATUS(*ON) MONMSG MSGID(CPF9999) EXEC(GOTO CMDLBL(ERROR)) /* MAKE SURE SUBSYSTEM IS STARTED */ STRSBS SBSD(QSNADS) MONMSG MSGID(CPF1010) /* MESSAGE */ IF COND(&OBJTYP *EQ '*MSG') THEN(DO) SNDNETMSG MSG(&MSG) TOUSRID((&TOUSRID &TOUSRAD)) GOTO CMDLBL(ENDPROGRAM) ENDDO /* SPOOL FILE */ IF COND(&OBJTYP *EQ '*SPOOL') THEN(DO) SNDNETSPLF FILE(&SPOOL) TOUSRID((&TOUSRID &TOUSRAD)) + JOB(&JOBNUMBER/&JOBUSER/&JOBNAME) SPLNBR(&SPLNBR) GOTO CMDLBL(ENDPROGRAM) ENDDO /* EVERYTHING ELSE: MAKE SURE SAVE FILE IS THERE */ CRTSAVF FILE(QTEMP/SAVF1) TEXT('Temporary File for SNDNETWRK') MONMSG MSGID(CPF5813) MONMSG MSGID(CPF7302) IF COND(&OBJTYP *EQ '*LIB') THEN(DO) SAVLIB LIB(&OBJECT) DEV(*SAVF) SAVF(QTEMP/SAVF1) CLEAR(*ALL) ENDDO IF COND(&OBJTYP *EQ '*OTHER') THEN(DO) SAVOBJ OBJ(&OBJECT) LIB(&LIB) DEV(*SAVF) SAVF(QTEMP/SAVF1) + CLEAR(*ALL) FILEMBR((*ALL (&MEMBER))) ENDDO /* PROGRAM WILL INITIATE JOB ON REMOTE SYSTEM TO RESTORE THIS + SAVF */ /* DATA AREA SENT WILL CONTAIN ALL NECESSARY PARAMETERS */ CHKOBJ OBJ(DTAARA) OBJTYPE(*DTAARA) MONMSG MSGID(CPF9801) EXEC(CRTDTAARA DTAARA(QTEMP/DTAARA) + TYPE(*CHAR) LEN(50)) /* IF A LIBRARY USE OBJECT NAME FOR LIBRARY */ IF COND(&LIB *EQ ' ') THEN(CHGVAR VAR(&LIB) VALUE(&OBJECT)) CHGDTAARA DTAARA(QTEMP/DTAARA (01 10)) VALUE(&TOUSRID) CHGDTAARA DTAARA(QTEMP/DTAARA (11 10)) VALUE(&LIB) /* MAKE SURE SAVE FILE FOR DATA AREA IS THERE */ CRTSAVF FILE(QTEMP/SAVF2) TEXT('Temp File for DataArea') MONMSG MSGID(CPF5813) MONMSG MSGID(CPF7302) SAVOBJ OBJ(DTAARA) LIB(QTEMP) DEV(*SAVF) SAVF(QTEMP/SAVF2) + CLEAR(*ALL) SNDNETF FILE(QTEMP/SAVF2) TOUSRID((&TOUSRID &TOUSRAD)) SNDNETF FILE(QTEMP/SAVF1) TOUSRID((&TOUSRID &TOUSRAD)) GOTO CMDLBL(ENDPROGRAM) ERROR: + SNDPGMMSG MSGID(CPF9898) MSGF(QSYS/QCPFMSG) MSGDTA('Problem + VARYing on Line' *BCAT &CTL *BCAT '. Please check and retry + SNDOBJECT') ENDPROGRAM: + ENDPGM
Object Distribution Utility
Figure 3B CL program RCVOBJ
RCVOBJ: + PGM DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&USER) TYPE(*CHAR) LEN(10) /* MAKE SURE SAVE FILES AREN'T THERE ALREADY */ DLTF FILE(QTEMP/SAVF1) MONMSG MSGID(CPF0000) DLTF FILE(QTEMP/SAVF2) MONMSG MSGID(CPF0000) CRTSAVF FILE(QTEMP/SAVF1) TEXT('Temporary Save File') CRTSAVF FILE(QTEMP/SAVF2) TEXT('Temporary Save File') /* RETRIEVE DATA AREA AND THEN RETRIEVE INFORMATION */ RCVNETF FROMFILE(SAVF1) TOFILE(QTEMP/SAVF1) MBROPT(*REPLACE) RCVNETF FROMFILE(SAVF2) TOFILE(QTEMP/SAVF2) MBROPT(*REPLACE) DLTDTAARA DTAARA(DTAARA) MONMSG MSGID(CPF2105) RSTOBJ OBJ(DTAARA) SAVLIB(QTEMP) DEV(*SAVF) OBJTYPE(*ALL) + SAVF(SAVF2) MONMSG MSGID(CPF3773) RTVDTAARA DTAARA(QTEMP/DTAARA (01 10)) RTNVAR(&USER) RTVDTAARA DTAARA(QTEMP/DTAARA (11 10)) RTNVAR(&LIB) CRTLIB LIB(&LIB) MONMSG MSGID(CPF2111) RSTOBJ OBJ(*ALL) SAVLIB(&LIB) DEV(*SAVF) SAVF(QTEMP/SAVF1) + MBROPT(*ALL) ALWOBJDIF(*ALL) MONMSG MSGID(CPF3773) DLTF FILE(QTEMP/SAVF1) DLTF FILE(QTEMP/SAVF2) DLTDTAARA DTAARA(DTAARA) ENDPGM
Object Distribution Utility
Figure 4A Command SNDOBJ
CMD PROMPT('Send Network Objects') PARM KWD(OBJTYP) TYPE(*CHAR) LEN(6) RSTD(*YES) + VALUES(*MSG *SPOOL *LIB *OTHER) MIN(1) + PROMPT('Object Type') PARM KWD(OBJECT) TYPE(*GENERIC) LEN(10) MIN(0) + PMTCTL(OTHER) PROMPT('Object Name') PARM KWD(MEMBER) TYPE(*CHAR) LEN(10) DFT(*FIRST) + MIN(0) PMTCTL(OTHER) PROMPT('Member + Name, *FIRST, *ALL') PARM KWD(LIB) TYPE(*CHAR) LEN(10) MIN(0) + PMTCTL(OTHER) PROMPT('Library Name') PARM KWD(MSG) TYPE(*CHAR) LEN(256) MIN(0) + PMTCTL(MESSAGE) PROMPT('Message Text') PARM KWD(SPOOL) TYPE(*CHAR) LEN(10) + MIN(0) PMTCTL(SPOOL) PROMPT('Spool File + Name') PARM KWD(JOBNUMBER) TYPE(*CHAR) LEN(10) + MIN(0) PMTCTL(SPOOL) PROMPT('Job Number') PARM KWD(JOBUSER) TYPE(*CHAR) LEN(10) + MIN(0) PMTCTL(SPOOL) PROMPT('Job User') PARM KWD(JOBNAME) TYPE(*CHAR) LEN(10) + MIN(0) PMTCTL(SPOOL) PROMPT('Job Name') PARM KWD(SPLNBR) TYPE(*CHAR) LEN(5) + MIN(0) PMTCTL(SPOOL) PROMPT('Spool#, *ONLY + or *LAST') PARM KWD(TOUSRID) TYPE(*CHAR) LEN(10) DFT(USER2) + PROMPT('To User ID Name') PARM KWD(TOUSRAD) TYPE(*CHAR) LEN(10) DFT(ADRS2) + PROMPT('To User Address') PARM KWD(SYSTEM) TYPE(*CHAR) LEN(1) RSTD(*YES) + DFT(1) VALUES(1 2) + MIN(0) PROMPT('System (1=Dialer, 2=+ Answerer)') MESSAGE: PMTCTL CTL(OBJTYP) COND((*EQ *MSG)) + NBRTRUE(*EQ 1) SPOOL: PMTCTL CTL(OBJTYP) COND((*EQ *SPOOL)) + NBRTRUE(*EQ 1) OTHER: PMTCTL CTL(OBJTYP) COND((*EQ *OTHER) + (*EQ *LIB)) NBRTRUE(*EQ 1) LGLREL(*OR)
Object Distribution Utility
Figure 4B Command RCVOBJ
CMD PROMPT('Receive Network Objects')
LATEST COMMENTS
MC Press Online