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

To write header based on condition


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jemonthomas

New User


Joined: 24 Jul 2006
Posts: 35
Location: india

PostPosted: Tue Jan 03, 2012 3:59 pm
Reply with quote

Hi,

In a Jcl I need to write a header when ever space comes in the input record.Could anyone help me in writing header based on this condition?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Jan 03, 2012 4:04 pm
Reply with quote

Hi,
Show us a sample of input and the output records & the rules, someone might be able to help.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jan 03, 2012 4:06 pm
Reply with quote

To add to Vasanthz's request, tell us what program you'd like the JCL to use to do this, please.
Back to top
View user's profile Send private message
Soumik Das

New User


Joined: 06 Aug 2011
Posts: 25
Location: India

PostPosted: Tue Jan 03, 2012 4:07 pm
Reply with quote

Quote:
when ever space comes in the input record


What do you exactly mean by that?

Some examples might help us understand your requirement better.
Back to top
View user's profile Send private message
jemonthomas

New User


Joined: 24 Jul 2006
Posts: 35
Location: india

PostPosted: Tue Jan 03, 2012 4:16 pm
Reply with quote

For Example Input file looks as below

ABCD Thomas
ABCD James
ABCD Tom

BCDE Charlie
BCDE Mahesh
BCDE Sunil

CDEF Sachin
CDEF Arun

Output file should looks like
Sl No: Name
ABCD Thomas
ABCD James
ABCD Tom

Sl No: Name
BCDE Charlie
BCDE Mahesh
BCDE Sunil

Sl No: Name
CDEF Sachin
CDEF Arun
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jan 03, 2012 6:41 pm
Reply with quote

If you want to use Sort:

Put in an IF in an Outrec which identifies a blank record, use the Slash operator (if Syncsort has that or an equivalent), outputting your blank first and then generating the header.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Jan 04, 2012 12:09 am
Reply with quote

Here is the code...



Code:

//S1A  EXEC PGM=SORT                               
//$ORTPARM  DD DSN=IMS.PARMLIB(IMSMS005),DISP=SHR 
//SORTIN    DD *                                   
ABC THOMAS                                         
ABC RICHARD                                       
ABC MATHEW                                         
ABC TOM                                           
                                                   
BCD NEENA                                         
BCD NAMITHA                                       
BCD NISHA                                         
                                                   
CDE ARUN                                           
CDE NIRMAL                                         
//SORTOUT   DD SYSOUT=*                           
//SYSOUT    DD SYSOUT=*                           
//SYSPRINT  DD SYSOUT=*                                               
//SYSIN     DD *                                                       
 INREC IFTHEN=(WHEN=(1,3,CH,NE,C' '),BUILD=(1,3,X,5,10,X,16:SEQNUM,   
                      8,ZD,RESTART=(1,3))),                           
      IFTHEN=(WHEN=(1,3,CH,EQ,C' '),BUILD=(1,3,X,5,10))               
 SORT FIELDS=COPY                                                     
 OUTFIL IFOUTLEN=80,                                                   
 IFTHEN=(WHEN=(16,8,ZD,GT,1),BUILD=(1,03,4X,5,10,61X)),               
 IFTHEN=(WHEN=(16,8,ZD,EQ,1),BUILD=(C'SL NO: NAME',/,1,03,4X,5,10,61X))




Your output:-
Code:

SL NO: NAME           
ABC    THOMAS         
ABC    RICHARD       
ABC    MATHEW         
ABC    TOM           
                     
SL NO: NAME           
BCD    NEENA         
BCD    NAMITHA       
BCD    NISHA         
                     
SL NO: NAME           
CDE    ARUN           
CDE    NIRMAL


Thanks
-3nadh
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Jan 04, 2012 4:49 pm
Reply with quote

Or even this.
Code:
//SYSIN     DD *                                           
 OPTION COPY                                               
 OUTREC OVERLAY=(81:SEQNUM,8,ZD)                           
 OUTFIL IFTHEN=(WHEN=(01,1,CH,EQ,C' '),                   
                BUILD=(1,80,/,C'SL NO: NAME')),           
        IFTHEN=(WHEN=(81,8,ZD,EQ,1),                       
                BUILD=(C'SL NO: NAME',/,1,80)),IFOUTLEN=80
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top