ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Macro To open & update a *.txt file

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

  • Macro To open & update a *.txt file

    Hi Friends,

    I need to write a macro to open a *.txt file and amend some data in the text file.
    This process is not required to be displayed in the monitor.
    It should run in the backend so that the user does not see it.

    Kindly help me oout !!!

    Regards,
    Suresh

  • #2
    Re: Macro To open & update a *.txt file

    This was written by Jagannath Lenka


    Usage for IFS operation

    It is always a headache to handle IFS files using RPG programs.
    We have to write separate RPG programs using C APIs to handle
    this functionality. But QShell commands ease this process.

    Syntax:

    To replace the contents of the IFS and write the fresh text
    Code:
    QSH CMD('print It is working > /home/mydir/myfile.txt')
    To append to the contents of the IFS file in next line
    Code:
    QSH CMD('print It is working >> /home/mydir/myfile.txt')
    To use other features of print, go through the QSHELL
    manual of IBM.

    I found this functionality helped me while creating CSV
    files out of database files using CPYTOIMPF. With this
    command we create the comma separated files out of
    the database file. To add the report headings, field
    descriptions, etc., the print command helps a lot.

    Example:
    PHP Code:
    QSH CMD('print ", , ,Report for  Health Care," > /home/mydir/myexport.csv')
    QSH CMD('print "Patient,Date of Adm,Doctor Attended, Remarks" >> /home/mydir/myexport.csv')
    CPYTOIMPF FROMFILE(MYLIB/HLTHCARTOSTMF('/home/jlenka/myexport.csv'MBROPT(*ADDRCDDLM(*CRLF
    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