Sorry for the English language skills!
SAS version 9.3
It is necessary to automate the process of obtaining the source code of Job
. I know the way through deploy/redeploy, but it is not suitable for the creation of deploy metadata.
Through macro:
data job_source_code;
length uri source_uri $256.;
length text $1000.;
_rc = metadata_getnobj("omsobj:Job?@Name='JOB_NAME'", 1, uri);
_rc = METADATA_GETNASN(uri, 'SourceCode', 1, source_uri);
_rc = METADATA_GETATTR(source_uri, 'StoredText', text);
run;
But the field text
is always empty.
What am I doing wrong? Is there any other way to automate the process of obtaining the source code of Job
?
I know it's too late that I am answering the question. Recently I have got the same request, before trying did a search in the Web to see if I can get any code. But was not able to find any, luckily I found your code and worked on completing the remaining part. Thanks.
data server_details_in_smc_1;
length uri $256 Name PublicType TransId_uri $100 text f_Direct SourceCode_Location $1000.;
nobj=1;
n=1;
do while(nobj >= 0);
n=n+1;
nobj=metadata_getnobj("omsobj:Job?@Id contains '.'",n,uri);
if (nobj > 0) then
do;
arc=metadata_getattr(uri,"Name",Name);
arc=metadata_getattr(uri,"PublicType",PublicType);
TransId_obj=metadata_getnasn(uri,'SourceCode',1,TransId_uri);
arc = metadata_getnasn(TransId_uri,"Directories",1,f_Direct);
arc = metadata_getattr(f_Direct,"DirectoryName",SourceCode_Location);
output ;
end;
end;
keep Name PublicType SourceCode_Location ;
run;