× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm working with a multi-format logical that has been created for an EDI translator, one of our clients wants the file contents in raw text. I'm working on a program to read the multi-format logical and write to a text file with a header on each line with the filename, for example:
HEADERFILE:<header data>
DETAILFILE:<detail data>
DETAILFILE:<detail data>
NOTESFILE:<notes data>
...

I saw the method mentioned in the V5R3 RPG programmers reference guide for reading into a data structure with a bunch of overlays to get the data out of the DS in the right format, but I have to write this for a customer with V5R2. The V5R3 method doesn't compile in R2, when you do a "READ FILE DS;" R2 requires that the DS be defined on the Dspec with LIKEREC or EXTNAME.

I've gotten this to compile in V5R2, but all it ever writes to the text file is the data from first record read. It uses the right data length of each structure, but each line has the same data on it.

    Ffpw945ma  IF   E           K DISK    USROPN INFDS(INF945)

     //File information data structure
    DINF945           ds                  Qualified
    D   recname             261    270

     //File access DS
    Drec945ma       e ds                  extname(fpw945ma)

    D r945            ds                  Qualified
    D   r945m01                           likerec(IPW945M01) overlay(r945)
    D   r945m02                           likerec(IPW945M02) overlay(r945)
    D   r945m03                           likerec(IPW945M03) overlay(r945)
    D   r945m04                           likerec(IPW945M04) overlay(r945)
    D   r945m05                           likerec(IPW945M05) overlay(r945)

      /FREE
        dou %eof(fpw945ma);
           read fpw945ma;
           r945 = rec945ma;
           if not %eof(fpw945ma);

           select;
              when INF945.recname = 'IPW945M01';
                 line = 'FPW945M01:' + r945.r945m01;
                 RC = writeline(fd:line);
              when INF945.recname = 'IPW945M02';
                 line = 'FPW945M02:' + r945.r945m02;
                 RC = writeline(fd:line);
              when INF945.recname = 'IPW945M03';
                 line = 'FPW945M03:' + r945.r945m03;
                 RC = writeline(fd:line);
              when INF945.recname = 'IPW945M04';
                 line = 'FPW945M04:' + r945.r945m04;
                 RC = writeline(fd:line);
              when INF945.recname = 'IPW945M05';
                 line = 'FPW945M05:' + r945.r945m05;
                 RC = writeline(fd:line);
           endsl;

           endif;
        enddo;
       ...
      /END-FREE

Does anyone know a good method for accessing the data from the right record format?

Thanks,


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.