Page 1 of 1

with prebalnk replace character with space and move left

PostPosted: Wed Dec 14, 2016 6:57 pm
by Surabhi
Hi All,

I have tried using the below control card to replace a character astrisk (*) with sapce and then shift the record to left.

Input file:-
//*abcd 123 xyz

control card:-
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=(83,4,CH,EQ,C'ABCD'),
BUILD(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'*'))),
IFTHEN=(WHEN=NONE,
BUILD=(1,80))
/*

Output file:-
//abcd123xyz

Expected output:-
//abcd 123 xyz

Note:- i only want the the asterisk to be removed and then whole record should shift left, the in between spaces should remain as it is.

Can anyone help me with this.

Thanks.

Re: with prebalnk replace character with space and move left

PostPosted: Wed Dec 14, 2016 8:55 pm
by Aki88
Hello,

The output you're receiving is primarily because of 'SQZ' operator, refer the DFSORT programming guide to understand the what and how it does so, of SQZ operator, there is a reason why it is called 'squeeze'.

Having said that, two quick approaches to achieve what you're looking for:

1. Modifying your BUILD statement:

//SYSIN    DD *                          
 OPTION COPY                              
 OUTREC IFTHEN=(WHEN=(83,4,CH,EQ,C'ABCD'),
                BUILD(1,2,4,77)),         <-- Modified line
        IFTHEN=(WHEN=NONE,                
                BUILD=(1,80))            
/*                                        
 


2. Using FINDREP:

//SYSIN    DD *                            
 OPTION COPY                                
 OUTREC IFTHEN=(WHEN=(83,4,CH,EQ,C'ABCD'),  
                FINDREP=(INOUT=(C'*',C''))),         <-- Modified line
        IFTHEN=(WHEN=NONE,                  
                BUILD=(1,80))              
/*                                          
 


Both yield:

//ABCD 123 XYZ
//*ABCD 123 XYZ
//ABCD 123 XYZ
 


Word of caution: FINREP will replace all '*' in the data if the condition is satisfied.

Edit: Aside, SQZ can be used, but to get the results you're looking for, additional code will be required. Look at the usage of PAIR, try building a logic around it; though, personal opinion - really not necessary for this task; I'd use the modified BUILD instead of SQZ or anything else.

Re: with prebalnk replace character with space and move left

PostPosted: Wed Dec 14, 2016 9:21 pm
by Surabhi
Thank you so much Aki88, modifying Build did my job.

Re: with prebalnk replace character with space and move left

PostPosted: Thu Dec 15, 2016 1:21 am
by BillyBoyo
PREBLANK is turning that character to a blank before squeezing the blanks. Have a look at MID=C' ' which will replace squeezed sequences (one or more) of space by that one blank character.

However, the simple BUILD you are now using is preferable in this case.

Note that with FINDREP, the number of replacements can be limited by DO=. So DO=1 will stop the FINDREP after making one chage, D=8 after making eight changes.

There is no need for the WHEN=NONE with BUILD. If you have conditional IFTHEN, and you need to drop off excess bytes, you can use IFOUTLEN= to "set the record-length once all IFTHEN processing is complete". This will be more efficient than your WHEN=NONE with the BUILD.