Using APIs to Interact with WebDocs iSeries Edition - Support

Using APIs to Interact with WebDocs iSeries Edition

From Support

Jump to: navigation, search

Contents

WebDocs iSeries Edition API Interfaces

Several customers need the ability to interface to the RJS WebDocs iSeries Edition software from their own applications to streamline document checkin, searching and retrieval. This document serves as a concept index as to the API interface capabilities for the WebDocs iSeries Edition software.

If you need a conference call to discuss specific requirements as you get into specific coding situations, please let RJS know how we can help you with FREE example code. We are always working with customers to provide FREE integration samples.

RJS can also provide consulting services for more complex programming requirements. We have skills in almost all iSeries and PC languages including VB, VBScript, Javascript, ASP, JSP, Java, RPG, COBOL and more.

WebDocs Database Tables in RJSIMAGE library

DOCS00 - Holds main document index keys info. Also holds IFS location of each document file. DOCVER00 - Version info. Tracks document revisions. There is always at least 1 version record for every document. DOCFLR00 - Document folder list DOCSEC00 - Document user folder security DOCUSR00 - User table DOCTYPE00 - Document type descriptions DOCKEY00 - Holds keyword descriptions for each doc type to display on screen.

Standard Document Search Fields

DOCID - Document ID TITLE - Document Title DOCTYPE - Document File Type - (TIF, PDF, DOC, etc.) DOCTYPE2 - Document Type - (A/R, A/P, Orders, etc.) CHKDATE - Document creation date. FOLDER1 - FOLDER3 - Folder levels 1-3. KEYWORD1 - KEYWORD10 - Search keywords 1 - 10.

iSeries Report Search Fields

DCSPOOL - Spool file name. DCDATE - Spool file date. DCUSRDTA - Spool user data. DCUSRDFN - User defined data. DCUSERID - Spool user ID. DCFORM - Spool file form type. DCJOB - Spool file job name. DCOUTQ - Search output queue. DCOLIB - Search user defined data.

Simple example to specifically limit a customers view to their own orders and invoices based on their customer number: 123456 only in KEYWORD1:

(KEYWORD1 = '123456')

Example to specifically limit a customers view to their own orders and invoices based on their customer number: 123456 in field KEYWORD1 and document type = ORDERS and INVOICES:

((KEYWORD1 = '123456'  and DOCTYPE2 = 'ORDERS') and (KEYWORD1 = '123456'  and DOCTYPE2 = 'INVOICES'))

Example to specifically limit a customers view to their own orders and invoices based on their customer number: 123456 in field KEYWORD1 and document type = ORDERS and INVOICES and folder name = CUSTOMERS:

((KEYWORD1 = '123456'  and DOCTYPE2 = 'ORDERS') and (KEYWORD1 = '123456'  and DOCTYPE2 = 'INVOICES')) and (FOLDER1='CUSTOMERS')

Searching for documents by Web URL

The easiest way to interface with the WebDocs iSeries Edition software is to use the URL search interface that is built in to the WebDocs executable on the iSeries. Then any application that can call a web URL can perform document searches. This would include any web application that can create a web link, any ASP, JSP/Servlet PHP, Python and even .Net web applications. This would also include VB or VB.Net applications that can use the ShellExecute function to execute a command line.

The basic process would be to build a URL with the relevent criteria and then perform a document search by calling or clicking on the URL link.

Format of search URL strings:

Beginning of search string (uses your AS/400 web server IP address)

http://1.1.1.1/imageserver/doc100r?action=Search

Session ID. This is a unique session login ID (See CL samples in file SOURCE in library RJSIMAGE)

&ISESSION=<session ID>

Additional search keywords (multiple search keywords can be put together with the & symbol) &srchtitle=Invoice

URL Search Examples

Example search URL looking for all docs with a title of "Invoice"

http://1.1.1.1/imageserver/doc100r?action=Search&ISESSION=<session ID>&srchtitle=Invoice

Example search URL looking for all docs with a title of "User Guide" where part number = "123456"

http://1.1.1.1/imageserver/doc100r?action=Search&ISESSION=<session ID>&srchtitle=User Guide&srchfld01=123456

Office Integrator CL Sample for Searching for documents by Web URL from within an iSeries Application

