$FunLoad: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
(No difference)

Revision as of 19:19, 16 June 2012

Fast/Unload records in Model 204 list or found set

This requests an unload of the data in a Model 204 list or found set using Fast/Unload. If Fast/Unload is not installed at your site, this function returns a -1 error code.

The $FunLoad function accepts six arguments and returns a numeric result.

  • The first argument is a string that identifies a found set or a list. This is a required parameter. If you want to unload records in a found set created with a FIND statement, pass the label of the found set as the first argument. To unload the records in a list, specify the name of the list as the first argument. If you have a FIND statement label and a list with the same name, $FunLoad will use the FIND statement label, unless you explicitly specify that you want to unload a list by preceding the name of the list with the word LIST. For example, in the following program the unload at label FUN1 unloads all records found in the FIND statement at label DATA, while the unload at label FUN2 unloads the records on list DATA:

    DECLARE LIST DATA IN BIGFILE DATA: IN BIGFILE FIND ALL RECORDS FOR WHICH ..... END FIND FUN1: %RC = $FunLoad('DATA',...) FUN2: %RC = $FunLoad('LIST DATA',..)


    Model 204 FIND statement record locking protects the record sets you are unloading. For jobs where data consistency is critical, reorganizing a file, for example, this record locking is essential. For jobs that can tolerate some inconsistent data, like certain report creation, unlocked record sets (FIND WITHOUT LOCKS) may be suitable.

    You cannot unload records that are not in a found set or a list. For example, you cannot unload a sorted record set (although you can use sorted output in the FUEL program that $FunLoad runs, as described in the Fast/Unload Reference Manual).

  • The second argument is either the identifier of a $list or the DDname of an input program. This argument corresponds to FUNIN in batch mode Fast/Unload. This is a required parameter.
  • The third argument is either the identifier of the $list that is to receive the Fast/Unload report data or the DDname of a file that is to receive the Fast/Unload report data. Note that if you specify the ASYNCH parameter, you cannot specify a $list identifier for this argument. This argument corresponds to FUNPRINT in batch mode Fast/Unload. If this parameter is not specified, all report data will go to the Fast/Unload audit trail.
  • The fourth argument, which corresponds to FUNOUT in batch mode Fast/Unload, specifies the destination for the output data. This argument is required, and it may be one of the following:
    • A %variable that identifies the $list that is to receive the unloaded data. If you use a $list for output, you are allowed only one output stream in the FUEL program you are invoking. The $list you specify will be the sole output destination, and any destination names specified in the FUEL program are ignored.
    • An asterisk (*), indicating that the unloaded data will be processed with $FUNIMG, $FUNSKIP, and/or $FunsStr. Specifying an asterisk for this argument implies that the unload is asynchronous, whether or not the ASYNCH parameter is actually specified.
    • A string (eight characters at most), which indicates that the output data is to be sent to the one or more data sets specified in the FUEL program. Prior to Sirius Mods Version 6.5, multiple output data sets are not supported by the Fast/Unload User Language Interface. This fourth argument must be the DDname of the destination file for the single output stream specified or implied in the FUEL program. $FunLoad will validate the existence and attempt to obtain an exclusive enqueue on the output data set. As of Sirius Mods Version 6.5, processing of this argument depends on the Fast/Unload Version.:
      • For Fast/Unload versions prior to 4.2, only a single output stream is supported, and processing is as described above for Sirius Mods prior to Version Version 6.5..
      • For Fast/Unload 4.2 and higher, multiple output data sets are supported, and this argument string serves as a placeholder only, indicating that the output data is to be sent to the one or more data sets specified in the FUEL program. Fast/Unload will validate the existence and attempt to obtain an exclusive enqueue on all output data sets specified or implied in the FUEL program.
  • The fifth argument is a string that specifies the Fast/Unload parameters. This string can contain any of the parameters allowed on the PARM option on the EXEC card for batch mode Fast/Unload and can, in addition, contain the parameters ASYNCH, ALLMSG and NOTIFY. The description of parameters in the Fast/Unload Reference Manual shows the default parameter values, showing any differences when invoked via the Fast/Unload User Language Interface.
  • The sixth argument is a number indicating the maximum amount of time in seconds that the request is to be allowed to complete. If the $FunLoad request does not complete within this time, the $FunLoad request is immediately cancelled. The User Language request is not cancelled in such a case, but, for synchronous requests, the $FunLoad returns a 32. This is an optional argument and, if not specified, defaults to the FUNMAXT system parameter setting. An explicit or default value of 0 means that there will be no time limit placed on the request. This argument is only available in Sirius Mods Version 6.7 and later. Before that, no time limits were placed on any $FunLoad requests. Note that the time limit includes the time waiting for the request to actually be run by a Fast/Unload task, so a request could time out because of other long-running requests tying up the Fast/Unload tasks.

Syntax

