/******************************************************************************
 * Programme : SAS Viya Job Code Retrieval Test
 * Reference : SASVIY7A16
 * Source    : https://www.wearecas.eu/en/sampleCode/SASVIY7A16
 ******************************************************************************/

/* --- BLOC 1 --- */
%let incode=%str(data test; set sashelp.class;run;);
filename testref temp;
data _null_;
  file testref;
  put "&incode";
run;

/* --- BLOC 2 --- */
%mv_createjob(
  code=testref,
  path=&mcTestAppLoc/services/temp,
  name=some_job
)

/* --- BLOC 3 --- */
%mp_assertscope(SNAPSHOT)
%mv_getjobcode(
  path=&mcTestAppLoc/services/temp,
  name=some_job,
  outref=mycode
)
%mp_assertscope(COMPARE,
  ignorelist=MCLIB2_JADP1LEN MCLIB2_JADP2LEN MCLIB2_JADPNUM MCLIB2_JADVLEN
    MCLIB2_JADP3LEN
)

/* --- BLOC 4 --- */
%let diditexist=NO;
data work.test1;
  infile mycode;
  input;
  putlog _infile_;
  line=_infile_;
  check=symget('incode');
  if _infile_=symget('incode') then call symputx('diditexist','YES');
run;

/* --- BLOC 5 --- */
%mp_assert(
  iftrue=(&diditexist=NO),
  desc=Check if the code that was sent was successfully retrieved
)

