• User's guide
  • API
Search Results for

    Show / Hide Table of Contents
    • Concepts
    • Installation
    • Configuration
      • Overview
      • License
      • Datasources
      • Configuration
      • Plug-Ins
      • Codepages
      • Environment Variables
      • Include files
      • Example
    • Jobs
      • Jobs
      • Include
      • Multi-Threaded Jobs
      • Tracking Jobs
    • Tasks
      • Overview
      • Copy Check
      • Excel
      • Execute
      • File Compare
      • File Copy
      • File Dump
      • File Edit
      • File Format
      • Foreach
      • Generate
      • IMS/DB Data Conversion
      • JCL Submit
      • Listcat
      • Log
      • Powershell
      • Set Environment Variable
      • Sql
      • Stored Procedure Compare
      • Table Compare
      • Table Copy
      • Table Load
      • Table Scan
      • Table Unload
      • User Script
    • Layouts
      • Overview
      • XML Definition
      • COBOL Definition
      • Field data Types
    • Extensibility
      • Extending Ianus
      • Column Comparators
      • Column Converters
      • Record Comparators
      • File Editors
      • User Script
      • Record Layout Match Class
      • Column Layout Match Class
      • User Fields
      • Codepages
      • Resources
    • Usage
      • Command Line
      • Monitors
      • Programmatically
      • Unit Testing
      • Docker
    • Known Issues
    • Disclaimers

    File Edit

    The file edit task (fileedit) copies a file, filtering and editing the content, using user provide routines.

    The edit routine can change the file format, filter and change the record content.

    File edit can operate in two modes:

    • binary: the record can be filtered and edited using purely the bytes array of the Record class
    • layout: the record can be filtered and edited using both the bytes array and the user defined record layouts

    The file edit task is defined by the XML element fileedit whose attributes configure the execution parameters.

    The following attributes configure the task:

    Attribute Type Purpose Default
    source string Name of the source repository
    target string Name of the target repository
    mode string Operating mode: binary or layout binary
    append string If true, the target file is open in append mode false

    The following elements configure the task:

    Element Purpose
    source Name and attributes of the source file. Refer to Source and Target Files.
    target Name and attributes of the target file. Refer to Source and Target Files.
    layouts Defines the record layout(s) contained in the file. Refer to Layouts.
    edit Defines the user provided editing class. Refer to Edit Class.

    Source and Target Files

    The source and target elements define, respectively, the input and output files of the task.

    The following attributes configure the file:

    Attribute Type Purpose Default
    recfmt string Defines the record format of the file. Refer to File Formats fixed
    reclen integer Defines the maximum record length
    varfmt string Defines the variable record format. Refer to Variable Record Formats If not specified, the repository default is assumed.
    dd string When used with in a JCL interface, the name of the DD JCL statement referencing the file. The file characteristics are extracted from the file catalog and, therefore, the other attributes (recfmt, reclen and varfmt) are ignored.
    trim bool If true, trailing spaces and NULLs (0x00) are removed from line sequential records false
    encoding string Name of the text encoding to be used for Line Sequential files. Latin1
    cache bool If false, file copy is refreshed (applies to cached repositories only) true
    Note

    The list of available encodings is listed here: https://docs.microsoft.com/it-it/dotnet/api/system.text.encoding?view=net-5.0

    Note

    For MARS repositories, recfmt, reclen and varfmt are ignored. The file characteristics are extracted from the MARS file catalog.

    File Formats

    Type Synonim Description
    fixed fb Fixed Record Length
    variable vb Variable Record Length
    lineseq ls Line Sequential

    Variable Record Formats

    Type Description
    ibm IBM variable record format
    microfocus Micro Focus variable record format

    Layouts

    The layouts element defines one or more record layout to compare/convert the files as well as the match script in case of multiple layouts.

    The following elements configure the layouts:

    Element Purpose
    layout Adds a layout definition. Refer to Layout
    match Defines the match algorithm. Refer to Match

    Layout

    The layout element defines a one or more record layouts. Each layout must be identified by a unique name (task-wide).

    By default, the layout fields are defined using XML:

    • Each layout element defines one single layout
    • Record fields are defined using field elements

    But there is also the possibility to define the layout using COBOL data definition syntax:

    • Each layout element defines one or more layouts (one each level 01)
    • Record fields are defined using COBOL notation

    For further information on layout definition, refer to Record Layouts

    Match

    The match element defines the "match class". Whenever more than on layout is provided, Ianus needs a match class to drive the selection of the correct layout for each record compared.

    This class must implement the interface HPE.Ianus.Scripting.ILayoutMatch. For a detailed description of the match class please refer to the Record Layout Layout Matcher section.

    The class can be provided as:

    • C# script: the code is compiled on the fly by Ianus and declared either:
      • inline, by adding the code in the element value, or
      • by reference, providing the filename of the script on the path attribute. If the script file name is not absolute, the script is searched in the same path of the job script.
    • Class library: the class can be coded in any .NET language such as C# or VB.NET but also COBOL for .NET and compiled as .NET class library. The class can be referenced either:
      • directly: providing the filename of the DLL containing the class on the assembly attribute and the full name of the class on the class attribute, or
      • by alias: providing the name of the plugin alias defined in the Plug-ins section of the Environment Configuration File.

    The following attributes configure the element:

    Attribute Type Purpose Default
    path string Indicates to load the class script from the specified file
    assembly string Indicates to load the class assembly from the specified DLL
    class string Indicates the name of the class to use
    plugin string Indicates to load the class from the plugin alias defined in Plug-ins

    Edit Class

    The edit element defines the record editor class. Ianus takes care of reading and writing the files but delegates the records inclusion and manipulation to the user provided class.

    This class must extend the interface HPE.Ianus.Scripting.FileEditor. For a detailed description of the record editor class please refer to File Editor.

    The class can be provided as:

    • C# script: the code is compiled on the fly by Ianus and declared either:
      • inline, by adding the code in the element value, or
      • by reference, providing the filename of the script on the path attribute. If the script file name is not absolute, the script is searched in the same path of the job script.
    • Class library: the class can be coded in any .NET language such as C# or VB.NET but also COBOL for .NET and compiled as .NET class library. The class can be referenced either:
      • directly: providing the filename of the DLL containing the class on the assembly attribute and the full name of the class on the class attribute, or
      • by alias: providing the name of the plugin alias defined in the Plug-ins section of the Environment Configuration File.

    The following attributes configure the element:

    Attribute Type Purpose Default
    path string Indicates to load the class script from the specified file
    assembly string Indicates to load the class assembly from the specified DLL
    class string Indicates the name of the class to use
    plugin string Indicates to load the class from the plugin alias defined in Plug-ins

    Example

      <fileedit name="EDITBIN" source="REPOASCII" target="TMPA" mode="binary">
    	<source recfmt="fixed" reclen="80">IANUS.TEST.SEQ01.ASCII.DAT</source>
    	<target recfmt="ls" reclen="80">FILECOPY.01.TXT</target>
    	<edit><![CDATA[
    	using System;
    	using System.Collections.Generic;
           using HPE.Ianus;
           using HPE.Ianus.Log;
           using HPE.Ianus.File;
           using HPE.Ianus.Scripting;
    
           namespace TestScript
           {
              public class DummyFilter : HPE.Ianus.Scripting.FileEditor
              {
    	    	public override bool Include(FileEditorData fed)
    		{
    			Record r=fed.InputRecord;
    			return (r[6]=='2' || r[6]=='4');
    		}
                	public override void Edit(FileEditorData fed)
    		{
    			Record r=fed.InputRecord;
    			Record o=fed.OutputRecord;
    			Buffer.BlockCopy(r.Bytes, 0, o.Bytes, 0, 8);
    			o.Length=8;
    			for (int i=0; i<o.Length; i++)
    			{
    				if (o[i]==0x00) o[i]=(byte)' ';
    			}
    		}
              }
    	}
    	]]></edit>
    	</fileedit>
    	<fileedit name="EDITLAYOUT" source="REPOASCII" target="TMPA" mode="layout">
    		<source recfmt="fixed" reclen="80">IANUS.TEST.SEQ01.ASCII.DAT</source>
    		<target recfmt="ls" reclen="80" trim="true">FILECOPY.02.TXT</target>
    		<layouts>
    			<include>ZZREC01.xml</include>
    			<layout name="REDEF">
    				<field name="redef-key" length="8"  type="char"/>
    				<field name="redef-txt" length="72" type="char"/>
    			</layout>
    		</layouts>
    		<edit><![CDATA[
    	 using System;
    	 using System.Collections.Generic;
            using HPE.Ianus;
            using HPE.Ianus.Log;
            using HPE.Ianus.File;
            using HPE.Ianus.Scripting;
    
            namespace TestScript
            {
              	public class DummyFilter : HPE.Ianus.Scripting.FileEditor
              	{
    		    	public override bool Include(FileEditorData fed)
    			{
    				int val=(int)fed.CurrentInputLayout["COMP01"].Value;
    			    return (val % 2) == 0;
    			}
    			public override void Edit(FileEditorData fed)
    			{
    				long val=(int)fed.CurrentInputLayout["COMP01"].Value;
    				val+=11;
    				fed.CurrentOutputLayout["ZONED01"].Value=val;
    				
    				Layout lo= fed.OutputLayouts["REDEF"];
    				lo["REDEF-KEY"].Value=
                                   fed.CurrentInputLayout["CHAR01"].Value
                                   .ToString().Replace('\0', ' ').ToLower();
    				lo["REDEF-TXT"].Value=
                                   "X"+fed.CurrentInputLayout["COMP01"].Value.ToString();
    			}
    		  }
     }
          ]]></edit>
    	</fileedit>
    

    Status codes

    Status Status code Description
    Ready -1 Task is initialized, but not yet started
    Running -2 Task is running
    Success 0 Task completed successfully
    Warnings 1 Task completed with warnings
    Errors 2 Task completed with errors
    Aborted 9 Task cannot be executed
    In This Article
    Back to top Copyright 2021 - Hewlett-Packard Enterprise