WRITE_PROCESS

Use the WRITE_PROCESS script function to write the content of a data sequence to a file. WRITE_PROCESS exports the content of any data sequence to a text file. You must specify a reference to the corresponding data sequence, which is stored when you create the data sequence in a script variable. Each line of the data sequence is a line in the file. You can define whether you want all or only a specific column of the data sequence written to the file.

Syntax

WRITE_PROCESS (Data-Sequence Reference, File, Agent, Login,[Mode],[CodeTable], [File Attributes], [Column])
WRITE_PROCESS (Data-Sequence Reference, File, Agent, Login,[Mode],[CodeTable], [File Attributes], [ALL], [Delimiter])

Parameters

  • WRITE_PROCESS
    Writes the content of a data sequence to a file

  • Data-Sequence Reference
    Reference to the data sequence whose content should be exported to a file
    Format: script variable

  • File
    Path and the name of the file
    Format: script variable or script literal

  • Agent
    Name of the agent whose host should be used to store the file
    Format: AE name, script variable or script literal

  • Login
    Name of the Login object that is used for logging on to the host of the specified agent
    Format: AE name, script variable or script literal

  • Mode
    (Optional) Defines the further procedure if the specified file already exists
    Format: AE name, script variable or script literal
    Allowed values:

    • CANCEL (default)
      The script function returns an error code in case of a failure so that you can react to this code. For details, see Examples.
    • OVERWRITE
      The file is overwritten
    • APPEND
      The existing file is extended for the new lines
  • CodeTable
    (Optional) Name of a Code Table object that should be used for coding the file. For example, <ISO-8859-15> or<UTF-8>. For more information, see Code Tables (CODE).
    The default CodeTable is the one that is defined in the Agent's INI file.

    Format: AE name, script variable or script literal

  • File Attributes
    (Optional) Additional file attributes for the generated file. Use commas to separate attributes if you define multiple attributes. Depending on the agent's INI file, you can specify the attributes that can also be used for file transfers. For more information, see File Transfers (JOBF).
    Format: script variable or script literal

  • Column
    (Optional) The number of the column(s) of the data sequence that should be written to the file.
    Format: script literal, script variable, a number without quotation marks
    Allowed values:

    • ALL (default)
      All columns
    • The number of the column that should be written to the file such as 2.
  • Delimiter
    (Optional) The character that should be used if you define several columns. This parameter is only relevant if you export all columns.
    Format: script literal, script variable, a number without quotation marks

Return Codes

  • 0
    The file has successfully been exported
  • 20554
    The agent is currently not active

Examples

The following example creates a data sequence that stores a list of the file names of a particular directory. Then, the content of this data sequence is stored in a file on a different host. If an error occurs (return code of WRITE_PROCESS > 0), an error message is written and sent to the responsible AE user.

:SET &HND# = PREP_PROCESS_FILENAME("WIN01","c:\AUTOMIC\server\bin\*.exe",,,,"COL=DELIMITER","DELIMITER=*\*")
:SET &RET# = WRITE_PROCESS(&HND#,"C:\temp\export.txt",WIN02, LOGIN.GLOBAL,OVERWRITE)

:IF &RET# > 0

: SET &ERRNR# = SYS_LAST_ERR_NR()
: SET &ERRINS# = SYS_LAST_ERR_INS()
: SET &MESSAGE# = GET_MSG_TXT(&ERRNR#,&ERRINS#)
: SEND_MSG &$USER#, &$DEPARTMENT#, &MESSAGE#
:ENDIF

The next example defines UTF-8 in the CodeTable parameter so that a smiley can be interpreted and written to a file:

:SET &LINE1# = "Hello Test "
:SET &RET# = PUT_PROCESS_LINE(&HND#, &LINE1#, ",")
:SET &RET# = WRITE_PROCESS(&HND#,"C:\temp\write_process_utf8.txt",WIN04, LOGIN.WINDOWS,OVERWRITE,"<UTF-8>")

:IF &RET# > 0
: SET &ERRNR# = SYS_LAST_ERR_NR()
: SET &ERRINS# = SYS_LAST_ERR_INS()
: SET &MESSAGE# = GET_MSG_TXT(&ERRNR#,&ERRINS#)
: SEND_MSG &$USER#, &$DEPARTMENT#, &MESSAGE#
:ENDIF

See also: