Re: Layout Hell.: leave it
From: Lueko Willms (l.willms_at_jpberlin.de)
Date: 07/26/04
- Next message: Michael Russell: "Re: MicroFocus & Win XP file problems"
- Previous message: Charles Godwin: "Re: Cobol compilers with free deployment of App"
- In reply to: Lueko Willms: "Re: Layout Hell.: leave it"
- Next in thread: Lueko Willms: "Re: Layout Hell.: leave it"
- Reply: Lueko Willms: "Re: Layout Hell.: leave it"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Jul 2004 15:37:00 GMT
. Am 25.07.04
schrieb L.Willms@JPBERLIN.de (Lueko Willms)
auf /COMP/LANG/COBOL
in 9DZW$M2eflB@jpberlin-l.willms.jpberlin.de
ueber Re: Layout Hell.: leave it
LW>> What I said in my contribution is that the actual COBOL program to
LW>> do these conversions would be the same for all 20 different file
LW>> layouts, and would differ only in the COPY element describing the
LW>> files record layout; everything else in that program would not need
LW>> to be altered, except maybe the file description in the ENVIRONMENT
LW>> DIVISION and the DATA DIVISION, FILE SECTION (the FD entry, FD being
LW>> the abbreviation for File Description).
LW>>
LW>> One would COPY the original COPY-book unchanged for the input
LW>> file, and with the REPLACING clause for the output file; one
LW>> could produce 20 identical copies of that utility program, just
LW>> by changing the name of the COPY element.
here comes an enhanced version of that program which produces the
output file as a CSV-file, actually by prefixing each field with a
semikolon ";". Some explanations are added in the text.
Both versions of the program were compiled and verified with
Fujitsu's COBOL V.3, but not tested in practice for lack of real test
data.
--------- schnipp -----------------------------------------
000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID.
000030 COPYCSV.
000040 ENVIRONMENT DIVISION.
000050 INPUT-OUTPUT SECTION.
000060 FILE-CONTROL.
000070 SELECT INFILE
000080 ASSIGN TO "INFILE.DAT"
000090 FILE STATUS IS FILE-STATUS-INPUT
000100 .
000110 SELECT OUTFILE
000120 ASSIGN TO "OUTFILE.DAT"
000130 FILE STATUS IS FILE-STATUS-OUTPUT
000140 .
000150
000160 DATA DIVISION.
000170 FILE SECTION.
000180 FD INFILE
000190 .
000200 01 INRECORD
000210 .
000220 COPY RECDES01
000230 REPLACING
000240 == 01 == BY == 02 ==
000250 .
000251* The Recorddescription is being INCLUDEd in toe program here
000252* with REPLACING the level number from 01 to 02
000253* so that one can use a standard record name independently
000254* of the name given in the original record description.
000255* Just change the name of the COPY element here and for all the other
000256* record descriptions and leave the rest of the program unchanged.
000257*
000260
000270 FD OUTFILE
000280 .
000290 01 OUTRECORD
000300 .
000310 COPY RECDES01
000320 REPLACING
000330 == 01 == BY == 02 ==
000340 == COMP == BY == DISPLAY ==
000350 == COMP-1 == BY == DISPLAY ==
000360 == COMP-2 == BY == DISPLAY ==
000370 == COMP-3 == BY == DISPLAY ==
000380 == COMP-4 == BY == DISPLAY ==
000390 == COMP-5 == BY == DISPLAY ==
000400 == . == BY == .
000410 10 FILLER PIC X .
000420 ==
000430 .
000431* For the output, all USAGE COMP-n are being replaced by DISPLAY,
000432* so that this record is text only and can be read in in any kind of program
000433* before each elementary item (they happen to be written with level number 10)
000434* a one character field is being placed which will take up a semikolon: ";"
000440
000450 WORKING-STORAGE SECTION.
000460
000470 01 EDITRECORD
000480 .
000490 COPY RECDES01
000500 REPLACING
000510 == 01 == BY == 02 ==
000520 == COMP == BY == DISPLAY ==
000530 == COMP-1 == BY == DISPLAY ==
000540 == COMP-2 == BY == DISPLAY ==
000550 == COMP-3 == BY == DISPLAY ==
000560 == COMP-4 == BY == DISPLAY ==
000570 == COMP-5 == BY == DISPLAY ==
000580 == .
000590 10
000600 == BY == .
000610 10 FILLER PIC X VALUE ";".
000620 10 ==
000630 .
000640* This is the same record descriptions, but the one character field
000641* is defined as with predefined value of ";"
000650
000660
000670 01 FILE-STATUS-INPUT.
000680 88 FILE-OK VALUE '00'.
000690 02 FILLER PIC 9.
000700 88 FILE-AT-END VALUE 1.
000710 02 FILLER PIC 9.
000720
000730 01 FILE-STATUS-OUTPUT.
000740 88 FILE-OK VALUE '00'.
000750 02 FILLER PIC 9.
000760 88 FILE-AT-END VALUE 1.
000770 02 FILLER PIC 9.
000780
000790
000800 PROCEDURE DIVISION.
000810 MY-MAIN SECTION.
000820 ANFANG.
000830 OPEN INPUT INFILE
000840 OPEN OUTPUT OUTFILE
000850 READ INFILE
000860 PERFORM
000870 WITH TEST BEFORE
000880 UNTIL NOT (FILE-OK IN FILE-STATUS-INPUT)
000890 MOVE CORRESPONDING INRECORD TO EDITRECORD
000900 WRITE OUTRECORD FROM EDITRECORD
000910 READ INFILE
000920 END-PERFORM
000930 CLOSE INFILE
000940 CLOSE OUTFILE
000950 .
000960 ENDE.
000970 STOP RUN.
------------------ schnapp --------------------------------
I have also added the two CLOSE statements which I had forgotten in
the first version.
Yours,
Lüko Willms http://www.mlwerke.de
/--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --
"Es sind nicht die Generäle und Könige, die die Geschichte machen,
sondern die breiten Massen des Volkes" - Nelson Mandela
- Next message: Michael Russell: "Re: MicroFocus & Win XP file problems"
- Previous message: Charles Godwin: "Re: Cobol compilers with free deployment of App"
- In reply to: Lueko Willms: "Re: Layout Hell.: leave it"
- Next in thread: Lueko Willms: "Re: Layout Hell.: leave it"
- Reply: Lueko Willms: "Re: Layout Hell.: leave it"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|