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
 

 

COBOL NON PRINTABLE CHARACTERS
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
srinut123

New User


Joined: 11 Oct 2005
Posts: 62
Location: India

PostPosted: Thu Nov 26, 2009 11:21 am    Post subject: COBOL NON PRINTABLE CHARACTERS
Reply with quote

Hi
Requirement: I've to replace all non printable characters with spaces.

Can any one help?
Thanks
SRK
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Thu Nov 26, 2009 3:48 pm    Post subject:
Reply with quote

Use reference modification to look at each character; if it is a "non printable character" (whatever that means to you), change it. The process will run slow since you're looking at every byte, but it's very standard code. There are examples of very similar code on the forum already.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Nov 26, 2009 11:42 pm    Post subject:
Reply with quote

I have done this on many occasions by coding two 256-byte working storage elements - the first containing All of the 256 possible byte values ( x'00' thru x'FF' ), and the second containing the same, except for replacing each "non-printable" position with x'40' - and then using the INSPECT source-field CONVERTING source-values TO target-values. The execution is very fast if the source-field is less than 257 bytes - slower if greater than 256 since it requires looping under the covers. Here's the code:
Code:

In Working Storage:

       01  SOURCE-VALUES.
           05  PIC X(16) VALUE X'000102030405060708090A0B0C0D0E0F'.
           05  PIC X(16) VALUE X'101112131415161718191A1B1C1D1E1F'.
           05  PIC X(16) VALUE X'202122232425262728292A2B2C2D2E2F'.
           05  PIC X(16) VALUE X'303132333435363738393A3B3C3D3E3F'.
           05  PIC X(16) VALUE X'404142434445464748494A4B4C4D4E4F'.
           05  PIC X(16) VALUE X'505152535455565758595A5B5C5D5E5F'.
           05  PIC X(16) VALUE X'606162636465666768696A6B6C6D6E6F'.
           05  PIC X(16) VALUE X'707172737475767778797A7B7C7D7E7F'.
           05  PIC X(16) VALUE X'808182838485868788898A8B8C8D8E8F'.
           05  PIC X(16) VALUE X'909192939495969798999A9B9C9D9E9F'.
           05  PIC X(16) VALUE X'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.
           05  PIC X(16) VALUE X'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.
           05  PIC X(16) VALUE X'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.
           05  PIC X(16) VALUE X'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.
           05  PIC X(16) VALUE X'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.
           05  PIC X(16) VALUE X'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
       01  TARGET-VALUES.
           05  PIC X(16) VALUE X'40404040404040404040404040404040'.
           05  PIC X(16) VALUE X'40404040404040404040404040404040'.
           05  PIC X(16) VALUE X'40404040404040404040404040404040'.
           05  PIC X(16) VALUE X'40404040404040404040404040404040'.
           05  PIC X(16) VALUE X'404040404040404040404A4B4C4D4E4F'.
           05  PIC X(16) VALUE X'504040404040404040405A5B5C5D5E5F'.
           05  PIC X(16) VALUE X'606140404040404040406A6B6C6D6E6F'.
           05  PIC X(16) VALUE X'404040404040404040797A7B7C7D7E7F'.
           05  PIC X(16) VALUE X'40818283848586878889404040404040'.
           05  PIC X(16) VALUE X'40919293949596979899404040404040'.
           05  PIC X(16) VALUE X'40A1A2A3A4A5A6A7A8A9404040404040'.
           05  PIC X(16) VALUE X'40404040404040404040404040404040'.
           05  PIC X(16) VALUE X'C0C1C2C3C4C5C6C7C8C9404040404040'.
           05  PIC X(16) VALUE X'D0D1D2D3D4D5D6D7D8D9404040404040'.
           05  PIC X(16) VALUE X'E040E2E3E4E5E6E7E8E9404040404040'.
           05  PIC X(16) VALUE X'F0F1F2F3F4F5F6F7F8F9404040404040'.

In Procedure Division

           INSPECT source-field CONVERTING SOURCE-VALUES TO TARGET-VALUES
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: Fri Nov 27, 2009 3:01 am    Post subject:
Reply with quote

Hello,

Another way to do this is to use the input value as the displacement into the "target array" and simply "move" the target value to the output byte. It would require a loop to process the input string.

This may (or may not) use less cpu cycles than the inspect. It has been too long since i did any timing testing on something like this for me to say positively.
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: Fri Nov 27, 2009 8:45 am    Post subject: Reply to: COBOL NON PRINTABLE CHARACTERS
Reply with quote

A pre-defined translate-table is often defined in a shop, which contains all 256-byte values and can be accessed from both Batch and CICS. This table is Assembled and Linked as if it were a plain-jane Batch Assembler program. It would be incorrect to run this through the CICS translator and then Assembling/Linking it as a CICS/Assembler program -

Code:

