¿ Are CL pgms able to write or update, physical or logical files ? - IBM AS400

This is a discussion on ¿ Are CL pgms able to write or update, physical or logical files ? - IBM AS400 ; ¿ Are CL pgms able to write or update, physical or logical files ? if so ... which si the OS version since they can write or update files, (not DSP files) and the related commands? Thanks in advance...

+ Reply to Thread
Results 1 to 9 of 9

Thread: ¿ Are CL pgms able to write or update, physical or logical files ?

  1. ¿ Are CL pgms able to write or update, physical or logical files ?

    ¿ Are CL pgms able to write or update, physical or logical files ? if so ...
    which si the OS version since they can write or update files, (not DSP
    files) and the related commands?


    Thanks in advance



  2. =?iso-8859-1?q?Re:_=BF_Are_CL_pgms_able_to_write_or_update,_p hysical_or_logical_files_=3F?=

    The short answer to your question is "no".
    The long answer is that there are workarounds / disgusting hacks
    (depending on your point-of-view) in some circumstances.

    What are you trying to do?


  3. Re: ¿ Are CL pgms able to write or update, physical or logical files ?

    I am just trying to update a source file, a few records sequencially, I
    mean, change a member source file type TXT to be used by mmail feeware
    utility in order to change the text of the e-mail message body dynamically.



    "walker.l2" escribió en el mensaje
    news:1185290607.777313.181680@m3g2000hsh.googlegro ups.com...
    > The short answer to your question is "no".
    > The long answer is that there are workarounds / disgusting hacks
    > (depending on your point-of-view) in some circumstances.
    >
    > What are you trying to do?
    >




  4. Re: ¿ Are CL pgms able to write or update, physical or logical files ?

    I wrote my own "disgusting hack" to solve this. It is not elegant but
    it works.

    Write Source (WRTSRC) Type choices,
    press Enter. Source Data . . . . . . . . . . *NONE Source
    Sequence Number . . . . . Number Source Date (yymmdd)
    .. . . . . . Number File . . . . . . . . . . . . . .
    QTXTSRC Name Library . . . . . . . . . . . *LIBL
    Name, *LIBL Member . . . . . . . . . . . . . *FIRST Name,
    *FIRST LR indicator . . . . . . . . . . '0' 0, 1 It is a
    CL commnad to add 1 line at a time to a source file.

    Let me know if you want the source.

    Denny

    On Tue, 24 Jul 2007 17:21:09 +0100, "CENTRINO"
    wrote:

    >I am just trying to update a source file, a few records sequencially, I
    >mean, change a member source file type TXT to be used by mmail feeware
    >utility in order to change the text of the e-mail message body dynamically.
    >
    >
    >
    >"walker.l2" escribió en el mensaje
    >news:1185290607.777313.181680@m3g2000hsh.googlegro ups.com...
    >> The short answer to your question is "no".
    >> The long answer is that there are workarounds / disgusting hacks
    >> (depending on your point-of-view) in some circumstances.
    >>
    >> What are you trying to do?
    >>

    >


  5. Re: =?ISO-8859-1?Q?=BF_Are_CL_pgms_able_to_write_o?==?ISO-8859-1?Q?r_update=2C_physical_or_logical_files_=3F?=

    il 24/07/2007 18.21, Scrive CENTRINO 40726184:
    > I am just trying to update a source file, a few records sequencially, I
    > mean, change a member source file type TXT to be used by mmail feeware
    > utility in order to change the text of the e-mail message body dynamically.

    Even if a better result can be obtained with a HLL language other then
    CL, if you are at least at V5R3 you will achieve your objective using a
    few IFS function as stat(), open(), lseek(), write(), read() and close().
    As you can see there's not an update function, so to update the file you
    need a combination of lseek() and write(). As you need to know the
    record length of your source file member to read() and write() you shoul
    calculate it with
    (lseek(fd, 0, SEEK_END) - lseek(fd, 0, SEEK_SET))/&reccount
    where &reccount is the record count retrieved with
    RTVMBRD FILE(FILE) MBR(MEMBER) NBRCURRCD(&RECCOUNT)
    command, or you can get the same info with:
    RTVMBRD FILE(FILE)
    MBR(MEMBER)
    NBRCURRCD(&CURREC)
    NBRDLTRCD(&DLTREC)
    DTASPCSIZ(&DTASIZ)
    CHGVAR &RECLEN (&DTASIZ/(&CURREC + &DLTREC))

    An example to use IFS functions this way:

    PGM
    DCL &ERRNOPTR *PTR

    DCL &ERRNO *INT STG(*BASED) LEN(4) BASPTR(&ERRNOPTR)

    DCL &ERRNOCHR *char 4

    DCL &MSGID *char 7

    DCL &NUL *CHAR (1) x'00'

    DCL &FD *INT (4)

    DCL &RC *INT (4)

    DCL &OFFSET *INT (4) 0

    DCL &BEGIN *INT (4) 0

    DCL &FPOS *INT (4) 0 /* SEEK_SET */

    DCL &OFLAG *INT (4) 4 /* O_RDWR */

    DCL &BUFLEN *INT (4)

    DCL &BUF *CHAR 132

    DCL &PATH *CHAR 256 '/qsys.lib/ugo.lib/src.file/aaaifs.mbr'

    DCL &RECLEN *DEC (5 0) 132



    chgvar &path (&path *tcat &nul)

    CALLPRC PRC('__errno') RTNVAL(&ERRNOPTR)

    chgvar &errno 0

    CALLPRC PRC('open') +
    PARM((&PATH *BYREF) (&OFLAG *BYVAL)) +
    RTNVAL(&RC)
    if (&rc *ge 0) do

    chgvar &buflen &reclen

    chgvar &fd &rc

    CALLPRC PRC('read') +
    PARM((&FD *BYVAL) (&BUF *BYREF) (&BUFLEN *BYVAL)) +
    RTNVAL(&RC)
    if (&rc *gt 0) do

    chgvar %sst(&buf 30 30) '/* changed by CL program */'

    CALLPRC PRC('lseek') +
    PARM((&FD *BYVAL) (&begin *BYVAL) (&FPOS *BYVAL)) +
    RTNVAL(&rc)
    if (&rc *ge 0) do

    chgvar &offset &rc

    CALLPRC PRC('write') +
    PARM((&FD *BYVAL) (&BUF *BYREF) (&BUFLEN *BYVAL)) +
    RTNVAL(&RC)
    enddo

    enddo

    CALLPRC PRC('close') +
    PARM((&FD *BYVAL))
    enddo

    if (&rc *lt 0) do

    chgvar &errnochr &errno

    chgvar &msgid ('CPE' *cat &errnochr)

    SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG)

    enddo

    ENDPGM


    The program changes the first line of the program source itself with a
    comment.
    The record length is hard-coded in the program because the behaviour of
    source file using IFS api is sligtly different from non-described files,
    as what read/write/lseek operate on, is only the source data field, so
    yu have to act as it were a non-described PF with the length of record
    the same as the length of SRCDTA field of the source PF.
    The &BUF field is also declared as the same &RECLEN length, but it's not
    really required, it can be longer too, as both read and write use
    &BUFLEN to trasfer data buffer.
    Note the use of __errno function, this function changes the pointer of
    the based-variable &ERRNO so that each time an API repurns -1 &ERRNO
    variable is changed too. As each errno is mapped in a message the
    program send that message to warn user.
    For further documentation about IFS APIs see
    http://publib.boulder.ibm.com/infoce...apis/unix2.htm
    Hope this helps.
    >
    >
    >
    > "walker.l2" escribió en el mensaje
    > news:1185290607.777313.181680@m3g2000hsh.googlegro ups.com...
    >> The short answer to your question is "no".
    >> The long answer is that there are workarounds / disgusting hacks
    >> (depending on your point-of-view) in some circumstances.
    >>
    >> What are you trying to do?
    >>

    >
    >



    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  6. Re: =?ISO-8859-1?Q?=BF_Are_CL_pgms_able_to_write_o?==?ISO-8859-1?Q?r_update=2C_physical_or_logical_files_=3F?=

    il 24/07/2007 15.14, Scrive CENTRINO 40343864:
    > ¿ Are CL pgms able to write or update, physical or logical files ? if so ...
    > which si the OS version since they can write or update files, (not DSP
    > files) and the related commands?

    Not yet. From V5R3 you can use IFS API and/or file C functions to access
    DB File from an ile cl (CLLE), as from this release callprc supports
    byval arguments while in previous releases only pointer arguments were
    supported.

    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  7. Re: =?ISO-8859-1?Q?=BF_Are_CL_pgms_able_to_write_o?==?ISO-8859-1?Q?r_update=2C_physical_or_logical_files_=3F?=

    Dr.UgoGagliardelli wrote:
    > il 24/07/2007 15.14, Scrive CENTRINO 40343864:
    >> ¿ Are CL pgms able to write or update, physical or logical files ? if
    >> so ...
    >> which si the OS version since they can write or update files, (not DSP
    >> files) and the related commands?

    > Not yet. From V5R3 you can use IFS API and/or file C functions to access
    > DB File from an ile cl (CLLE), as from this release callprc supports
    > byval arguments while in previous releases only pointer arguments were
    > supported.


    And in V5R4, *PTR (pointer) data types, added to the V5R3 enhancements,
    make essentially every API directly available in ILE CL. Pre-V5R4, QM
    queries and RUNSQLSTM were the easiest ways to update or write to files.
    Now, any of the SQL CLI APIs can also be used.

    But CL itself is a "control Language". It's not well suited for data
    maintenance.

    REXX, though, interacts with the SQL environment. SQL embedded in REXX
    procedures is available on essentially every AS/400, iSeries, System i,
    that most of us are likely to see running.

    --
    Tom Liotta
    http://zap.to/tl400

  8. Re: =?ISO-8859-1?Q?=BF_Are_CL_pgms_able_to_write_o?==?ISO-8859-1?Q?r_update=2C_physical_or_logical_files_=3F?=

    il 29/07/2007 8.47, Scrive Thomas 40728448:
    > Dr.UgoGagliardelli wrote:
    >> il 24/07/2007 15.14, Scrive CENTRINO 40343864:
    >>> ¿ Are CL pgms able to write or update, physical or logical files ? if
    >>> so ...
    >>> which si the OS version since they can write or update files, (not DSP
    >>> files) and the related commands?

    >> Not yet. From V5R3 you can use IFS API and/or file C functions to
    >> access DB File from an ile cl (CLLE), as from this release callprc
    >> supports byval arguments while in previous releases only pointer
    >> arguments were supported.

    >
    > And in V5R4, *PTR (pointer) data types, added to the V5R3 enhancements,
    > make essentially every API directly available in ILE CL. Pre-V5R4, QM
    > queries and RUNSQLSTM were the easiest ways to update or write to files.
    > Now, any of the SQL CLI APIs can also be used.
    >
    > But CL itself is a "control Language". It's not well suited for data
    > maintenance.

    As you see, the sample I posted here makes use of new data types,
    pointers too.
    The original poster said he wants to update a text file, in other words
    a non-described file, so SQL is not well suited too.
    By the way, I totally agree with you that the correct way should not be CL.


    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  9. =?iso-8859-1?q?Re:_=BF_Are_CL_pgms_able_to_write_or_update,_p hysical_or_logical_files_=3F?=

    no it is not possible with CL program but u can create a utility to do
    so. I had worked on that it is of 5*800 line utility. I had try it &
    its working.




    On Jul 24, 7:37 pm, "Dr.UgoGagliardelli"
    wrote:
    > il 24/07/2007 15.14, Scrive CENTRINO 40343864:> ¿ Are CL pgms able to write or update, physical or logical files ? if so ...
    > > which si the OS version since they can write or update files, (not DSP
    > > files) and the related commands?

    >
    > Not yet. From V5R3 you can use IFS API and/or file C functions to access
    > DB File from an ile cl (CLLE), as from this release callprc supports
    > byval arguments while in previous releases only pointer arguments were
    > supported.
    >
    > --
    > Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    > Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    > Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    > schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'




+ Reply to Thread