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.
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','))
//*
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.
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:
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.
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
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.