/**
@class Valence_RPG_Toolkit.vvOut
The vvOut procedures provide the data from the RPG program back to the client browser. The 'output'
for Ext is generally JSON and vvOut provides several methods to automatically convert 
data from database tables, data structures, or character strings into properly formatted JSON.
Output can also be IFS files, or data converted into Spreadsheets or comma separated files 
for downloading to the client browser.

*/

/**
@method _buffer
Buffer data before sending back to the browser.  The data must be formatted manually.

@param {65535a, const varying (required)} string
The string to be buffered (65535 chars max)

@param {1p0 const (optional)} mode
When passed, indicates the start or end of the buffer load.  The following constants, automatically included as part of the VVDSPEC copy source member, may be used:
 
 - `STARTBUFFER` - This must be passed on the first call.
 - `ENDBUFFER` - Passed on the last call, invokes the call to vvOut_data to send the buffered data to the browser, flagging the data as JSON format.
 - `ENDBUFFERHTML` - Passed on the last call, invokes the call to vvOut_data to send the buffered data to the browser, flagging the data as HTML format.
 - `ENDBUFFERXML` - Passed on the last call, invokes the call to vvOut_data to send the buffered data to the browser, flagging the data as XML format.

 
# RPG Example
 
      /free
       
       // pass the STARTBUFFER parameter on the first call...
       vvOut_buffer('Content-type:text/json'+LF+LF+' {' : STARTBUFFER);
 
       // continue to add to the buffer...
       vvOut_buffer('"fieldA":"abc","fieldB":"xyz"');
       vvOut_buffer('"num1":123,"num2":999');
 
       // on the last call, pass the ENDBUFFER parameter...
       vvOut_buffer('}' : ENDBUFFER);
      /end-free
*/

/**
@method _data
Sends a string of data to the browser. The string must be formatted manually.
 
@param {65535a, const varying (required)} string
The string to be passed to the browser

@param {30a, const varying (optional)} type
Indicates the format (content type) of the passed data, which is output to the browser along with the passed string. The following constants, automatically included as part of the VVDSPEC copy source member, may be used:
 
 - `HTML` - "text/html" - data is in HTML format
 - `JSON` - "text/json - data is in JSON format
 - `JSONP` - "text/javascript - data is in JSONP format
 - `CSV` - "text/csv" - data is in comma-separated variable format
 - `PDF` - "application/pdf" - data is in PDF format

@param {*pointer, value (optional)} pointer
Pointer to a variable containing data to be sent to the browser.  This is particularly suited for situations where the data being sent to the browser exceeds the size restriction for the "string" parm above.

@param {10s0, const (optional)} size
Required when a pointer is passed, this indicates the number of bytes (characters) in the pointed field that should be sent to the browser.

@param {n, const (optional)} binaryIndicator
If not passed or set to *off then data will be sent to the browser in UTF8 format.  Passing *on will send the data in raw binary format.


# RPG Examples
 
## Example 1

      d textField       s            100a
       /free
  
         // simply output some text to the browser...
         vvOut_data('Send this text to the browser');
  
         // alternately, pass in a text field...
         textField='Send this text to the browser';
         vvOut_data(textField);


##Example 2

        // This example is simply outputting the content type to the browser
        // without data...
        // In this case, the browser would next expect to receive html data
        vvOut_data(*omit:HTML);
 
##Example 3 - using a pointer

       d textField       s             50a
       d ptrTextField    s               *   inz(%addr(textField))

        /free
 
          // example of outputting text to the browser using a pointer
          textField= 'hello';
 
          vvOut_data(*omit
                     :*omit
                      :ptrTextField
                      :%len(textField));
*/

/**
@method _execSQLtoCSV
Executes an SQL statement and sends the results in CSV format to either the browser or to the IFS.

@param {DS (required)} vvOut
The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_execSQLtoCSV are as follows:

 - `csvSeparator` - Optionally specify the CSV separator. Defaults to the CSV separator defined in Settings.
 - `download` - set to "1" if CSV is to be downloaded as a file, or "F" if CSV should be created in the IFS.
 - `file` - If download is "1", sets the default download file name when the file is being downloaded. This may be overridden by the user in the download prompt window. If download is "F" then this field should be set to the full name (path and file) of the file to be created in the IFS.
 - `logStmt` - Set to "1" to log the SQL statement and call duration to file VVGENLOG.  If set to "0" then no logging will take place.  If set to blank then the Portal Admin/Settings "Log all SQL Statements" setting will be used.
 - `longSqlNames` - Set to "1" to extract long SQL field names.
 - `maxResults` - Identifies the number of records (beyond the startFrom value) to include in the CSV data.
 - `startFrom` - Identifies the record number from the SQL output from which the CSV data should begin.
 
@param {32766a, const varying (required)} SQLstatement
The SQL statement to be executed.

@return {n}
An indicator value will be returned as a response, with *on indicating success and *off indicating an error occurred. The vvOut data structure field 'error' will contain error text.

# RPG Example

     /copy qcpylesrc,vvDspec

     /free
      // download the entire customer master file, sort by state, city...
      //
      vvOut.download = '1';
      vvOut.file     = 'customerMaster.csv';
      vvOut_execSqlToCSV(vvOut:'select * from CustMaster order by cusstate,cuscity');

      // download 50 records of the customer master file starting at
      // the 100th record...
      //
      vvOut.download   = '1';
      vvOut.file       = 'customerMaster.csv';
      vvOut.startFrom  = 100;
      vvOut.maxResults = 50;
      vvOut_execSqlToCSV(vvOut:'select * from CustMaster order by cusstate,cuscity');
 
     /end-free
*/

