ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using Text File as Input & Reading Each Record

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

  • Using Text File as Input & Reading Each Record

    Is it possible, similar to Windows PowerShell, that the AS400 can read from a plain .txt file, or even .csv placed on IFS?

    Then based on what's in the text file, have it perform an action in a CL pgm?

    E.g. Have a text file with only AS400 profiles - this will be the input. Then in CL have it read each line or AS400 profile and perform a specific cmd on them. Something like this: dspusrprf usrprf(&USRPRF) output(library/file)

    I appreciate any input, thanks.

  • #2
    Reading from the IFS is not possible with CL, but with embedded SQL in RPG, Cobol or C.
    The result can easily be written in a table / outputf file.
    If you need to execute CL Commands after, you will be able to perform them in composition with the QCMDEXC API.

    Birgitta

    Comment


    • #3
      You could copy the text file into a temporary database file using CPYFRMSTMF and then read the temp file in the CL program.

      Comment


      • #4
        Thank you both! I'll look into it.

        Comment


        • #5
          Originally posted by B.Hauser View Post
          Reading from the IFS is not possible with CL, but with embedded SQL in RPG, Cobol or C.
          Its possible. I'd definitely recommend one of the other options you mentioned, instead of trying to read it directly in CL. But, its possible.

          Comment

          Working...
          X