|
View previous topic :: View next topic
|
| Author |
Message |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
| 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 |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
| Thanks very much, this gives me a good indication of how it is done and I can build on it. |
|
| Back to top |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Can you show the control cards you are using, and the sample input for that output? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
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 |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
| Thanks very much for your help,........and patience, I will try this out and let you know the outcome. |
|
| Back to top |
|
 |
Charl Barnard
New User
Joined: 01 Apr 2014 Posts: 9 Location: South Africa
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|