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: 8201
Location: Dubuque, Iowa, 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: 6970
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: 10375
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 Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 6 Thu Dec 14, 2017 3:52 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Formatting multiple records to a sing... Vignesh Sid SYNCSORT 3 Tue Nov 07, 2017 12:22 pm
No new posts Updating multiple counts in trailer!! Vignesh Sid SYNCSORT 4 Mon Nov 06, 2017 1:04 pm
No new posts Selecting a row from multiple tables! Vignesh Sid DB2 2 Thu Oct 26, 2017 6:09 pm

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