Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Converting multiple spaces in to none

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

New User


Joined: 24 Jun 2008
Posts: 7
Location: Pune

PostPosted: Thu Jan 14, 2010 6:50 pm    Post subject: Converting multiple spaces in to none
Reply with quote

Hi,
Can some bdy tell me an answer to this. I have a string 'X Y Z A'. There are spaces in between al the alphabets. Now I want to remove all the spaces and just have the output string as XYZA. How can I do it? Please help...

Thanks
Priyesh
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jan 14, 2010 6:54 pm    Post subject:
Reply with quote

Is the variable DBCS? UTF-8?

Assuming it is a "normal" (i.e., not DBCS nor UTF) variable, reference modification will do this -- see the COBOL Language Reference manual (link at the top of the page) for details on how to code it.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Jan 14, 2010 7:19 pm    Post subject:
Reply with quote

Code:

01  input-string-size          pic s9(4) comp.
01  input-string               pic x(10).  (or however large it is)
01  input-table     
    redefines
    input string.
    05  input-item             pic x(01)
                               occurs 10 times    (or however large input-string is)
                               indexed by input-index.
        88  input-is-space     value space.
*
01  output-string              pic x(10).  (or however large input-string is)
    88  output-string-to-space value spaces.
01  output-table     
    redefines
    output string.
    05  output-item            pic x(01)
                               occurs 10 times    (or however large input-string is)
                               indexed by output-index.
*

Code:

   move length of input-string to input-string-size.
   set  output-index           to 1   
        set  output-string-to-space true
   perform varying input-index
           from    1
           by      1
           until   input-index > input-string-size         
      if input-is-space(input-index)
      then
         continue
      else
         move input-item  (input-index)
         to   output-item (output-index)       
         set  output-index
              up by 1
      end-if
   end-perform 


I would think, IMUO that advice to a novice should be to use/learn indexing first, since it is much more effecient than reference modification, especially since he could not figure out how to accomplish this task.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Thu Jan 14, 2010 7:25 pm    Post subject: Reply to: Converting multiple spaces in to none
Reply with quote

The following post maybe helpful (or maybe not), if you apply the logic in a reverse manner or extract some of the logic as needed:

http://www.ibmmainframes.com/viewtopic.php?p=143786&highlight=#143786

Bill
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Jan 15, 2010 4:00 pm    Post subject:
Reply with quote

Robert Sample wrote:
Assuming it is a "normal"
icon_smile.gif, you're now habitual of this forum, Robert.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10310
Location: italy

PostPosted: Fri Jan 15, 2010 4:27 pm    Post subject: Reply to: Converting multiple spaces in to none
Reply with quote

but it' s much more fun with ... ABnormal <thingies>
as in Frankestein junior
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 ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us