Skip to Content
author's profile photo Former Member
Former Member

check a convertion from CHAR TO NUMC

Hi,

I import a flatfile into a structure that contains only CHAR-fields. Then I make a TRY-CATCH construct for every field in P,I,F,N..-datatypes to check if the data is correct.

P,I,F raise a CONVERT-Exception that i can handle.

A move to N-field raise no exception but put a wrong values to the N-field.

Example:

Charfield contains ' 1 1 0000', N-field is '110000'.

A compare in the program like

IF C-Field <> N-Field raise a exception that can't be catched by TRY-Catch.

How can i check if the field is correct?

Anybody understand me and have an idea?

Regards,

Stefan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 18, 2005 at 12:18 PM

    Hi Stefan!

    I'm not sure, if I could follow you: the If C-field is outside your program?

    Nevertheless, add some checks / conversions before you try to move into a N-field:

    - Depending if you would like to accept your example, use condense

    - replace space with 0 (e.g. use translate ' 0')

    - only convert, if c-field CO '0123456789'.

    Especially the 'contains only' should prevent any problems during the conversion.

    Regards,

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 18, 2005 at 12:16 PM

    Try something like this...

    IF field CN '0123456789'.
    * This field is not all numeric
    ENDIF.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.