If the RJS iSeries Office Integrator is used to integrate document scanning and retrieval with an existing 5250 application, a function key can be created in any RPG or COBOL application that can call scanning or documents retreival functionality. This allows users to have an application function key that can quickly locate documents that match a selected criteria, effectively providing one button access to documents from their business applications.

Listed below is a document search CL sample.


PGM    PARM(&SEARCHVAL)

DCL        VAR(&SEARCHVAL) TYPE(*CHAR) LEN(100) +
                         VALUE('123456') /* Sample KEYWORD 1 value +
                         of 123456 */
DCL        VAR(&NEWSESSION) TYPE(*CHAR) LEN(255)
DCL        VAR(&MAINURL) TYPE(*CHAR) LEN(200)
DCL        VAR(&URL) TYPE(*CHAR) LEN(255)

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

/***********************************************************/
/* Retrieve MAIN Image Server/400 URL Setting.             */
/* Example: http://192.168.1.1                             */
/***********************************************************/
   RTVDTAARA  DTAARA(MAINURL) RTNVAR(&MAINURL)

/***********************************************************/
/* 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)

/***********************************************************/
/* Build URL to Launch Image Server/400 document search.   */
/* This example searches using KEYWORD1                    */
/* Search Keyword values:                                  */
/* SRCHFLD01 - SRCHFLD10 - Keyword Fields to search        */
/*                         Multiple keywords can be used.  */
/* SRCHTITLE - Search the document title                   */
/* SRCHDOCTYP- Search the specified document type          */
/* BEGDAT    - Set the beginning doc date 'MM/DD/YYYY'     */
/* ENDDAT    - Set the beginning doc date 'MM/DD/YYYY'     */
/***********************************************************/
   CHGVAR     VAR(&URL) VALUE(&MAINURL |< +
              '/IMAGESERVER/DOC100R?ACTION=Search&ISESSIO +
              N=' |< &NEWSESSION |< '&SRCHFLD01=' |< +
              &SEARCHVAL)

/***********************************************************/
/* Use the iSeries Integrator to launch the web browser    */
/* search for Image Server/400.                            */
/***********************************************************/
   RJSOFFICE/OFCRUNPC RMTSYS(*CURRENT) CMD(&URL) +
                      OPTION(*WEBSITE)

   RETURN /* Normal exit */

/***********************************************************/
/* Handle errors */
/***********************************************************/
   ERRORS:   SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Errors +
                        occurred while launching Image Server search URL')

   ENDPGM

5250 Screen Scraping Access to Documents

By utilizing the RJS 5250 Integrator in conjunction with Client Access/400, information can be easily grabbed from your 5250 application screens for scanning and indexing purposes as well as document searching via URL. The 5250 Integrator utilizes a VB scripting engine, so if needed a 5250 screen scraping macro can call any ODBC data source to interact with another database and can perform any logic that VBScript can do.

Web Facing and HATS

IBM has some new tools available for building web applications from existing 5250 applications. If you are using HATS or Web Facing, please contact RJS and we can help you put together the appropriate Java/JSP pages needed to interface with WebDocs. JSP is a nice way to quickly build URL's for locating documents via the WebDocs URL search mechanism.

ODBC, ADO and OLEDB Driver Database Access

If you are writing custom PC or web based business applications that run in VB, ASP, ASNA Visual RPG, any of the .Net languages or any other language that can read/write data via an ODBC, ADO or OLEDB then you can interface with the WebDocs software for retreiving or creating documents in the WebDocs system. Most people limit access to retreiving documents so as not to bypass WebDocs document checkin processes, but as long as the PC based applications can read/write data with the ADO drivers provided by IBM Client Access/400, then they can interface directly with WebDocs.

The interface for a VB application would typically go as follows:

1.) Developer would configure Client Access/400 ODBC data source to talk to the iSeries database.

2.) Developer would write VB or ASP code that utilizes the ODBC driver.

3.) When the business application needs documents it would perform an SQL query against the DOCS00 table and read by folder or limit the document list by providing selection criteria for the KEYWORD1 - KEYWORD10 fields.

JDBC Driver Database Access

