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
 

 

regarding INSPECT stmt

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kalyan_lc5

New User


Joined: 06 Jul 2006
Posts: 9

PostPosted: Tue May 25, 2010 7:24 pm    Post subject: regarding INSPECT stmt
Reply with quote

Hi,

Is it possible to combine INSPECT REPLACING and INSPECT CONVERTING?

I have a requirement, wherein the string should not contain any special characters, spaces and leading zeros. I am trying to use like this.

INSPECT DATA1 REPLACING LEADING '0'BY SPACES
CONVERTING '!@#$%^&*()_-+=' TO SPACES.

later checking byte by byte of the string and if it is not spaces i am moving to the output field.

but i am getting compilation error by using the above syntax.
Kindly help on this.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Tue May 25, 2010 7:34 pm    Post subject:
Reply with quote

The COBOL Language Reference manual (link at the top of the page) section 6.2.21 is quite clear that you can use REPLACING or you can use CONVERTING but you cannot use both in the same INSPECT statement.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue May 25, 2010 7:50 pm    Post subject: Reply to: regarding INSPECT stmt
Reply with quote

Please review the following -

http://ibmmainframes.com/viewtopic.php?p=143786&highlight=#143786

Instead of dynamically building the "FROM-TBL", it can be predefined/assembled and accessed via a PROCEDURE-POINTER, which is not to be confused with POINTER, introduced with VS/COBOL II.

Code:

PRMDSECT DSECT                    PARM-DSECT (R7)
         USING *,R7               INFORM ASSEMBLER
PRMTRGT  DS    CL8                TARGET-PGM
PRMADDR  DS    XL4                TARGET-PGM LOAD-ADDRESS
PRMERRCD DS    XL4                TARGET-PGM ERROR-CODE   
PRMRSA   EQU   *                  BEGIN PARM-RSA     
LOADPGM  CSECT
         USING *,R3               INFORM ASSEMBLER
         LA    R3,0(,R15)         CSECT ADDRESSABILITY
         L     R7,0(,R1)          PARMAREA ADDRESSABILITY
         LA    R9,PRMRSA          POINT TO OUR RSA
         XC    0(72,R9),0(R9)     ENSURE X'00'S
         LA    R15,0(,R9)         LOAD WITH OUR RSA-ADDRESS
         ST    R13,4(,R15)        BACKWARD-CHAIN
         ST    R15,8(,R13)        FORWARD-CHAIN
         LR    R13,R15            LOAD WITH OUR RSA-ADDRESS
         XC    PRMADDR,PRMADDR    ENSURE X'00'S
         LOAD  EPLOC=PRMTRGT,ERRET=BADLOAD     
         STCM  R0,B'1111',PRMADDR STORE IN PARM-FWORD
         XR    R1,R1              ENSURE X'00'S
BADLOAD  EQU   *
         STCM  R1,B'1111',PRMERRCD
RTN2CLLR EQU   *
         L     R13,4(,R13)        RESTORE CALLERS R13
         XC    0(72,R9),0(R9)     ENSURE X'00'S
*
         RETURN (14,12),RC=(15)   RESTORE AND RETURN
*
         LTORG ,           
         YREGS ,                  MVS REGISTER-MACRO
LOADPGM  AMODE 31  ,       
LOADPGM  RMODE ANY ,           
         END   ,               



Code:

HEXTBL   CSECT                                                           
         DC    256AL1(*-HEXTBL)    CREATE ALL 256-BYTE HEXTBL-ENTRIES     
HEXTBL   AMODE 31                                                         
HEXTBL   RMODE ANY                                                       
         END                                                             

Code:

           03  WS-XLATE-TO-TBL     PIC  X(256).
           03  WS-XLATE-FROM-TBL   PIC  X(256).
           03  WS-PROCEDURE-POINTER
                                   PROCEDURE-POINTER.
           03  FILLER REDEFINES    WS-PROCEDURE-POINTER.
               05  WS-LOAD-POINT   POINTER.
               05  FILLER          PIC  X(004).
           03  WS-HEXTBL           PIC  X(008)     VALUE 'HEXTBL'.
           03  WS-LOAD-PGM         PIC  X(008)     VALUE 'LOADPGM'.
           03  WS-LOAD-PGM-PARMLST.
               05  WS-LOAD-PGM-TRGT
                                   PIC  X(008).
               05  WS-LOAD-PGM-ADDR
                                   PIC  9(008)     COMP.
               05  WS-LOAD-PGM-ERROR-CODE
                                   PIC  9(008)     COMP.
               05  WS-LOAD-PGM-RSA PIC  X(072).
       LINKAGE SECTION.
       01  LS-XLATE-FROM-TBL       PIC  X(256).
       PROCEDURE DIVISION.
           MOVE SPACES                 TO WS-XLATE-TO-TBL.
           SET  WS-PROCEDURE-POINTER   TO ENTRY WS-HEXTBL.
           SET  ADDRESS OF LS-XLATE-FROM-TBL
                                       TO WS-LOAD-POINT.
           MOVE LS-XLATE-FROM-TBL      TO WS-XLATE-FROM-TBL.
           MOVE WS-HEXTBL              TO WS-LOAD-PGM-TRGT.
       *
       *   FOR LESS THAN COBOL/370 COMPLIANCE, 'HEXTBL' ADDRESS
       *   CAN BE FOUND IN 'WS-LOAD-PGM-ADDR', AFTER THE 'CALL'.
       *
           CALL WS-LOAD-PGM            USING WS-LOAD-PGM-PARMLST.

Once WS-XLATE-FROM-TBL is populated from the HEXTBL contents, you can then customize WS-XLATE-TO-TBL (first initialized to SPACES), such as what was done in the above LINK.

In order to use PROCEDURE-POINTER, your COBOL version/release must be a minimum of COBOL/370, the successor to VS/COBOL II. If you're still on VS/COBOL II or OS/VS COBOL, you'd have to establish addressability to HEXTBL via an Assembler Sub-Program (see LOADPGM above), which issues an MVS LOAD Macro and returns the load address in a Parmarea Fullword.

Don't ever use PROCEDURE-POINTER or an MVS LOAD Macro in CICS. Rather, use the LOAD PROGRAM API.
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 Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm
No new posts Using Inspect in cobol Ajay Dwivedi COBOL Programming 8 Sat Sep 26, 2015 11:33 pm
No new posts EQUIVALENT OF COBOL INSPECT IN REXX pshongal CLIST & REXX 2 Fri Nov 22, 2013 10:44 am
No new posts Find the occurrence of keywords using... suraaj COBOL Programming 15 Fri Aug 30, 2013 8:27 pm
No new posts Inspect using replace dharmaraok COBOL Programming 9 Fri Aug 16, 2013 10:28 pm


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