AS400 Dynamic IP Printing

We have documented how to set up a CL program in the AS/400 so one can print to a queue with a Dynamic IP address. Current RPM Remote Print Manager user’s have provided us with this CL Program. We are providing it for your consideration. Our clients have provided us with this CL Program. We are providing it for your consideration. As you can see, this program does the following:

  1. Prompts the user for the name of the OUTQ (printer) they want to use
  2. Automatically obtains their IP Address.
  3. Notifies the user that the OUTQ’s IP address is being updated.
  4. Updates the OUTQ they provided with their IP address.
  5. Prompts them to update another OUTQ.

This CL program may be used and modified for your needs. It is possible to modify the program to eliminate user interaction and perform the OUTQ update automatically. This program can be placed in the user’s profile to run at the time of login.

Try RPM for Free

/* SHORT FORM DYNAMIC IP ADDRESS */
/* DIALUP CONNECTION */
 
/* LPD: OBTAIN IP ADDRESS OF USER AND MODIFY TCP/IP DEVICE */
/* QUEUE TO USE NEW ADDRESS (FIREWALL PRINTING) */
/* OS/400 V3.7 */
/* */
PGM
 
  DCL VAR(&RECEIVER) TYPE(*CHAR) LEN(892)
  DCL VAR(&DEVICE) TYPE(*CHAR) LEN(10)
  DCL VAR(&USER) TYPE(*CHAR) LEN(10)
  DCL VAR(&PRTQ) TYPE(*CHAR) LEN(10)
  DCL VAR(&CHANGE) TYPE(*CHAR) LEN(3)
  DCL VAR(&ERROR) TYPE(*CHAR) LEN(4) +
    VALUE(X’00000000′)
  DCL VAR(&RCVRLN) TYPE(*CHAR) LEN(4)
  DCL VAR(&FORMAT) TYPE(*CHAR) LEN(8) +
    VALUE(’DEVD0600′)
  DCL VAR(&IPADDR) TYPE(*CHAR) LEN(15)
  DCL VAR(&DONEXT) TYPE(*CHAR) LEN(1)
  DCL VAR(&YESNO) TYPE(*CHAR) LEN(1)
  DCL VAR(&PRINTER) TYPE(*CHAR) LEN(10)
 
/* OBTAIN DEVICE NAME AND USERID */
  RTVJOBA JOB(&DEVICE) CURUSER(&USER)
  CHGVAR VAR(&CHANGE) VALUE(%SST(&USER 1 3))
 
/* NAME PRINT QUEUE TO CHANGE */
  SNDUSRMSG MSG(’Enter the name of the printer to +
    change!’) MSGTYPE(*INQ) TOMSGQ(*) +
    MSGRPY(&PRINTER)
  CHGVAR VAR(&PRTQ) VALUE(&PRINTER)
 
/* OBTAIN IP ADDRESS */
  CHGVAR VAR(%BIN(&RCVRLN)) VALUE(892)
  CALL PGM(QDCRDEVD) PARM(&RECEIVER &RCVRLN &FORMAT +
    &DEVICE &ERROR)
  CHGVAR VAR(&IPADDR) VALUE(%SST(&RECEIVER 878 15))
 
/* MODIFY OUTQ WITH CURRENT IP ADDRESS */
  SNDMSG MSG(’IP address is being updated, it will +
    take about 15 seconds, please wait: +
    <<<hit enter>>>’) TOUSR(*REQUESTER) +
    MSGTYPE(*INFO)
  ENDWTR WTR(&PRTQ) OPTION(*IMMED)
  MONMSG MSGID(CPF3313) /* SUPPRESS WRITER NOT STARTED MSG */
  GOTO CMDLBL(CHGOUTQ)
 
TRYAGAIN:    
  CHGVAR VAR(&DONEXT) VALUE(’a')
  SNDUSRMSG MSG(’Enter the name of the printer to +
    change!’) MSGTYPE(*INQ) TOMSGQ(*) +
    MSGRPY(&PRINTER)
  CHGVAR VAR(&PRTQ) VALUE(&PRINTER)
  SNDMSG MSG(’IP address is being updated, it will +
    take about 15 seconds, please wait: +
    <<<hit enter>>>’) TOUSR(*REQUESTER) +
    MSGTYPE(*INFO)
  ENDWTR WTR(&PRTQ) OPTION(*IMMED)
  MONMSG MSGID(CPF3313) /* SUPPRESS WRITER NOT STARTED MSG */
 
CHGOUTQ:
  DLYJOB DLY(15) /* WAIT 15 SECONDS */
  CHGOUTQ OUTQ(QUSRSYS/&PRTQ) AUTOSTRWTR(1) +
    INTNETADR(&IPADDR)
  MONMSG MSGID(CPF3319) EXEC(SNDMSG MSG(’UNABLE TO +
    MODIFY IP ADDRESS, WRITER IS CURRENTLY IN +
    USE. (CPF3319)’) TOUSR(&USER))
  MONMSG MSGID(CPF3357) EXEC(SNDUSRMSG MSG(’Printer +
    not found!, <<R-Retry(enter PRT name), +
    C-Cancel(end program)>>’) VALUES(R C) +
    TOMSGQ(*) MSGRPY(&DONEXT))
  IF COND(&DONEXT *EQ ‘C’) THEN(GOTO CMDLBL(ENDPGM))
  IF COND(&DONEXT *EQ ‘R’) THEN(GOTO +
    CMDLBL(TRYAGAIN))
 
ADDPRT:
  SNDUSRMSG MSG(’Update another printer address? +
    Yes/No(Y/N)’) VALUES(Y N) MSGTYPE(*INQ) +
    TOMSGQ(*) MSGRPY(&YESNO)
  IF COND(&YESNO *EQ ‘N’) THEN(GOTO CMDLBL(ENDPGM))
  IF COND(&YESNO *EQ ‘Y’) THEN(GOTO +
    CMDLBL(TRYAGAIN))
 
ENDPGM:    
  ENDPGM  

Try RPM for Free

Both RPM and ExcelliPrint are available for you to try free of charge, for 21 days. If you run into problems or have questions, please contact our tech support at (208) 523-6970. Download RPM Remote Print Manager or download ExcelliPrint IPDS software.