Optim - Test Data Management and Archiving

Expand all | Collapse all

z/OS Lua I/O processing

  • 1.  z/OS Lua I/O processing

    Posted Mon September 09, 2019 02:27 PM
    We use Lua procedures in the Column Maps with in Optim z/OS.  I was wondering if there is a way in Lua to read an input batch file within the CM?  and if so how is this accomplished?

    Thank you,

    Allen Tsygan

  • 2.  RE: z/OS Lua I/O processing

    Posted Tue September 10, 2019 07:15 AM
    Hi Allen,

    I don't have an example of reading an external file but I do have one for writing to on.  It should be fairly easy to read the script and figure out the differences to make it read.

    function cm_load()
    -- Set up environment
         sParm = 'pro=lkp'
         sParm = sParm .. ',srch="SALESMAN_ID"'
         sParm = sParm .. ',rep="TERRITORY"'
         sParm = sParm .. ',id=SAMPLES.SALES_CHECK'
         sParm = sParm .. ',lib=ORACLE'
         sParm = sParm .. ',user=optim'
         sParm = sParm .. ',pass=manager1'
         sParm = sParm .. ',conn=win7vm2'
         sParm = sParm .. ',whennf=pre'
         sParm = sParm .. ',flddef1=(name="SALESMAN_ID",dt=wvarchar_sz)'
         sParm = sParm .. ',flddef2=(name="TERRITORY",dt=wvarchar_sz)'
         optim.print('Static Parameters Are: '..sParm)
    -- Open output file
         file = assert(uio.open("C:\\IBM\\data\\test.txt","w+"))
    -- setFile()
    function cm_transform()
         local inVal = optim.source.getcolumnvalue()
         local outVal = nil
         outVal = optim.mask(inVal,sParm)
             if outVal == nil then
            optim.print('Value missing for: '..inVal)
    function cm_unload()
    function setFile()
         file:write("set output C:\\IBM\\data\\test.out")
         file:write("set pagesize 99999")
         file:write(" ")

    I hope that helps some.



  • 3.  RE: z/OS Lua I/O processing

    Posted Tue September 10, 2019 08:34 AM
    Optim for z/OS allows for standard use of the io functions. The only tricky part is to figure out how to correlate the the DSN with the file you will be working with. For example:
    IFileName = "DD:LUADD"   -- associate the file via a DDNAME, or
    IFileName = "//'GREGCZ.LUA.IO.INPUT'"  -- associate the file via a DSN and dynamic allocation
    Both forms assume that the data set exists already.
    After that a chunk like this one will be able to read or write to the data set.

    -- Lua IO test
    -- The input file should have have at least one record with some contents
    io.write("Hello world, from ",_VERSION,"!\n")
    IFileName = "//'GREGCZ.LUA.IO.INPUT'"
    -- Open the input file
    IFile = assert(io.input(IFileName), "Input file failed to open")
    -- Identify the input file in the process report
    print(string.format("Input is Being Read From: %s\n", IFileName))
    local IType = io.type(IFile)
    print(string.format("Input File Type is: %s", IType))
    -- Read the input file
    for InRec in io.lines() do
    print(InRec .. "\n")
    -- close input file
    OFile = assert(io.open(IFileName,"a+"), "Output file failed to open")
    OutRec = string.format("* This file was processed on %s\n",

    Gregory Czaja

  • 4.  RE: z/OS Lua I/O processing

    Posted Wed September 11, 2019 09:32 AM




    There is an example for various file operations in the Optim Sample Library (SFOPSAMP)

    FOPLUAF - demonstrates use of various file operations.

    Here is a link that describes the various Lua sample members.



    I have never used any file operations so I can not say how will or difficult this is to implement


    Good luck, let us know how thing turn out.






    Bruce Fischer | Complex Data Privacy Specialist

    Information Management

    Phone +1(218)252-8726


    1999 S. Bascom Ste 700

    Campbell, CA 95008


    Unstructured Data Masking

    Data Privacy/Test data Management - fabrication, optimization, obfuscation