PreviousNext
Help > Programming with LAUNCHER Office > CL Commands > LNCPRTDOC - CL Command
LNCPRTDOC - CL Command

The LNCPRTDOC command is used to compose a document from a Word template, and data from a file or request from the AS/400.

 

The following operations can be processed with this  command :

     Template and data merging 

     Merged document saving

     Merged document  printing

     Document display

Using Word documents templates  (*.dot, *.dotx) is recommended.

 

The online help available on the AS400 can be more complete for the LNCPRTDOC command.

 

Parameters

Document Name for the template

DOC

 

 

Folder of the template

FLR

*DFT

 

Root Access path

ROOT

*DFT

 

Data source type for the merge

MRGTYPE

*NONE

 

Source filename

 FROMFILE

 

Library

 

*LIBL

Source member

 FROMMBR

*FIRST

SQL query

 FROMSQL

'SELECT * FROM'

Query

 FROMQRY

 

Library

 

*LIBL

Output option

OUTPUT

*

 

Save the resolved document

OUTSAVE

*NO

 

Show the resolved document

SHOWDOC

*YES

 

LAUNCHER PC Server to use

EXESRV

*DFT

 

Ending Option

ENDOPT

*NONE

 

Word Default directory

WORDPATH

*DFT

 

Exécuter le publipostage

EXECMRG

*YES

 

Suppression des champs

NLINK

*YES

 

 

Details

 

The LNCPRTDOC command merges a Word document template with data from the AS/400 database.

 

 

Document (DOC)

Specifies the document template name.

Possible values are :

Document_name

Specifies the document name.

Note : It is possible to set the full path to the document in this parameter.

In that case, parameter FLR and ROOT must be set to *NONE.

A full path to a network directory can be set.
(Example : \\MyServer\MyShare\MyDir\MyDoc.docx).

*NEW

A new empty Word document will be created.

*CURRENT

The actual call to LNCPRTDOC will use the current document.

The current document was opened by a previous call to LNCPRTDOC,

or any other LAUNCHER command that did not close the document.

 

 

Folder (FLR)

Specifies the folder or directory path, where the document is located.

Note : When the path is specified in the parameter

DOC this parameter must be set to *NONE.

The character '\' must not appear at the end.

 

 

Root path (ROOT)

Specifies the path to the model directories or saved resolved documents.

Note: This parameter is optional. If specified, this parameter is used to build

the path to the model document (DOC) and to the document to be backed up

(SAVDOC).

The '\' character must not appear at the end of the entered path.

 

A network path in the form \\Server\Share\Directory can be specified for

the ROOT parameter. 

 

 

Merge Type (MRGTYPE)

Specifies the type of the data source for the mail merge.

Possible values are :

*NONE

No data source is specified. The document will be displayed or printed, without any merge of data.

*QRY

The data to merge with the template are in a query (object type *QRYDFN).

*FILE

The data to merge with the template are in database file (LF or PF).

*SQL

The data to merge with the template are selected by a SQL request.

*DOC

The data source is defined in the Word template.

 

 

Query (QRYDFN)

Specifies the name of the query to use to get the data.

This parameter is used when parameter MRGTYPE is set to *QRY.

Query-name

Enter the name of the query.

Possible library values are :

*LIBL

The library list is searched to find the library where the query file is located.

Library Name

Enter the name of the library that contains the query file.

 

 

Database File (FROMFILE)

Specifies the name of the file and the library to use to get the data.
This parameter is used when parameter MRGTYPE is set to *FILE.
The database file can be physical or logical.

Possible values for the library are :

  *LIBL

         The search is performed in all libraries

         user and system from the list of work libraries

         until the first occurrence is found.

  *CURLIB

         The database file is searched in the library

         during the work, if it is not specified. 

 

 

File member (FROMMBR)

Enter the name of the member that contains the data.
This parameter is used when parameter MRGTYPE is set to *FILE.

Possible values are :

*FIRST

The first member of the database file contains the data.

Member-name

 

 

SQL request (FROMSQL)

Enter the SQL request to retrieve the records from the AS/400 database.

This parameter is used when parameter MRGTYPE is set to *SQL.

 

 

Output unit (OUTPUT)

Specifies if the resolved document will be printed or displayed.

Possible values are :

*

The document will not be printed. It will be displayed if the parameter

SHOWDOC is set to the value *YES.

*PRINT

The document will be printed.

*OUTPRN

The document will not be printed to a file (PRN).

* PDF

     The document will be converted to PDF. The OUTPDF parameter must be

     populated with the path and the name of the PDF file to generate.

*E-MAIL

     Each letter will be sent to an email recipient. Fill in the MAILOPT parameter to

     indicate the subject and the name of the column of the file containing the

     addresses of the recipients.

     This feature is only available with an OUTLOOK messaging client.

 

 

