IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Adding records simultaniously


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Thu Oct 11, 2007 3:09 pm
Reply with quote

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?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Oct 11, 2007 3:36 pm
Reply with quote

pinkroses,

If you want it done thru jcl, here is the topic which might give you some idea (change according to your requirement). This uses DFSORT -

ibmmainframes.com/viewtopic.php?t=24724
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Thu Oct 11, 2007 3:47 pm
Reply with quote

Hi Pinkroses,

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.


Do all these, TAKE CARE OF LOOPING!!!!
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Oct 11, 2007 4:07 pm
Reply with quote

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.
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Thu Oct 11, 2007 4:17 pm
Reply with quote

Hi Murali,

Sorry, Thanx For Correcting me, While posting, I done Copy & Paste instead of typing all.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Oct 11, 2007 4:56 pm
Reply with quote

pinkroses

Please check with the below SYNCSORT code for your requirement
Code:
// EXEC PGM=SYNCTOOL                               
//DFSMSG DD SYSOUT=*                             
//TOOLMSG DD SYSOUT=*                             
//INFILE DD DSN=QA02N.YDDYDJY.F161,DISP=SHR       
//T1 DD DSN=&&T1,DISP=(,PASS)                     
//T2 DD DSN=&&T2,DISP=(,PASS)                     
//T3 DD DSN=&&T3,DISP=(,PASS)                     
//CTL3JNF1 DD DSN=&&T4,DISP=(,PASS)               
//CTL3JNF2 DD DSN=&&T5,DISP=(,PASS)               
//CTL4JNF2 DD DSN=&&T6,DISP=(,PASS)               
//CTL4JNF1 DD DSN=&&T7,DISP=(,PASS)               
//OUT DD SYSOUT=*                                 
//TOOLIN DD *                                     
 COPY FROM(INFILE) TO(T1,T2,T3) USING(CTL1)       
 COPY FROM(T1) TO(CTL3JNF1) USING(CTL2)           
 COPY FROM(T2) TO(CTL3JNF2) USING(CTL2)           
 COPY FROM(T3) TO(CTL4JNF2) USING(CTL2)           
 COPY FROM(CTL3JNF1) TO(CTL4JNF1) USING(CTL3)     
 COPY FROM(CTL4JNF1) TO(OUT) USING(CTL4)             
/*                                                   
//CTL1CNTL DD *                                       
 OUTFIL FNAMES=(T1,T2,T3),SPLIT                       
/*                                                   
//CTL2CNTL DD *                                       
 INREC OVERLAY=(162:SEQNUM,2,ZD)                     
/*                                                   
//CTL3CNTL DD *                                       
 OPTION COPY                                         
 JOINKEYS FILE=F1,FIELDS=(162,2,A),SORTED             
 JOINKEYS FILE=F2,FIELDS=(162,2,A),SORTED             
 REFORMAT FIELDS=(F1:1,161,F2:1,163)                 
/*                                                   
//CTL4CNTL DD *                                       
 OPTION COPY                                         
 JOINKEYS FILE=F1,FIELDS=(323,2,A),SORTED             
 JOINKEYS FILE=F2,FIELDS=(162,2,A),SORTED             
 REFORMAT FIELDS=(F1:1,322,F2:1,161)       
/*                                         
//                                         
Back to top
View user's profile Send private message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Fri Oct 12, 2007 11:14 am
Reply with quote

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.
Back to top
View user's profile Send private message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Fri Oct 12, 2007 11:33 am
Reply with quote

Hi Shankar,

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
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Oct 12, 2007 12:45 pm
Reply with quote

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.
Back to top
View user's profile Send private message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Fri Oct 12, 2007 3:11 pm
Reply with quote

Hi Shankar,

here I am attaching the DFSMSG and TOOLMSG
Back to top
View user's profile Send private message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Fri Oct 12, 2007 3:14 pm
Reply with quote

Sorry,

I am using this site for the first time. So confusion.
Here is the attachement for TOOLMSG
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Oct 12, 2007 3:31 pm
Reply with quote

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.

Code:
// EXEC PGM=ICETOOL                               
//DFSMSG DD SYSOUT=*                             
//TOOLMSG DD SYSOUT=*                             
//INFILE DD DSN=F161,DISP=SHR       
//T1 DD DSN=&&T1,DISP=(,PASS)                     
//T2 DD DSN=&&T2,DISP=(,PASS)                     
//T3 DD DSN=&&T3,DISP=(,PASS)                     
//CTL3JNF1 DD DSN=&&T4,DISP=(,PASS)               
//CTL3JNF2 DD DSN=&&T5,DISP=(,PASS)               
//CTL4JNF2 DD DSN=&&T6,DISP=(,PASS)               
//CTL4JNF1 DD DSN=&&T7,DISP=(,PASS)
//OUT DD SYSOUT=*                             
//TOOLIN DD *                                 
 COPY FROM(INFILE) TO(T1,T2,T3) USING(CTL1)   
 COPY FROM(T1) TO(CTL3JNF1) USING(CTL2)       
 COPY FROM(T2) TO(CTL3JNF2) USING(CTL2)       
 COPY FROM(T3) TO(CTL4JNF2) USING(CTL2)       
 COPY FROM(CTL3JNF1) TO(CTL4JNF1) USING(CTL3)
 COPY FROM(CTL4JNF1) TO(OUT) USING(CTL4)     
/*                                           
//CTL1CNTL DD *                               
 OUTFIL FNAMES=(T1,T2,T3),SPLIT               
/*                                           
//CTL2CNTL DD *                               
 INREC OVERLAY=(162:SEQNUM,9,ZD)             
/*                                           
//CTL3CNTL DD *                               
 OPTION COPY                                 
 JOINKEYS FILE=F1,FIELDS=(162,9,A),SORTED     
 JOINKEYS FILE=F2,FIELDS=(162,9,A),SORTED       
 REFORMAT FIELDS=(F1:1,161,F2:1,170)             
/*                                               
//CTL4CNTL DD *                                 
 OPTION COPY                                     
 JOINKEYS FILE=F1,FIELDS=(323,9,A),SORTED       
 JOINKEYS FILE=F2,FIELDS=(162,9,A),SORTED       
 REFORMAT FIELDS=(F1:1,322,F2:1,161)             
/*                                               
//
Back to top
View user's profile Send private message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Fri Oct 12, 2007 4:03 pm
Reply with quote

Hi Shankar,

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.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Oct 12, 2007 4:33 pm
Reply with quote

pinkroses,
Quote:
Could you please suggest me where I need to make changes to avoid B37.

Please increase the amount of space in output file(s).
Back to top
View user's profile Send private message
pinkroses

New User


Joined: 07 Nov 2005
Posts: 19

PostPosted: Fri Oct 12, 2007 4:44 pm
Reply with quote

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
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Oct 12, 2007 4:50 pm
Reply with quote

pinkroses,

Please code SPACE=(CYL,(X,Y),RLSE) in all temp files and do a run.
X,Y=1,2,3,4,......
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
Search our Forums:

Back to Top