feat: adding ability to define the target table for excel maps
Some checks failed
Build / Build-and-ng-test (pull_request) Failing after 13s

This commit is contained in:
zmaj 2024-01-11 18:11:22 +00:00
parent e747e6e4e7
commit c86fba9dc7
17 changed files with 248 additions and 93 deletions

View File

@ -1,18 +1,18 @@
/**
@file
@brief DDL for MPE_EXCEL_UPLOAD
@brief DDL for MPE_XLMAP_DATA
@version 9.3
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd
**/
create table &curlib..mpe_excel_upload(
create table &curlib..MPE_XLMAP_DATA(
LOAD_REF char(32) not null,
XLMAP_ID char(32) not null,
XLMAP_RANGE_ID char(32) not null,
ROW_NO num not null,
COL_NO num not null,
VALUE_TXT char(4000),
constraint pk_mpe_excel_upload
constraint pk_MPE_XLMAP_DATA
primary key(LOAD_REF, XLMAP_ID, XLMAP_RANGE_ID, ROW_NO, COL_NO));

View File

@ -0,0 +1,17 @@
/**
@file
@brief DDL for mpe_xlmap_info
@version 9.3
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd
**/
create table &curlib..mpe_xlmap_info(
tx_from num not null,
XLMAP_ID char(32) not null,
XLMAP_DESCRIPTION char(1000) not null,
XLMAP_TARGETLIBDS char(41) not null,
tx_to num not null,
constraint pk_mpe_xlmap_info
primary key(tx_from,XLMAP_ID));

View File

@ -1,13 +1,13 @@
/**
@file
@brief DDL for MPE_EXCEL_MAP
@brief DDL for mpe_xlmap_rules
@version 9.3
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd
**/
create table &curlib..mpe_excel_map(
create table &curlib..mpe_xlmap_rules(
tx_from num not null,
XLMAP_ID char(32) not null,
XLMAP_RANGE_ID char(32) not null,
@ -15,5 +15,5 @@ create table &curlib..mpe_excel_map(
XLMAP_START char(1000) not null,
XLMAP_FINISH char(1000),
tx_to num not null,
constraint pk_mpe_excel_map
constraint pk_mpe_xlmap_rules
primary key(tx_from,XLMAP_ID,XLMAP_RANGE_ID));

View File

@ -13,7 +13,7 @@ libname &dclib "/your/dc/path";
* New MPE_SUBMIT table
*/
proc sql;
create table &dclib..mpe_excel_map(
create table &dclib..mpe_xlmap_rules(
tx_from num not null,
XLMAP_ID char(32) not null,
XLMAP_RANGE_ID char(32) not null,
@ -21,15 +21,24 @@ create table &dclib..mpe_excel_map(
XLMAP_START char(1000) not null,
XLMAP_FINISH char(1000),
tx_to num not null,
constraint pk_mpe_excel_map
constraint pk_mpe_xlmap_rules
primary key(tx_from,XLMAP_ID,XLMAP_RANGE_ID));
create table &dclib..mpe_excel_upload(
create table &dclib..MPE_XLMAP_DATA(
LOAD_REF char(32) not null,
XLMAP_ID char(32) not null,
XLMAP_RANGE_ID char(32) not null,
ROW_NO num not null,
COL_NO num not null,
VALUE_TXT char(4000),
constraint pk_mpe_excel_upload
primary key(LOAD_REF, XLMAP_ID, XLMAP_RANGE_ID, ROW_NO, COL_NO));
constraint pk_MPE_XLMAP_DATA
primary key(LOAD_REF, XLMAP_ID, XLMAP_RANGE_ID, ROW_NO, COL_NO));
create table &dclib..mpe_xlmap_info(
tx_from num not null,
XLMAP_ID char(32) not null,
XLMAP_DESCRIPTION char(1000) not null,
XLMAP_TARGETLIBDS char(41) not null,
tx_to num not null,
constraint pk_mpe_xlmap_info
primary key(tx_from,XLMAP_ID));

View File

@ -451,7 +451,7 @@ run;
%do i=1 %to %sysfunc(countw(&pk));
%let iWord=%scan(&pk,&i);
call symputx('duplist',symget('duplist')!!
" &iWord="!!trim(&iWord));
" &iWord="!!cats(&iWord));
%end;
run;
%let msg=This upload contains duplicates on the Primary Key columns %trim(

View File

@ -270,149 +270,159 @@ insert into &lib..mpe_datadictionary set
,tx_to='31DEC5999:23:59:59'dt;
/**
* MPE_EXCEL_MAP
* mpe_xlmap_info
*/
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_info set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_description='Basel 3 Key Metrics report'
,XLMAP_TARGETLIBDS="&lib..MPE_XLMAP_DATA";
/**
* mpe_xlmap_rules
*/
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:a'
,xlmap_sheet='KM1'
,xlmap_start='MATCH 4 R[2]C[0]:a';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:b'
,xlmap_sheet='KM1'
,xlmap_start='MATCH 4 R[2]C[0]:b';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:c'
,xlmap_sheet='KM1'
,xlmap_start='MATCH 4 R[2]C[0]:c';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:d'
,xlmap_sheet='KM1'
,xlmap_start='MATCH 4 R[2]C[0]:d';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:e'
,xlmap_sheet='KM1'
,xlmap_start='MATCH 4 R[2]C[0]:e';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:f'
,xlmap_sheet='KM1'
,xlmap_start='MATCH 4 R[2]C[0]:f';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1/a'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[0]C[1]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1/b'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[0]C[2]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1/c'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[0]C[3]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1/d'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[0]C[4]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1/e'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[0]C[5]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1/f'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[0]C[6]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1a/e'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[1]C[5]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:1a/f'
,xlmap_sheet='KM1'
,xlmap_start='MATCH C R[1]C[6]:Common Equity Tier 1 (CET1)';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:2/a'
,xlmap_sheet='KM1'
,xlmap_start='ABSOLUTE D10';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:2/b'
,xlmap_sheet='/3'
,xlmap_start='ABSOLUTE E10';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:2/c'
,xlmap_sheet='/3'
,xlmap_start='RELATIVE R[10]C[6]';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:2/d'
,xlmap_sheet='/3'
,xlmap_start='RELATIVE R[10]C[8]';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:2/e'
,xlmap_sheet='/3'
,xlmap_start='RELATIVE R[10]C[9]';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
,xlmap_range_id='KM1:2/f'
,xlmap_sheet='/3'
,xlmap_start='RELATIVE R[10]C[10]';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
@ -420,7 +430,7 @@ insert into &lib..mpe_excel_map set
,xlmap_sheet='KM1'
,xlmap_start='ABSOLUTE H11'
,xlmap_finish='RELATIVE R[0]C[1]';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-KM1'
@ -428,7 +438,7 @@ insert into &lib..mpe_excel_map set
,xlmap_sheet='KM1'
,xlmap_start='RELATIVE R[12]C[4]'
,xlmap_finish='ABSOLUTE I13';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-CR2'
@ -436,7 +446,7 @@ insert into &lib..mpe_excel_map set
,xlmap_sheet='CR2'
,xlmap_start='ABSOLUTE D8'
,xlmap_finish='BLANKROW';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='BASEL-CR2'
@ -444,7 +454,7 @@ insert into &lib..mpe_excel_map set
,xlmap_sheet='CR2'
,xlmap_start='ABSOLUTE D18'
,xlmap_finish='LASTDOWN';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='Sample'
@ -452,7 +462,7 @@ insert into &lib..mpe_excel_map set
,xlmap_sheet='/1'
,xlmap_start='ABSOLUTE B3'
,xlmap_finish='ABSOLUTE B8';
insert into &lib..mpe_excel_map set
insert into &lib..mpe_xlmap_rules set
tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,xlmap_id='Sample'
@ -461,6 +471,8 @@ insert into &lib..mpe_excel_map set
,xlmap_start='ABSOLUTE B13'
,xlmap_finish='ABSOLUTE E16';
/**
* MPE_GROUPS
*/
@ -1177,20 +1189,33 @@ insert into &lib..mpe_selectbox set
set tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,libref="&lib"
,dsn='MPE_EXCEL_MAP'
,dsn='MPE_XLMAP_INFO'
,num_of_approvals_required=1
,loadtype='TXTEMPORAL'
,var_txfrom='TX_FROM'
,var_txto='TX_TO'
,buskey='XLMAP_ID'
,notes='Docs: https://docs.datacontroller.io/complex-excel-uploads'
,post_edit_hook='services/hooks/mpe_xlmap_info_postedit'
;
insert into &lib..mpe_tables
set tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,libref="&lib"
,dsn='MPE_XLMAP_RULES'
,num_of_approvals_required=1
,loadtype='TXTEMPORAL'
,var_txfrom='TX_FROM'
,var_txto='TX_TO'
,buskey='XLMAP_ID XLMAP_RANGE_ID'
,notes='Docs: https://docs.datacontroller.io/complex-excel-uploads'
,post_edit_hook='services/hooks/mpe_excel_map_postedit'
,post_edit_hook='services/hooks/mpe_xlmap_rules_postedit'
;
insert into &lib..mpe_tables
set tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,libref="&lib"
,dsn='MPE_EXCEL_UPLOAD'
,dsn='MPE_XLMAP_DATA'
,num_of_approvals_required=1
,loadtype='UPDATE'
,buskey='LOAD_REF XLMAP_ID XLMAP_RANGE_ID ROW_NO COL_NO'
@ -1472,7 +1497,17 @@ insert into &lib..MPE_VALIDATIONS set
insert into &lib..MPE_VALIDATIONS set
tx_from=0
,base_lib="&lib"
,base_ds="MPE_EXCEL_MAP"
,base_ds="MPE_XLMAP_INFO"
,base_col="XLMAP_ID"
,rule_type='CASE'
,rule_value='UPCASE'
,rule_active=1
,tx_to='31DEC5999:23:59:59'dt;
insert into &lib..MPE_VALIDATIONS set
tx_from=0
,base_lib="&lib"
,base_ds="MPE_XLMAP_RULES"
,base_col="XLMAP_ID"
,rule_type='CASE'
,rule_value='UPCASE'

View File

@ -270,24 +270,7 @@ proc datasets lib=&lib noprint;
quit;
proc sql;
create table &lib..mpe_excel_map(
tx_from num &notnull,
tx_to num &notnull,
XLMAP_ID char(32) &notnull,
XLMAP_RANGE_ID char(32) &notnull,
XLMAP_SHEET char(32) &notnull,
XLMAP_START char(1000) &notnull,
XLMAP_FINISH char(1000)
);quit;
proc datasets lib=&lib noprint;
modify mpe_excel_map;
index create
pk_mpe_excel_map=(tx_to xlmap_id xlmap_range_id)
/nomiss unique;
quit;
proc sql;
create table &lib..mpe_excel_upload(
create table &lib..MPE_XLMAP_DATA(
LOAD_REF char(32) &notnull,
XLMAP_ID char(32) &notnull,
XLMAP_RANGE_ID char(32) &notnull,
@ -296,9 +279,42 @@ create table &lib..mpe_excel_upload(
VALUE_TXT char(4000)
);quit;
proc datasets lib=&lib noprint;
modify mpe_excel_upload;
modify MPE_XLMAP_DATA;
index create
pk_mpe_excel_upload=(load_ref xlmap_id xlmap_range_id row_no col_no)
pk_MPE_XLMAP_DATA=(load_ref xlmap_id xlmap_range_id row_no col_no)
/nomiss unique;
quit;
proc sql;
create table &lib..mpe_xlmap_info(
tx_from num &notnull,
tx_to num &notnull,
XLMAP_ID char(32) &notnull,
XLMAP_DESCRIPTION char(1000) &notnull,
XLMAP_TARGETLIBDS char(41) &notnull
);quit;
proc datasets lib=&lib noprint;
modify mpe_xlmap_info;
index create
pk_mpe_xlmap_info=(tx_to xlmap_id)
/nomiss unique;
quit;
proc sql;
create table &lib..mpe_xlmap_rules(
tx_from num &notnull,
tx_to num &notnull,
XLMAP_ID char(32) &notnull,
XLMAP_RANGE_ID char(32) &notnull,
XLMAP_SHEET char(32) &notnull,
XLMAP_START char(1000) &notnull,
XLMAP_FINISH char(1000),
XLMAP_TARGETLIBDS char(41)
);quit;
proc datasets lib=&lib noprint;
modify mpe_xlmap_rules;
index create
pk_mpe_xlmap_rules=(tx_to xlmap_id xlmap_range_id)
/nomiss unique;
quit;

View File

@ -15,10 +15,10 @@
%local ismap;
proc sql noprint;
select count(*) into: ismap
from &dclib..MPE_EXCEL_MAP
where XLMAP_ID="&tgtds";
from &dclib..mpe_xlmap_info
where XLMAP_TARGETLIBDS="&tgtds" and &dc_dttmtfmt. le TX_TO ;
%if &tgtds=&dclib..MPE_EXCEL_UPLOAD or &ismap>0 %then %do;
%if "&tgtds"="&dclib..MPE_XLMAP_DATA" or &ismap>0 %then %do;
data &inds;
set &inds;
LOAD_REF="&mperef";

View File

@ -8,7 +8,7 @@
@li mp_assertscope.sas
<h4> SAS Includes </h4>
@li mpe_excel_upload.ddl ul
@li mpe_xlmap_data.ddl ul
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
@ -23,7 +23,7 @@ proc sql;
%inc ul;
data work.test1;
if 0 then set work.mpe_excel_upload;
if 0 then set work.MPE_XLMAP_DATA;
LOAD_REF='0';
XLMAP_ID='Sample';
XLMAP_RANGE_ID='Range 1';
@ -47,7 +47,7 @@ run;
desc=Checking load ref was not applied
)
%mpe_xlmapvalidate(DCTEST2,work.test1,&dclib,&dclib..MPE_EXCEL_UPLOAD)
%mpe_xlmapvalidate(DCTEST2,work.test1,&dclib,&dclib..MPE_XLMAP_DATA)
data _null_;
set work.test1;

View File

@ -34,7 +34,8 @@ run;
%mp_testservice(&_program,
viyacontext=&defaultcontext,
inputdatasets=work.sascontroltable work.jsdata,
outlib=web1
outlib=web1,
mdebug=&sasjs_mdebug
)
%let status=0;

View File

@ -537,8 +537,8 @@ run;
%put params;
%let ismap=0;
proc sql noprint;
select count(*) into: ismap from &mpelib..mpe_excel_map
where xlmap_id="&orig_libds";
select count(*) into: ismap from &mpelib..mpe_xlmap_info
where XLMAP_TARGETLIBDS="&orig_libds" and &dc_dttmtfmt. le TX_TO;
data sasparams;
length colHeaders $20000 filter_text $32767;
@ -557,7 +557,7 @@ data sasparams;
if %mf_nobs(work.cls_rules)=0 then cls_flag=0;
else cls_flag=1;
put (_all_)(=);
if "&orig_libds"="&mpelib..MPE_EXCEL_UPLOAD" or &ismap ne 0 then ismap=1;
if "&orig_libds"="&mpelib..MPE_XLMAP_DATA" or &ismap ne 0 then ismap=1;
else ismap=0;
run;

View File

@ -14,7 +14,7 @@
<h5> xlmaprules </h5>
Filtered output of the dc.mpe_excel_map table
Filtered output of the dc.MPE_XLMAP_RULES table
|XLMAP_ID|XLMAP_RANGE_ID|XLMAP_SHEET|XLMAP_START|XLMAP_FINISH|
|---|---|---|---|---|
@ -26,7 +26,7 @@
|TARGET_DS|
|---|
|DCXXX.MPE_EXCEL_UPLOAD|
|DCXXX.MPE_XLMAP_DATA|
<h4> SAS Macros </h4>
@li mp_abort.sas
@ -42,6 +42,12 @@
%mpeinit()
data _null_;
set work.getxlmaps_in;
putlog (_all_)(=);
call symputx('xlmap_id',xlmap_id);
run;
proc sql noprint;
create table work.xlmaprules as
select xlmap_id
@ -49,28 +55,24 @@ create table work.xlmaprules as
,XLMAP_SHEET
,XLMAP_START
,XLMAP_FINISH
from &mpelib..mpe_excel_map
where &dc_dttmtfmt. lt tx_to
and xlmap_id in (select xlmap_id from work.getxlmaps_in)
from &mpelib..MPE_XLMAP_RULES
where &dc_dttmtfmt. lt tx_to and xlmap_id="&xlmap_id"
order by xlmap_sheet, xlmap_range_id;
%global target_ds;
select XLMAP_TARGETLIBDS into: target_ds
from &mpelib..MPE_XLMAP_INFO
where &dc_dttmtfmt. lt tx_to and xlmap_id="&xlmap_id";
%mp_abort(iftrue= (&syscc ne 0)
,mac=&_program..sas
,msg=%str(syscc=&syscc)
)
%let chk=0;
proc sql noprint;
select count(*) into: chk
from &mpelib..mpe_tables
where catx('.',libref,dsn) in (select xlmap_id from work.getxlmaps_in);
data work.xlmapinfo;
set work.getxlmaps_in;
length target_ds $32;
if &chk=0 then target_ds="&mpelib..MPE_EXCEL_UPLOAD";
else target_ds=xlmap_id;
keep target_ds;
target_ds=coalescec("&target_ds","&mpelib..MPE_XLMAP_DATA");
output;
stop;
run;
%webout(OPEN)

View File

@ -52,7 +52,7 @@ data work.xlmapinfo;
call symputx('tgtds',target_ds);
run;
%mp_assert(
iftrue=(&tgtds=&dclib..MPE_EXCEL_UPLOAD),
iftrue=(&tgtds=&dclib..MPE_XLMAP_DATA),
desc=Checking correct target table is returned,
outds=work.test_results
)

View File

@ -24,6 +24,7 @@ proc format lib=DCTEST.DCFMTS cntlout=work.fmtextract;
run;
data work.jsdata;
set work.fmtextract;
fmtrow=_n_;
if _n_<5 then _____DELETE__THIS__RECORD_____='Yes';
else _____DELETE__THIS__RECORD_____='No';
if _n_>20 then stop;

View File

@ -0,0 +1,70 @@
/**
@file
@brief Post Edit Hook script for the MPE_XLMAP_INFO table
@details Post edit hooks provide additional backend validation for user
provided data. The incoming dataset is named `work.staging_ds` and is
provided in mpe_loader.sas.
Available macro variables:
@li DC_LIBREF - The DC control library
@li LIBREF - The library of the dataset being edited (is assigned)
@li DS - The dataset being edited
<h4> SAS Macros </h4>
@li mf_existds.sas
@li mf_getvarlist.sas
@li mf_wordsinstr1butnotstr2.sas
@li dc_assignlib.sas
@li mp_validatecol.sas
**/
data work.staging_ds;
set work.staging_ds;
/* apply the first excel map to all cells */
length tgtds $41;
retain tgtds;
drop tgtds is_libds;
if _n_=1 then do;
if missing(XLMAP_TARGETLIBDS) or index(XLMAP_TARGETLIBDS,)
then tgtds="&dc_libref..MPE_XLMAP_DATA";
else tgtds=upcase(XLMAP_TARGETLIBDS);
%mp_validatecol(XLMAP_TARGETLIBDS,LIBDS,is_libds)
call symputx('tgtds',tgtds);
call symputx('is_libds',is_libds);
end;
XLMAP_TARGETLIBDS=tgtds;
run;
%mp_abort(iftrue=(&is_libds ne 1)
,mac=Invalid target dataset (&tgtds)
,msg=%superq(errmsg)
)
/**
* make sure that the supplied target dataset exists and
* has the necessary columns
*/
%dc_assignlib(READ,%scan(&tgtds,1,.))
%mp_abort(iftrue=(%mf_existds(libds=work.someview) ne 1)
,mac=Target dataset (&tgtds) could not be opened
,msg=%superq(errmsg)
)
%let tgtvars=%upcase(%mf_getvarlist(&tgtds));
%let srcvars=%upcase(%mf_getvarlist(&dc_libref..MPE_XLMAP_DATA));
%let badvars1=%mf_wordsInStr1ButNotStr2(Str1=&srcvars,Str2=&tgtvars);
%let badvars2=%mf_wordsInStr1ButNotStr2(Str1=&tgtvars,Str2=&srcvars);
%mp_abort(iftrue=(%length(&badvars1.X)>1)
,mac=Target dataset (&tgtds) has missing vars: &badvars1
,msg=%superq(errmsg)
)
%mp_abort(iftrue=(%length(&badvars2.X)>1)
,mac=Target dataset (&tgtds) has unrecognised vars: &badvars2
,msg=%superq(errmsg)
)

View File

@ -1,6 +1,6 @@
/**
@file
@brief Post Edit Hook script for the MPE_EXCEL_MAP table
@brief Post Edit Hook script for the MPE_XLMAP_RULES table
@details Post edit hooks provide additional backend validation for user
provided data. The incoming dataset is named `work.staging_ds` and is
provided in mpe_loader.sas.
@ -10,10 +10,14 @@
@li LIBREF - The library of the dataset being edited (is assigned)
@li DS - The dataset being edited
**/
/* ensure uppercasing */
data work.staging_ds;
set work.staging_ds;
/* ensure uppercasing */
XLMAP_ID=upcase(XLMAP_ID);
run;

View File

@ -132,7 +132,7 @@ create table saslibs as
proc sql;
create table work.xlmaps as
select distinct XLMAP_ID
from &mpelib..mpe_excel_map
from &mpelib..MPE_XLMAP_RULES
where &dc_dttmtfmt. lt tx_to;
%webout(OPEN)