/**
@method _execSQLtoJSON
Executes an SQL statement and sends the results in JSON format to the browser.
 
@param {DS (required)} vvOut
The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_execSQLtoJSON are as follows:

  - `applyFilters` - if set to "1", filter fields (as passed by the front-end, i.e., on a grid with remoteFilter=true) will result in the appropriate "where" clause being added to the SQL statement.  Note that complex SQL statements (i.e., statements containing sub-queries or "with" clauses) may result in the filter clause being applied to the incorrect location.  In such cases, developers should manually apply the filter conditions to the SQL statement using either vvIn_getFilters() or vvUtility_buildFilterClause().
  - `applyPaging` - If set to "1", "start" and "limit" parameters will automatically be applied to vvOut.startFrom and vvOut.maxResults respectively.  This is typically used in conjunction with a paging plugin on grids.
  - `applySorters` - If set to "1", sort fields/directions (as passed by the front-end) will automatically be applied to the SQL statement.
  - `buffer` - If set to "1" then the response will be buffered in memory.  Data will not be sent until a subsequent VVOUT is called with buffering set to "0".
  - `columnData` - If set to "1" then front-end column model data will be included, based on the data object
  - `embed` - Additional free-form JSON text to be embedded into the JSON response
  - `encodeUTF16` - If set to "1", graphic fields will be encoded to a UTF16 hex string, which must be decoded by the front-end program (using Valence.util.decodeUTF16). This ensures that special characters are not lost during translation.
  - `JSONP` - Set to "1" to format the response in JSONP.
  - `logStmt` - Set to "1" to log the SQL statement and call duration to file VVGENLOG.  If set to "0" then no logging will take place.  If set to blank then the Portal Admin/Settings "Log all SQL Statements" setting will be used.
  - `longSqlNames` - Set to "1" to extract long SQL field names.
  - `maxResults` - Identifies the maximum number of records (beyond the startFrom value) to send to the browser.
  - `metaData` - If set to "1" then meta data will be derived from the SQL output and provided to the front-end as part of the JSON response.
  - `prefix` - If non-blank, this value will serve as a prefix for all field names on the front-end (added to the back-end field name)
  - `rootName` - The name of the root specified in the front-end data store. If left blank, will default to "dataRoot".
  - `singleRow` - If set to "1" then only the first record of the response will be sent, and the result set will not be in array form.
  - `skipCountCalc` - If set to "1" then the "totalCount" of the result set will not be calculated. If you are using paging functionality then you will need to include the appropriate "totalCount" in the vvOut.embed field yourself.
  - `startFrom` -  Identifies the record number from the SQL output from which Valence should begin sending data to the browser.
  - `success` - If set to "1" then a {"SUCCESS":"1"} string will be included in the JSON response; if set to "true" then a {"success":true} will be included in the JSON response.
  - `totalProperty` - if not blank and `skipCountCalc` is not set to "1", then this value is used as the field name of the totalCount.  If blank then the total row count is returned as "totalCount".
  - `useAsensitveCursor` - If set to "1" then the sql query will use an asensitive cursor and, when needed, determine the totalCount of the result set by running a second query with a select count(\*). This is the method used by version 3.1 and prior; If set to "0" then the sql query will use an insensitive cursor and determine totalCount by the DB2_NUMBER_ROWS; If not set, the global default is used, as set in the Valence setting VVOUT_USE_ASENSITIVE_CURSOR (typically set to "0")

@param {32766a, const varying (required)} SQLstatement
The SQL statement to be executed.
 
@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. `vvOut.returnLength` will contain the number of bytes (rows x row size) sent to the browser.
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text.
 

# RPG Example

     // send data to the browser
     vvOut.startFrom =vvIn_num('start'); // starting point
     vvOut.maxResults=vvIn_num('limit'); // number of records to retrieve
     // note: in lieu of the above, could also specify vvOut.applyPaging='1';

     stmt='select * from DemoCmast'+
          ' where Cstate='+SQ+'TX'+SQ+
          ' order by Cstate';
     vvOut.rootName='TexasCustomersGrid'; // name of data store on the front-end
     vvOut_execSqlToJson(vvOut:stmt);
*/

/**
@method _execSQLtoSS
Executes the SQL statement and sends the results as an XML Spreadsheet to either the browser or to 
the IFS compatible with Microsoft Excel. The Spreadsheet reference specification used is the <a href="http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx" target="_blank">XML Spreadsheet Reference</a>

@param {DS (required)} vvOut
The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_execSQLtoSS are as follows:

 - `applyPaging` - If set to "1", "start" and "limit" parameters will automatically be applied to vvOut.startFrom and vvOut.maxResults respectively.
 - `applySorters` - If set to "1", sort fields/directions (as passed by the front-end) will automatically be applied to the SQL statement.
 - `download` - set to "1" if spreadsheet is to be downloaded as a file, "F" if spreadsheet should be created in the IFS.
 - `embed` - Optionally specify rows and cells that will appear before the Spreadsheet Column Headings and Data. The data must be valid XML data using and tags.
 - `file` - If download is "1", sets the default download file name when spreadsheet is being downloaded. This may be overridden by the user in the download prompt window. If download is "F" then this field should be set to the full name (path and file) of the file to be created on the IFS.
 - `logStmt` - Set to "1" to log the SQL statement and call duration to file VVGENLOG.  If set to "0" then no logging will take place.  If set to blank then the Portal Admin/Settings "Log all SQL Statements" setting will be used.
 - `longSqlNames` - Set to "1" to extract long SQL field names.
 - `maxResults` - Identifies the number of records (beyond the startFrom value) to include in the CSV data.
 - `ssFilterRow` - The Row number for AutoFilter. This is the Row of the Spreadsheet that should contain the data column headings (which will vary if vvOut.embed is used). If zero then Autofilter will not be used.
 - `ssSheetName` - The name worksheet name. Defaults to SHEET1.
 - `ssTemplate` - The path and filename of the file in the IFS that contains the XML Workbook and Styles settings to use to create the spreadsheet. If a value is not provided, then the default template is used as specified in the Valence Setting DEFAULT_SS_TEMPLATE with the path of the Valence setting ROOT_PATH.
 - `startFrom` -  Identifies the record number from the SQL output from which the spreadsheet data should begin.
 
@param {32766a, const varying (required)} SQLstatement
The SQL statement to be executed.

@param {*pointer, value (optional)} columnsPointer
Pointer to array of vvSSCol data structures used to control the order and formatting on individual columns within the Spreadsheet. The data structure is automatically included as part of the VVDSPEC copy source member. Each array element number represents the spreadsheet column number. The subfields pertinent to this procedure are as follows:

 - `colWidth`  The column width in pixels.  If not specified, the width is calculated from the SQL column size.  A rough approximation for determining an appropriate value for this setting is to multiply by 7 the number of characters you would like to show in the column.  Alternatively, if creating an .XLSX file, you can explicitly set the number of characters for the column by leaving this value at zero and instead putting the desired characters in 'XLSXcolW'.
 - `XLSXcolW`  (valid for .XLSX files only) If specified and colWidth is zero, this is the width of the column in characters.  May be sepecified as a non-whole value, like 10.5.
 - `heading`  The text for the column Heading. If blank the SQLName is used.
 - `omit`  If set to "1", sets the column to Hidden in spreadsheet.
 - `prefix`  If specified, the value is used to prefix each column value.
 - `SQLName`  The name of the column in the SQL statement.
 - `styleID` The name of the styleID in the ssTemplate used on this column. If not specified a default style based on the SQL column attributes is used. The default spreadsheet Template has the following styleIDs defined:
   - `bool`  a numeric value displayed as true if a positive value or false if zero or negative value. Right justified
   - `char`  left justified
   - `dDMY`  date formatted dd-mm-yyyy right justified
   - `dMDY`  date formatted mm/dd/yyyy right justified
   - `dYMD`  date formatted yyyy-mm-dd right justified
   - `num0`  a number with thousands separators and no decimals, right justified
   - `num1`  a number with thousands separators and one decimal, right justified
   - `num2`  a number with thousands separators and two decimals, right justified
   - `num3`  a number with thousands separators and three decimals, right justified
   - `num4`  a number with thousands separators and four decimals, right justified
   - `num5`  a number with thousands separators and five decimals, right justified
   - `num6`  a number with thousands separators and six decimals, right justified
   - `num7`  a number with thousands separators and seven decimals displayed, right justified
   - `num8`  a number with thousands separators and eight decimals displayed, right justified
   - `num9`  a number with thousands separators and nine decimals displayed, right justified
   - `percnt`  format as a percent. Note that the value shold have proper decimal positions - 1.00 = 100%, .5 = 50%. Right justified
   - `phone`  7 or 10 digit number formatted as nnn-nnnn or (nnn) nnn-nnnn. Right justified
   - `time`  time formatted hh:mm AM/PM right justified
   - `TIN`  number formatted as a personal Tax Identification number nnn-nn-nnnn right justified
   - `tStamp` Time stamp formatted mm/dd/yy hh:mm AM/PM right justified
   - `USCur`  number formatted with $ and 2 decimal places, parentheses around negative values, blank for zero values. Right justified
   - `val0`  a number with no commas and no decimal positions, right justified.
   
@param {6p0, const (optional)} numberOfColumns
 The number of data structures (columns) passed in the columns array. Required if columnsPointer is passed.

@return {n}
 An indicator value will be returned as a response, with *on indicating success and *off indicating an error occurred. The vvOut data structure field 'error' will contain error text.

# RPG Example

     // send data to the browser
     /copy qcpylesrc,vvDspec

      /free
       // download the entire customer master file, sort by state, city...
       vvOut.download = '1';
       vvOut.file     = 'customerMaster.xls';
       vvOut_execSqlToSS(vvOut:'select * from CustMaster order by cusstate,cuscity');

       // download 50 records of the customer master file starting at
       // the 100th record...
       vvOut.download   = '1';
       vvOut.file       = 'customerMaster.xls';
       vvOut.startFrom  = 100;
       vvOut.maxResults = 50;
       vvOut_execSqlToSS(vvOut:'select * from CustMaster order by cusstate,cuscity');

       // note: see vvOut_ss section for example of formatting the spreadsheet columns
      /end-free
*/