Printer file (OUTPRN)

Specifies the path and name of the file to print to, when the parameter OUTPUT

is set to the value *OUTPRN

 

 

Save the resolved document (OUTSAVE)

Specifies if the resolved document is saved.

Possible values are :

*NO

The resolved document is not saved.

*YES

The resolved document will be saved. The parameter SAVDOC must be set.

 

 

Show the document (SHOWDOC)

Specifies if the document is made visible on the Windows screen

Possible values are :

*NO

The resolved document is not visible.

*YES

The resolved document is visible.

 

 

Launcher server to use (EXESRV)

Specifies the name or IP address of the PC to use to build the document.

Possible values are :

*DFT

The value from the keyword LNCSRV in file LNCDFTP is used.

*DEV

The mail merge is processed on the PC where the terminal for the current job is located.

*CURRENT

When *CURRENT is specified, the current job must be already connected to a

LAUNCHER Server on a PC. That connection will be used.

   IP address or name

        The document is built on the specified PC.

            Note : The LAUNCHER server application must be running on the PC.

 

 

Ending Option (ENDOPT)

Specifies what object needs to be closed at the end of the process.

Possible values are :

*ALL

The following elements are closed: Word Document, Word application,

LAUNCHER Connection between the job and the PC.

The next LNCPRTDOC command will not be able to use the value *CURRENT for any parameter.

*APP

The following elements are closed: Word Document, Word application.

The LAUNCHER Connection between the job and the PC is still active.

The next LNCPRTDOC command will be able to use the value *CURRENT for the parameter EXESRV.

*DOC

The following elements are closed: Word Document.

The Word application, and the LAUNCHER Connection are still active.

The next LNCPRTDOC command will be able to use the value *CURRENT for the parameter EXESRV.

*CON

Only the LAUNCHER connection between the job and the PC is closed.

Word and the document remain in memory.

*NONE

The connection, Word and the document are left active.

The next LNCPRTDOC command will be able to use the value *CURRENT for

the parameters EXESRV and DOC.

 

 

Document name to save (SAVDOC)

Specifies the name for the new document to save after the mail merge.

Note : This parameter can contain the full directory path.

The file extension must be set.

Example : MyResultLetter.docx

 

 

Folder for the saved document. (SAVFLR)

Specifies the folder or directory where the resolved document will be saved.

Possible values are :

*DFT

The default value from the file LNCDFTP, for the keyword LNCSAV will be used.

Folder_name

The path to the folder or directory is specified.

Note : The character '\' must not be typed at the end of the string.

*NONE

Specifies that the parameter SAVDOC contains the directory path.

 

 

WORD merge type (MRGSEL)

Specifies the merge type that Word will process.

Possible values are :

*LTR

The word merge is a letter.

A letter is built for each record in the data source. The letters are separated

from each other by a "Form Feed".

*CAT

The Word merge is a catalog.

Only one document is built, with all the records from the data source.

*NONE

The merge type is set in the Word template.

 

 

Default Word directory (WORDPATH)

Specifies the default directory for Word during the mail merge process.

Possible values are :

*DFT

The value from the keyword LNCDIR in file LNCDFTP is used.

Default_directory

Set the full path to the default directory.

*NONE

     The default directory is not changed. It is set in the Word options.

 

 

Temporary file for transfer (DOCTMP)

The data are transferred to a temporary file on the PC. The file name and path for

this file can be set.

Possible values are :

*DFT

The value from the keyword LNCTMP in file LNCDFTP is used.

Temporary_file_name

Set the path and name for the temporary file to use.

 

 

Word merge options (WORDMRG))

Several options are available.

Header file

Specifies the name of a file containing the fields names for the data source.

Possible values are :

*FILE

The fields names come from the AS/400 database file.

Header-file-name

Enter a PC file name containing the names of the fields.

Suppress blank lines

In the document, when a line containing merge fields is blank after the mail

merge, Word can suppress it.

Possible values are :

*NO

The blank lines are kept in the resolved document.

*YES

The blank lines are deleted from the resolved document.

 

 

Run the mail merge (EXECMRG)

Specifies if the mail merge process is to be run or not.

Possible values are :

*YES

The mail merge is processed. The data and the template are merged

together. A resolved document is built.

*NO

The mail merge is not processed. The final document is attached to the

data source. The document is ready for editing.

 

 

Example

 

LNCPRTDOC SELDOC(F) DOC('%LNCDIR%\Samples\sp_cust.docx') FLR(*NONE)

ROOT(*NONE) MRGTYPE(*FILE) FROMFILE(SP_CUST) SHOWDOC(*YES)

EXESRV(*DEV)