×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Turn variable into a string

Turn variable into a string

Turn variable into a string

(OP)
Hello!

I set a variable by adding values. Thus it is an integer. But later on I need it as a string. How can I convert it into a string?

Here's the code:

-SET &MONAT1 = IF &MONAT GE '02'
-               THEN &MONAT -1
-              ELSE &MONAT + 11;


(where &MONAT is given by the user in a prompt)

Later I use it in a WHERE statement:

WHERE MONAT EQ '&MONAT' OR MONAT EQ '&MONAT1'


The part OR MONAT EQ '&MONAT1' is not considered (the data is present in the database). I used also OR MONAT EQ &MONAT1 but then I get the error message
"(FOC280) VERGLEICH ZWISCHEN ZIFFERN UND BUCHSTABEN NICHT MÖGLICH"
which translates into comparison between numbers and characters is not possible. That's why I'd like to have the variable &MONAT1 as a string.

Eva

RE: Turn variable into a string

Eva,

Firat question is, what format is the field MONAT? If alpha, then you need quotes around the literals; if numeric, then the quotes should be removed.

If that doesn't resolve the issue, try putting parentheses around each comparison, like this:

WHERE (MONAT EQ '&MONAT') OR (MONAT EQ '&MONAT1')

RE: Turn variable into a string

Try this.  I'm not sure it works but it should.

WHERE (MONAT EQ EDIT(&MONAT)) OR (MONAT EQ EDIT(&MONAT1))


The simple EDIT() (with no mask) turns numeric to character and vice-versa.  Not sure if it works with ¶meters.

RE: Turn variable into a string

Eva,

if you're still having difficulty, try

WHERE MONAT EQ '&MONAT.EVAL' OR MONAT EQ '&MONAT1.EVAL';

I don't know the exact rules for using .EVAL but it's always the first thing I try when errors like this occur.

RE: Turn variable into a string

Eva,

What the FOCWIZARD is telling you is that &MONAT and &MONAT1 are already strings. Thus, if the field MONAT is a number, you statement should read;

  WHERE (MONAT EQ &MONAT) OR (MONAT EQ &MONAT1);

If the field MONAT is alphanumeric, your statement should be:

  WHERE (MONAT EQ '&MONAT') OR (MONAT EQ '&MONAT1');

The parentheses are not necessary, but I think they clarify the logic. Neither 'EDIT' nor 'EVAL' add anything to your situation.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close