/**
@method _ssOpenWorkbook
The _SS procedures can create customized spreadsheets with full control over the rows and formatting,
including custom row and cell formatting, sections or worksheets from multiple data sources, 
and even formulas.  The procedures are executed in sequence:

 - *vvOut_SSOpenWorkbook* - Begins the xml spreadsheet using the Workbook and style settings from the IFS.
 - *vvOut_SSOpenWorksheet* - Begins the sheet within the workbook and optionally defines the column widths and headings. There can be multiple worksheets within the workbook.
 - *vvOut_SSSQLRows* - Appends the resulting rows of a SQL statement to the Worksheet, similar to vvOut_execSQLtoSS. Can be executed multiple times within the same worksheet.
 - *vvOut_SSDSRows* - Appends the records of the externally defined datastructure to the worksheet, similar to vvOut_toSS. Can be executed multiple times within the worksheet.
 - *vvOut_SSData* - Appends the data to the worksheet.  The data should be fully formed xml data that follows the XML Spreadsheet specification. This can be used to append rows and cells within in the worksheet.
 - *vvOut_SSCloseWorksheet* - Ends the xml worksheet. Either a SSCloseWorkbook or a SSOpenWorksheet must be executed immediately after.
 - *vvOut_SSCloseWorkbook* - Ends the XML spreadsheet and completes the process.

 The Spreadsheet reference specification used is the <a href="http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx" target="_blank">XML Spreadsheet Reference</a>

@param {DS (required)} vvOut
The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_SSOpenWorkbook are as follows:

 - `download` - set to "1" if spreadsheet is to be downloaded as a file, "F" if spreadsheet should be created in the IFS.
 The method used here will be used for the subsequent spreadsheet procedures until the ssCloseWorkbook procedure is executed to write the final data.
 - `file` - If download is "1", sets the default download file name when spreadsheet is being downloaded. This may be overridden by the user in the download prompt window. If download is "F" then this field should be set to the full name (path and file) of the file to be created in the IFS.
 - `ssTemplate` - The path and filename of the file in the IFS that contains the XML Workbook and Styles settings to use to create the spreadsheet. If a value is not provided, then the default template is used as specified in the Valence Setting DEFAULT_SS_TEMPLATE with the path of the Valence setting ROOT_PATH.

@return {n}
 An indicator value will be returned as a response, with *on indicating success and *off indicating an error occurred. The vvOut data structure field 'error' will contain error text.

*/
/**
@method _ssOpenWorksheet
Begin a worksheet within the Workbook (see _SSOpenWorkbook for an overview of the custom spreadsheet processing). 

@param {DS (required)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_execSQLtoSS are as follows:

 - `embed` - If the second parameter of columns is passed, the xml data in this field will be appended to the spreadsheet before column headings. The data must be valid XML spreadsheet data .
 - `ssFilterRow` - The Row number for AutoFilter. This is the Row of the Spreadsheet that should contain the data column headings (which will vary if vvOut.embed is used). If zero then Autofilter will not be used.
 - `ssSheetName` - The name worksheet name. Defaults to SHEET1.  Must be a unique name within the workbook.
 - `ssTitleColF` - if specified, indicates the starting ("From") column number to be used as a static vertical title along the left of the workbook.
 - `ssTitleColT` - used in conjunction with ssTitleColF to indicate the ending ("To") column number for the vertical title.
 - `ssTitleRowF` - if specified, indicates the starting ("From") row number to be used as a static horizontal title along the top of the worksheet.
 - `ssTitleRowT` - used in conjunction with ssTitleRowF to indicate the ending ("To") row number for the horizontal title.

@param {*pointer, value (optional)} columnsPointer

Pointer to array of vvSSCol data structures used to control the order and formatting on individual columns within the Spreadsheet.
The spreadsheet columns may be omitted and the column attributes set by the next output of _SSSQLRows or _SSDSRows - the advantage of setting 
the columns with these procedures is that the column widths can be derived from the field attributes.  If columns 
are not passed on the OpenWorksheet and the next procedure does not set the columns, then the Worksheet default is used for all 
columns. The datastructure is automatically included as part of the VVDSPEC copy source member. Each array element number represents 
the spreadsheet column number. The subfields pertinent are as follows:

 - `colWidth`  The column width in pixels.  If not specified, the width is calculated from the SQL column size.  A rough approximation for determining an appropriate value for this setting is to multiply by 7 the number of characters you would like to show in the column.  Alternatively, if creating an .XLSX file, you can explicitly set the number of characters for the column by leaving this value at zero and instead putting the desired characters in 'XLSXcolW'.
 - `XLSXcolW`  (valid for .XLSX files only) If specified and colWidth is zero, this is the width of the column in characters.  May be sepecified as a non-whole value, like 10.5. - `heading` - (optional) The text for this column Heading. If any of the columns contain a heading then a Heading row is produced, otherwise the worksheet will be empty.
 - `omit` - If set to "1", sets the column to Hidden in spreadsheet.
 - `styleID` - The name of the styleID in the spreadsheet Styles used for  this column. If not specified the default style of the workbook is used.  The default spreadsheet Template has the following styleIDs defined:
   - `bool` - a numeric value displayed as true if a positive value or false if zero or negative value. Right justified
   - `char` - left justified
   - `dDMY` - date formatted dd-mm-yyyy right justified
   - `dMDY` - date formatted mm/dd/yyyy right justified
   - `dYMD` - date formatted yyyy-mm-dd right justified
   - `num0` - a number with thousands separators and no decimals, right justified
   - `num1` - a number with thousands separators and one decimal, right justified
   - `num2` - a number with thousands separators and two decimals, right justified
   - `num3` - a number with thousands separators and three decimals, right justified
   - `num4` - a number with thousands separators and four decimals, right justified
   - `num5` - a number with thousands separators and five decimals, right justified
   - `num6` - a number with thousands separators and six decimals, right justified
   - `num7` - a number with thousands separators and seven decimals displayed, right justified
   - `num8` - a number with thousands separators and eight decimals displayed, right justified
   - `num9` - a number with thousands separators and nine decimals displayed, right justified
   - `percnt` - format as a percent. Note that the value shold have proper decimal positions - 1.00 = 100%, .5 = 50%. Right justified
   - `phone` - 7 or 10 digit number formatted as nnn-nnnn or (nnn) nnn-nnnn. Right justified
   - `time` - time formatted hh:mm AM/PM right justified
   - `TIN` - number formatted as a personal Tax Identification number nnn-nn-nnnn right justified
   - `tStamp` - Time stamp formatted mm/dd/yy hh:mm AM/PM right justified
   - `USCur` - number formatted with $ and 2 decimal places, parentheses around negative values, blank for zero values. Right justified
   - `val0` - a number with no commas and no decimal positions, right justified.
 - `HstyleID` - The name of the Heading styleID in the ssTemplate used on this column. The default values for the spreadsheet template are the same as described above for styleID.

@param {6p0, const (optional)} numberOfColumns
Number of data structures (columns) passed in the columns Array. Required if columnsPointer is passed.

@return {n}
 An indicator value will be returned as a response, with *on indicating success and *off indicating an error occurred. The vvOut data structure field 'error' will contain error text.

*/
/**
@method _ssSQLRows
Executed as part of a customized Spreadsheet - see overview in vvOut_SSOpenWorkbook.  Similar to the stand-alone vvOut_execSQLtoSS - Executes the SQL statement and sends the results as an XML Spreadsheet to either the browser or to 
the IFS compatible with Microsoft Excel. The Spreadsheet reference specification used is the <a href="http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx" target="_blank">XML Spreadsheet Reference</a>

@param {DS (required)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_execSQLtoSS are as follows:

 - `applyPaging` - If set to "1", "start" and "limit" parameters will automatically be applied to vvOut.startFrom and vvOut.maxResults respectively.
 - `embed` - Optionally specify rows and cells that will appear before the Spreadsheet Column Headings and Data. The data must be valid XML data using and tags.
 - `longSqlNames` - Set to "1" to extract long SQL field names.
 - `maxResults` - Identifies the number of records (beyond the startFrom value) to include in the CSV data.
 - `omitHeading` -  If set to "1" then the column heading row is omitted.
 - `startFrom` -  Identifies the record number from the SQL output from which the spreadsheet data should begin.
 
@param {65535a, const varying (required)} SQLstatement
 The SQL statement to be executed.

@param {*pointer, value (optional)} columnsPointer
 Pointer to array of vvSScol data structures used to control the order and formatting on individual columns within the Spreadsheet.

 Note: If _SSSQLRows is not the first procedure after _SSOpenWorksheet, or if columns were passed when _SSOpenWorksheet was passed, then the Worksheet column widths and styles will *NOT* be used.  Each array element number represents the spreadsheet column number.

 Pertinent vvSScol DS fields if spreadsheet columns are not yet set:

 - `colWidth`  The column width in pixels.  If not specified, the width is calculated from the SQL column size.  A rough approximation for determining an appropriate value for this setting is to multiply by 7 the number of characters you would like to show in the column.  Alternatively, if creating an .XLSX file, you can explicitly set the number of characters for the column by leaving this value at zero and instead putting the desired characters in 'XLSXcolW'.
 - `XLSXcolW`  (valid for .XLSX files only) If specified and colWidth is zero, this is the width of the column in characters.  May be sepecified as a non-whole value, like 10.5.
 - `omit`  If set to "1", sets the column to Hidden in spreadsheet.
 - `styleID`  The name of the styleID in the ssTemplate used on this column. If not specified a default style based on the SQL column attributes is used. The default spreadsheet Template has the following styleIDs defined:
   - `bool`  a numeric value displayed as true if a positive value or false if zero or negative value. Right justified
   - `char`  left justified
   - `dDMY`  date formatted dd-mm-yyyy right justified
   - `dMDY`  date formatted mm/dd/yyyy right justified
   - `dYMD`  date formatted yyyy-mm-dd right justified
   - `num0`  a number with thousands separtors and no decimals, right justified
   - `num1`  a number with thousands separtors and one decimal, right justified
   - `num2`  a number with thousands separtors and two decimals, right justified
   - `num3`  a number with thousands separtors and three decimals, right justified
   - `num4`  a number with thousands separtors and four decimals, right justified
   - `num5`  a number with thousands separtors and five decimals, right justified
   - `num6`  a number with thousands separtors and six decimals, right justified
   - `num7`  a number with thousands separtors and seven decimals displayed, right justified
   - `num8`  a number with thousands separtors and eight decimals displayed, right justified
   - `num9`  a number with thousands separtors and nine decimals displayed, right justified
   - `percnt`  format as a percent. Note that the value shold have proper decimal positions - 1.00 = 100%, .5 = 50%. Right justified
   - `phone`  7 or 10 digit number formatted as nnn-nnnn or (nnn) nnn-nnnn. Right justified
   - `time`  time formatted hh:mm AM/PM right justified
   - `TIN`  number formatted as a personal Tax Identification number nnn-nn-nnnn right justified
   - `tStamp` Time stamp formatted mm/dd/yy hh:mm AM/PM right justified
   - `USCur`  number formatted with $ and 2 decimal places, parentheses around negative values, blank for zero values. Right justified
   - `val0`  a number with no commas and no decimal positions, right justified.

 Pertinent vvSScol DS fields when vvOut data structure field "omitHeadings" is false:

 - `heading`  The text for the column Heading. If blank the SQLName is used.
 - `prefix`  If specified, the value is used to prefix each column value.
 - `SQLName`  The name of the column in the SQL statement.
   
@param {6p0, const (optional)} numberOfColumns
 Number of data structures (columns) passed in the columns Array.  Required if columnsPointer is passed.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. 
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text.

*/
/**
@method _ssDSRows
Executed as part of a customized Spreadsheet - see overview in vvOut_ssOpenWorkbook.  Similar to the stand-alone vvOut_toSS, this procedurea ppends rows to an XML Spreadsheet from the data (passed as an externally defined datastructure with multiple records) to either the browser or to the IFS compatible with Microsoft Excel. The Spreadsheet reference specification used is the <a href="http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx" target="_blank">XML Spreadsheet Reference</a></span>

@param {DS (required)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_ssDSRows are as follows:

 - `object` - The object to serve as the definition for the data being passed. This is typically a physical file object serving as an external data structure definition.
 - `library` - The library corresponding to the object above. If not specified, *LIBL is assumed.
 - `recordFormat` - The record format for the data object. If not specified, *FIRST is assumed.
 - `embed` - Optionally specify rows and cells that will appear before the Spreadsheet Column Headings and Data. The data must be valid XML data using and tags.
 - `maxResults` - Identifies the number of records (beyond the startFrom value) to include in the CSV data.
 - `omitHeading` -  If set to "1" then the column heading row is omitted.
 - `startFrom` -  Identifies the record number from the SQL output from which the spreadsheet data should begin.
 
@param {*pointer, value} dataPointer
 Pointer to the data to be converted and sent to the front-end

@param {6p0, const (optional)} type
 Total number of records to be sent to the front-end. If no value specified or passed then 1 is assumed.
 
@param {*pointer, value (optional)} columnsPointer
 Pointer to array of vvSSCol data structures used to control the order and formatting on individual columns within the Spreadsheet. The datastructure is automatically included as part of the VVDSPEC copy source member. Each array element number represents the spreadsheet column number. The subfields pertinent are as follows:

 - `colWidth`  The column width in pixels.  If not specified, the width is calculated from the SQL column size.  A rough approximation for determining an appropriate value for this setting is to multiply by 7 the number of characters you would like to show in the column.  Alternatively, if creating an .XLSX file, you can explicitly set the number of characters for the column by leaving this value at zero and instead putting the desired characters in 'XLSXcolW'.
 - `XLSXcolW`  (valid for .XLSX files only) If specified and colWidth is zero, this is the width of the column in characters.  May be sepecified as a non-whole value, like 10.5.
 - `heading` - The text for the column Heading. If blank the SQLName is used.
 - `omit` - If set to "1" (or any non-blank value), sets the column to Hidden in spreadsheet.
 - `prefix` - If specified, the value is used to prefix each column value
 - `SQLName` - The name of the column in the SQL statement.
 - `styleID` - The name of the styleID in the ssTemplate used on this column. If not specified a default style based on the SQL column attributes is used. The default spreadsheet Template has the following styleIDs defined:
   - `bool` - a numeric value displayed as true if a positive value or false if zero or negative value. Right justified
   - `char` - left justified
   - `dDMY` - date formatted dd-mm-yyyy right justified
   - `dMDY` - date formatted mm/dd/yyyy right justified
   - `dYMD` - date formatted yyyy-mm-dd right justified
   - `num0` - a number with thousands separtors and no decimals, right justified
   - `num1` - a number with thousands separtors and one decimal, right justified
   - `num2` - a number with thousands separtors and two decimals, right justified
   - `num3` - a number with thousands separtors and three decimals, right justified
   - `num4` - a number with thousands separtors and four decimals, right justified
   - `num5` - a number with thousands separtors and five decimals, right justified
   - `num6` - a number with thousands separtors and six decimals, right justified
   - `num7` - a number with thousands separtors and seven decimals displayed, right justified
   - `num8` - a number with thousands separtors and eight decimals displayed, right justified
   - `num9` - a number with thousands separtors and nine decimals displayed, right justified
   - `percnt` - format as a percent. Note that the value shold have proper decimal positions - 1.00 = 100%, .5 = 50%. Right justified
   - `phone` - 7 or 10 digit number formatted as nnn-nnnn or (nnn) nnn-nnnn. Right justified
   - `time` - time formatted hh:mm AM/PM right justified
   - `TIN` - number formatted as a personal Tax Identification number nnn-nn-nnnn right justified
   - `tStamp` - Time stamp formatted mm/dd/yy hh:mm AM/PM right justified
   - `USCur` - number formatted with $ and 2 decimal places, parentheses around negative values, blank for zero values. Right justified
   - `val0` - a number with no commas and no decimal positions, right justified.
 - `HstyleID` - The name of the Heading styleID in the ssTemplate used on this column. The default values for the spreadsheet template are the same as described above for styleID.

@param {6p0, const (optional)} numberOfColumns
 Number of data structures (columns) passed in the columns Array.  Required if columnsPointer is passed.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. `vvOut.returnLength` will contain the number of bytes (rows x row size) sent to the browser.
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text. 
 
*/

