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
 

 

convert the NUMERICALS using INSPECT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Hi Friends
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

Site Director


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

PostPosted: Thu Aug 30, 2007 9:12 pm    Post subject:
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    Post subject: Convert the INTEGERS into ' * ' by using the INSPECT command
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: 686
Location: Earth

PostPosted: Fri Aug 31, 2007 10:25 am    Post subject:
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    Post subject:
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    Post subject: Reply to: convert the NUMERICALS using INSPECT
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: 686
Location: Earth

PostPosted: Mon Sep 03, 2007 12:13 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Mon Sep 03, 2007 2:52 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Sep 04, 2007 3:27 am    Post subject:
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    Post subject:
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    Post subject:
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: 686
Location: Earth

PostPosted: Tue Sep 04, 2007 3:38 pm    Post subject:
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    Post subject:
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    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 Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


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