How to pass the FILECOPY return code to a numeric field in a script in the TIBCO iProcess Engine to be used in an expression

How to pass the FILECOPY return code to a numeric field in a script in the TIBCO iProcess Engine to be used in an expression

book

Article ID: KB0089303

calendar_today

Updated On:

Products Versions
TIBCO iProcess Engine (Oracle) -
Not Applicable -

Description

Resolution:
Description:
============
The FILECOPY function that is available in the TIBCO iProcess Engine can be used to copy files from the server to the client or from the client to the server using the TIBCO iProcess Workspace Client (Windows). The return values are as follows: "1 Success", "-4 Failed to open either file" and "-2 Failed to copy for any other reason". If this value is passed into a numeric field with a length of one digit  it will return a '1' or a '0', which looks like an incorrect return value.

Environment:
============
TIBCO iProcess Engine: 11.1.1 Windows SQL / ORACLE (Not tested on the older products. The same may apply).
OOTB iProcess Workspace Client (windows): 11.1.0

Symptoms:
=========
Incorrect return value for FILECOPY()

Cause:
======
Field length for return value too small.

Resolution:
============
To resolve this problem updated the field length for the return code as a numeric of length '2'.  The following script will then work correctly:

SOURCE := "$SWDIR\addons\tmp2\" + SW_USER:NAME + ".abx"
messagebox ("string check", "SOURCE: " + SOURCE, 4,0)

DEST := "D:\TibcoiProcessWorkspace11.1\addons\tmp\" + SW_USER:NAME + ".abx"
messagebox ("string check 2", "DEST: " + DEST, 4,0)

RETURNCODE2 := filecopy (SOURCE, DEST) ;pass return code into a string - this works!
RETURNCODE := num(RETURNCODE2) ;pass a string into a numeric of '2' digits

if RETURNCODE <> 1
  messagebox ("Error", "The copying of the data file has failed! " + str(RETURNCODE,0), 4,0)
endif

References:
==========
TIBCO iProcess™ Expressions and Functions Reference Guide

Issue/Introduction

How to pass the FILECOPY return code to a numeric field in a script in the TIBCO iProcess Engine to be used in an expression