Field with embedded spaces.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Field with embedded spaces.

Postby thecabbb » Tue Jul 09, 2013 4:25 pm

I have a 5 byte field. Want to eliminate all records which have embedded spaces. The space can be at leading or trailing or anywhere at middle. The file have millions of records.
Please provide an efficient way to achieve this in cobol.
thecabbb
 
Posts: 2
Joined: Sun Jul 07, 2013 7:36 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Field with embedded spaces.

 

Re: Field with embedded spaces.

Postby Akatsukami » Tue Jul 09, 2013 4:31 pm

INSPECT the field TALLYING spaces. If the count is greater than zero, do not write the record.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Field with embedded spaces.

Postby NicC » Tue Jul 09, 2013 5:25 pm

An alternative would be to drop the unwanted records before your program even starts by running the data through your sort product.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Field with embedded spaces.

Postby c62ap90 » Tue Jul 09, 2013 5:40 pm

Reference Modification would work.

IF  field (1:1) = SPACE
OR  field (2:1) = SPACE
OR  field (3:1) = SPACE
OR  field (4:1) = SPACE
OR  field (5:1) = SPACE
    <bypass logic>
END-IF
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Field with embedded spaces.

Postby BillyBoyo » Tue Jul 09, 2013 11:26 pm

Just sub-defining the field will also do it.

01  a-nice-name.
    05  FILLER PIC X.
        88  a-nice-name-byte-1-blank-ign value space. 
    05  FILLER PIC X.
        88  a-nice-name-byte-2-blank-ign value space. 
    05  FILLER PIC X.
        88  a-nice-name-byte-3-blank-ign value space. 
    05  FILLER PIC X.
        88  a-nice-name-byte-4-blank-ign value space. 
    05  FILLER PIC X.
        88  a-nice-name-byte-5-blank-ign value space. 


If this is all your program is doing, or the data is already going through a SORT somewhere handy, then SORT will be a good solution.

  OMIT COND=(1,5,SS,EQ,C' ')

BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Field with embedded spaces.

Postby c62ap90 » Tue Jul 09, 2013 11:52 pm

Darn, the
OMIT COND=(1,5,CH,SS,C' ')
did not work for me.

...+....10...+....20...+....30...+....40...+....50...+....60...+....70...+....80...+....
SYNCSORT FOR Z/OS  1.4.0.1R    U.S. PATENTS: 4210961, 5117495   (C) 2010 SYNCSORT INC. 
                                                      z/OS   1.13.0                     
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 671A7, MODEL 2827 707             LICENSE/PRODUC
SYSIN :                                                                                 
    SORT FIELDS=(1,5,CH,A)                                                             
    OMIT COND=(1,5,CH,SS,C' ')                                                         
                      *                                                                 
WER251A  INCLUDE/OMIT INVALID COND                                                     
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                           
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                           
************************************************************ End of Data ***************

These users thanked the author c62ap90 for the post:
BillyBoyo (Wed Jul 10, 2013 12:24 am)
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Field with embedded spaces.

Postby BillyBoyo » Wed Jul 10, 2013 12:23 am

Thanks c62ap90, that's cos I bloopered it. I'll update the original as well to avoid the confusion.

Should be:
  OPTION COPY
  OMIT COND=(1,5,SS,EQ,C' ') 
                                             
//SORTIN   DD *
12345
1 345
123 5
1234
12  5
 2345


Output is:



The SS is a "field type". Here it will find one (or more) blanks in positions 1,5.

Another use of SS is to test the same field for multiple values, which can simplify things by removing an OR or two.

  OPTION COPY
  OMIT COND=(1,5,SS,EQ,C'12345,1 345, 2345')
                                             
//SORTIN   DD *
12345
1 345
123 5
1234
12  5
 2345


Output is:

123 5 
1234   
12  5 
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Field with embedded spaces.

Postby c62ap90 » Wed Jul 10, 2013 4:36 pm

Thanks for the correction BillyBoyo. Tested well now.
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post