/**
@method _ssData
Executed as part of a customized Spreadsheet - see overview in vvOut_ssOpenWorkbook.

@param {65535a, const varying} string
 The string of valid xml to be appended to the spreadsheet.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. 
 - `*OFF` indicates an error occurred. 

*/
/**
@method _ssCloseWorkSheet
Executed as part of a customized Spreadsheet - see overview in vvOut_ssOpenWorkbook. This procedure is executed after the contents of the worksheet
have been added. After executing the ssCloseWorksheet either vvOut_ssOpenWorksheet (to begin another worksheet) or vvOut_ssCloseWorkbook must be called.


@param {DS (optional)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member.  If present, the closing worksheet tags and elements are appended to the Workbook.  If it is not passed, the Worksheet is closed but no data is written to the Worksheet.  This can be used in conjunction with vvOut_ssData to customize the spreadsheet ending tags.  See the sample program exSS01 for an example that includes some conditional formatting in the closing tags.

The only subfield pertinent to vvOut_ssCloseWorkSheet is:

 - `ssFilterRow` - The Row number for AutoFilter. This is the Row of the Spreadsheet that should contain the data column headings.  
 This value must match the row used on the vvOut_ssWorksheetOpen or the spreadsheet file will show a warning when opening.


@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. 
 - `*OFF` indicates an error occurred or the procedure was not called in the proper sequence.

*/

