|
Sure enough, as soon as you ask the question, you discover the answer. I'm responding to my own email in case some other lost soul comes looking for this answer. In V5R2 you can declare the external data structures like so: D r945m01 e ds extname(FPW945MA:IPW945M01) D r945m02 e ds extname(FPW945MA:IPW945M02) D r945m03 e ds extname(FPW945MA:IPW945M03) D r945m04 e ds extname(FPW945MA:IPW945M04) D r945m05 e ds extname(FPW945MA:IPW945M05) Where the MA file is the multiformat logical, and each IPW are the multiple formats themselves. Based on the format name you get from the file information data structure, you read the appropriate data structure and process accordingly. Or you could just upgrade to V5R3 :). Sorry to have bothered all of you. Wiley -------- Original Message -------- Subject: More multi-format logical fun Date: Thu, 13 Apr 2006 09:32:19 -0400 From: Wiley Ammons <wiley.ammons@xxxxxxxxxxxxx> Organization: ICS, Inc. To: rpg400-l@xxxxxxxxxxxx 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, -- Wiley Ammons Logimax Wiley.Ammons@xxxxxxxxxxxxx
As an Amazon Associate we earn from qualifying purchases.
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.