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

Need to skip junk value from the processing


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

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Thu Apr 25, 2013 2:45 am
Reply with quote

Hello All,

I have a program for which the input file has some junk value, i am not getting how to handle it in the code, i have tried below code.

Its not working.

Code:
IF NOT WS-KO-CODE  =  LOW-VALUES 
   CONTINUE                       
ELSE                             
   MOVE SPACES  TO WS-KO-CODE     
END-IF.                 



Value for WS-KO-CODE in hex format.

Code:
4444444
0000000
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Thu Apr 25, 2013 3:08 am
Reply with quote

What values do you consider "keepers", such as alphabetic letters (upper/lower case), numerics 0-9, etc?

The following code keeps alphabetic letters (upper/lower) as well as numerics 0-9. All other values are converted to spaces. Note, the code uses COBOL Special-Register TALLY, which is perfectly legitimate -

Code:

           03  WS-XLATE-FROM-TBL   PIC  X(256).
           03  WS-XLATE-TO-TBL     PIC  X(256).
           03  WS-SUB              PIC  9(008)     COMP.
           03  WS-SUB-X            REDEFINES WS-SUB
                                   PIC  X(004).
           03  WS-KEEPER-KTR       PIC  9(008)     COMP.
           03  WS-MIXED-KTR        PIC  9(008)     COMP.
           03  WS-BAD-KTR          PIC  9(008)     COMP.
                                               
      *     
           MOVE ZERO                   TO WS-SUB.
           MOVE 1                      TO TALLY.
      * 
           PERFORM UNTIL TALLY > LENGTH OF WS-XLATE-FROM-TBL
               MOVE WS-SUB-X (4:1)     TO WS-XLATE-FROM-TBL (TALLY:1)
               ADD  1                  TO TALLY
               ADD  1                  TO WS-SUB
           END—PERFORM.
      *
           MOVE SPACES                 TO WS-XLATE-TO-TBL.
           MOVE ZERO                   TO WS-KEEPER-KTR.
           MOVE ZERO                   TO WS-MIXED-KTR.
           MOVE ZERO                   TO WS-BAD-KTR.
           MOVE WS-XLATE-FROM-TBL (129:)
                                       TO WS-XLATE-TO-TBL (129:9).
           MOVE WS-XLATE-FROM-TBL (145:)
                                       TO WS-XLATE-TO-TBL (145:9).
           MOVE WS-XLATE-FROM-TBL (162:)
                                       TO WS-XLATE-TO—TBL (162:8).
           MOVE WS-XLATE-FROM-TBL (193:)
                                       TO WS-XLATE-TO-TBL (193:9).
           MOVE WS-XLATE-FROM-TBL (209:)
                                       TO WS-XLATE-TO-TBL (209:9).
           MOVE WS-XLATE-FROM-TBL (226:)
                                       TO WS-XLATE-TO-TBL (226:8).
           MOVE WS-XLATE-FROM-TBL (240:)
                                       TO WS-XLATE-TO-TBL (240:10).
           MOVE ZERO                   TO TALLY.
      *
           INSPECT WS-KO-CODE          CONVERTING WS-XLATE-FROM-TBL
                                       TO WS-XLATE-TO-TBL.
      *
           INSPECT WS-KO-CODE          TALLYING TALLY FOR ALL SPACE.
      *
           EVALUATE TALLY
               WHEN < 1                     
                   ADD  1              TO WS-KEEPER-KTR
               WHEN < LENGTH OF WS-KO-CODE
                   ADD  1              TO WS-MIXED-KTR
               WHEN OTHER
                   ADD  1              TO WS-BAD-KTR
           END-EVALUATE.           

After the first INSPECT, WS-KO-CODE will contain all SPACES or a mixture of SPACES and legitimate characters or all legitimate characters.

After the second INSPECT, if TALLY is equal to the LENGTH OF WS-KO-CODE (4) then WS-KO-CODE contains non-keepers and were converted to SPACE. If TALLY is equal to ZERO, then all characters are legitimate. IF TALLY equals 1, 2 or 3, then it contains a mixture of legitimate and non-legitimate (SPACES) characters, either interspersed or sequential.

HTH....
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 25, 2013 5:29 am
Reply with quote

There is no such thing as a junk value in COBOL. Every byte has a value from the 256 possible values of the EBCDIC collating sequence. Whether or not that value is one you expected, that is a different question.

The data you posted indicates the variable contained SPACES, not LOW-VALUES. Spaces are X'40' and LOW-VALUES are X'00'. Since you did not indicates what are the good data values for your variable, you might implement Bill's solution.
Back to top
View user's profile Send private message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 62
Location: Boston

PostPosted: Fri Apr 26, 2013 1:50 am
Reply with quote

I am not clear, even Bill is proposing to make spaces which are already having space in the field WS-KO-CODE.
Do having spaces is a junk value?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Apr 26, 2013 2:37 am
Reply with quote

For those values which you consider to be "junk", what value (if at all) would you like them to be converted? An example would be X'00' converts to X'40'.

If WS-KO-CODE contains values which are partial or totally "junk", what do you need to do with the contents?

Do you write these exceptions to a report? (you'll need to convert the contents of WS-KO-CODE to 8-bytes of displayable-hex, which is not too difficult).

Please advise....
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: Fri Apr 26, 2013 6:48 am
Reply with quote

Hello,

Quote:
Do having spaces is a junk value?
No - as has been explained There Are No Junk Values. Suggest you lose the term "junk values". Some around you may believe this sounds "cool" but it surely is not.

You need to establish (or obtain) the data rules - then enforce them. By whatever code is needed. If the processing is to continue when invalid data is encountered, you need to define the replacement/default value that will be substituted for the invalid value.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Apr 26, 2013 10:54 am
Reply with quote

Are Amsar (OP) and 'Karthikeyan Subbarayan' following-on on the same problem...?
Back to top
View user's profile Send private message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 62
Location: Boston

PostPosted: Fri Apr 26, 2013 7:30 pm
Reply with quote

Thanks for correcting me !! icon_redface.gif
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: Fri Apr 26, 2013 7:37 pm
Reply with quote

You're welcome icon_smile.gif

Several of us work hard to improve the terms used.

d
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Identify unused (junk) REXX scripts TSO/ISPF 30
No new posts icetool empty file and not empty file... DFSORT/ICETOOL 5
No new posts SKIP LOCKED DATA in UPDATE statement DB2 9
No new posts CICS file processing using applicatio... CICS 3
Search our Forums:

Back to Top