/**
@method _ssCloseWorkbook
Executed as part of a customized Spreadsheet - see overview in vvOut_ssOpenWorkbook. This is the final procedure in the spreadsheet creation.

@param {DS (optional)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member.  If present, the closing workbook tag is appended to the Workbook and all data is written.   If the parameter is not passed, the Worksheet is closed and the closing tag is omitted. This can be used in conjunction with vvOut_ssData to customize the spreadsheet ending tags.

None of the datastructure subfields are required for input; the "error" subfield will be set if an error is encountered.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. 
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text.

*/


/**
@method _file
Sends an IFS file to the browser for the user to view or download.

@param {500a, const varying (required)} filePath
 The full IFS file path for the file to be downloaded.

@param {DS (optional)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_file are as follows:

 - `contentType`  Indicates the format (content type) of the passed data, in a string of up to 30 characters, to be provided to the browser. The following constants, automatically included as part of the DSPECS copy source member, may be used:
   - `HTML`  "text/html" - data is in HTML format
   - `JSON`  "text/json" - data is in JSON format
   - `CSV`  "text/csv" - data is in comma-separated variable format
   - `PDF`  "application/pdf" - data is in PDF format
   -  `*` If no contentType is provided, or the vvOut data structure is not passed, Valence will attempt to derive the content type from the extension (suffix) of the file. The extension must exist in the VVFILEXT physical file for this to work.
 - `binary` - Indicates if the file should be treated as binary ("1" or "0"). If no binary value is provided, Valence will attempt to derive the binary value from the VVFILEXT physical file for the extension (suffix) of the file. If no match is found, the default for binary is "0".
 - `download` - If set to "1" then the browser will prompt the user to download the file
 - `file` - The default file name for the download (only applies when vvOut.download is set to "1")
 
When completed, the field `vvOut.fileHandle` will be returned with the file handle ID for the IFS file. A negative number indicates an error in retrieval. `vvOut.error` will contain any error messages encountered in the process.


# RPG Example

     // Download a PDF file from the IFS to the user's browser
     // (in this case, the "pdf" extension of the file name
     //  will provide the needed contentType/binary values)
     vvOut.download = '1';
     vvOut.file     = 'myDowloadedFile.pdf';
     vvOut_file('/valence-4.0/temp/pdfSample.pdf':vvOut);
*/

