Handling Bad Data

Sort:
You are not authorized to post a reply.
Author
Messages
Chad Dirst
Advanced Member
Posts: 42
Advanced Member

    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
    Veteran Member
    Posts: 468
    Veteran Member
      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
      Advanced Member
      Posts: 42
      Advanced Member
        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.