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

Removing space in tab seperated file


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

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Wed Aug 04, 2010 12:23 am
Reply with quote

I have a file in mainframe which is being created by the defined process with 800 lenght. This file gets created as tab seperated on mainframe so ever field is seperated by TAB. This is handled in code itself.

There appears to be a change on the receiver end of this file and now we need this file as TAB seperated but this time without any extra space between the fields. From a design point of view I thought getting this new type of file created in mainframe with program change or writing new code could take more effort so thought of doing test with DFSORT I used following sort. The good part is that if removed most of the spaces but as I defined it puts one space for all the spaces it removed which is definately not needed. The file layput is as follows.

Code:
03     EERS-EXTRACT.                                         
    05 LAST-NAME                 PIC X(29).               
    05 DELIMIT1                  PIC X(01).               
    05 FIRST-NAME                PIC X(29).               
    05 DELIMIT2                  PIC X(01).               
    05 LOGIN-ID                  PIC X(19).               
    05 DELIMIT3                  PIC X(01).               
    05 ID                        PIC X(09)  VALUE SPACES.
    05 DELIMIT4                  PIC X(01).               
    05 ID1                       PIC X(10)  VALUE SPACES.
    05 DELIMIT5                  PIC X(01).               
    05 FUNC-TITLE-CODE           PIC X(69).               
    05 DELIMIT6                  PIC X(01).               
    05 FUNC-CODE-DESC            PIC X(254).             
    05 DELIMIT7                  PIC X(01).               
    05 ID2                       PIC X(06)  VALUE SPACES.
    05 DELIMIT8                  PIC X(01).               
    05 LEVEL-ENTITLE-DESC        PIC X(254) VALUE SPACES.
    05 DELIMIT9                  PIC X(01).               
    05 EXTERNAL-DRILL-DOWN-CODE  PIC X(08)  VALUE SPACES. 
    05 DELIMIT10                 PIC X(01).               
    05 FILLER                    PIC X(95)  VALUE SPACES. 
    05 DELIMIT11                 PIC X(01).               
    05 APPLICATION-ID            PIC X(06)  VALUE '111111'.


I used the following code:

OPTION COPY
INREC BUILD=(1,800,SQZ=(SHIFT=LEFT,MID=C' '))

I've tried to explain it well but if any piece is missing please let me know. I tried running without MID=C' ' but it removed up the spaces between the words for the fields 05 FUNC-TITLE-CODE PIC X(69). This field is descriptive field and without using MID C all words are clubbing together. THe same is happening with field 05 FUNC-CODE-DESC PIC X(254) also.
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 Aug 04, 2010 1:04 am
Reply with quote

Quote:
The good part is that if removed most of the spaces but as I defined it puts one space for all the spaces it removed which is definately not needed


It did what you told it to do. By using MID=C' ', you're telling it to put one space between each "word". DFSORT doesn't know that some of your fields are "descriptive fields" consisting of more than one word. How could it? YOU can tell DFSORT about these "descriptive fields" by putting quotes around them before you SQZ them and using PAIR=QUOTE to ignore anything between the quotes. If you don't know how to do that, then show me an example of your input and what you expect for output and I'll show you how to do it.
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Wed Aug 04, 2010 2:20 am
Reply with quote

I agree it is doing what I told it to do.But probably I am not able to think of what to do exactly when I looked what the results.
I do not know if I can attach a text input record over this editor I am typing.
But here are the two sample input records on the input file. The fields are defined by layput I earlier posted. The filler is TAB seperation. Following are the two samples which I do see see good coming up when I copied from text file over this editor. I need the fields should be TAB seperated with additionally no extra spaces between any of the fields. LIke in this case if last name is x(30) in layout but actually the TAB should come as soon as it realizes that there is end of characters in last name field so if for some record last name is 6 byte long there should be TAB coming on 7th byte and so on for other values. So I would say it would be variable lenght record probably.

JOHN MARCELLA 5006 ACP PROCESSING TYPE ACP PROCESSING TYPE INDICATES IF THE USER IS SUPER ID (A) OR NOT (N) OR A RECORDED MESSAGE B (R) LEVEL 30 111111
MARY CANDAS 5031 USER CLASS PROF VAL 01 USER CLASS PROFILE ID IDENTIFIES THE USER CLASS PROFILE WITH WHICH THE USER IS ASSOCIATED. 01 IS THE DEFAULT VALUE AND 02 ALLOWS MONITORING BY QA REPS AND MANAGERS LEVEL 30 111111
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 Aug 04, 2010 3:07 am
Reply with quote

As you realized, the records are NOT being displayed here in any way that makes it possible for me to decipher which field is which.

How about showing the input record with an @ for each tab and a b for each blank, e.g.

JOHNbb...@MARCELLAbb...@bb5006bb...@ACPbPROCESSINGbTYPEbb...@ ...

