Focal Point
Can I assign a field name to an &var?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4041087331

June 04, 2004, 04:30 PM
<Jim Rich>
Can I assign a field name to an &amp;var?
I want to assign Defined Field Name to an &var to I can display it in other than a Heading section.

TD/YYM- = '&thrud';
FD/YYM- = TD - 11;
ADATE/A6YYM-=FD;
BDATE/A8=ADATE;
CDATE/A8=EDIT(BDATE,'9999')||('-'||EDIT(BDATE,'$$$$99'));

CDATE contains the value I want to use.
I have tried:
SET &cdate = CDATE
-SET &cdate = CDATE
-DEFAULT &cdate = CDATE
&cdate =
All of the above with/without the < and '' with no luck. The most I get is nothing or CDATE rather than the value of CDATE.

Any clues?
June 04, 2004, 05:49 PM
susannah
take the ' away from your &var;
TD/YYM- = '&thrud';
should be
TD/YYM = &thrud ;
also, that dash - after the format YYM-
is goofy; whats up with that?
In your code below, you want to read out to an &var.
you have 2 choices;
1) do all the date calcs in dialog manager. (best way)
2) after the defines,write the CDATE out to a file, then READ the file with a -READ , setting your new &var.
June 04, 2004, 06:16 PM
<Jim Rich>
Here is a larger part of the code
I need '&thrud' with the quotes because it is coming in as an text string. My problem is how to set &cdate to equal to value of CDATE rather than the word in both my ACROSS statement and my Heading.

DEFINE FILE LOG_KPI_SMRY ADD
TD/YYM- = '&thrud';
FD/YYM- = TD - 11;
ADATE/A6YYM-=FD;
BDATE/A8=ADATE;
CDATE/A8=EDIT(BDATE,'9999')||('-'||EDIT(BDATE,'$$$$99'));
DEFCNT/I6 WITH JOB_OID = IF JOB_OID IS MISSING THEN 0 ELSE 1;
SUB_PSL_NM/A64 WITH SUB_PSL_NM = 'Global';
END
-SET &cdate = CDATE

TABLE FILE LOG_KPI_SMRY
SUM
SUB_PSL_NM NOPRINT OVER
DEFCNT AS 'Number of Jobs' OVER
LT_JOB_FLG AS 'Number of Lost Time Jobs' OVER
TOT_NBR_SRVC AS 'Number of Services' OVER
....
COMPUTE SERV1/D12.2 = TOT_NBR_SRVC / NBR_LT_FAIL; AS 'Services per LT Failure' OVER
COMPUTE SERV2/D12.2 = TOT_NBR_SRVC / DEFCNT; AS 'Services per Jobs'

WHERE ( JOB_YR_MO GE CDATE );
WHERE ( JOB_YR_MO LE '&thrud' );
LIKE '&loc' ) OR ( PLNT_NM LIKE '&loc' );
WHERE ( PRNT_CUST_NM LIKE '&custname' ) OR ( CUST_NM LIKE '&custname' );
WHERE ( SUB_PSL_NM LIKE '&subpsl' );
ACROSS SUB_PSL_NM AS '&cdate - &thrud'

ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
HEADING
" KPI Comparison Report "
" &cdate - &thrud "
END
June 09, 2004, 09:16 AM
Tony A
Jim

Change the heading section to -

HEADING<br />" KPI Comparison Report "<br />" <CDATE - &thrud " 
That will use the field value that you want.

Incidently, the reason you can not use a field value in an amper variable in this manner is that setting an amper variable is a dialogue manager function and settings are performed outside of the actual TABLE request.

As has been mentioned, you can table the file and save the output the read the value in.

Using the actual data value as suggested above is the way to go.
June 09, 2004, 01:03 PM
Mikel
Jim,

In this case, you can calculate variable values before request, &THRUD and &CDATE would be constants, not data depending fields. After, you can use these variables anywhere. Try the following example:


-* Variables definition.
-DEFAULT &THRUD1 = 200406 ;
-SET &CDATE1 = AYM(&THRUD1 , -11, 'I6') ;
-SET &THRUD2 = EDIT(&THRUD1, '9999-99') ;
-SET &CDATE2 = EDIT(&CDATE1, '9999-99') ;

-* Test variables:
-TYPE THRUD1 - &THRUD1
-TYPE CDATE1 - &CDATE1
-TYPE THRUD2 - &THRUD2
-TYPE CDATE2 - &CDATE2

-* Fields definition.
DEFINE FILE LOG_KPI_SMRY ADD
DEFCNT/I6 WITH JOB_OID = IF JOB_OID IS MISSING THEN 0 ELSE 1;
SUB_PSL_NM/A64 WITH SUB_PSL_NM = 'Global';
END

-* Report.
TABLE FILE LOG_KPI_SMRY
HEADING
"KPI Comparison Report "
"From &CDATE2 to &THRUD2 "
" "
SUM
SUB_PSL_NM NOPRINT OVER
DEFCNT AS 'Number of Jobs' OVER
LT_JOB_FLG AS 'Number of Lost Time Jobs' OVER
TOT_NBR_SRVC AS 'Number of Services' OVER
....
ACROSS SUB_PSL_NM AS 'From &CDATE2 to &THRUD2'

WHERE JOB_YR_MO GE '&CDATE1' ;
WHERE JOB_YR_MO LE '&THRUD1' ;
...
END

I hope this helps. Regards,
Mikel

This message has been edited. Last edited by: <Mabel>,
June 16, 2004, 08:17 PM
<Jim Rich>
quote:
Originally posted by Tony Alsford:
[qb] Jim

Change the heading section to -

HEADING<br />" KPI Comparison Report "<br />" <CDATE - &thrud " 
That will use the field value that you want.

Incidently, the reason you can not use a field value in an amper variable in this manner is that setting an amper variable is a dialogue manager function and settings are performed outside of the actual TABLE request.

As has been mentioned, you can table the file and save the output the read the value in.

Using the actual data value as suggested above is the way to go. [/qb]
----
I tried using
June 16, 2004, 08:19 PM
<Jim Rich>
quote:
Originally posted by Jim Rich:
[qb]
quote:
Originally posted by Tony Alsford:
[qb] Jim

Change the heading section to -

HEADING<br />" KPI Comparison Report "<br />" <CDATE - &thrud " 
That will use the field value that you want.

Incidently, the reason you can not use a field value in an amper variable in this manner is that setting an amper variable is a dialogue manager function and settings are performed outside of the actual TABLE request.

As has been mentioned, you can table the file and save the output the read the value in.

Using the actual data value as suggested above is the way to go. [/qb]
----
I tried using
Didn't stick. I tried using <CDATE but then the header line did not show at all.
June 16, 2004, 08:22 PM
<Jim Rich>
quote:
Originally posted by susannah:
[qb] take the ' away from your &var;
TD/YYM- = '&thrud';
should be
TD/YYM = &thrud ;
also, that dash - after the format YYM-
is goofy; whats up with that?
In your code below, you want to read out to an &var.
you have 2 choices;
1) do all the date calcs in dialog manager. (best way)
2) after the defines,write the CDATE out to a file, then READ the file with a -READ , setting your new &var. [/qb]
----
also, that dash - after the format YYM-
is goofy; whats up with that?
The dash - after YYM is the coding for using a dash in the output format. 4 digit year-2 digit month i.e. 2004-06 rather than yym which gives 2004/06
June 18, 2004, 04:35 PM
susannah
oh! isn't that interesting. Cool to know.