<section begin="syntax" /> %RESULT = $FunLoad(found_set, funin, funprint, funout, - [parms], [timelimit]) <section end="syntax" />

$FunLoad Function

%RESULT is set to the return code from Fast Unload, to the positive request number for asynchronous requests, or to a negative number if &amp;FUNL. is unable to process the request.

Error Codes

-1 - &amp;FUNL. PST not available -2 - Input/report/output DDname in use -3 - Ran out of CCATEMP or free storage -4 - Input/report/output DDname not found -5 - Required parameter not specified -11 - Invalid found set specified -12 - Invalid input/report/output descriptor specified -13 - Conflicting parameters

$FunLoad Error Codes

In addition to the above error codes, if $FunLoad discovers that a required capability is not supported by the version of Fast/Unload in use, the User Language request is cancelled with an error message indicating the missing capability. If any missing capabilities which would prevent successful $FunLoad operation are discovered during Model 204 initialization, an operator warning is issued and saved in the VIEW ERRORS table, so that corrective action may be taken in advance.

Under Sirius Mods Version 6.7 and later, if the X'01' bit is set in the system FUNPARM parameter, the request will be cancelled if a $FunLoad is issued in the middle of an updating transaction. Whether or not FUNPARM X'01' is set, it is generally best to avoid $FunLoad calls in the middle of an updating transaction, since $FunLoad calls can take a long time to run, even if the specific $FunLoad request is relatively small. This is so because all $FunLoad requests share the same FUNTSKN subtasks, and if these are tied up with relatively long-running requests, all other requests must wait for access to a Fast/Unload task.

To make it easier to diagnose problems where Fast/Unload User Language Interface is involved, under Sirius Mods Version 6.7 and later, messages are also sent to the Model 204 journal/audit trail at each Fast/Unload request made and at each completed by the Fast/Unload User Language Interface. The message when the requests are started look like:

MSIR.0890: Asynchronous request 2 made by $FunLoad

And the message when the requests are completed look like:

MSIR.0891: Asynchronous request 2 completed, RC = 0

Examples

In the following example, the Fast/Unload input data is in DDname FUNIN, the report is to go to DDname FUNPRINT and the data is to be unloaded to DDname FUNOUT.

B FIND1: FIND ALL RECORDS IN COMICS FOR WHICH NAME = 'SIMPSON' END FIND %RC = $FunLoad('FIND1', 'FUNIN', 'FUNPRINT', - 'FUNOUT', 'NOBUFF=6') IF %RC NE 0 THEN PRINT 'ERROR PERFORMING FAST UNLOAD... RC =' AND %RC END IF END


In the following example, we dynamically build the unload input program, have the report data simply go to the Fast/Unload audit trail, and have the data unloaded to a $list.

BEGIN %LIST1 = $ListNew %LIST2 = $ListNew %RC = $ListAdd( %LIST1, 'FOR EACH RECORD' ) %RC = $ListAdd( %LIST1, ' PUT *' ) %RC = $ListAdd( %LIST1, ' OUTPUT' ) %RC = $ListAdd( %LIST1, ' PAI' ) %RC = $ListAdd( %LIST1, 'END FOR' ) FIND1: IN CLOWNS FIND ALL RECORDS FOR WHICH TRADEMARK = 'PRATFALL' END FIND %RC = $FunLoad( 'FIND1', %LIST1, , %LIST2) . . . . . . . . . . END

In the following example, the input FUEL program is contained in procedure 'UNLOAD1' in the Model 204 procedure file called 'FUELPROC'. The data is processed with $FunImg calls (not shown).

BEGIN DECLARE LIST HOHO IN BIGFILE . . . . . . . . . . %REPLIST = $ListNew %RECORDS = 'LIST HOHO' %INLIST = $ListNew %RC = $ProcOpn('UNLOAD1','FUELPROC') %RC = $ProcDat(%INLIST) %OPTIONS = 'NEBUFF=4,NBBUFF=2,UPPER,ALLMSG' %RC = $FunLoad( %RECORDS, %INLIST, , '*', %OPTIONS ) . . . . . . . . . . END

The following is an example of an asynchronous unload request. The input program is in DDname FUNIN, the report data is to go to the Fast/Unload audit trail, and the data is to be dumped to DDname OUTFILE.

BEGIN FINDX: IN MOVIES FIND ALL RECORDS FOR WHICH DIRECTOR = 'HITCHCOCK' END FIND %OPTIONS = 'ASYNCH ALLMSG NOBUFF=8' %RC = $FunLoad( 'FINDX', 'FUNIN', , 'OUTFILE', %OPTIONS ) IF %RC > 0 THEN PRINT 'FAST UNLOAD REQUEST ACCEPTED,' AND - 'REQUEST NUMBER =' WITH %RC ELSE PRINT 'FAST UNLOAD REQUEST REJECTED,' AND - 'ERROR CODE =' AND %RC END IF END


Products authorizing $FunLoad