As Dmitry has said, there is no easy way, so all we have is workarounds for this.
Adding to Dmitry’s suggestions, a couple more possible options depending on how you have implemented MA:
If the Subject Name is unique across your business contexts, then you can use this as a proxy for Business Context, and there are 2 macro variables that could be checked in the STP: OUTSUBJECTNAME or INSUBJECTNAME
(this is my preferred one) The Campaign Code *should* be unique across business contexts (although this is not always true, in my experience its unlikely that a campaign code is used in the same campaign in 2 business contexts in the same CI install, or even more rarely in the same CDM). In which case the Business Context can be retrieved from the CDM based upon the campaign code and some PROC SQL. This method relies on the campaign being published first (which for execution is always true assuming you have a CDM). Once you have the BC name you can then check that you have only 1 or return an error to the user.
%macro GetBC;
proc sql noprint;
select value into :libval
from &matableformacro
where name = 'CICOMMON_LIBNAME';
quit;
&libval;
%let CDMLibref = %scan(&libval, 2);
proc sql noprint;
SELECT business_context_nm,
count(distinct(business_context_nm)) into :bc_name, :bc_count
FROM &CDMLibref..CI_CAMPAIGN
WHERE CAMPAIGN_CD = %tslit(&CAMPCODE);
quit;
%let bc_count = &bc_count;
%if %NRQUOTE(&bc_count) eq %NRQUOTE(0) %then %do ;
%** Campaign isnt in the CDM! ;
%let MAMsg=Error. The &CINODENAME node failed to execute successfully. The campaign was not found in the CDM. Please publish the campaign;
%let SYSCC=12 ;
%mastatus(&_stpwork.status.txt) ;
%return ;
%end ;
%if %NRQUOTE(&bc_count) ne %NRQUOTE(1) %then %do ;
%** Duplicates or something else is wrong! ;
%let MAMsg=Error. The &CINODENAME node failed to execute successfully. More than one Business Context found;
%let SYSCC=12 ;
%mastatus(&_stpwork.status.txt) ;
%return ;
%end ;
%if %NRQUOTE(&bc_count) eq %NRQUOTE(1) %then %do ;
%PUT Campaign executing in &bc_name business context;
%end ;
%mend;
%GetBC;
... View more