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
 

 

Removing Spaces in the output

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

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Tue Sep 16, 2008 7:04 pm    Post subject: Removing Spaces in the output
Reply with quote

Hi,
I want to remove the spaces in the output.

For ex: Output:ABCD_123_IUTOER_545_JLLDF_____1_____
'_' indicates SPACE

Now my output should looks like: ABCD123IUTOER545JLLDF1

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

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Sep 16, 2008 7:07 pm    Post subject:
Reply with quote

Had you have used tags to show your example the spaces would appear as spaces

Click HERE to see how to use tags.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 16, 2008 7:43 pm    Post subject:
Reply with quote

Quote:

(we can remove the spaces by using INSPECT verb. Give me the Pseudo code)

I think NO. when you use replacing you need to give same size character string which you want to replace.

You need to use perform loop using combination string and unstring using pointers
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 16, 2008 7:58 pm    Post subject:
Reply with quote

Hope you have digged out something by now..
here is solution
Code:

*WS
01 VIN PIC X(40) VALUE 'ABCD 12  IUTOER 545 JLLDF    1   '.
01 VOUT PIC X(40).                                         
01 VTEMP PIC X(40).                                         
01 PTR1 PIC 99.                                             
01 PTR2 PIC 99.                                             

*PD
    MOVE 1 TO PTR1 PTR2.               
    MOVE SPACES TO VOUT VTEMP.         
    PERFORM UNTIL PTR1 > 40             
    UNSTRING VIN DELIMITED BY ALL SPACES
      INTO VTEMP  POINTER PTR1         
    STRING VTEMP DELIMITED BY SPACES   
      INTO VOUT POINTER PTR2           
    END-PERFORM.                       
    DISPLAY "INPUT :" VIN.             
    DISPLAY "OUTPUT:" VOUT.             

Output is
Code:

INPUT :ABCD 12  IUTOER 545 JLLDF    1     
OUTPUT:ABCD12IUTOER545JLLDF1             
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Sep 17, 2008 1:39 pm    Post subject:
Reply with quote

Thanks for the quick response and thanks again for your time.....
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Sep 17, 2008 1:44 pm    Post subject:
Reply with quote

Is there any other way of achieving the same without declating VOUT and VTEMP? Bcoz my output field is having huge length. So I can't declare another variable with the same length.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed Sep 17, 2008 5:54 pm    Post subject:
Reply with quote

otherway is follow reference modification and move the required values into the same input variable.

e.g., for your example ABCD_123_IUTOER
Code:

             move Input(1:4) to Input(1:4).
             move Input(6:3) to Input(5:3).
             move Input(10:6) to Input(8:6). and so on.


As this involves lot of coding may not be feasible if your input is very big.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Sep 17, 2008 8:49 pm    Post subject: Re: Removing Spaces in the output
Reply with quote

Review the below link -

http://ibmmainframes.com/viewtopic.php?t=32610

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

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Sep 17, 2008 9:13 pm    Post subject:
Reply with quote

Quote:

Is there any other way of achieving the same without declating VOUT and VTEMP?


You will require atleast one temp variable ...

Use perform checking for each character for spaces .. and if not space then move it to the temp variable using ref modification ...
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Sep 18, 2008 5:59 pm    Post subject:
Reply with quote

Quote:

Is there any other way of achieving the same without declating VOUT and VTEMP? Bcoz my output field is having huge length. So I can't declare another variable with the same length.


Yes ther is a way. You can achieve it using redefines clause.
Check out below code
Code:

*WS
01 VINTEMP.                                                   
   02 VIN PIC X(40) VALUE 'ABCD 12  IUTOER 545 JLLDF    1   '.
   02 VIN1 REDEFINES VIN PIC X OCCURS 40 TIMES.               
*PD
MOVE 1 TO IDX1.                                     
PERFORM STRIP-PARA VARYING IDX FROM 1 BY 1 UNTIL   
        IDX = 40.                                   
DISPLAY "IDX1:" IDX1.                               
PERFORM MOVE-SPACES VARYING IDX FROM IDX1 BY 1 UNTIL
        IDX = 40.                                   
DISPLAY "WITHOUT USING TEMP VARIABLE: " VIN.       
.
.
.
STRIP-PARA.                           
    IF VIN1(IDX) NOT = ' '  THEN       
       IF IDX NOT = IDX1 THEN         
          MOVE VIN1(IDX) TO  VIN1(IDX1)
       END-IF                         
    COMPUTE IDX1 = IDX1 + 1.           
MOVE-SPACES.                           
    MOVE ' ' TO VIN1(IDX).             
'
'
*Output
WITHOUT USING TEMP VARIABLE: ABCD12IUTOER545JLLDF1

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 How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts JES2 doesn't honor the priority of th... Aron Lendvai JCL & VSAM 7 Thu Jun 29, 2017 1:41 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am


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