/**
@method _toCSV
Converts the supplied data into CSV (comma separated values) format and sends the results to the browser.

@param {DS (required)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_toCSV are as follows:

 - `object` - The object to serve as the definition for the data being passed. This is typically a physical file object serving as an external data structure definition.
 - `library` - The library corresponding to the object above. If not specified, *LIBL is assumed.
 - `recordFormat` - The record format for the data object. If not specified, *FIRST is assumed.
 - `download` - set to "1" if CSV data is to be downloaded as a file (otherwise it will simply be displayed in the browser)
 - `file` - Sets the default download file name when CSV is being downloaded. This may be overridden by the user in the download prompt window.
 - `longSqlNames` - Set to "1" to extract long SQL field names.
 - `csvSeparator` - Optionally specify the CSV separator. Defaults to the CSV separator defined in Settings.

If an external object is not being used (via vvOut.object), you may alternatively "hard code" the output structure using the following vvOut.fieldxxxx subfields (works best for drop-downs or grids with a single column):

 - `fieldName` - The name of the field to be used in the JSON response. This is not the back-end RPG field name, but rather the name for the front-end field.
 - `fieldType` - The type of field, as defined in the RPG program. The following constants, automatically included as part of the VVDSPEC copy source, may be used:
   - `CHARACTER`
   - `NUMERIC (signed)`
   - `PACKED`
   - `DATE (*ISO format)`
 - `fieldLength` - The length of the field, as defined in the RPG program
 - `fieldDecimals` - For numeric fields, the number of decimal places to include

@param {*pointer, value (required)} dataPointer
 Pointer to the data to be converted and sent to the front-end

@param {6p0, const (optional)} numberOfRecords
 The total number of records to be sent to the front-end.  If no value specified or passed then 1 is assumed.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. 
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text.

# RPG Example

     // Download a PDF file from the IFS to the user's browser
     f* Customer Master by Customer#
     fdemocmast if   e           k disk
     
      /copy qcpylesrc,vvDspec
     d cusRecsArray    ds                  likerec(cmast) inz dim(999)
     d cusRecsDS       ds                  likerec(cmast) inz
     d count           s              3  0
     
      /free
       // load data into array...
       setll *loval democmast;
       read democmast cusRecsDS;
       dow not %eof and count<999;
           count+=1;
           cusRecsArray(count)=cusRecsDS;
           read democmast cusRecsDS;
       enddo;

       // set up the CSV download...
       vvOut.object  ='DEMOCMAST'; // this tells vvOut how to parse the array data
       vvOut.download='1';         // this tells vvOut to send to browser as a download
       vvOut.file    ='CustomerRecs.csv'; // this is the default name for the download
       // (user may override it to something else)

       // send CSV data to browser
       vvOut_toCSV(vvOut:%addr(cusRecsArray):count);
       *inlr=*on;
*/

/**
@method _toJSONpair
Sends one or more pairs of "field:value" in JSON format to the browser through the HTTP server instance.

@param {65535a, const varying (required)} string
 The string of name:value pairs to be converted and passed to the browser (65535 chars max). No quotation marks are needed.

@param {5a, const varying (optional)} nameValSeparator
 Specifies a separator value to be used between field names and their values. Defaults to a colon (:) if not specified or passed.

@param {5a, const varying (optional)} pairSeparator
 Specifies the character used in "string" to separate pairs of values. Defaults to a comma (,) if not specified or passed.

@param {1a, const (optional)} JSONP
 A "1" here indicates the response should be formatted for a JSONP request.

@param {n, const (optional)} quoteBooleansAndNumbers
 If set to *ON then any boolean values (true/false) or numbers will be enclosed in quotes.  If set to *OFF then booleans and numbers will no be quoted.  If not passed then the procedure will defer to the global default, as set in Settings (see "Always use quotes in VVOUT_TOJSONPAIR" in Hidden Settings section).

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. 
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text.


# RPG Example

       // Notify the user that an error was detected in the front-end "CustomerNumber" field
       vvOut_toJSONpair('success:false,fld:CustomerNumber,msg:The customer number is invalid');

       // This results in the following JSON string being sent to the browser...
       // {"success":false, "fld":"CustomerNumber", "msg":"The customer number is invalid"}
*/

