EngageOne™ Enrichment

 View Only
  • 1.  Capture filename

    Posted 04-16-2025 08:45

    Is there a technique to capture the filename from the <INPUT> tag group's <FILE> tag?



    ------------------------------
    John Julitz
    DFS Corporate Services LLC
    ------------------------------


  • 2.  RE: Capture filename

    Employee
    Posted 04-16-2025 09:14

    The best way to do this would be use variable filenames as follows:

    <input>
        <name>in
        <file>%%input_file
        <type>I
        <document>1
    </input>

    <rule>
      <content>
        WRITE("temp.txt", %%input_file)
      </content>
    </rule>

    <output>
      <name> out
      <file> tempout.txt
    </output>

    This control file has %%input_file specified as the input filename. Assuming it is saved as controlFile1.con, you would run Enrichment using a user variable on the command line such as:

    sweaver -c=controlFile1.con -u=input_file=someLinedataFile.lin

    This initializes the %%input_file variable prior to parsing the control file, so it can be used in <file> tags, as well as normal processing in the rule file.



    ------------------------------
    Eric Olson
    Senior Principal Software Engineer
    Precisely Software Inc.
    ------------------------------



  • 3.  RE: Capture filename

    Posted 04-18-2025 13:24

    Since I could be passing in 100s of files (varies each day), this may not work with my script creation and dynamic control file creation. Are there alternatives to capture the filename from within the control file either via <FILE> or some other feature? Thanks.



    ------------------------------
    John Julitz
    DFS Corporate Services LLC
    ------------------------------



  • 4.  RE: Capture filename

    Employee
    Posted 04-18-2025 13:37

    There is no specific language mechanism to do this. If the control files are being systematically generated, you could generate a separate file whose contents are the input file name and read the value of the contents with a READ function call. If you are processing multiple files at once, you could generate a file that contains each filename, one per line, and iterate over the file until READ fails.

    Alternatively, you could generate the <NAME> tag with a value that you can use to calculate the <FILE> value. You can use the %%INPUT system variable in the rule file which tells you the value of the <NAME> tag used.

    For example, if you are generating <INPUT> groups that contain

    <file> dailyrun_123456_operations.afp

    you could generate a <NAME> tag with a value of

    <name> dailyrun_123456_operations

    and use the %%INPUT value in the document section, and use string operations to append ".afp"



    ------------------------------
    Eric Olson
    Senior Principal Software Engineer
    Precisely Software Inc.
    ------------------------------