View previous topic :: View next topic
|
Author |
Message |
logeswarank Warnings : 1 New User
Joined: 15 Oct 2006 Posts: 22 Location: Chennai
|
|
|
|
I am able to converting the NUMERICAL Value by SPACES using the INSPECT command, but I am not able to convert the NUMERICALS by '*'.I declared that variable as X(250) char's.Please give me suggestion. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forums,
Your request is not clear.
Please post some sample data and what you want the "output" to be. |
|
Back to top |
|
|
logeswarank Warnings : 1 New User
Joined: 15 Oct 2006 Posts: 22 Location: Chennai
|
|
|
|
Hi Dick,
How r u?
I want to convert the integers into '*' by using the INSPECT command.
INSPECT WS-RPT-REC-DTL(150:16)
CONVERTING '0123456789' TO SPACES.
instead of spaces I want '*'.Please let me know your solution. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Code: |
INSPECT WS-RPT-REC-DTL(150:16)
CONVERTING '0123456789' TO '**********'. |
Did you try this? What problems did you face. |
|
Back to top |
|
|
logeswarank Warnings : 1 New User
Joined: 15 Oct 2006 Posts: 22 Location: Chennai
|
|
|
|
agkshirsagar wrote: |
Code: |
INSPECT WS-RPT-REC-DTL(150:16)
CONVERTING '0123456789' TO '**********'. |
Did you try this? What problems did you face. |
If the variable WS-RPT-REC-DTL contains any numerical value(0 to 9) in between 150th position to 165th position then I want to convert that numerical value to '*' not '0123456789' to '**********'. |
|
Back to top |
|
|
kbmkris
Active User
Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Hi logesh,
Please find the below code.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTJOB.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(30) VALUE 'BALAM2135123ISHNAN1234567890BA'.
PROCEDURE DIVISION.
DISPLAY WS-NAME.
INSPECT WS-NAME(19:10)
CONVERTING '0123456789' TO '**********'.
DISPLAY WS-NAME.
STOP RUN. |
SYSOUT content:
Code: |
BALAM2135123ISHNAN1234567890BA
BALAM2135123ISHNAN**********BA |
Hope this may help you. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Logeswaran,
What I wrote, exactly addresses your requirement. Again Did you try what I and bala have posted? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi logeswarank,
Is it mandatory that this needs to be done using INSPECT?. If not you can do it using a a simple perform loop.
Code: |
01 WS-VALIDATE-CHAR PIC X(001) VALUE SPACE.
88 WS-VALID-CHAR VALUE
'0' THRU '9'.
MOVE 150 TO WS-INDX
PERFORM
UNTIL WS-INDX > 165
MOVE WS-RPT-REC-DTL(WS-INDX:1)
TO WS-VALIDATE-CHAR
IF WS-VALID-CHAR
MOVE '*' TO
WS-RPT-REC-DTL(WS-INDX:1)
END-IF
ADD WS-ONE TO WS-INDX
END-PERFORM |
Hope this helps,
Abin |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Logeswaran,
Have you yet tried the INSPECT solution that was posted by 2 people?
When you ask for a solution and receive one, it is a good idea to try the suggestion and post a reply about success or if there was any problem or additional question(s). |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
It could also have been written as
Code: |
CONVERTING '9A0A8A1A7A2A6A3A5A4' TO '*A*A*A*A*A*A*A*A*A*'
|
though unnecessary, the way INSPECT CONVERT would have been obvious, since the OP, obviously, does not bother to read the manual. |
|
Back to top |
|
|
logeswarank Warnings : 1 New User
Joined: 15 Oct 2006 Posts: 22 Location: Chennai
|
|
|
|
Hi Abin,
It's working fine,In my variable conatins 150 characters,In that 150 characters I want '*' in particular position not fully.Some times it may contain Alphabets or Zeros fully.So only one way to convert the integers to '*' by using INSPECT command.If u have any alternative solution for this problem let me know.
Thank's For ur help. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Logeswaran,
Again,
Did you try what I posted?
If you did, you would not have asked for 'alternative solution'. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Logeswaran,
you need to explain your requirements with a detailed example. Each requirement that you have thus far presented, has received a solution. |
|
Back to top |
|
|
|