View previous topic :: View next topic
|
Author |
Message |
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
Thanks for the quick response and thanks again for your time..... |
|
Back to top |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
|