If you will be developing interactive or web applications in Java or any language that can read/write data via a JDBC driver then you can interface with the WebDocs software for retreiving or creating documents in the WebDocs system. Most people limit access to retreiving documents so as not to bypass WebDocs document checkin processes, but as long as the PC based applications can read/write data with the JDBC drivers provided by IBM Java Toolbox, then they can interface directly with WebDocs. Most people will use the Java Toolbox to interface with WebDocs if they are writing in Java.

The interface for a Java application would typically go as follows:

1.) Developer would configure Java Toolbox JDBC data source to talk to the iSeries database.

2.) Developer would write Java, JSP or Servlet code that utilizes the iSeries JDBC driver.

3.) When the business application needs documents it would perform an SQL query against the DOCS00 table and read by folder or limit the document list by providing selection criteria for the KEYWORD1 - KEYWORD10 fields.

Document Checkin Exit Points

A lot of times customers want to scan incoming documents with key indexing information such as customer#, invoice#, PO#, etc and then have an exit program get information from their business application after a new document checkin and update the indexes in the WebDocs database. We call this exit point processing or backfilling data after document checkin. This is a great way to limit or eliminate manual entry of index information for new documents.

The DOCHKIN CL command performs checkin of a new documents and calls an exit point program named DOCEXITC. All keyword parameters, document type, IFS file name and document ID are passed to the exit program so the user can update the index keys with info from their iSeries database.

DOCCHKIN can also call a pre-exit checkin program (DOCEXITPC)that can be used to validate information in an iSeries database prior to actually checking-in the document. If the user defined validation steps fail, the pre-exit checkin program can send an ESCAPE message back to an iSeries program or a popup message back to the RJS Scan Workstation software.

The sample programs RJS provides for pre-exit and post-checkin processing can be found in source file: SOURCE in library RJSIMAGE.

Listed below is a CL/RPG sample of updating keywords after checkin via the DOCEXITC exit point processing.

DOCEXITC CL Exit point program.

This program will call DOCEXITR which is an RPG program which performs the keyword updates.

/***********************************************************************/
/*             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 &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(&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))


/***************************************************/
/* CALL EXIT RPG PROGRAM TO UPDATE                 */
/* DOCUMENT KEYWORDS. PASS THE DOCID & KEYWORD 1   */
/* SO WE KNOW WHICH DOC WE'RE UPDATING             */
/* THIS ALLOWS KEYWORDS TO BE AUTO-FILLED          */
/* AFTER DOCUMENT CHECK-IN.                        */
/***************************************************/
   CALL       PGM(DOCEXITR) PARM(&DOCID &KEY1 &ERRRTN)

   RETURN /* NORMAL EXIT */

/***************************************************/
/* HANDLE ERRORS */
/***************************************************/

   ERRORS:
   SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +
              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   


DOCEXITR RPG Exit point program called by DOCEXITC

H******************************************************************
H*                                                                *
H*  PROGRAM:    DOCEXITR                                          *
H*  PURPOSE:    Update Document Keywords based on values          *
H*              found in previous document with matching          *
H*              value in Key Field 1.                             *
H*  DATE:       04/23/2003                                        *
H*  AUTHOR:     RICHARD J. SCHOEN.                                *
H*                                                                *
H******************************************************************

F* Documents by DOCID
FDOCS01    UF   E           K DISK
F* Documents by KEYWORD1
FDOCS04    IF   E           K DISK
F                                     RENAME(DOCS00R:DOCS04R)
D*****
D* Timestamp data area
D*****         
D tstamp          s               z
D date            s               d   datfmt(*iso)
D time            s               t   timfmt(*iso)
D                 ds
D timeres                       12s 0
D   timetime                     6s 0 overlay(timeres:1)
D   timedate                     6s 0 overlay(timeres:7)

D WDOCTITLE       s            100A   inz()
D WKEYWORD1       s            200A   inz()
D WKEYWORD2       s            200A   inz()
D WKEYWORD3       s            200A   inz()
D WKEYWORD4       s            200A   inz()
D WKEYWORD5       s            200A   inz()
D WKEYWORD6       s            200A   inz()
D WKEYWORD7       s            200A   inz()
D WKEYWORD8       s            200A   inz()
D WKEYWORD9       s            200A   inz()
D WKEYWORD10      s            200A   inz()

