Sample Program using FAXCASTELE command - Support

Sample Program using FAXCASTELE command

From Support

Jump to: navigation, search

Listed below is a sample program for faxing a spool file created within a user application via the FAXCASTELE CL command.

The sample program runs an RPG report, retreives the report spool file info and then sends to the selected recipient. This command queues the fax to the Castelle Faxpress fax server and then Castelle will send the fax.

The FRADDRESS parameter uses the fax senders AS/400 user ID to determine the email address where email notifications will be sent if the fax send fails or is successful.

Setting Up System i Users for Fax Sending

Each AS/400 user who will be sending faxes should be set up in the Enterprise Faxing Address Book (GO RJSFAX, Option 6 (Edit address book)) so that they will receive appropriate fax notifications from the Castelle Faxpress Fax Server upon fax delivery or failure.

Note: When setting up each System i user in the address book, make sure to fill in the "System i User" parameter with the appropriate AS/400 user ID.

PGM 

DCL VAR(&RTNSPOOL) TYPE(*CHAR) LEN(10)
DCL VAR(&RTNJOB) TYPE(*CHAR) LEN(10)
DCL VAR(&RTNUSER) TYPE(*CHAR) LEN(10)
DCL VAR(&RTNJNBR) TYPE(*CHAR) LEN(6)
DCL VAR(&RTNSPLNBR) TYPE(*CHAR) LEN(6) 

/* Fax Recipient Parameters */
DCL VAR(&TONAME) TYPE(*CHAR) LEN(30)
DCL VAR(&TOFAX) TYPE(*CHAR) LEN(30)
DCL VAR(&TOCOMPANY) TYPE(*CHAR) LEN(30)
DCL VAR(&TOPHONE) TYPE(*CHAR) LEN(30)
DCL VAR(&TOSUBJECT) TYPE(*CHAR) LEN(30)
DCL VAR(&MESSAGE) TYPE(*CHAR) LEN(2048)

MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS)) 

/******************************************************/
/* Run report program */
/******************************************************/
CALL PGM(RPT100) 

/******************************************************/
/* Set fax recipient info */
/* This info can also be set from a user program */
/* If calling the fax API from a user written CL/RPG */
/******************************************************/
/* To fax recipient name (required) */
CHGVAR     VAR(&TONAME) VALUE('Test Fax User')  
/* To fax number (required) */
CHGVAR     VAR(&TOFAX) VALUE('222-333-3333')  
/* To company name (optional) */
CHGVAR     VAR(&TOCOMPANY) VALUE('Test Company')  
/* To recipient contact phone number (optional) */
CHGVAR     VAR(&TOPHONE) VALUE('  ')  
/* To subject (optional) */
CHGVAR     VAR(&TOSUBJECT) VALUE('Your Test Fax')  
/* Text message  (optional) */
CHGVAR     VAR(&MESSAGE) VALUE('Please call with any questions.')  

/******************************************************/
/* Retreive spool info for report just generated */
/******************************************************/
ERSNUM SPLF(RPT100P) JOB(*) SPLNBR(*LAST) +
              RTNSPLF(&RTNSPOOL) RTNJOBNAME(&RTNJOB) +
              RTNJOBUSER(&RTNUSER) RTNJOBNUM(&RTNJNBR) +
              RTNSPLNUM(&RTNSPLNBR) 

/******************************************************/
/* Fax the report to the selected recpient */
/******************************************************/
FAXCASTELE FILE(&RTNSPOOL) +                   
              JOB(&RTNJNBR/&RTNUSER/&RTNJOB) +         
              SPLNBR(&RTNSPLNBR) TONAME(&TONAME) +     
              TOFAX(&TOFAX) TOCOMPANY(&TOCOMPANY) +    
              TOPHONE(&TOPHONE) SUBJECT(&TOSUBJECT) +  
              MESSAGE(&MESSAGE) FRADDRESS(*USERID)     

RETURN 

/******************************************************/
/* Handle errors */
/******************************************************/
ERRORS:

/* SEND EXIT MESSAGE ON ERROR */                                    
SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Errors +  
                      occurred while sending report via +         
                      fax. Check the job log') MSGTYPE(*ESCAPE)  

ENDPGM
Personal tools