PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03/14/2013 11:13 AM by  Chad Dirst
Handling Bad Data
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Chad Dirst
Software Manager
EDMC
Advanced Member
(61 points)
Advanced Member
Posts:33


Send Message:

--
03/13/2013 9:39 PM

    Greetings,

    We have some bad data in our database which is causing issues in one of our interface programs.  We are working on ensuring this data does not get entered on the front end, however, we are also looking to have checks in the interface program to ensure we can handle the data appropriately.

     

    Here is a sample of the data as seen via SQL

        Staplesßéó  Medium-Weight

    Here is a sample of the data as seen in the Debugger:
        Staples^^^^ Medium-Weight

    I have tried to define a table of all hexidecimal characters (see sample WS section below) and then use the following statement to "clean" the data.

     

    INSPECT MAD-ITEM-DESC CONVERTING WS-SOURCE TO SPACES.

    However, this does not solve the issue.  It does end up concerting regular ascii characters to spaces, however, still leaves "bad" data. 

     

    Any advise/suggestions would be greatly appreciated.

     

    Thank you in advance.

     

    01 WS-SOURCE.

              05 FILLER PIC X(01) VALUE X"00".
              05 FILLER PIC X(01) VALUE X"01".
              05 FILLER PIC X(01) VALUE X"02".
              05 FILLER PIC X(01) VALUE X"03".
              05 FILLER PIC X(01) VALUE X"04".
              05 FILLER PIC X(01) VALUE X"05".
               ……………………..
               ……………………..
               ……………………..

    Ragu Raghavan
    Private
    Private
    Veteran Member
    (823 points)
    Veteran Member
    Posts:287


    Send Message:

    --
    03/13/2013 10:42 PM
    How about something like this: assuming the field WS-DESCRIPTION is X(30)

    PERFORM VARYING WS-INDEX FROM 1 BY 1
    UNTIL (WS-INDEX > 30)
    IF (WS-DESCRIPTION(WS-INDEX:1) NOT NUMERIC)
    AND (WS-DESCRIPTION(WS-INDEX:1) NOT ALPHABETIC)
    MOVE SPACES TO WS-DESCRIPTION(WS-INDEX:1)
    END-IF
    END-PERFORM
    Chad Dirst
    Software Manager
    EDMC
    Advanced Member
    (61 points)
    Advanced Member
    Posts:33


    Send Message:

    --
    03/14/2013 11:13 AM
    Thank you.  That solution does remove the "bad" data from the field.  The exact code I used was:

    PERFORM
      VARYING I1 FROM 1 BY 1
         UNTIL (I1 > 30
         IF     (MAD-ITEM-DESC(I1:1)   NOT NUMERIC)
         AND (MAD-ITEM-DESC(I1:1)   NOT ALPHABETIC)
              MOVE SPACES            TO MAD-ITEM-DESC(I1:1)
         END-IF
    END-PERFORM.
    You are not authorized to post a reply.