Then show the output record you want, e.g.

JOHN@MARCELLA@5006@ACPbPROCESSINGbTYPE@ ...

Also, tell me which of your fields can have multiple words.

What is the RECFM and LRECL of your input file?

What RECFM and LRECL do you want for the output file?

My knowledge of COBOL is limited - what does "VALUE SPACES" mean?
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Wed Aug 04, 2010 9:35 pm
Reply with quote

Okay Frank let me work on a sample input and output record as you said as the file lenght is 800 defined by the file layout which I earlier posted so it might take some time for me to construct the sample record for posting here.
But just as a sample here is a quick thing I can think of which should work as a sample unit for my 800 lenght file

Input file(I am adding header just for the sake of field descriton)

last name First Name Description

Yaeger Frank He is a DFSORt expert.Gives really nice tricks.
Raghav tp Having doubt on doing this.

Output expected file.I am using @ as TAB

Yaeger@Frank@He is a DFSORt expert.Gives really nice tricks.
Raghav@tp@Having doubt on doing this.


Now if you see this input file the last name in first record is 6 characters long,first name has got only 5 charcaters and description has got 40 characters,if I counted right exluding spaces after every word)
The second record could have different acutal number of characters in fields but can not be more than the file layout.

The layout dfinition of the fields could be as follows in cobol

Last name pic x(30)
filler x(1) which will be filled with TAB
First Name pic x(30)
filler x(1) which will be filled with TAB
description x(100)

I hope this makes clear for what is needed but if not please let me know.As I said I just tried to put a sample by making s small sample with less file lenght.800 would be long record for me.
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 Aug 05, 2010 4:28 am
Reply with quote

Code:

Last name pic x(30)   <- does this appear in 1-30 with trailing blanks as needed?

filler x(1) which will be filled with TAB  <- does this always appear in position 31?

First Name pic x(30)     <- does this always start in position 32?

filler x(1) which will be filled with TAB  <- does this always appear in position 62?

description x(100) <- does this always start in position 63?
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Thu Aug 05, 2010 9:00 pm
Reply with quote

Hello Frank,

Please specify if your questions are on input or output file.Sorry but I did not understood.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 05, 2010 9:16 pm
Reply with quote

deleted by dbz
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 Aug 05, 2010 10:30 pm
Reply with quote

Quote:
Please specify if your questions are on input or output file.Sorry but I did not understood.


My questions are on input. I'm still trying to figure out exactly what your input fields look like (e.g. are they fixed length with trailing blanks).
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Fri Aug 06, 2010 12:38 am
Reply with quote

Hello Frank sorry for delay in response.This is what based on input file

Last name pic x(30) <- does this appear in 1-30 with trailing blanks as needed?

Ans: Last name would always appear in column 1-30.

filler x(1) which will be filled with TAB <- does this always appear in position 31?

Ans:Filler which is TAB in my case will always appears on column 31 and so on as I tried to put in my sample records initially which was small record not my 800 orignal.


c)First name would always start on 32,after TAB on input file.

Ans:Yes.

filler x(1) which will be filled with TAB <- does this always appear in position 62?

Ans:Yes

description x(100) <- does this always start in position 63?
Ans:Yes



Please let me know if any further information would be needed for where I am not clear about.Thanks
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: Fri Aug 06, 2010 1:28 am
Reply with quote

Ok, I'll use your 162 byte example above to show you the technique for doing this kind of thing with DFSORT. The idea is to surround the multiple word fields with quotes, then SQZ with PAIR=QUOTE and then use FINDREP to remove the quotes. Here's the example:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/162)
//SORTOUT DD DSN=...  output file (FB/162)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=162,
   IFTHEN=(WHEN=INIT,
    BUILD=(1,62,63,100,JFY=(SHIFT=LEFT,LEAD=C'"',
    TRAIL=C'"',LENGTH=102))),
   IFTHEN=(WHEN=INIT,BUILD=(1,164,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),
   IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',OUT=C''))
/*


So if the input is these 162 byte records

Code:

Yaeger                        @Frank                         @He is a DFSORt expert.Gives really nice tricks.
Raghav                        @tp                            @Having doubt on doing this.


The output would be these 162 byte records:

Code:

Yaeger@Frank@He is a DFSORt expert.Gives really nice tricks.     
Raghav@tp@Having doubt on doing this.                           
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Aug 06, 2010 2:07 pm
Reply with quote

Frank Yaeger wrote:
Code:

Yaeger@Frank@He is a DFSORt expert.Gives really nice tricks.     
Raghav@tp@Having doubt on doing this.                           
A good read for Friday...icon_smile.gif
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Wed Aug 18, 2010 2:52 am
Reply with quote

Thanks Frank,I was out for vaccation but am getting the expected result using your nice groupiing trick after integrating with what was needed in my case.Thanks and it was really nice trick!!
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
Search our Forums:

Back to Top