ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

how to read comma separated file in RPGLE

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

  • how to read comma separated file in RPGLE

    Hi

    I have a a stream file(comma separated between three fields) in IFS directory(IFS path is /etc/apps/XnP/JPMCS_AccountInfo.txt) as below:
    PHP Code:
    ,03354,73692845        
    ,03354,73692845        
    ,04324,613350842       
    ,04324,613350842       
    ,05446,57843260        
    ,05446,57843260        
    ,07727,13390062        
    ,07727,13390062        
    ,08726,                
    ,
    08726,835768193       
    9370
    ,09370,108404021   
    10006
    ,10006,4558586    
    10006
    ,10006,4558586    
    10028
    ,10028,20003943 
    I have to compare the field account# of MMFILE(A PF declared as input) in my RPGLE with first field of above comma separated file(CSFILE),
    If I find exact match
    I have to evaluate XPRXP as below. If I dont find match I will ve to read next record of CSFILE till end of file....
    F MMFILE IF E DISK
    C Eval XPRXP = %trim(2nd field of CSFILE) +
    %trim(3rd field of CSFILE)
    XPRXP is rcdfmt of flat file for which im building record...

    Please suggest me how to delcare the IFS file in my RPGLE& how do I process comma separated file and what logic I should use in dealing with above file to meet my requirements.

    Thanks for the pointers. Pls help me asap.

    Donna.

  • #2
    Re: how to read comma separated file in RPGLE

    Donna,

    Take a look at this program...you can mod it to read rather than write to subfile
    and it should work just fine.



    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


    • #3
      Re: how to read comma separated file in RPGLE

      Jamie

      Iam nt sure whether it tells me how to read file from IFS or I donot understand,
      Can you take a look on my reqt and respond?

      Donna

      Comment


      • #4
        Re: how to read comma separated file in RPGLE

        If you want to read the file from the IFS you can use the link jamie posted above.

        However, if you are dealing with fixed length fileds you could always import the file to a PF using
        CPYFRMIMPF
        Predictions are usually difficult, especially about the future. ~Yogi Berra

        Vertical Software Systems
        VSS.biz

        Comment


        • #5
          Re: how to read comma separated file in RPGLE

          Hi donna --- It does read from the IFS....I wrote the program so that you pass it a link to the document..... so of course you would hardcode that in your RPG program...

          then my program reads the entire ifs document.....and writes the data to
          a subfile...you would remove the subfile and just read and scan.....

          Im sure this code will work for what you need.

          let me know if I can help further.

          jamie (download the READIFS program and DDS)
          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


          • #6
            Re: how to read comma separated file in RPGLE

            Hi Donna:

            I noticed that some of the fields in your .csv file are empty.

            Should you choose to use Kpmac's suggestion be careful when using the cpyfrmimpf command to use the RPLNULLVAL paramater (on the third screen i think)

            I suggest you do not allow null values but to use the *FLDDFT value.

            Best of Luck
            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: how to read comma separated file in RPGLE

              I have converted the file by using CPYFRMIMPF to keyed physical file and used chain to compare fields with MMFILE..
              I succeeded...
              But Iam help less on IFS reading and doing chain on one field.

              Thanks by the way...
              Donna

              Comment


              • #8
                Re: how to read comma separated file in RPGLE

                Donna,

                Thanks for letting us know........If at a later time you want to get the reading
                of the ifs file working you can send me a copy of the document and the path on the IFS you are using and Ill throw something together......

                take care
                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