on 10-18-2005 1:12 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian and Rich,
thank you for your fast reply.
I've written one TRY method that has a import-parameter with TYPE ANY and a import-parameter for the target field.
The target field can be everything like P,I,F,N,C,D.
The method checks if the value can be converted into the target field and avoid a shortdump, when the flatfile contains bad data.
So I have to get the type by
cl_abap_typedescr=>describe_by_data
and then make your suggested Conatins-only-check if it is a
cl_abap_typedescr=>typekind_num
???
Thanks,
Stefan
Hi Stefan,
I have the feeling, I can follow your description a little better now. You are writing an extension / own TRY-method? Wow!
But yes, this would be the logic: in case of typekind_num, place the if ... CO numbers
Isn't this the way, you are checking the other types, too? Of course with different IF-clause, but testing some rules to be fulfilled?
Regards,
Christian
Try something like this...
IF field CN '0123456789'.
* This field is not all numeric
ENDIF.
Regards,
Rich Heilman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.