Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Insert a string after copying of records from a file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Fri Mar 19, 2010 12:54 pm    Post subject: Insert a string after copying of records from a file.
Reply with quote

Hi,

Using the below code,
//STEPA EXEC PGM=SORT,REGION=0M
//SORTIN DD DSN=... input file1 (FB/50)
// DD DSN=... input file2 (FB/50)
// DD DSN=... input file3 (FB/50)
//SORTOUT DD DSN=... output file (FB/100)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC BUILD=(23,5,95X)
OUTFIL REMOVECC,
HEADER1=(2/,
'PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL',
/,5:'AGE',/,
5:'HEIGHT',/,
5:'WEIGHT',/)
/*


I get the ouput as
----------------------------------------------------------------------
PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL
AGE
HEIGHT
WEIGHT

23
158
45
18
157
47
------------------------------------------------------------------------------

My expected output is
------------------------------------------------------------------------------
PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL
AGE
HEIGHT
WEIGHT

STUDENT1
---------
23
158
45

STUDENT2
--------
18
157
47
-----------------------------------------------------------------------------

Can someone help me to inser those titles?

Thanks,
Jasand
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Mar 19, 2010 1:04 pm    Post subject:
Reply with quote

Hello Jasmad,

Would you kindly provide your input as well. I think you have student records in seperate file & you are trying to merge it with header . Please use code option while posting .
Back to top
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Fri Mar 19, 2010 1:47 pm    Post subject:
Reply with quote

Hi Guptae,
Yes, I have the inputs in 3 seperate files
//SORTIN DD DSN=... input file1 (FB/50)
// DD DSN=... input file2 (FB/50)
// DD DSN=... input file3 (FB/50)


Code:
***************************** Top of Data ***
AGE                  :   23                 
HEIGHT               :  158                 
WEIGHT               :   45                 
**************************** Bottom of Data *


The above file is for Student1
Similarly there are many input files, one for each student.

Thanks,
Jasand
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Mar 19, 2010 10:28 pm    Post subject:
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//STEPA    EXEC  PGM=SORT,REGION=0M
//SORTIN   DD  DSN=...  input file1 (FB/50)
//         DD  DSN=...  input file2 (FB/50)
//         DD  DSN=...  input file3 (FB/50)
//SORTOUT  DD  DSN=...  output file (FB/100)
//SYSOUT   DD  SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=INIT,BUILD=(23,5)),
    IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(24:ID=5))
  OUTFIL REMOVECC,
   HEADER1=(2/,
     'PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL',
      /,5:'AGE',/,
      5:'HEIGHT',/,
      5:'WEIGHT',/),
   BUILD=(1,5,100:X),
   SECTIONS=(24,5,HEADER3=('STUDENT',24,5,/,'------------'))
/*
Back to top
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Mon Mar 22, 2010 12:00 pm    Post subject:
Reply with quote

Thank you Frank. It gave the desired result. I got it as below,

Code:
****** ***************************** Top of Data ************
000001                                                       
000002                                                       
000003 PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL     
000004     AGE                                               
000005     HEIGHT                                           
000006     WEIGHT                                           
000007                                                       
000008 STUDENT00001                                         
000009 ------------                                         
000010    19                                                 
000011   135                                                 
000012    40                                                 
000013 STUDENT00002                                         
000014 ------------                                         
000015    15                                                 
000016   123                                                 
000017    38                                                 
000018 STUDENT00003                                         
000019 ------------                                         


To add on it, can I get the result as below,( with the individual names displayed instead of STUDENT00001...)
I do have only 5 to 6 names/sections to be displayed , and not much...and so hope there is no need for a seperate i/p file to hold the names.

eg:

Code:
****** ***************************** Top of Data *********
000001                                                   
000002                                                   
000003 PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL 
000004     AGE                                           
000005     HEIGHT                                         
000006     WEIGHT                                         
000007                                                   
000008 KATHERINE                                         
000009 ------------                                       
000010    19                                             
000011   135                                             
000012    40                                             
000013 CLIVE                                             
000014 ------------                                       
000015    15                                             
000016   123                                             
000017    38                                             
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Mar 22, 2010 10:43 pm    Post subject:
Reply with quote

Quote:
To add on it, can I get the result as below,( with the individual names displayed instead of STUDENT00001...)
I do have only 5 to 6 names/sections to be displayed , and not much...and so hope there is no need for a seperate i/p file to hold the names.


Well, the names have to come from somewhere ... either hardcoded or a separate file or Symbols or somewhere. Do you just have a list of 6 names that you want to hardcode in the control statements that's always the same? If so, what are the names? If not, where do the names come from?
Back to top
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Tue Mar 23, 2010 9:52 am    Post subject:
Reply with quote

Hi Frank,

I just need to hardcode 7 names as the titles for the seven groups which will be in the output as below,

Code:
****** ***************************** Top of Data *********
000001                                                   
000002                                                   
000003 PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL 
000004     AGE                                           
000005     HEIGHT                                         
000006     WEIGHT                                         
000007                                                   
000008 KATHERINE                                         
000009 ------------                                       
000010    19                                             
000011   135                                             
000012    40                                             
000013 CLIVE                                             
000014 ------------                                       
000015    15                                             
000016   123                                             
000017    38 
000018 ROBERT                                         
000019 ------------                                       
000020    19                                             
000021   135                                             
000022    40                                             
000023 SAM                                             
000024 ------------                                       
000025    15                                             
000026   123                                             
000027    38 
000028 GEORGE                                         
000029 ------------                                       
000030    19                                             
000031   135                                             
000032    40                                             
000033 LEENA                                             
000034 ------------                                       
000035    15                                             
000036   123                                             
000037    38 
000038 GRACE                                             
000039 ------------                                       
000040    15                                             
000041   123                                             
000042    38



Thanks,
Jasand
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Mar 23, 2010 10:29 pm    Post subject:
Reply with quote

Here's a DFSORT job for that:

Code:

//STEPA    EXEC  PGM=SORT,REGION=0M
//SORTIN   DD  DSN=...  input file1 (FB/50)
//         DD  DSN=...  input file2 (FB/50)
//         DD  DSN=...  input file3 (FB/50)
//         DD  DSN=...  input file4 (FB/50)
//         DD  DSN=...  input file5 (FB/50)
//         DD  DSN=...  input file6 (FB/50)
//         DD  DSN=...  input file7 (FB/50)
//SORTOUT  DD  DSN=...  output file (FB/100)
//SYSOUT   DD  SYSOUT=*
//SYSIN    DD *
 SORT FIELDS=COPY
 INREC IFTHEN=(WHEN=INIT,BUILD=(23,5)),                       
   IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(24:ID=1)),               
   IFTHEN=(WHEN=(24,1,ZD,EQ,1),OVERLAY=(24:C'KATHERINE')),     
   IFTHEN=(WHEN=(24,1,ZD,EQ,2),OVERLAY=(24:C'CLIVE')),         
   IFTHEN=(WHEN=(24,1,ZD,EQ,3),OVERLAY=(24:C'ROBERT')),       
   IFTHEN=(WHEN=(24,1,ZD,EQ,4),OVERLAY=(24:C'SAM')),           
   IFTHEN=(WHEN=(24,1,ZD,EQ,5),OVERLAY=(24:C'GEORGE')),       
   IFTHEN=(WHEN=(24,1,ZD,EQ,6),OVERLAY=(24:C'LEENA')),         
   IFTHEN=(WHEN=(24,1,ZD,EQ,7),OVERLAY=(24:C'GRACE'))         
  OUTFIL REMOVECC,
   HEADER1=(2/,
     'PLEASE FIND THE BELOW DETAILS FOR EACH INDIVIDUAL',
    /,5:'AGE',/,
      5:'HEIGHT',/,
      5:'WEIGHT',/),
   BUILD=(1,5,100:X),
   SECTIONS=(24,5,HEADER3=(24,9,/,'------------'))
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us