/**
@method _toJSON
Converts the supplied data into JSON (JavaScript Object Notation) format and sends the results to the browser. JSON is the native format for the Valence front-end (ExtJS, Sencha Touch).

@param {DS (required)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_toJSON are as follows:

 - `object` - The object to serve as the definition for the data being passed. This is typically a physical file object serving as an external data structure definition. If "VVDSTREE1" is supplied, the JSON output will be formatted for use in a tree structure on the front-end.
 - `library` - The library corresponding to the object above. If not specified, *LIBL is assumed.
 - `recordFormat` - The record format for the data object. If not specified, *FIRST is assumed.
 - `columnData` - If set to "1" then front-end column model data will be included based on the data object
 - `prefix` - If non-blank, this value will serve as a prefix for all field names on the front-end (added to the back-end field name)
 - `reverse` - If set to "1" then the record data will be placed in the JSON response in reverse order
 - `metaData` - If set to "1" then meta data will be derived from the data and provided to the front-end
 - `encodeUTF16` -  If set to "1", graphic fields will be encoded to a UTF16 hex string, which must be decoded by the front-end program (using Valence.util.decodeUTF16). This ensures that any characters are not lost during translation.
 - `rootName` - The name of the root specified in the front-end data store. If left blank, will default to "dataRoot".
 - `embed` - Additional free-form JSON text to be embedded into the JSON response
 - `success` - If set to "1" then a {"SUCCESS":"1"} string will be included in the JSON response; if set to "true" then a {"success":true} string will be included in the JSON response.
 - `formResponse` - If set to "1" then the response will be formatted to be compatible with the "form.submit" method.
 - `longSqlNames` - Set to "1" to extract long SQL field names.
 - `buffer` - If set to "1" then the response will be buffered in memory.
 - `JSONP` - Set to "1" to format the response in JSONP.
 - `totalProperty` - if set, then the value is used as the key name for the totalCount.  If blank then the total row count is returned as "totalCount".


If an external object is not being used (via vvOut.object), you may alternatively "hard code" the output structure using the following vvOut.fieldxxxx subfields (works best for drop-downs or grids with a single column):

 - `fieldName` - The name of the field to be used in the JSON response. This is not the back-end RPG field name, but rather the name for the front-end field.
 - `fieldType` - The type of field, as defined in the RPG program. The following constants, automatically included as part of the VVDSPEC copy source, may be used:
   - `CHARACTER`
   - `NUMERIC (signed)`
   - `PACKED`
   - `DATE (*ISO format)`
 - `fieldLength` - The length of the field, as defined in the RPG program
 - `fieldDecimals` - For numeric fields, the number of decimal places to include

@param {*pointer, value (required)} dataPointer
 Pointer to the data to be converted and sent to the front-end

@param {6p0, const (optional)} recordsToSend
 Total number of records to be sent to the front-end. If no value specified then 1 is assumed.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. `vvOut.returnLength` will contain the number of bytes (rows x row size) sent to the browser.
 - `*OFF` indicates an error occurred. The vvOut data structure field 'error' will contain error text.
 

# RPG Examples

##Example 1 - Send a single record to the browser using a data structure

       // In this first example, we will be working with a file named PRDMASTER,
       // with a recordformat of PRDMSTR.
       //
       // Suppose the file has two fields as follows:
       //   PRDNO = the product number
       //   DESCP = the product description
       //

       fprdmaster if   e           k disk

       d prdRecord       ds                  likerec(prdmstr)

        /copy qcpylesrc,vvDspec

         /free

          // Chain to the PRDMASTER file and immediately move the result into
          // the @prdRecord data structure...
          chain ('ITEMABC') prdmaster prdRecord;

          vvOut.object = 'PRDMASTER';  // this tells vvOut how to parse the array data
          vvOut_toJSON(vvOut:%addr(prdRecord));

          // vvOut has sent the entire product master record for product "ITEMABC"
          // to the browser:
          //
          //  {"PRDNO":"ITEMABC", "DESCP":"Testing Product"}
          //
          // (the value of vvOut.returnLength would be set to 46)

          // Now let's take the same example but set some additional vvOut fields...
          vvOut.object = 'PRDMASTER';
          vvOut.rootName = 'ItemDetail';
          vvOut.prefix = 'XX';
          vvOut.success = 'true';
          vvOut_toJSON(vvOut:%addr(prdRecord));

          // In this case vvOut would have sent the following to the browser...
          //
          //  {"success":true, "ItemDetail":[{"XXPRDNO":"ITEMABC", "XXDESCP":
          //  "Testing Product"}]}

         /end-free

##Example 2 - Send multiple records to the browser using a data structure

          // Using the same PRDMSTR file as an example, let's create a JSON response
          // with multiple records based off the product master data structure...
          //

         fprdmaster if   e           k disk

         d ii              s              2  0

         d prdRecords      ds                  likerec(prdmstr) dim(5)

          /copy qcpylesrc,vvDspec

          /free

           // Read in 5 records, moving each result into the prdRecords data structure
           // array...
           //
           // Suppose this data is going to be sent back to a JavaScript grid named
           // "Items", so we will set the "rootName" accordingly...
           //
           // Notice that we are now passing in the third parameter to the toJSON
           // procedure to indicate the number of records associated with the
           // pointer...
           dow ii < 5;
             ii+=1;
             read prdmaster prdRecords(ii);
           enddo; 
           
           vvOut.object = 'PRDMASTER';
           vvOut.rootName = 'Items';
           vvOut_toJSON(vvOut:%addr(prdRecords):ii);

           // This caused the first 5 records of the PRDMASTER file to be sent to the
           // browser:
           //
           //  {"Items":[{"PRDNO":"ABC123", "DESCP":"Description for ABC123"},
           //            {"PRDNO":"ABC456", "DESCP":"Description for ABC456"},
           //            {"PRDNO":"BAA101", "DESCP":"1 inch bolt"},
           //            {"PRDNO":"CABA02", "DESCP":"Yellow 4X6 labels"},
           //            {"PRDNO":"CABA03", "DESCP":"Yellow 5X8 labels"}]}

          /end-free

##Example 3 - Send multiple records to the browser without an external data structure

          // This last example demonstrates using the toJSON procedure without basing the pointer
          // on an external object, so we must explicitly define the content for the service program...
          //
     
         fprdmaster if   e           k disk
         
         d ii              s              2s 0
         d descriptions    s             30a   dim(5)
     
          /copy qcpylesrc,vvDspec

          /free

           // Read 5 records from the PRDMASTER file and move the description field into the
           // descriptions array...
           dow ii<5;
             read prdmaster;
             ii+=1;
             descriptions(ii)=DESCP;
           enddo;

           // Suppose this data is destined for a front-end grid named "DescriptionGrid"...
           vvOut.rootName = 'DescriptionGrid';

           // Since we are basing the data on an internal array (as opposed to an external object),
           //  we must define the characteristics here...
           vvOut.fieldName ='ItemDescp';
           vvOut.fieldType = VVCHARACTER;
           vvOut.fieldLength = 30;

           vvOut_toJSON(vvOut:%addr(descriptions):ii);

           // The browser thus receives the following...
           //
           //  {"DescriptionGrid":[{"ItemDescp":"Description for ABC123"},
           //                      {"ItemDescp":"Description for ABC456"},
           //                      {"ItemDescp":"1 inch bolt"},
           //                      {"ItemDescp":"Yellow 4X6 labels"},
           //                      {"ItemDescp":"Yellow 5X8 labels"}]}

         /end-free
*/

