Optim

Expand all | Collapse all

z/OS Lua I/O processing

  • 1.  z/OS Lua I/O processing

    Posted 6 days ago
    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.

    ------------------------------
    Allen Tsygan
    ------------------------------


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

    Posted 6 days ago
    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()
    end
    function cm_transform()
         local inVal = optim.source.getcolumnvalue()
         local outVal = nil
         outVal = optim.mask(inVal,sParm)
             if outVal == nil then
             file:write(inVal.."\n")
            optim.print('Value missing for: '..inVal)
         end
         optim.target.setcolumnvalue(inVal)
    end
    function cm_unload()
         file:close()
    end
    function setFile()
         file:write("set output C:\\IBM\\data\\test.out")
         file:write("set pagesize 99999")
         file:write(" ")
    end

    I hope that helps some.

    Jimmy

    ------------------------------
    JIMMY WILSON
    ------------------------------



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

    Posted 5 days ago
    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
    io.input(IFile)
    for InRec in io.lines() do
    print(InRec .. "\n")
    end
    -- close input file
    io.close(IFile)
    OFile = assert(io.open(IFileName,"a+"), "Output file failed to open")
    OFile:setvbuf("line")
    OutRec = string.format("* This file was processed on %s\n",
    os.date())
    OFile:write(OutRec)
    OFile:flush()
    OFile:close()


    ------------------------------
    Gregory Czaja
    ------------------------------



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

    Posted 4 days ago

     

    Hello,

     

    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.

    https://www.ibm.com/support/knowledgecenter/en/SSC623_11.3.0/com.ibm.nex.optimz.common.doc/ColumnMapsHASH/opzcommon-r-sample_lua_expression.html

     

    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.

     

    Cheers

     

     

     

    Bruce Fischer | Complex Data Privacy Specialist

    Information Management

    Phone +1(218)252-8726

    bfischer@abmartin.com

    1999 S. Bascom Ste 700

    Campbell, CA 95008

     

    Unstructured Data Masking

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