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
 

 

Need to skip junk value from the processing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need to skip junk value from the processing
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Apr 25, 2013 3:08 am    Post subject: Reply to: Need to skip junk value from the processing
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: 7913
Location: Bellevue, IA

PostPosted: Thu Apr 25, 2013 5:29 am    Post subject:
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: 56
Location: Boston

PostPosted: Fri Apr 26, 2013 1:50 am    Post subject: Reply to: Need to skip junk value from the processing
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 26, 2013 2:37 am    Post subject: Reply to: Need to skip junk value from the processing
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

Site Director


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

PostPosted: Fri Apr 26, 2013 6:48 am    Post subject:
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

Senior Member


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

PostPosted: Fri Apr 26, 2013 10:54 am    Post subject:
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: 56
Location: Boston

PostPosted: Fri Apr 26, 2013 7:30 pm    Post subject: Reply to: Need to skip junk value from the processing
Reply with quote

Thanks for correcting me !! icon_redface.gif
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 Apr 26, 2013 7:37 pm    Post subject:
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    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 Run stats processing on zIIP Engine Virendra Shambharkar DB2 9 Fri Oct 14, 2016 10:24 am
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts why i need hit enter after EXECIO * D... jackzhang75 CLIST & REXX 10 Fri May 20, 2016 9:16 pm
No new posts Extracting Information from DD Statem... Charles Wolters All Other Mainframe Topics 7 Wed Apr 13, 2016 10:21 pm
No new posts how to implement multi-thread process... dejunzhu COBOL Programming 7 Sat Oct 31, 2015 2:15 pm


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