I have a dataset with record length 161. I need to make first 3 records into 1 record that means make it to records length 483 and next 3 record into 1 record and so on. Could you please let me know, the logic how to do using COBOL program. Can we do this by using JCL?
Yep You can do in Cobol Programming logic. It means Read Input File into Different Working Storage Variable, Move Main Working Storage variable.
Then write your Output file using Main Working storage Variable.
Just Like This,
Code:
FD INFILE-A
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS.
01 INREC-A PIC X(161).
AND OUTPUT FILE WILL BE,
Code:
FD OUTFILE-A
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS.
01 OUTREC-A PIC X(483).
Working Storage Variable will be like this,
Code:
01 WS-MAIN-RREC.
05 WS-1ST-REC PIC X(161) VALUE SPACES.
10 SUB-CONTENT
05 WS-2ND-REC PIC X(161) VALUE SPACES.
10 SUB-CONTENT
05 WS-3RD-REC PIC X(161) VALUE SPACES.
10 SUB-CONTENT
While Fetching your File, Count record And check Rec-count.
Like Below,
Code:
READ INFILE-A INTO INREC-A
AT END SET EOF TO TRUE
NOT AT END
MOVE INREC-A TO WS-1ST-REC
ADD 1 TO WS-REC-COUNT
END-READ.
IF EOF-N
READ INFILE-A INTO INREC-A
AT END SET EOF TO TRUE
NOT AT END
MOVE INREC-A TO WS-2ND-REC
ADD 1 TO WS-REC-COUNT
END-READ.
ELSE IF EOF-N
READ INFILE-A INTO INREC-A
AT END SET EOF TO TRUE
NOT AT END
MOVE INREC-A TO WS-RD-REC
ADD 1 TO WS-REC-COUNT
END-READ.
PERFORM ABOVE IN LOOP. CHECK THE CONDITION LIKE THIS,
Code:
EVALUATE TRUE
WHEN WS-REC-COUNT=3
WRITE OUTREC-A FROM WS-MAIN-REC
MOVE ZEROS TO WS-REC-COUNT
PERFORM 1000-READ-PARA THRU EXIT
WHEN WS-REC-COUNT=2
WRITE OUTREC-A FROM WS-MAIN-REC
MOVE ZEROS TO WS-REC-COUNT
PERFORM 1000-READ-PARA THRU EXIT
WHEN WS-REC-COUNT=1
WRITE OUTREC-A FROM WS-MAIN-REC
MOVE ZEROS TO WS-REC-COUNT
PERFORM 1000-READ-PARA THRU EXIT
WHEN OTHER
DISPLAY 'INFILE IS EMPTY'
PERFORM 9999-ABEND-PARA THRU EXIT
END-EVALUATE.
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
Hemantha,
Quote:
IF EOF-N
READ INFILE-A INTO INREC-A
AT END SET EOF TO TRUE
NOT AT END
MOVE INREC-A TO WS-2ND-REC
ADD 1 TO WS-REC-COUNT
END-READ.
ELSE IF EOF-N
When you are posting code, be careful with the syntaxes and AVOID typ errors. In the code above, IF EOF-N scope ends at END-READ.. Else will be hanging in the MID-AIR.
Thanks Murali. That link helped me lot but still I didn't achive the target.
For example I have a dataset with 20,000+ records. In that I have to make every 3 records into 1 records.
The link you have provided has given me for the first line. Next 3 records to make 2 line and so on... I couln't able to do it. Could you please help me out on how to do for rest of records.
I have tried your code but I am getting MAXCC 16. You have given me the exact solution which I am looking for but I need to make 3 lines to 1 records. each record length is 161 only. Could you please help me out
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
pinkroses,
Quote:
I have tried your code but I am getting MAXCC 16.
Is your site having SYNCSORT?
Quote:
You have given me the exact solution which I am looking for but I need to make 3 lines to 1 records. each record length is 161 only. Could you please help me out
The code which i posted was worked fine for record length 161 with SYNCSORT FOR Z/OS 1.2.3.
If your site has the SYNCSORT, please post your DFSMSG and TOOLMSG messages and JCL.
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
pinkroses,
The code i posted using SEQNUM with length 2, this means that maximum of 99 records in input file. As you are having more than 99 records in input file, you are getting MAXCC=16. Try with the below code in which i have used SEQNUM of length 9.
Thank you so much for your help. I have made the changes which you have suggested and I ran the JOB, it abended with B37. Later I just took 2000 records and ran the same job it is working fine. Could you please suggest me where I need to make changes to avoid B37.
I have executed your code only and I have written those records in spool(OUT DD SYSOUT=*). Is it any problem with temp files. do we need to increse number of temp files. I don't have any idea on ICETOOL. Please suggest me and thank you so much for your help