When trying to upload a notepad/CSV file that contains lines shorter than 80 characters to a mainframe file with LRECL of 80, the lines from the notepad or CSV file will be stored continuously in the mainframe file, with delimiter x'25', instead of individual records.
The below job can used to extract the individual lines from the uploaded file and store them as separate record in a output file
//COB EXEC PGM=IGYCRCTL
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT5 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT6 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT7 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT8 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT9 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT10 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT11 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT12 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT13 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT14 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT15 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT16 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT17 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT18 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT19 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT20 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSMDECK DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSLIN DD DSN=&&LOADSET,UNIT=SYSDA,DISP=(MOD,PASS),
// SPACE=(TRK,(3,3)),DCB=BLKSIZE=800
//SYSIN DD *
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO INFILE.
SELECT OUTPUT-FILE ASSIGN TO OUTFILE.
DATA DIVISION.
FILE SECTION.
FD INPUT-FILE.
01 INPUT-REC.
05 IN-CHAR PIC X(01) OCCURS 80 TIMES.
FD OUTPUT-FILE.
01 OUTPUT-REC PIC X(80).
WORKING-STORAGE SECTION.
01 WS-REC.
05 WS-CHAR PIC X(01) OCCURS 80 TIMES.
01 WS-IN PIC S9(04) COMP.
01 WS-OUT PIC S9(04) COMP.
01 WS-EOF PIC X(01) VALUE 'N'.
PROCEDURE DIVISION.
OPEN INPUT INPUT-FILE
OUTPUT OUTPUT-FILE
MOVE SPACES TO WS-REC
READ INPUT-FILE
AT END MOVE 'Y' TO WS-EOF
END-READ
PERFORM UNTIL WS-EOF = 'Y'
PERFORM VARYING WS-IN
FROM 1 BY 1 UNTIL WS-IN > 80
EVALUATE TRUE
WHEN IN-CHAR (WS-IN) = '"'
CONTINUE
WHEN IN-CHAR (WS-IN) = X'25'
WRITE OUTPUT-REC FROM WS-REC
MOVE ZEROS TO WS-OUT
MOVE SPACES TO WS-REC
WHEN OTHER
ADD 1 TO WS-OUT
MOVE IN-CHAR (WS-IN) TO WS-CHAR (WS-OUT)
END-EVALUATE
END-PERFORM
READ INPUT-FILE
AT END MOVE 'Y' TO WS-EOF
END-READ
END-PERFORM
CLOSE INPUT-FILE
OUTPUT-FILE
GOBACK.
//*
//LKED EXEC PGM=IEWL,PARM='LIST,MAP',COND=(5,LT,COB)
//SYSLIN DD DSN=&&LOADSET,DISP=(OLD,DELETE)
// DD DDNAME=SYSIN
//SYSLMOD DD SPACE=(CYL,(5,5,5)),DISP=(,PASS),DSN=&&TEMP(GO),
// DSNTYPE=LIBRARY
//SYSLIB DD DISP=SHR,DSN=CEE.SCEELKED
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSPRINT DD SYSOUT=*
//*
//GO EXEC PGM=*.LKED.SYSLMOD,COND=((5,LT,COB),(5,LT,LKED))
//SYSOUT DD SYSOUT=*
//INFILE DD DISP=SHR,DSN=PS file with uploaded text data
//OUTFILE DD DSN=output file
// LRECL=80,RECFM=FB,
// DISP=(,CATLG),SPACE=(CYL,(50,50),RLSE)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.