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

DFSORT : SqueeZe out blanks between a PAIR


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

New User


Joined: 14 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Wed Jun 04, 2008 12:03 pm
Reply with quote

Hi there, I have come to see that DFSORT helps to retain between a PAIR , but is there an option that can be turned on to remove blanks only between a PAIR

The below code retains a space between two apostrophes.

OPTION COPY
OUTFIL BUILD=(1,8,SQZ=(SHIFT=LEFT,PAIR=APOST,MID=C','))

Can this be modified to consider only spaces between apostrophes some how ?

I have tried to looking into User Guide for DFSORT PTFs UK90007 and UK90006 but I am not able to figure it out. Pardon me if it is out there and I have missed it.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 04, 2008 7:24 pm
Reply with quote

Hello mohanaraj_e and welcome to the forums,

Quote:
Can this be modified to consider only spaces between apostrophes some how ?
Please post some sample input and the output you want from that input.

Please mention the dsorg and lrecl of the data as well as the positons within the record you want to work with - if it is the entire record, mentio that as well.
Back to top
View user's profile Send private message
mohanaraj_e

New User


Joined: 14 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Wed Jun 04, 2008 7:31 pm
Reply with quote

Hello Dick !

I am looking at an input file with data similar to the lines below


Input
-------

Code:

~1234~James Anderson~        ~ TELNO1~XX~
~       ~John Doe          ~1234 ~            ~YY~


And what what I want is

Output
---------

Code:

~1234~James Anderson~~ TELNO1~XX~
~~John Doe~1234 ~~YY~


I had earlier run a SQZ blanks with left shift and what I got was

Code:

~1234~JamesAnderson~~ TELNO1~XX~
~~JohnDoe~1234 ~~YY~


Hope this makes sense .

P.S: The file is Tilde Delimited
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Jun 04, 2008 9:28 pm
Reply with quote

I don't understand what you're trying to do. You say "Can this be modified to consider only spaces between apostrophes some how ?".
But your example doesn't have any apostrophes.

You need to explain more clearly what you're trying to do with an example that fits what you say.

It looks like you want to remove blanks in some cases but not others, but it's not clear from you example what the rules are and they don't seem consistent. For example:

Code:

~John Doe          ~ becomes
~John Doe~

~1234 ~ is not changed.


So in one case you're keeping a blank in the middle but removing the trailing blanks and in the other case you're keeping the trailing blank.

What rule would the program use to know which blanks you want to remove and which blanks you want to keep? DFSORT is not a mind reader ... it must follow rules you give it. If you can't explain the rules, then there's no way we can "encode" them.
Back to top
View user's profile Send private message
mohanaraj_e

New User


Joined: 14 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Wed Jun 04, 2008 9:42 pm
Reply with quote

Apologies for the confusion. I had tried to make a general statement regarding pair and used apostrophes but gave a different input on files .Didnt realise that i messed it up.

What I was looking for was whether a blanks between a pair,Let me say in this case what I am looking for is a tilde delimited file from a file which has been created by a COBOL program with fixed copy book.

My requirements are twofold

1.Any blanks between two tildes should be squeezed out i.e if there is no data between those two all blanks must be removed.
2.If there is data between two tildes, only trailing blanks before the next Tilde should be removed

My earlier details should be read as

Input
--------

Code:

~1234~James Anderson~        ~TELNO1~XX~
~    ~John Doe      ~1234    ~      ~YY~ 


Output
----------

Code:

~1234~James Anderson~~TELNO1~XX~
~~John Doe~1234~~YY~



Hope I am clearer than the last time around. Thanks in advance for your help on this !
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Jun 04, 2008 9:50 pm
Reply with quote

Yes, that's clearer.

Are there always four fields in each record?

Is it only the second field that can have blanks in the middle (as in your example) or can any field have blanks in the middle?

What is the RECFM and LRECL of the input file?

What is the maximum length of each field?
Back to top
View user's profile Send private message
mohanaraj_e

