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

I need to copy, change and truncate fields using DFSORT.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Tue Apr 01, 2014 9:06 pm
Reply with quote

Hi there I have only recently started to use DFSORT to it's full extent and so busy with data extraction and manipulation. I am not too sure how to use all the control statements together in one go. I need to extract only certain fields from the input file, insert comma delimiter, change certain fields using "IFTHEN=WHEN..." and then I need to remove blanks after each field.
I have manually changed Infile field 43,2 from eq=SA to c'864' and ne=SA to c'000', but this is what I need to do using DFSORT and then sqeeze the blanks after each field before comma to the left.

This is quite a mouthfull!!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Apr 01, 2014 9:24 pm
Reply with quote

charl barnard,

Your attachments are useless. Not every one can access them and it is tough to copy and paste from screen shots like that. You can enclose the data in code tags and you will retain the spacing and looks like a mainframe screen.

Anyway here is a DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
CHARLES   10000     LINE1245  ORANGE      SA PROGRAMMER                 
BARNARD   2000000   ABCDEFGHI APPLE       NU MANAGER                   
WOODGER   300000000 LMNOPQRS  PLUM        SA C.E.O                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INREC BUILD=(01,42,                                                   
               43,02,CHANGE=(3,C'SA',C'864'),NOMATCH=(C'000'),         
               45,35)                                                   
  OUTREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C','))                         
//*


produces
Code:

CHARLES,10000,LINE1245,ORANGE,864,PROGRAMMER
BARNARD,2000000,ABCDEFGHI,APPLE,000,MANAGER
WOODGER,300000000,LMNOPQRS,PLUM,864,C.E.O   
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Tue Apr 01, 2014 9:27 pm
Reply with quote

Apology, but it is the first time I am using this Forum, I am sure I will pick up on these tricks as I go along.
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Tue Apr 01, 2014 9:46 pm
Reply with quote

I forgot to mention that at certain offsets I insert my own data not coming from the Input file.

Code:

----+----1----+
AEL,S,SYSA,ZOS,


That I achived by using this:

Code:

OUTFIL OUTREC=(C'AEL',C',',C'S',C',',C'SYSA',C',',C'ZOS',


I hope I have the screen shots right now!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 02, 2014 2:27 am
Reply with quote

Charl Barnard,

You really don't need to use OUTFIL, you can do that on INREC itself and account for the length on OUTREC. The constant you had was 15 bytes length, so the length was increased to 95 for the sqz function.

Code:

//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC BUILD=(C'AEL,S,SYSA,ZOS,',                             
               01,42,                                           
               43,02,CHANGE=(3,C'SA',C'864'),NOMATCH=(C'000'), 
               45,35)                                           
  OUTREC BUILD=(1,95,SQZ=(SHIFT=LEFT,MID=C','))                 
//*
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Wed Apr 02, 2014 8:10 pm
Reply with quote

Thanks very much, this gives me a good indication of how it is done and I can build on it.
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Wed Apr 02, 2014 10:00 pm
Reply with quote

I got it to work perfectly but just one more question.
In the name field I need to seperate the surname form the first name but the seperation offset is variable.
This is what it looks like now:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
AEL,S,SYSA,ZOS,BARNACH,864/I/000000//BARNARDCHARL,ENABLED,31/03/14,AUDIT
AEL,S,SYSA,ZOS,BIANCDE,864/I/000000//BIANCHINADEON,ENABLED,31/03/14,NON-
AEL,S,SYSA,ZOS,BONHOVI,864/I/000000//BONHOMMEVIRGIL,ENABLED,20/01/14,NON


This is what I need it to be:

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
AEL,S,SYSA,ZOS,BARNACH,864/I/000000//BARNARD CHARL,ENABLED,31/03/14,AUDI
AEL,S,SYSA,ZOS,BIANCDE,864/I/000000//BIANCHINA DEON,ENABLED,31/03/14,NON
AEL,S,SYSA,ZOS,BONHOVI,864/I/000000//BONHOMME VIRGIL,ENABLED,20/01/14,NO
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: Wed Apr 02, 2014 10:09 pm
Reply with quote

