From Support
PGM
DCL VAR(&NEWSESSION) TYPE(*CHAR) LEN(255)
DCL VAR(&MAINURL) TYPE(*CHAR) LEN(200)
DCL VAR(&URL) TYPE(*CHAR) LEN(255)
DCL VAR(&DOCID) TYPE(*CHAR) LEN(100)
DCL VAR(&DOCTITLE) TYPE(*CHAR) LEN(200)
DCL VAR(&RTNHITS) TYPE(*DEC) LEN(15 0)
DCL VAR(&HITFOUND) TYPE(*DEC) LEN(1 0)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/***********************************************************/
/* Run Document Search - Return a max of 5 hits */
/* Search for all doc titles that start with "Test" */
/***********************************************************/
DOCSRCH DOCTITLE('Test*') USERID(TEST) MAXHITS(5)
MONMSG MSGID(CPF9898) EXEC(DO)
/* Bail out on search failure with user message */
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('Document search failed') +
MSGTYPE(*ESCAPE)
ENDDO
/***********************************************************/
/* Retrieve First Search Hit from Search Results */
/***********************************************************/
DOCSRCHID HITNUMBER(1) DOCID(&DOCID) +
DOCTITLE(&DOCTITLE) RTNHITS(&RTNHITS) +
HITFOUND(&HITFOUND)
/* Bail out if hit record not found */
IF COND(&HITFOUND *NE 1) THEN(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Unable +
to retrieve document search hit') +
MSGTYPE(*ESCAPE)
ENDDO
/***********************************************************/
/* Create Image Server Web Session ID. This logs the green */
/* screen user into the Image Server/400 software. */
/* */
/* *AS400USER can be used for the WEBUSER parm if desired */
/* and you have set up Image Server user IDs which match */
/* the corresponding AS/400 user id. */
/* */
/* *NOPASSWORD can be used for WEBPASS is you want to */
/* ignore Image Server passwords when launching a new */
/* web session from a green screen. */
/***********************************************************/
DOCSESRTV WEBUSER(TEST) WEBPASS(*NOPASSWORD) +
RTNSESSION(&NEWSESSION)
/***********************************************************/
/* Attempt to Check-Out Document for Modification */
/***********************************************************/
DOCCHKO DOCID(&DOCID) USERID(TEST) COMPMSGTYP(*COMP)
MONMSG MSGID(CPF9898) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Error +
occurred checking out document. It may be +
checked out by someone else.') +
MSGTYPE(*ESCAPE)
ENDDO
/***********************************************************/
/* Launch Selected Image Server/400 Document on User PC */
/***********************************************************/
DOCIMGVW RMTSYS(*CURRENT) DOCID(&DOCID) CLOSEPGM(1) +
USR(TEST) PWD(TEST)
RETURN /* Normal exit */
/***********************************************************/
/* Handle errors */
/***********************************************************/
ERRORS: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Errors +
occurred while launching document for + viewing')