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
 
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: 2504
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 Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Where is output from PARM ABEXIT (SNA... packerm CA Products 3 Thu Sep 28, 2017 4:06 pm
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts it is possible output a SET value fro... Martylin JCL & VSAM 5 Fri Sep 22, 2017 7:08 am
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am

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