C****************************************************************
C* *ENTRY PARAMETER LIST
C****************************************************************
C     *ENTRY        PLIST
C                   PARM                    IDOCKEY         100
C                   PARM                    IKEYWORD1       200
C                   PARM                    ERRRTN            1

C****************************************************************
C* RETRIEVE DOCUMENT INFO FROM EXISTING DOCUMENT WITH MATCHING
C* VALUE IN KEY 1 AND UPDATE TO NEW DOCUMENT
C****************************************************************
C                   EVAL      ERRRTN = '0'

 *                  ** Chain for document record with Keyword 1
 *                  ** We need to see if old doc exists or not.
C     IKEYWORD1     SETLL     DOCS04
C     IKEYWORD1     READE     DOCS04                               33

 *                  ** Bail out if our current DOCID is the only
 *                  ** matching record. No need to update keywords.
C                   IF        %TRIM(DOCID) = %TRIM(IDOCKEY)
C                   EVAL      ERRRTN = '1'
C                   MOVE      *ON           *INLR
C                   RETURN
C                   ENDIF

 *                  ** Bail out if old record does not exist
 *                  ** matching record. No need to update keywords.
C                   IF        *IN33 = *ON
C                   EVAL      ERRRTN = '1'
C                   MOVE      *ON           *INLR
C                   RETURN
C                   ENDIF

 *                  ** If old document exists.
 *                  ** Save keywords 2 - 10 to work fields
C                   Eval      WKEYWORD2  = %trimr(KEYWORD2)
C                   Eval      WKEYWORD3  = %trimr(KEYWORD3)
C                   Eval      WKEYWORD4  = %trimr(KEYWORD4)
C                   Eval      WKEYWORD5  = %trimr(KEYWORD5)
C                   Eval      WKEYWORD6  = %trimr(KEYWORD6)
C                   Eval      WKEYWORD7  = %trimr(KEYWORD7)
C                   Eval      WKEYWORD8  = %trimr(KEYWORD8)
C                   Eval      WKEYWORD9  = %trimr(KEYWORD9)
C                   Eval      WKEYWORD10 = %trimr(KEYWORD10)

 *                  ** Retreive new DOCID record and update new keywords 2-10
 *                  ** based on the previous checkin values.
C     IDOCKEY       CHAIN     DOCS01                             34

 *                  ** Bail out if record does not exist
C                   IF        *IN34 = *ON
C                   EVAL      ERRRTN = '1'
C                   MOVE      *ON           *INLR
C                   RETURN
C                   ENDIF

 *                  ** Move keywords 2 - 10 to current doc fields
C                   Eval      KEYWORD2  = %trimr(WKEYWORD2)
C                   Eval      KEYWORD3  = %trimr(WKEYWORD3)
C                   Eval      KEYWORD4  = %trimr(WKEYWORD4)
C                   Eval      KEYWORD5  = %trimr(WKEYWORD5)
C                   Eval      KEYWORD6  = %trimr(WKEYWORD6)
C                   Eval      KEYWORD7  = %trimr(WKEYWORD7)
C                   Eval      KEYWORD8  = %trimr(WKEYWORD8)
C                   Eval      KEYWORD9  = %trimr(WKEYWORD9)
C                   Eval      KEYWORD10 = %trimr(WKEYWORD10)

 *                  ** Update doc info
C                   UPDATE    DOCS00R

C*                  ** Exit after adding new record
C                   MOVE      *ON           *INLR
C                   RETURN

Updating Index Keys with Information from Non iSeries Databases

A lot of times customers want to scan incoming documents with key information such as customer#, invoice#, PO#, etc and then have an exit program get information from their business application after a new document checkin. By using the DOCEXITC exit point, as described in the previous section along with an RPG or COBOL program that uses the RJS RPG2SQL Integrator product, index information can be retreived or backfilled after document check-in from any database that can be accessed via ODBC. This includes MySQL, SQL Server, Oracle, Sybase, Filemaker, MS Access or any other database that can be accessed via ODBC. Using the RPG2SQL Integrator in conjunction with WebDocs can be a valuable way to automatically index your documents with index info from multiple business systems.

Personal tools