MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Identify (not replace) spaces within a string.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Tue Aug 07, 2018 12:31 pm    Post subject: Identify (not replace) spaces within a string. Reply with quote

Good day,
please let me know how to accomplish the following using DFSort.

Have an FB dataset, LRECL=80, where a 40 bytes product name field can have extra (>1) spaces between values.
There could be trailing spaces, but not leading.
I don't need to squeeze or shirt those values, just identify records with extra spaces in the product name and copy them to output.
Thanks.

Data layout.
IND-NUM PIC X(15).
FILLER PIC X(19).
PROD-NAME PIC X(40).
FILLER PIC X(06).

Input data.
Code:

AAZZ12300000111...................METRIC  UNIT CONVERTER                  ......
BBZZ12300000111...................CHART CONVERTER  Z100DL                 ......
CCZZ12300000111...................FORCE                                   ......
DDZZ12300000111...................ANGULAR ACCELERATOR                     ...... 



Output data.
Code:

AAZZ12300000111...................METRIC  UNIT CONVERTER                  ......
BBZZ12300000111...................CHART CONVERTER  Z100DL                 ......
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Aug 07, 2018 1:25 pm    Post subject: Reply with quote

ramy2016,

You can use INCLUDE COND=(35,40,SS,EQ,C' ') to include the records with 2 spaces , however this would also bring the records that have trailing spaces. So you need to pad the trailing spaces with some thing other than a space and then use the INCLUDE. So we use JFY to pad the trailing spaces with $ and put it at the end of the record and then use INCLUDE on the new field to find the records with 2 spaces.

So here is a sample.
Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
AAZZ12300000111...................METRIC  UNIT CONVERTER             
BBZZ12300000111...................CHART CONVERTER  Z100DL           
CCZZ12300000111...................FORCE                             
DDZZ12300000111...................ANGULAR ACCELERATOR               
TEST RECORD WITH ALL SPACES                                         
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC OVERLAY=(81:35,40,JFY=(SHIFT=LEFT,LENGTH=40,                 
                TRAIL=C'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')) 

  OUTFIL BUILD=(1,80),                                               
         INCLUDE=(81,40,SS,EQ,C'  ')                                 
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Wed Aug 08, 2018 4:12 pm    Post subject: Reply with quote

Thank you, kolusu, works like a clock.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group