View previous topic :: View next topic
|
Author |
Message |
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
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 |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Thanks Bill
I will try your suggestions and post the solution here. |
|
Back to top |
|
|
|