Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Remove the hyphens from the input

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sandeep kumar302

New User


Joined: 14 Mar 2012
Posts: 69
Location: India

PostPosted: Tue May 26, 2015 5:42 pm    Post subject: Remove the hyphens from the input
Reply with quote

I have an input field IN1 PIC X(12)
which might contain any numbers of hyphens. I want to remove the hyphens like:
asd--kjk-1-- should be replaced as asdkjk1
-----------i should be replaced as i

i am thinking of below options:
1) use INSPECT
2) Run a loop using perform
3) use Reference modification

Can someone please tell me which is the best and efficient one

If possible, please give me the sample code
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Tue May 26, 2015 5:52 pm    Post subject: Reply to: Remove the hyphens
Reply with quote

How many input records do you have? Since Enterprise COBOL on z/OS executes hundreds of millions of COBOL statements per second of CPU time, worrying about performance (ESPECIALLY when you have no indications of a performance issue) is pointless. Just pick a method, code it up, and try it.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue May 26, 2015 6:03 pm    Post subject: Reply to: Remove the hyphens
Reply with quote

Well, you can't do it with INSPECT. Doing it with reference-modification without a loop would be possible but an unrealistic amount of code for you to write and to have maintained.

So you do it in a loop.

Code:
MOVE SPACE TO output-filed

set your subscript items to initial values

PERFORM LENGTH OF input-field TIMES
  IF current-byte-of-input-is-hyphen ( input-subscript-item )
    increment  output-subscript-item
    MOVE current-byte-of-input ( input-subscript-item )
                                        TO current-byte-of-output
                                             ( output-subscript-item )
  END-IF
  increment  input-subscript-item
END-PERFORM


If you need it to go faster, you need to know about your data, like how many times zero, one or more than one hyphen.
Back to top
View user's profile Send private message
sandeep kumar302

New User


Joined: 14 Mar 2012
Posts: 69
Location: India

PostPosted: Wed May 27, 2015 10:22 am    Post subject:
Reply with quote

Quote:

How many input records do you have? Since Enterprise COBOL on z/OS executes hundreds of millions of COBOL statements per second of CPU time, worrying about performance (ESPECIALLY when you have no indications of a performance issue) is pointless. Just pick a method, code it up, and try it.


We have only 1 input record which contains hyphens and we have to remove all those hyphens.
Back to top
View user's profile Send private message
sandeep kumar302

New User


Joined: 14 Mar 2012
Posts: 69
Location: India

PostPosted: Wed May 27, 2015 10:24 am    Post subject:
Reply with quote

Thanks Bill

I will try your suggestions and post the solution here.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts How to copy PDS using dataset as input Ayodhya prasad JCL & VSAM 5 Wed Jun 01, 2016 6:02 pm
No new posts Need Help to Define 36 Input Fields (... satish.ms10 CLIST & REXX 2 Sat May 07, 2016 3:08 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us