with prebalnk replace character with space and move left



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

with prebalnk replace character with space and move left

Postby Surabhi » Wed Dec 14, 2016 6:57 pm

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.
Surabhi
 
Posts: 44
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 3 times
Been thanked: 0 time

Re: with prebalnk replace character with space and move left

 

Re: with prebalnk replace character with space and move left

Postby Aki88 » Wed Dec 14, 2016 8:55 pm

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.

These users thanked the author Aki88 for the post:
Surabhi (Wed Dec 14, 2016 9:21 pm)
Aki88
 
Posts: 362
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 34 times

Re: with prebalnk replace character with space and move left

Postby Surabhi » Wed Dec 14, 2016 9:21 pm

Thank you so much Aki88, modifying Build did my job.
Surabhi
 
Posts: 44
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 3 times
Been thanked: 0 time

Re: with prebalnk replace character with space and move left

Postby BillyBoyo » Thu Dec 15, 2016 1:21 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 263 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post