IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

convert the NUMERICALS using INSPECT


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
logeswarank
Warnings : 1

New User


Joined: 15 Oct 2006
Posts: 22
Location: Chennai

PostPosted: Thu Aug 30, 2007 10:17 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Aug 30, 2007 9:12 pm
Reply with quote

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
View user's profile Send private message
logeswarank
Warnings : 1

New User


Joined: 15 Oct 2006
Posts: 22
Location: Chennai

PostPosted: Fri Aug 31, 2007 10:04 am
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Aug 31, 2007 10:25 am
Reply with quote

Code:
INSPECT WS-RPT-REC-DTL(150:16)
CONVERTING '0123456789' TO '**********'.


Did you try this? What problems did you face.
Back to top
View user's profile Send private message
logeswarank
Warnings : 1

New User


Joined: 15 Oct 2006
Posts: 22
Location: Chennai

PostPosted: Mon Sep 03, 2007 10:13 am
Reply with quote

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
View user's profile Send private message
kbmkris

Active User


Joined: 24 Jun 2006
Posts: 101

PostPosted: Mon Sep 03, 2007 11:12 am
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon Sep 03, 2007 12:13 pm
Reply with quote

Logeswaran,
What I wrote, exactly addresses your requirement. Again Did you try what I and bala have posted?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Sep 03, 2007 2:52 pm
Reply with quote

Logeswaran,

Please look at the actual verb: INSPECT CONVERTING phrase (format 4)
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Sep 03, 2007 3:19 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 04, 2007 3:27 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 04, 2007 4:05 am
Reply with quote

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
View user's profile Send private message
logeswarank
Warnings : 1

New User


Joined: 15 Oct 2006
Posts: 22
Location: Chennai

PostPosted: Tue Sep 04, 2007 12:26 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Sep 04, 2007 3:38 pm
Reply with quote

Logeswaran,
Again,
Did you try what I posted?
If you did, you would not have asked for 'alternative solution'.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 04, 2007 3:50 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top