ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

how to write record to a pf through CLP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to write record to a pf through CLP

    Hello,

    I have to do following processing in a CLP:

    CPYF FROMFILE(ALIB/ZXFILE) TOFILE(QTEMP/XFILE) +
    MBROPT(*ADD) CRTFILE(*YES) FMTOPT(*NOCHK)
    (Here blank PF is created by copying ZXFILE)

    then i had to write some data to this PF (without calling rpg), then again use

    CPYF FROMFILE(BLIB/CCLP) TOFILE(QTEMP/XFILE) +
    MBROPT(*ADD) FMTOPT(*NOCHK)

    (copy data from CCLP to XFILE)

    and finally, again insert some data to XFILE in QTEMP.

    Is it possible to do it in a single CLP ??

    Thanks
    SAM

  • #2
    Can't you just put the CRTFILE(*YES) on the second CL?

    Or do you run that repeatedly and only want to create the file once? You could create a variable to hold '*YES' or '*NO' for CRTFILE option, and condition it on a CHKOBJ with MONMSG on the file--to see if it already exists, then specify it with your CL.

    Comment


    • #3
      Here is the description of the problem:

      Actually the CL is creating the PF XFILE from ZXFILE and then it is calling a set of PGMs. One of the called programs writes some data to this PF (XFILE) then further after some more processing, some data is copied to XFILE from CCLP(This data has to come after the previous data is written.) and finally after copying this data another program writes some more data to XFILE. Now the requirement is that i had to eliminate the called RPGs, so that one single CL creates this file and also writes some data to this PF.

      I hope there should be some way of doing it.

      Thanks
      SAM

      Comment


      • #4
        CL cannot write to a physical file

        You can't write data to a physical file from a CL program.

        To get the end requirements you are trying to achieve you will have to use RPG in some manner Or use SQL.


        Good luck

        Keep us posted on your progress...


        Jamie
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment

        Working...
        X