%macro ARMGTD2 ( txnname=, txndet=, appid=, level=, appidvar=, txnidvar=, metrDef1=, metrNam1=, metrDef2=, metrNam2=, metrDef3=, metrNam3=, metrDef4=, metrNam4=, metrDef5=, metrNam5=, metrDef6=, metrNam6=, metrDef7=, metrNam7= ); %*----------------------------------------------------------------------*; %* Copyright (C) 1998 by SAS Institute Inc., Cary, NC 27512-8000 *; %* *; %* Name: armgtd2.sas *; %* Support: cates, claire cates *; %* Product: base *; %* Purpose: ARM_GETID wrapper macro - This macro generates *; %* a TRANS_GETID function call and saves the transaction id *; %* in a macro variable. *; %* Input: an application id from a previous %arminit. *; %* Output: SAS variables and macro variables: *; %* 1) _armtxid - the returned transaction id *; %* 2) The variable pointed to by txnidvar is set if that *; %* parameter is supplied. *; %* Parms: positional: *; %* keyword: txnname - Transaction name. Required parameter.*; %* txndet - Transaction detail. Optional. *; %* appid - optional application id variable *; %* txnidvar - variable to contain the value of the *; %* transaction id *; %* appidvar - variable that contains the value of *; %* the application id. *; %* *; %* History: 13jul00 1.00 Initial implementation *; %* 21Aug00 1.01 S0093049 *; %* 27Nov01 sasjrs - add transaction metrics for ARM API 2.0 *; %* 08Jan03 sasjrs - allow quoted or unquoted user metric *; %* names - S015650 *; %* 06Oct06 sasjwg add support for setting SYSERR *; %* *; %* Notes: - *; %* - Note that each macro invocation will redefine all *; %* variables. *; %* - If the macro is unable to retrieve the application id, *; %* a negative id is generated. *; %* End *; %*----------------------------------------------------------------------*; %global _armapid; %global _armtxid; %global _armglvl; %global _armtlvl; %*--temporary variables so do not overwrite---*; %local _armtpid; %local _armtnam; %local _armtdtl; %local _armaid; %local _armmlvl; %local _armavar; %local _armtvar; %local _armmnm1; %local _armmdf1; %local _armmnm2; %local _armmdf2; %local _armmnm3; %local _armmdf3; %local _armmnm4; %local _armmdf4; %local _armmnm5; %local _armmdf5; %local _armmnm6; %local _armmdf6; %local _armmnm7; %local _armmdf7; %local _armMetr; %local _maxparm; %local _armindx; /* used to label sections */ %local _armtlen; /* used to calculate length for substr function */ %local _armtln2; /* used to calculate length for substr function */ %local _armI; %local _armJ; %let _maxparm = 7; %let _armtype1 = COUNT32; %let _armtype2 = COUNT64; %let _armtype3 = COUNTDIV; %let _armtype4 = GAUGE32; %let _armtype5 = GAUGE64; %let _armtype6 = GAUGEDIV; %let _armtype7 = ID32; %let _armtype8 = ID64; %let _armtype9 = SHORTSTR; %let _armtype10= LONGSTR; %armnoq(&txnname); %let _armtnam = %bquote(&_armqstr); %armnoq(&txndet); %let _armtdtl = %bquote(&_armqstr); %let _armaid = %bquote(&appid); %let _armmlvl = %bquote(&level); %let _armavar = &appidvar; %let _armtvar = &txnidvar; %*; %* Execution check ; %*; %*--assign default value---*; %let _armtpid = &_armapid; %*; %* Level check and parameter validation ; %*; %if ( &_armmlvl ne ) %then %do; %if (&_armtlvl ne) %then %do; %if &_armmlvl = &_armtlvl %then %goto _A1; %end; %if (&_armglvl ne ) %then %do; %if &_armmlvl le &_armglvl %then %goto _A1; %end; %else %if (&_armtlvl = ) %then %goto _A1; %goto _X1; %_A1:; %end; %if &_armtnam = %then %goto _ERR1; %*; %* Validate User Metrics ; %*; %do _armI=1 %to &_maxparm; %let _armnm&_armI = ; %let _armdf&_armI = ; %end; %do _armI=1 %to &_maxparm; /* check for blank metric name */ %if &&&metrNam&_armI ne %then %do; %let _armtln2 = %qsubstr(&&&metrNam&_armI,1,1); %if %quote(&_armtln2) = %str(%') OR %quote(&_armtln2) = %str(%") %then %do; %let _armtlen = %length(%quote(&&&metrNam&_armI)); %let metrNam&_armI = %qsubstr(&&metrNam&_armI,2,%eval(&_armtlen - 2)); %end; %let _armmnm&_armI = %unquote(&&metrNam&_armI); /* check for quotes on metric type definition */ %let _armtln2 = %qsubstr(&&&metrDef&_armI,1,1); %if %quote(&_armtln2) = %str(%') OR %quote(&_armtln2) = %str(%") %then %do; %let _armtlen = %length(%quote(&&&metrDef&_armI)); %let metrDef&_armI = %qsubstr(&&metrDef&_armI,2,%eval(&_armtlen - 2)); %end; %let tsttype = %unquote(%upcase(&&metrDef&_armI)); /* squeeze out the blanks */ %*put TSTTYPE= &tsttype; /* trace statement */ %let err = 1; %if &tsttype ne %then %do; /* validate against table */ %do _armJ=1 %to 10; %let _armtlen = %length(%quote(&tsttype)); %let _armtln2 = %length(%quote(&&_armtype&_armJ)); %if &_armtlen > &_armtln2 %then %let _armtlen = &_armtln2; /* if parm longer than table entry */ %if %quote(&tsttype) eq %qsubstr(&&_armtype&_armJ,1,&_armtlen) %then %do; %let err = 0; %let _armmdf&_armI = &&_armtype&_armJ; %*put 'Find a match:' _armmdf&_armI= &&_armmdf&_armI; /* trace statement */ %let _armJ = 10; %end; %end; %if &err eq 1 %then %goto _MetrErr1; %end; %else %do; %* metric type is blank ; %goto _MetrErr1; %end; %end; %else %do; %* name is blank, metric type specified ; %if &&&metrDef&_armI ne %then %do; %goto _MetrErr2; %end; %end; %end; %*; %* Validate 7th user metric parameter ; %*; %if &_armmnm7 ne %then %do; %if ((&_armmdf7 eq LONGSTR) or (&_armmdf7 eq )) %then %do; %end; %else %goto %_MetrERR3; %end; %*; %* Retrieve application id ; %*; %if &_armavar ne %then %do; %* appidvar parm passed in ; %if %datatyp(&_armavar)=NUMERIC %then %goto _ERR4; %let _armtpid = &&&_armavar; %end; %else %do; %if &_armaid ne %then %do; %* appid parm passed in ; %let _armtpid = &_armaid; %end; %else %do; %* no id parm passed in ; %if ( &_armtpid = ) %then %let _armtpid = %str(-1); %end; %end; %*; %* Issue the trans_getid function ; %*; %*put 1 drop blank user metric fields; %let _armMetr = ; /* drop blank user metric fields */ %*put 2 _armMetr= &_armMetr; %let maxsent = 0; %do _armI=&_maxparm %to 1 %by -1; %if (&&_armmnm&_armI ne ) %then %do; /* insert code into function call */ %let _armMetr = %qtrim(&&_armmnm&_armI/&&_armmdf&_armI)%str( )&_armMetr; %let maxsent = &_armI; %end; %else %do; %if &maxsent > 0 %then %let _armMetr = %qtrim(&_armMetr)%str(,); %end; %*put *_armI* _armMetr= &_armMetr; %end; %let _armtlen = %length(%qtrim(&_armMetr)); %*put 4 _armMetr= &_armMetr _armtlen= &_armtlen; %if (&_armtlen > 1) %then %do; %let _armMetr = %qsubstr(&_armMetr,1,%eval(&_armtlen - 1)); /* drop trailing comma */ %*put 5 _armMetr= &_armMetr _armtlen= &_armtlen; %*let _armMetr = %str(%')%qtrim(&_armMetr)%str(%'); %end; %else %let _armMetr = ; /* blank out initial comma */ %if (&_armtpid ne ) %then %do; %if (&_armMetr ne ) %then %do; /* user metrics specified */ %*put 6 User Metrics specified; %*put 7 _armMetr= &_armMetr; %let _armtxid = %qsysfunc(trans_getid( &_armtpid, %unquote(&_armtnam), %unquote(&_armtdtl), %unquote(&_armMetr) )); %end; %else %do; /* no user metrics specified */ %if (&_armtdtl ne ) %then %do; /* transaction detail name */ %*put 8 User detail name specified, no user metrics ; %let _armtxid = %sysfunc(trans_getid( &_armtpid, %unquote(&_armtnam), %unquote(&_armtdtl) )); %end; %else %do; %*put 9 No user detail name or user metrics specified ; %let _armtxid = %sysfunc(trans_getid( &_armtpid, %unquote(&_armtnam))); %end; %end; %if &_armtvar ne %then %do; %global &_armtvar; %let &_armtvar = &_armtxid; %end; %end; %goto _EXIT; %_ERR1: %put ERROR: The transaction name (txnname=) parameter is required.; %let _armexec = %sysfunc(trans_set_syserr( 1012 ); %goto _EXIT; %_ERR3: %put ERROR: Invalid level= parameter.; %let _armexec = %sysfunc(trans_set_syserr( 1012 )); %goto _EXIT; %_ERR4: %put ERROR: Invalid appidvar parameter: It must be a variable.; %let _armexec = %sysfunc(trans_set_syserr( 1012 )); %goto _EXIT; %_MetrERR1: %put ERROR: Invalid metrDef= parameter. Must be a valid type.; %let _armexec = %sysfunc(trans_set_syserr( 1012 )); %goto _EXIT; %_MetrERR2: %put ERROR: Invalid metrNam= parameter. Must be a valid SAS name.; %let _armexec = %sysfunc(trans_set_syserr( 1012 )); %goto _EXIT; %_MetrERR3: %put ERROR: Invalid metrDef7= parameter. Must be a LONGSTR.; %let _armexec = %sysfunc(trans_set_syserr( 1012 )); %goto _EXIT; %*; %* Exit ; %*; %_EXIT:; %_X1:; %mend armgtd2;