TRANSTBL CSECT                                                           
         DC    256AL1(*-TRANSTBL) CREATE ALL ENTRIES, X'00' - X'FF'   
TRANSTBL AMODE 31                                                         
TRANSTBL RMODE ANY                                                       
         END   

Assuming this is Batch (don't EVER use the following technique in CICS) you can keep the previously defined TARGET-VALUES group (these are the keepers) and define the SOURCE-VALUES group simply as -

Code:

01  SOURCE-VALUES PIC  X(256).

Then define the following -

Code:


WORKING-STORAGE SECTION.
01  WS-MISCELLANEOUS.
    03  WS-PROCEDURE-POINTER PROCEDURE-POINTER.
    03  FILLER               REDEFINES WS-PROCEDURE-POINTER.
        05  WS-LOAD-POINT    POINTER.
        05  FILLER           PIC  X(04).
    03  WS-TRANSTBL          PIC  X(08) VALUE 'TRANSTBL'.
LINKAGE SECTION.
01  LS-TRANSTBL-DSECT        PIC  X(256).
PROCEDURE DIVISION.
*
    SET  WS-PROCEDURE-POINTER         TO ENTRY WS-TRANSTBL.
    SET  ADDRESS OF LS-TRANSTBL-DSECT TO WS-LOAD-POINT.
    MOVE LS-TRANSTBL-DSECT            TO SOURCE-VALUES.

You've now loaded the pre-defined/static Assembler TRANSTBL into memory, established addressability to the LINKAGE SECTION "DSECT" assigned to TRANSTBL and moved the contents of the "DSECT" (values X'00' through X'FF') to the WS 01-level SOURCE-VALUES. In fact, SOURCE-VALUES can be considered optional as your FROM-TBL data can be found in LS-TRANSTBL-DSECT.

PROCEDURE-POINTER was introduced with COBOL/370, nearly 20 years ago and if you're using COBOL2 (or OS/VS COBOL for that matter), then this technique won't work and you'd need to Call an Assembler sub-program, which issues an MVS LOAD Macro, to mimic a PROCEDURE-POINTER.

Note that the COBOL Batch program must have been compiled with the compiler option DYNAM, which is typically used in Batch.

Having a pre-defined/static TRANSTBL in a shop's utility arsenal removes the redundancy of having to code this table in every program where it's needed.

FWIW, CICS access is performed via a "LOAD PROGRAM" API.

Bill
Back to top
View user's profile Send private message
srinut123

New User


Joined: 11 Oct 2005
Posts: 62
Location: India

PostPosted: Fri Nov 27, 2009 10:02 am    Post subject: Reply to: COBOL NON PRINTABLE CHARACTERS
Reply with quote

Many Thanks for your inputs.
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Wed Oct 06, 2010 6:01 pm    Post subject:
Reply with quote

Ronald , i tried ur method but while compilation it gives below error:
Can you please help out?

IGYPA3097-S
IDENTIFIER "WS-SOURCE (GROUP)" WAS NEITHER AN ELEMENTARY ITEM WITH "USAGE DISPLAY", "USAGE DISPLAY-1" OR "USAGE NATIONAL" NOR AN ALPHANUMERIC OR NATIONAL FUNCTION. THE STATEMENT WAS DISCARDED.


IGYPA3097-S
IDENTIFIER "WS-TARGET (GROUP)" WAS NEITHER AN ELEMENTARY ITEM WITH "USAGE DISPLAY", "USAGE DISPLAY-1" OR "USAGE NATIONAL" NOR AN ALPHANUMERIC OR NATIONAL FUNCTION. THE STATEMENT WAS DISCARDED.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Oct 06, 2010 6:10 pm    Post subject: Reply to: COBOL NON PRINTABLE CHARACTERS
Reply with quote

nobody can help You out because...
You did not use the code posted as is,
You did not post the code used !
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Wed Oct 06, 2010 6:14 pm    Post subject:
Reply with quote

here's the code used

Code:

IDENTIFICATION DIVISION.                                         
PROGRAM-ID.              SMPLEUC.                               
AUTHOR.                     XXXX.                                 
ENVIRONMENT DIVISION.                                           
CONFIGURATION SECTION.                                           
SOURCE-COMPUTER. IBM-3390.                                       
INPUT-OUTPUT SECTION.                                           
DATA DIVISION.                                                   
WORKING-STORAGE SECTION.                                         
01 WS-DATA                         PIC X(50) VALUE               
        'ABÄÆm|JKLOMM'.                                         
01 WS-SOURCE.                                                   
   05        PIC X(16) VALUE X'000102030405060708090A0B0C0D0E0F'.
   05        PIC X(16) VALUE X'101112131415161718191A1B1C1D1E1F'.
   05        PIC X(16) VALUE X'202122232425262728292A2B2C2D2E2F'.
   05        PIC X(16) VALUE X'303132333435363738393A3B3C3D3E3F'.
   05        PIC X(16) VALUE X'404142434445464748494A4B4C4D4E4F'.
   05        PIC X(16) VALUE X'505152535455565758595A5B5C5D5E5F'.
   05        PIC X(16) VALUE X'606162636465666768696A6B6C6D6E6F'.
   05        PIC X(16) VALUE X'707172737475767778797A7B7C7D7E7F'.
   05        PIC X(16) VALUE X'808182838485868788898A8B8C8D8E8F'.
   05        PIC X(16) VALUE X'909192939495969798999A9B9C9D9E9F'.
   05        PIC X(16) VALUE X'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.
   05        PIC X(16) VALUE X'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.
   05        PIC X(16) VALUE X'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.
   05        PIC X(16) VALUE X'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.
   05        PIC X(16) VALUE X'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.
   05        PIC X(16) VALUE X'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
01 WS-TARGET                                                     
   05        PIC X(16) VALUE X'40404040404040404040404040404040'.
   05        PIC X(16) VALUE X'40404040404040404040404040404040'.
   05        PIC X(16) VALUE X'40404040404040404040404040404040'.
   05        PIC X(16) VALUE X'40404040404040404040404040404040'.
   05        PIC X(16) VALUE X'404040404040404040404A4B4C4D4E4F'.
   05        PIC X(16) VALUE X'504040404040404040405A5B5C5D5E5F'.
   05        PIC X(16) VALUE X'606140404040404040406A6B6C6D6E6F'.
   05        PIC X(16) VALUE X'404040404040404040797A7B7C7D7E7F'.
   05        PIC X(16) VALUE X'40818283848586878889404040404040'.
   05        PIC X(16) VALUE X'40919293949596979899404040404040'.
   05        PIC X(16) VALUE X'40A1A2A3A4A5A6A7A8A9404040404040'.
   05        PIC X(16) VALUE X'40404040404040404040404040404040'.
   05        PIC X(16) VALUE X'C0C1C2C3C4C5C6C7C8C9404040404040'.
   05        PIC X(16) VALUE X'D0D1D2D3D4D5D6D7D8D9404040404040'.
   05        PIC X(16) VALUE X'E040E2E3E4E5E6E7E8E9404040404040'.
   05        PIC X(16) VALUE X'F0F1F2F3F4F5F6F7F8F9404040404040'.
 PROCEDURE DIVISION.                                       
 A000-MAIN-CONTROL SECTION.                               
     DISPLAY 'BEFORE: ' WS-DATA                           
     INSPECT WS-DATA CONVERTING WS-SOURCE TO WS-TARGET     
     DISPLAY 'AFTER:  ' WS-DATA                           
     STOP RUN                                             
     .                                                     
 A000-EXIT.                                               
     EXIT.                                                 
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: Wed Oct 06, 2010 7:11 pm    Post subject:
Reply with quote

Hello,

Which compiler is being used?

This is printed at the top of a compilation.
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Wed Oct 06, 2010 7:52 pm    Post subject:
Reply with quote

Not sure if this is it...

1PP 5655-S71 IBM ENTERPRISE COBOL FOR Z/OS 4.1.0 CS12
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: Wed Oct 06, 2010 7:57 pm    Post subject:
Reply with quote

essence21 wrote:
Not sure if this is it...

1PP 5655-S71 IBM ENTERPRISE COBOL FOR Z/OS 4.1.0 CS12

Then, Ron's code should work as the minimum COBOL version/release is VS/COBOL II, over 20+ years ago.

Bill
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Wed Oct 06, 2010 8:30 pm    Post subject:
Reply with quote

icon_sad.gif Apparently something is going wrong somewhere by me and i am not able to spot it icon_sad.gif
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: Wed Oct 06, 2010 8:35 pm    Post subject: Reply to: COBOL NON PRINTABLE CHARACTERS
Reply with quote

Note that (based upon your posted code), the WS-TARGET 01-Level does not have a delineating period, which should raise an "E" level error during compilation.

Otherwise, everything else looks fine....

Bill
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Wed Oct 06, 2010 8:45 pm    Post subject:
Reply with quote

Nope .. Just put in a period and tried again.. No luck...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Oct 06, 2010 9:42 pm    Post subject:
Reply with quote

from the compiler output,
what does the OPTIONS page look like.
(cut&paste, please).
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Wed Oct 06, 2010 9:49 pm    Post subject:
Reply with quote

I hope you mean this:

OPTIONS IN EFFECT:
NOADATA
ADV
APOST
ARITH(COMPAT)
NOAWO
BUFSIZE(16384)
NOCICS
CODEPAGE(1146)
NOCOMPILE(S)
NOCURRENCY
DATA(31)
NODATEPROC
NODBCS
NODECK
NODIAGTRUNC
NODLL
NODUMP
NODYNAM
NOEXIT
NOEXPORTALL
NOFASTSRT
FLAG(I,E)
NOFLAGSTD
INTDATE(ANSI)
LANGUAGE(UE)
LIB
LINECOUNT(60)
LIST
MAP
NOMDECK
NONAME
NSYMBOL(DBCS)
NONUMBER
NUMPROC(NOPFD)
OBJECT
NOOFFSET
NOOPTIMIZE
OUTDD(SYSOUT)
PGMNAME(COMPAT) TEST(NOHOOK,SEPARATE,NOEJPD)
NOTHREAD
TRUNC(OPT)
NOVBREF
WORD(TBL1)
XMLPARSE(XMLSS)
XREF(FULL)
YEARWINDOW(1900)
ZWB
RENT
RMODE(AUTO)
NOSEQUENCE
SIZE(MAX)
SOURCE
SPACE(1)
NOSQL
SQLCCSID
NOSSRANGE
NOTERM
TEST(NOHOOK,SEPARATE,NOEJPD)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Oct 06, 2010 10:49 pm    Post subject:
Reply with quote

do the errors reference the INSPECT statement?
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Oct 07, 2010 12:53 am    Post subject:
Reply with quote

Sorry about that. I "wrote" the code by memory rather than by cut/paste.
The SOURCE-VALUES and TARGET-VALUES data items MUST be elementary items - not group items (as was the case in my first code example ). The code should be corrected to mirror this example (note the lines that redefine the source/target values).
Code:
In Working Storage:

       01  CONVERSION-TABLES.
           05 SOURCE-BYTES.
              03  PIC X(16) VALUE X'000102030405060708090A0B0C0D0E0F'.
              03  PIC X(16) VALUE X'101112131415161718191A1B1C1D1E1F'.
              03  PIC X(16) VALUE X'202122232425262728292A2B2C2D2E2F'.
              03  PIC X(16) VALUE X'303132333435363738393A3B3C3D3E3F'.
              03  PIC X(16) VALUE X'404142434445464748494A4B4C4D4E4F'.
              03  PIC X(16) VALUE X'505152535455565758595A5B5C5D5E5F'.
              03  PIC X(16) VALUE X'606162636465666768696A6B6C6D6E6F'.
              03  PIC X(16) VALUE X'707172737475767778797A7B7C7D7E7F'.
              03  PIC X(16) VALUE X'808182838485868788898A8B8C8D8E8F'.
              03  PIC X(16) VALUE X'909192939495969798999A9B9C9D9E9F'.
              03  PIC X(16) VALUE X'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.
              03  PIC X(16) VALUE X'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.
              03  PIC X(16) VALUE X'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.
              03  PIC X(16) VALUE X'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.
              03  PIC X(16) VALUE X'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.
              03  PIC X(16) VALUE X'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
           05 SOURCE-VALUES REDEFINES SOURCE-BYTES  PIC X(256).
           05 TARGET-BYTES.
              03  PIC X(16) VALUE X'40404040404040404040404040404040'.
              03  PIC X(16) VALUE X'40404040404040404040404040404040'.
              03  PIC X(16) VALUE X'40404040404040404040404040404040'.
              03  PIC X(16) VALUE X'40404040404040404040404040404040'.
              03  PIC X(16) VALUE X'404040404040404040404A4B4C4D4E4F'.
              03  PIC X(16) VALUE X'504040404040404040405A5B5C5D5E5F'.
              03  PIC X(16) VALUE X'606140404040404040406A6B6C6D6E6F'.
              03  PIC X(16) VALUE X'404040404040404040797A7B7C7D7E7F'.
              03  PIC X(16) VALUE X'40818283848586878889404040404040'.
              03  PIC X(16) VALUE X'40919293949596979899404040404040'.
              03  PIC X(16) VALUE X'40A1A2A3A4A5A6A7A8A9404040404040'.
              03  PIC X(16) VALUE X'40404040404040404040404040404040'.
              03  PIC X(16) VALUE X'C0C1C2C3C4C5C6C7C8C9404040404040'.
              03  PIC X(16) VALUE X'D0D1D2D3D4D5D6D7D8D9404040404040'.
              03  PIC X(16) VALUE X'E040E2E3E4E5E6E7E8E9404040404040'.
              03  PIC X(16) VALUE X'F0F1F2F3F4F5F6F7F8F9404040404040'.
           05 TARGET-VALUES REDEFINES TARGET-BYTES  PIC X(256).

In Procedure Division

           INSPECT source-field CONVERTING SOURCE-VALUES TO TARGET-VALUES.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Oct 07, 2010 1:17 am    Post subject:
Reply with quote

Ronald Burr,

thanks for the clarification. I spent some time going thru the manual and
missed the part that identifier-6 & 7 had to be elementary items.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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