Using DOCEXITC
DOCEXITC is a CL program object (*PGM) in the RJSIMAGE library. A sample source member is in the RJSIMAGE/SOURCE file. The program is called after each new document is added to WebDocs. You can create your own version of this program as long as it accepts the parameters as shown in the following example.
/***********************************************************************/
/* AUTHOR: RICHARD J. SCHOEN */
/* DATE WRITTEN: 10/02/2002 */
/* PURPOSE: MAIN DOCUMENT CHECK-IN EXIT POINT */
/*EXPECTED PARAMETERS: NONE */
/* SWITCHES USED: NONE */
/* LDA: NONE */
/***********************************************************************/
PGM PARM(&DOCID &REVISION &DOCTITLE &DOCFLR1 +
&DOCFLR2 &DOCFLR3 &DOCFLR4 &DOCFLR5 &KEY1 +
&KEY2 &KEY3 &KEY4 &KEY5 &KEY6 &KEY7 &KEY8 +
&KEY9 &KEY10 &DOCPATH &DOCFILE &DOCTYPE)
DCL VAR(&DOCID) TYPE(*CHAR) LEN(100)
DCL VAR(&REVISION) TYPE(*DEC) LEN(9 0)
DCL VAR(&DOCTITLE) TYPE(*CHAR) LEN(200)
DCL VAR(&DOCFLR1) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR2) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR3) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR4) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR5) TYPE(*CHAR) LEN(100)
DCL VAR(&KEY1) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY2) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY3) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY4) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY5) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY6) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY7) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY8) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY9) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY10) TYPE(*CHAR) LEN(200)
DCL VAR(&DOCPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&DOCFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&DOCTYPE) TYPE(*CHAR) LEN(10)
DCL VAR(&ERRRTN) TYPE(*CHAR) LEN(1)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/***************************************************/
/* PUT YOUR CODE FOR CREATING WORKPIECES HERE */
/* BEFORE THE RETURN STATEMENT
/***************************************************/
RETURN /* NORMAL EXIT */
/***************************************************/
/* HANDLE ERRORS */
/***************************************************/
ERRORS:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('ERRORWARN: Exit point Errors +
occurred occurred while running Image +
Server document check-in for document +
ID:' |> &DOCID) MSGTYPE(*INFO)
MONMSG MSGID(CPF0000) /* MAKE SURE WE EXIT */
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('ERRORWARN: Exit point Errors +
occurred while running Image Server +
document check-in for document ID:' |> +
&DOCID) TOMSGQ(*SYSOPR)
MONMSG MSGID(CPF0000) /* MAKE SURE WE EXIT */
ENDPGM
Creating Workpieces for Selected Documents
You may want to create workpieces for only some kinds of new WebDocs documents. This code will be executed for every new WebDocs document. Use the parameter values passed when this program is called to skip over the workpiece creation code.
/***************************************/
/* Check whether to create a workpiece */
/* for the document to */
/***************************************/
IF COND(*NOT (&DOCTYPE2 = 'ENGDRAWINGAPPROVAL') +
*OR *NOT (&DOCFLR1 = 'ENGINEERING') ) +
THEN(DO)
GOTO CMDLBL(ENGDRWAPR)
ENDDO
/* Code to create the workpiece follows */
This example searches the code until it finds the ENGDRWAPR tag. It only executes if the Document Type is ENGDRAWINGAPPROVAL and the level-1 folder is ENGINEERING. The appropriate CL tag must follow the code to be executed.
/* Code to create the workpiece preceeds */
ENGDRWAPR:
Creating a Workpiece
To create a workpiece, add code to DOCEXITC. First, get a unique ID from the workflow creation process. Using that unique ID to identify the components, create attributes and item reference links for the workpiece to be created. Then create the workpiece.
Commands for this purpose are in the RJSFLOW library.
Getting a Unique ID - GETUNQID
/*******************************/
/* Get a unique identifier for */
/* workpiece create commands */
/*******************************/
GETUNQID UNIQUEID(&UNIQUEID)
&UNIQUEID must be a program variable you have defined to receive the value of the unique ID. You may name it whatever you like, but it must be defined as an 8-character-long *char variable.
DCL VAR(&UNIQUEID) +
TYPE(*CHAR) +
LEN(8)
Setting Attribute Values - CRTWKPVAL
/****************************/
/* Add values from document */
/****************************/
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('Engineer') +
VALUE(&KEY1)
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('Drawing') +
VALUE(&KEY5)
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('EngineeringOrder') +
VALUE(&KEY6)
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('Rev') +
VALUE(&KEY9)
Create as many workpiece attribute values as you need. The NAME parameter gives the name of the attribute. In most cases, this is a constant that matches one of the attributes you defined when you created the workpiece class.
VALUE may be any character value you choose. It may be a constant or, as shown here, the value of one of the keys of the WebDocs document being created. You can use any CL concatenation operations to construct the value.
Setting Item Reference Links - CRTWKPREF
/******************************/
/* Add reference for document */
/******************************/
/* This syntax will bring up */
/* the document details page */
/* for the document */
CHGVAR VAR(&URL) +
VALUE(&BASEURL *TCAT '/' +
*TCAT 'IMAGESERVER/DOC100R?ACTION=DOCINFO&IDOCID=' +
*TCAT &DOCID)
/* This syntax will bring up */
/* the associated viewer for */
/* the type of document */
/* CHGVAR VAR(&URL) +
VALUE(&BASEURL *TCAT '/' +
*TCAT 'IMAGESERVER/DOC100R?ACTION=VIEW&IDOCID=' +
*TCAT &DOCID)*/
CRTWKPREF UNIQUEID(&UNIQUEID) +
URL(&URL) +
CAPTION(&DOCTITLE)
Workpiece Item References are links in your workpiece. CRTWKPREF creates an HTML anchor tag based on the values supplied here. CAPTION is the text seen in the workpiece info. URL is the HTTP URL. For a WebDocs document reference, capture the BASEURL from the WebDocs data area MAINURL in RJSIMAGE.
/******************************/
/* Get the base URL for the */
/* WebDocs browser address */
/******************************/
RTVDTAARA DTAARA(MAINURL) +
RTNVAR(&BASEURL)
View the document information (DOCINFO) page for the document or go directly to the image viewer using the alternate syntaxes shown in the example. For more ways to link to WebDocs, contact RJS Support.
You can add as many item reference links as you like.
Creating a Workpiece from the Unique ID - CRTWRKPCE
/******************************/
/* Trigger workpiece creation */
/******************************/
CRTWRKPCE UNIQUEID(&UNIQUEID) +
DESCRIPT(&DOCTITLE) +
CLASS('Drawing Approval') +
PROCESS('Drawing Approval')
This command creates a workpiece with the values and references associated with the unique ID. Don't use the unique ID again. CLASS is the workpiece class associated with the new workpiece. PROCESS is the process the new workpiece is started on. The process name is the name you specified when you saved the process from the Visio using the RJS Visio Process Designer Add-In or other process designer capable of creating a process in Enterprise Workflow.
Complete Example
When done, your finished DOCEXITC program should look something like this:
/***********************************************************************/
/* AUTHOR: RICHARD J. SCHOEN */
/* DATE WRITTEN: 10/02/2002 */
/* PURPOSE: MAIN DOCUMENT CHECK-IN EXIT POINT */
/*EXPECTED PARAMETERS: NONE */
/* SWITCHES USED: NONE */
/* LDA: NONE */
/***********************************************************************/
PGM PARM(&DOCID &REVISION &DOCTITLE &DOCFLR1 +
&DOCFLR2 &DOCFLR3 &DOCFLR4 &DOCFLR5 &KEY1 +
&KEY2 &KEY3 &KEY4 &KEY5 &KEY6 &KEY7 &KEY8 +
&KEY9 &KEY10 &DOCPATH &DOCFILE &DOCTYPE)
DCL VAR(&DOCID) TYPE(*CHAR) LEN(100)
DCL VAR(&REVISION) TYPE(*DEC) LEN(9 0)
DCL VAR(&DOCTITLE) TYPE(*CHAR) LEN(200)
DCL VAR(&DOCFLR1) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR2) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR3) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR4) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCFLR5) TYPE(*CHAR) LEN(100)
DCL VAR(&KEY1) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY2) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY3) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY4) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY5) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY6) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY7) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY8) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY9) TYPE(*CHAR) LEN(200)
DCL VAR(&KEY10) TYPE(*CHAR) LEN(200)
DCL VAR(&DOCPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&DOCFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&DOCTYPE) TYPE(*CHAR) LEN(10)
DCL VAR(&ERRRTN) TYPE(*CHAR) LEN(1)
/***********************/
/* Workpiece variables */
/***********************/
DCL VAR(&BASEURL) +
TYPE(*CHAR) +
LEN(256)
DCL VAR(&UNIQUEID) +
TYPE(*CHAR) +
LEN(8)
DCL VAR(&URL) +
TYPE(*CHAR) +
LEN(1800)
DCL VAR(&CAPTION) +
TYPE(*CHAR) +
LEN(200)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/***************************************************/
/* PUT YOUR CODE FOR CREATING WORKPIECES HERE */
/* BEFORE THE RETURN STATEMENT
/***************************************************/
/******************************/
/* Get the base URL for the */
/* WebDocs browser address */
/******************************/
RTVDTAARA DTAARA(MAINURL) +
RTNVAR(&BASEURL)
/***************************************/
/* Check whether to create a workpiece */
/* for the document to */
/***************************************/
IF COND(*NOT (&DOCTYPE2 = 'ENGDRAWINGAPPROVAL') +
*OR *NOT (&DOCFLR1 = 'ENGINEERING') ) +
THEN(DO)
GOTO CMDLBL(ENGDRWAPR)
ENDDO
/* Code to create the workpiece follows */
/*******************************/
/* Get a unique identifier for */
/* workpiece create commands */
/*******************************/
GETUNQID UNIQUEID(&UNIQUEID)
/****************************/
/* Add values from document */
/****************************/
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('Engineer') +
VALUE(&KEY1)
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('Drawing') +
VALUE(&KEY5)
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('EngineeringOrder') +
VALUE(&KEY6)
CRTWKPVAL UNIQUEID(&UNIQUEID) +
NAME('Rev') +
VALUE(&KEY9)
/******************************/
/* Add reference for document */
/******************************/
/* This syntax will bring up */
/* the document details page */
/* for the document */
CHGVAR VAR(&URL) +
VALUE(&BASEURL *TCAT '/' +
*TCAT 'IMAGESERVER/DOC100R?ACTION=DOCINFO&IDOCID=' +
*TCAT &DOCID)
/* This syntax will bring up */
/* the associated viewer for */
/* the type of document */
/* CHGVAR VAR(&URL) +
VALUE(&BASEURL *TCAT '/' +
*TCAT 'IMAGESERVER/DOC100R?ACTION=VIEW&IDOCID=' +
*TCAT &DOCID)*/
CRTWKPREF UNIQUEID(&UNIQUEID) +
URL(&URL) +
CAPTION(&DOCTITLE)
/******************************/
/* Trigger workpiece creation */
/******************************/
CRTWRKPCE UNIQUEID(&UNIQUEID) +
DESCRIPT(&DOCTITLE) +
CLASS('Drawing Approval') +
PROCESS('Drawing Approval')
/* Code to create the workpiece preceeds */
ENGDRWAPR:
RETURN /* NORMAL EXIT */
/***************************************************/
/* HANDLE ERRORS */
/***************************************************/
ERRORS:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('ERRORWARN: Exit point Errors +
occurred occurred while running Image +
Server document check-in for document +
ID:' |> &DOCID) MSGTYPE(*INFO)
MONMSG MSGID(CPF0000) /* MAKE SURE WE EXIT */
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('ERRORWARN: Exit point Errors +
occurred while running Image Server +
document check-in for document ID:' |> +
&DOCID) TOMSGQ(*SYSOPR)
MONMSG MSGID(CPF0000) /* MAKE SURE WE EXIT */
ENDPGM