/**
@method _toSS
Creates an XML Spreadsheet from data passed as an externally defined data structure with multiple records to either the browser or to the IFS compatible with Microsoft Excel. The Spreadsheet reference specification used is the <a href="http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx" target="_blank">XML Spreadsheet Reference</a></span>

@param {DS (required)} vvOut
 The vvOut qualified data structure is automatically included as part of the VVDSPEC copy source member. The subfields pertinent to vvOut_execSQLtoSS are as follows:

 - `object` - The object to serve as the definition for the data being passed. This is typically a physical file object serving as an external data structure definition.
 - `library` - The library corresponding to the object above. If not specified, *LIBL is assumed.
 - `recordFormat` - The record format for the data object. If not specified, *FIRST is assumed.
 - `download` - set to "1" if spreadsheet is to be downloaded as a file, "F" if spreadsheet should be created in the IFS.
 - `embed` - Optionally specify rows and cells that will appear before the Spreadsheet Column Headings and Data. The data must be valid XML data using and tags.
 - `file` - If download is "1", sets the default download file name when spreadsheet is being downloaded. This may be overridden by the user in the download prompt window. If download is "F" then this field should be set to the full name (path and file) of the file to be created in the IFS.
 - `maxResults` - Identifies the number of records (beyond the startFrom value) to include in the CSV data.
 - `ssFilterRow` - The Row number for AutoFilter. This is the Row of the Spreadsheet that should contain the data column headings (which will vary if vvOut.embed is used). If zero then AutoFilter will not be used.
 - `ssSheetName` - The name worksheet name. Defaults to SHEET1.
 - `ssTemplate` - The path and filename of the file in the IFS that contains the XML Workbook and Styles settings to use to create the spreadsheet. If a value is not provided, then the default template is used as specified in the Valence Setting DEFAULT_SS_TEMPLATE with the path of the Valence setting ROOT_PATH.
 - `startFrom` -  Identifies the record number from the SQL output from which the spreadsheet data should begin.
 
@param {*pointer, value (required)} dataPointer
 Pointer to the data to be converted and sent to the front-end

@param {6p0, const (optional)} recordsToSend
 Total number of records to be sent to the front-end. If no value specified then 1 is assumed.
 
@param {*pointer, value (optional)} columnsPointer
 Pointer to array of vvSSCol data structures used to control the order and formatting on individual columns within the Spreadsheet. The data structure is automatically included as part of the VVDSPEC copy source member. Each array element number represents the spreadsheet column number. The subfields pertinent are as follows:

 - `colWidth`  The column width in pixels.  If not specified, the width is calculated from the SQL column size.  A rough approximation for determining an appropriate value for this setting is to multiply by 7 the number of characters you would like to show in the column.  Alternatively, if creating an .XLSX file, you can explicitly set the number of characters for the column by leaving this value at zero and instead putting the desired characters in 'XLSXcolW'.
 - `XLSXcolW`  (valid for .XLSX files only) If specified and colWidth is zero, this is the width of the column in characters.  May be sepecified as a non-whole value, like 10.5.
 - `heading` - The text for the column Heading. If blank the SQLName is used.
 - `omit` - If set to "1", sets the column to Hidden in spreadsheet.
 - `prefix` - If specified, the value is used to prefix each column value
 - `SQLName` - The name of the column in the SQL statement.
 - `styleID` - The name of the styleID in the ssTemplate used on this column. If not specified a default style based on the column attributes is used. The default spreadsheet Template has the following styleIDs defined:
   - `bool` - a numeric value displayed as true if a positive value or false if zero or negative value. Right justified
   - `char` - left justified
   - `dDMY` - date formatted dd-mm-yyyy right justified
   - `dMDY` - date formatted mm/dd/yyyy right justified
   - `dYMD` - date formatted yyyy-mm-dd right justified
   - `num0` - a number with thousands separtors and no decimals, right justified
   - `num1` - a number with thousands separtors and one decimal, right justified
   - `num2` - a number with thousands separtors and two decimals, right justified
   - `num3` - a number with thousands separtors and three decimals, right justified
   - `num4` - a number with thousands separtors and four decimals, right justified
   - `num5` - a number with thousands separtors and five decimals, right justified
   - `num6` - a number with thousands separtors and six decimals, right justified
   - `num7` - a number with thousands separtors and seven decimals displayed, right justified
   - `num8` - a number with thousands separtors and eight decimals displayed, right justified
   - `num9` - a number with thousands separtors and nine decimals displayed, right justified
   - `percnt` - format as a percent. Note that the value shold have proper decimal positions - 1.00 = 100%, .5 = 50%. Right justified
   - `phone` - 7 or 10 digit number formatted as nnn-nnnn or (nnn) nnn-nnnn. Right justified
   - `time` - time formatted hh:mm AM/PM right justified
   - `TIN` - number formatted as a personal Tax Identification number nnn-nn-nnnn right justified
   - `tStamp` - Time stamp formatted mm/dd/yy hh:mm AM/PM right justified
   - `USCur` - number formatted with $ and 2 decimal places, parentheses around negative values, blank for zero values. Right justified
   - `val0` - a number with no commas and no decimal positions, right justified.
 - `HstyleID` - The name of the Heading styleID in the ssTemplate used on this column. The default values for the spreadsheet template are the same as described above for styleID.

@param {6p0, const (optional)} numberOfColumns
 Number of data structures (columns) passed in the columns Array. Required if columnsPointer is passed.

@return {n}
An indicator value will be returned as a response.

 - `*ON`  indicates success. `vvOut.returnLength` will contain the number of bytes (rows x row size) sent to the browser.
 - `*OFF` indicates an error occured. The vvOut data structure field 'error' will contain error text. 
 
# RPG Examples

##Example 1

    f* Customer Master by Customer#
    fdemocmast if   e           k disk

     /copy qcpylesrc,vvDspec
    d cusRecsArray    ds                  likerec(cmast) inz dim(999)
    d cusRecsDS       ds                  likerec(cmast) inz
    d count           s              3  0

     /free 
      // load data into array...
      setll *loval democmast;
      read democmast cusRecsDS;
      dow not %eof and count<999;
        count+=1;
        cusRecsArray(count)=cusRecsDS;
        read democmast cusRecsDS;
      enddo;

      // set up the xls download...
      vvOut.object  ='DEMOCMAST'; // this tells vvOut how to parse the array data
      vvOut.download='1';         // this tells vvOut to send to browser as a download
      vvOut.file    ='CustomerRecs.xls'; // this is the default name for the download
                                         // (user may override it to something else)

      // send data to browser 
      vvOut_toSS(vvOut:%addr(cusRecsArray):count); 
      *inlr=*on;


##Example 2 - Using custom columns and headings

    f* Customer Master by Customer#
    fdemocmast if   e           k disk

     /copy qcpylesrc,vvDspec
    d cusRecsArray    ds                  likerec(cmast) inz dim(999)
    d cusRecsDS       ds                  likerec(cmast) inz
    d count           s              3  0

    d Col             ds                  likeDS(vvSSCol)
    d                                     dim(6)inz

     /free 
      // Same load of data as example 1...
      setll *loval democmast;
      read democmast cusRecsDS;
      dow not %eof and count<999;
        count+=1;
        cusRecsArray(count)=cusRecsDS;
        read democmast cusRecsDS;
      enddo;

      col(1).sqlName  = 'CUSNO';
      col(1).heading  = 'Customer';
      col(1).styleID  = 'val0';
      col(1).colWidth = 80;
      col(2).sqlName  = 'CNAME';
      col(2).heading  = 'Customer Name';
      col(3).sqlName  = 'CLASTACT';
      col(3).heading  = 'Last Active';
      col(4).sqlName  = 'CYTDSALES';
      col(4).heading  = 'YTD Sales';
      col(4).styleID  = 'UScur';
      col(5).sqlName  = 'CCITY';
      col(5).heading  = 'City';
      col(6).sqlName  = 'CSTATE';
      col(6).heading  = 'ST';
      // set up the xls download...
      vvOut.object  ='DEMOCMAST'; // this tells vvOut how to parse the array data
      vvOut.download='1';         // this tells vvOut to send to browser as a download
      vvOut.file    ='CustomerRecs.xls'; // this is the default name for the download
                                         // (user may override it to something else)

      // send data to browser 
      vvOut_toSS(vvOut:%addr(cusRecsArray):count:%addr(Col):6); 
      *inlr=*on;

*/

/**
 @method _getOutputData
 Returns a copy of all data sent thus far, or queued up to be sent, to the browser on the current call.  For this function to work, output logging must be activated in Portal Admin > Settings > "Log all data sent to browser".

 @param {n, const (optional)} clearBugger
 If set to *ON then all accumulated data is cleared. This has no effect on the data going to the browser; rather it just clears the buffer that contains a copy of all data queued up to be sent to the browser.

 @return {16000000a, varying}
 A string representing all the data (up to 16MB) sent thus far, or queued up to be sent, to the browser on the current call.

*/