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

Find and delete dynamic string


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

New User


Joined: 03 Dec 2015
Posts: 6
Location: India

PostPosted: Fri Dec 04, 2015 11:27 am
Reply with quote

I have a requirment.

Read a record, and find a 5 byte string starting with 'Q' (eg: Q$A12), and delete the string from record.
This 5 digit string can be present anywhere in the record.The string starting with 'Q' and rest of the 4 bytes can be vary. My record length is 15 bytes.

I have to do this in JCL.


Example:

Input:

ABCDEFG123QABC2
HAIQ&A12ACMATLK


Output:

ABCDEFG123
HAIACMATLK

Thanks in advance icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 04, 2015 3:51 pm
Reply with quote

PARSE and BUILD. Is there always a Q? Will it always be followed by four characters?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Dec 04, 2015 4:06 pm
Reply with quote

Cannot be done "in JCL". Maybe using your sort product - moving topic.

Please learn how to use the code tags for the presentation of code and data. You found out how to use the BOLD tags so the code tags should be easy!
Back to top
View user's profile Send private message
Prayag P V

New User


Joined: 03 Dec 2015
Posts: 6
Location: India

PostPosted: Sat Dec 05, 2015 8:33 pm
Reply with quote

Bill Woodger wrote:
PARSE and BUILD. Is there always a Q? Will it always be followed by four characters?


Yes.. Always it start with 'Q', and it will be always followed by four characters.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Sun Dec 06, 2015 10:38 am
Reply with quote

Quote:
Yes.. Always it start with 'Q', and it will be always followed by four characters.

The question is whether all the records will have 'Q****' ?
What do you want to do if there is No 'Q****' ?