New User


Joined: 14 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Wed Jun 04, 2008 10:10 pm
Reply with quote

The original file I am actually looking contains nearly 120 fields , LRECL is 909 and RECFM is FB .

But I feel that these 5 fields can be used for reference with a LRECL of 38 and RECFM of FB and the solution can be extrapolated to the entire file.But do let me know if you need more fields.

The maximum length of first field will be 4 characters
The maximum length of Second field will be 14 characters
The maximum length of third field will be 8 characters
The maximum length of fourth field will be 6 characters
The length of fifth field will be 2 characters

To answer your other question, any field in the file can have blanks in the middle.

I took a look at the file again and realised that there are are ~ in the first and last positions

The file looks like below

Code:


1234~James Anderson~        ~TELNO1~XX
    ~John Doe      ~1234    ~      ~YY


And expected output is

Code:


1234~James Anderson~~TELNO1~XX
~John Doe~1234~~YY



My apologies for the confusion and lengthy post.Didnt want make you go on the wrong path.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Thu Jun 05, 2008 1:19 am
Reply with quote

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

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/38)
//SORTOUT DD DSN=...  output file (FB/38)
//SYSIN    DD    *
  OPTION COPY
  ALTSEQ CODE=(40FF,FF40)
  INREC IFOUTLEN=38,
   IFTHEN=(WHEN=INIT,
     BUILD=(1,38,JFY=(SHIFT=RIGHT,TRAIL=C'~',LENGTH=39))),
   IFTHEN=(WHEN=INIT,
     PARSE=(%01=(ENDBEFR=C'~',FIXLEN=20),
            %02=(ENDBEFR=C'~',FIXLEN=20),
            %03=(ENDBEFR=C'~',FIXLEN=20),
            %04=(ENDBEFR=C'~',FIXLEN=20),
            %05=(ENDBEFR=C'~',FIXLEN=20)),
    OVERLAY=(1:%01,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"~'),
           21:%02,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"~'),
           41:%03,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"~'),
           61:%04,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"~'),
           81:%05,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"'),
           1:1,100,SQZ=(SHIFT=LEFT,PAIR=QUOTE),
           1:1,100,TRAN=ALTSEQ,
           1:1,100,SQZ=(SHIFT=LEFT,PREBLANK=C'"'),
           1:1,100,TRAN=ALTSEQ))
/*
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Jun 05, 2008 1:28 am
Reply with quote

mohanaraj_e wrote:
My requirements are twofold

1.Any blanks between two tildes should be squeezed out i.e if there is no data between those two all blanks must be removed.
2.If there is data between two tildes, only trailing blanks before the next Tilde should be removed


or to make it simpler any blanks preceeding a tilde should be removed.
Back to top
View user's profile Send private message
mohanaraj_e

New User


Joined: 14 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Thu Jun 05, 2008 9:58 am
Reply with quote

Thank you very much Frank for all your effort on this . I see that its working fine.

But as I said earlier the file is made up of more than 100 fields and I feel that writing a card like you have written may not be a good option. Thats my opinion though.

Now as Craq has put forth , my requirement can be simplified into any blanks preceding the delimiter(~) should be removed. Let me do some analysis to see if the guide provides some help on this. would be great if there is a silver bullet solution to this.


Let me give the back ground of why I have come up with such a requirement. I am re-engineering an Oracle-Unix system into an COBOL-DB2-JCL system.The earlier interface used to interact with a lot of external systems through delimited Variable Length files. But now when we have designed the new system we find that we may need the file in many other places internally and it might be a good option to create it based on a fixed copy book for internal use rather than a Variable one. The same file can be to be sent to external systems after squeezing out all the trailing blanks between the delimiters


Frank and Craq,Appreciate all your effort on this.
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 DFsort help with SUM() DFSORT/ICETOOL 12
No new posts DFSORT - VB file RDW getting overridden DFSORT/ICETOOL 3
Search our Forums:

Back to Top