Can you show the control cards you are using, and the sample input for that output?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 02, 2014 10:15 pm
Reply with quote

Charl Barnard,

There are other ways(Findrep, parse..) to preserve the spacing for names. Can you answer the following questions?

1. What is the LRECL and RECFM of the input file?
2. What is the position and length of the Name field?
3. Is the firstname and surname separated just by a space ?
4. Do you have a middle name or suffix or prefix for this name?
5. show us a sample of Raw input data.
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Wed Apr 02, 2014 10:19 pm
Reply with quote

Hi there,

This is the input record: The name field is column 15,20
Code:
     BARNACH  BARNARD CHARL         IBMSECSABARNACH          31/03/14           ENABLED  AUDIT,NON-CNCL 
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+


And these the control ststements I use:
Code:
 OPTION COPY                                                   
 INREC BUILD=(C'AEL,S,SYSA,ZOS,',                             
              06,08,                                           
              C',',                                           
              43,02,CHANGE=(3,C'SA',C'864'),NOMATCH=(C'000'), 
              C'/',                                           
              37,01,                                           
              C'/000000//',                                   
              15,20,                                           
              C',',                                           
              81,08,                                           
              C',',                                           
              62,08,                                           
              C',',                                           
              90,20,                                           
              C',')                                           
 OUTREC OVERLAY=(15:15,90,SQZ=(SHIFT=LEFT))                   
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Wed Apr 02, 2014 10:28 pm
Reply with quote

1. Input file dcb:
Code:
Dsorg  Recfm  Lrecl  Blksz
--------------------------
 PS    FB       160  27840


2. in my previous post.
3. Surname and first name seperated by space or comma
4, Nmae fields could contain more than one blank record or blank and comma.
5. previous post
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 02, 2014 10:54 pm
Reply with quote

Charl Barnard,

Use the following DFSORT Control Cards

Code:

//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC BUILD=(C'AEL,S,SYSA,ZOS,',                                   
               06,08,                                               
               C',',                                                 
               43,02,CHANGE=(3,C'SA',C'864'),NOMATCH=(C'000'),       
               C'/',                                                 
               37,01,                                               
               C'/000000//',                                         
               15,20,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=22),
               81,08,                                               
               C',',                                                 
               62,08,                                               
               C',',                                                 
               90,20,                                               
               C',')                                                 
                                                                     
  OUTREC OVERLAY=(15:15,90,SQZ=(SHIFT=LEFT,PAIR=QUOTE))             
  OUTFIL FINDREP=(INOUT=(C'"',C','))                                 
//*


or if you need OUTREC and OUTFIL for other processing , you can use

Code:

//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=INIT,                                           
        BUILD=(C'AEL,S,SYSA,ZOS,',                                   
               06,08,                                               
               C',',                                                 
               43,02,CHANGE=(3,C'SA',C'864'),NOMATCH=(C'000'),       
               C'/',                                                 
               37,01,                                               
               C'/000000//',                                         
               15,20,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=22),
               81,08,                                               
               C',',                                                 
               62,08,                                               
               C',',                                                 
               90,20,                                               
               C',')),                                               
  IFTHEN=(WHEN=INIT,OVERLAY=(15:15,90,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'"',C',')))                     
//*
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Fri Apr 04, 2014 2:17 pm
Reply with quote

Thanks very much for your help,........and patience, I will try this out and let you know the outcome.
Back to top
View user's profile Send private message
Charl Barnard

New User


Joined: 01 Apr 2014
Posts: 9
Location: South Africa

PostPosted: Mon Apr 07, 2014 4:52 pm
Reply with quote

I have added STARTPOS and ENDPOS to the last statement to change the leading " to / and the trailing " to comma and it is working 100% now.
Thanks very much for your help in this regard, I have learnt quite a lot from this forum.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top