I believe you would also need to use IFTHEN=(WHEN and OVERLAY after PARSE and BUILD (inrec) to get your desired result as the output.

.
Back to top
View user's profile Send private message
Prayag P V

New User


Joined: 03 Dec 2015
Posts: 6
Location: India

PostPosted: Sun Dec 06, 2015 4:22 pm
Reply with quote

RahulG31 wrote:

The question is whether all the records will have 'Q****' ?
What do you want to do if there is No 'Q****' ?

I believe you would also need to use IFTHEN=(WHEN and OVERLAY after PARSE and BUILD (inrec) to get your desired result as the output.

.


If the record have 'Q****', then delete that string or replace with ' '(spaces).
If there is no 'Q****' in the record, then no need to do anything.(write the actual data to output)


Thanks in advance icon_smile.gif
Back to top
View user's profile Send private message
boyti ko

New User


Joined: 03 Nov 2014
Posts: 78
Location: Malaysia

PostPosted: Mon Dec 07, 2015 2:52 pm
Reply with quote

you can try this on command line while editing/viewing the file if you need it quick for a few records.

Code:
C ALL P'Q====' ' '
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Dec 07, 2015 3:07 pm
Reply with quote

Quote:
editing/viewing


Editing yes, viewing not.



Code:
C ALL P'Q====' ' '


will insert a space.

Code:
C ALL P'Q====' ''


will remove the text[/quote]
Back to top
View user's profile Send private message
boyti ko

New User


Joined: 03 Nov 2014
Posts: 78
Location: Malaysia

PostPosted: Mon Dec 07, 2015 3:16 pm
Reply with quote

Actually I tried it in VIEW mode..

Code:
VIEW       XXXXXXXX.XXXXXXXX.BOYTI(TEST) - 01.04          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 ABCDEFG123QABC2                                                         
000002 HAIQ&A12ACMATLK                                                         
****** **************************** Bottom of Data ****************************


then did this command:
Code:
C ALL P'Q====' ' '


Code:
VIEW       XXXXXXXX.XXXXXXXX.BOYTI(TEST)  - 01.04        CHARS 'Q====' changed
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
==CHG> ABCDEFG123                                                             
==CHG> HAI ACMATLK                                                             
****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Dec 07, 2015 3:56 pm
Reply with quote

Quote:
Actually I tried it in VIEW mode..

Yes - but that is only temporary. If you do a simple F3 out of view any changes are not saved. You have to issue a REPLACE or CREATE command
Back to top
View user's profile Send private message
boyti ko

New User


Joined: 03 Nov 2014
Posts: 78
Location: Malaysia

PostPosted: Mon Dec 07, 2015 5:04 pm
Reply with quote

Ohh I see, so that's what you meant, because in our shop, we got VS or VSAVE shop-specific command to do SAVE in case we are on VIEW mode. That's why I had taken the habit of viewing only the files.

Anyways, Just what the others told to use PARSE and BUILD, Im thinking that maybe this can be resolve by doing something like this.

%00 - PARSE the string before Q.
%01 - PARSE the string with Q and 4 characters
%02 - PARSE the remaining

Then BUILD %00 and %02..
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Dec 07, 2015 7:18 pm
Reply with quote

That's essentially it, but it will need a SQZ as well (all PARSEd fields have a FIXLEN). Discovered later that data can contain blanks as well, so those need to be protected.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Dec 07, 2015 9:33 pm
Reply with quote

Noting that despite the samples provided, the input can contain blanks.

Nothing that Q followed by fewer than four should not occurs, but dealing with that possibility.

Code:
  OPTION COPY
                                             
  INREC IFOUTLEN=15,
        IFTHEN=(WHEN=INIT,
                 FINDREP=(IN=C' ',
                          OUT=X'FE')),
        IFTHEN=(WHEN=INIT,
                 FINDREP=(IN=C'Q',
                          OUT=X'FD',
                          STARTPOS=12)),
        IFTHEN=(WHEN=INIT,
                 PARSE=(%00=(ENDBEFR=C'Q',
                             FIXLEN=15),
                        %01=(SUBPOS=1,
                             STARTAT=C'Q',
                             FIXLEN=5),
                        %02=(FIXLEN=10)),
                 BUILD=(%00,
                        X'FEFEFEFEFE',
                        %02)),
        IFTHEN=(WHEN=INIT,
                 OVERLAY=(1,30,
                           SQZ=(SHIFT=LEFT))),
        IFTHEN=(WHEN=INIT,
                 FINDREP=(IN=X'FE',
                          OUT=C' ')),
        IFTHEN=(WHEN=INIT,
                 FINDREP=(IN=X'FD',
                          OUT=C'Q'))


The above will chance Qxxxx to five blanks. To remove (shift subsequent bytes (if any) left and right-pad with space (if necessary), simply deleted the line with X'FEFEFEFEFE', and change 30 to 25 in the OVERLAY.

Ensure the output is 15 bytes. Change original blanks to a non-display value. Change Q at or after position 12 to a diffetrent non-display value. PARSE to a maximum of three fields (prior to Q, five from Q, residue). BUILD a new record (30 bytes) and use OVERLAY with SQZ to get rid of blanks. Change blank-value back to blank, and Q-value back to Q.

%00 will be all blank (when Q is at position one) up to 15 bytes (when there is no Q). When Q is present but not at position one, %00 will contain all the bytes up to the Q and will be space-padded to a total length of 15.

%01 will be space when there is no Q in the first 11 positions of the input, otherwise will be bytes of length five.

%02 will be space when there is no Q in the first 11 positions of the input, and space when the Q is in position 11, otherwise it will contain the residue after the five characters including Q have been recognized.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Mon Dec 07, 2015 11:54 pm
Reply with quote

Bill, I am not sure why we are changing C'Q' to X'FD' and using a X'FEFEFEFEFE' in BUILD ?

I am using below mentioned and I think it works fine. Any comments?
Code:
 OPTION COPY
 INREC IFTHEN=(WHEN=INIT,
                  FINDREP=(IN=C' ',
                           OUT=X'FE')),
       IFTHEN=(WHEN=INIT,
                  PARSE=(%00=(ENDBEFR=C'Q',FIXLEN=15),
                         %01=(ADDPOS=4,FIXLEN=15))),
       IFTHEN=(WHEN=INIT,
                  OVERLAY=(%00,%01,1:1,30,SQZ=(SHIFT=LEFT))),
       IFTHEN=(WHEN=INIT,
                  FINDREP=(IN=X'FE',
                           OUT=C' '))


.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Dec 08, 2015 1:30 am
Reply with quote

For the first it is to ensure that Qxxx and Qxx and Qx and Q don't get changed (since only Qxxxx is supposed to be changed).

For the second, TS/OP is not totally clear as to whether the located text is to be "deleted" or replaced by space.

The OVERLAY in place of BUILD is OK. There is no chance that any data will be "left over" from the original record. The two PARSE fields instead of three is good, you can use FIXLEN=10 on the second and then the 1,30 can be 1,25.

The "space" version should fit in with this as well (just add the constant, and put the 1,25 back to 1,30).
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Dec 08, 2015 2:45 am
Reply with quote

Thanks for making it clear to me.
Back to top
View user's profile Send private message
Prayag P V

New User


Joined: 03 Dec 2015
Posts: 6
Location: India

PostPosted: Wed Dec 09, 2015 12:45 pm
Reply with quote

Thanks all..

Especially Bill Woodger and RahulG31

Yours code working fine icon_smile.gif 36_8_11.gif
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts DELETE SPUFI DB2 1
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top