310 likes | 436 Views
PROFILE for Your Synonym: . MFD_PROFILE. Noreen Redden FOCUS Users of New England 2012. MFD_PROFILE The Basics. 2. MFD_PROFILE. Why? Set the values of global variables defined in the Master File for use in Master and/or Access File Descriptions.
E N D
PROFILE for Your Synonym: MFD_PROFILE Noreen Redden FOCUS Users of New England 2012
MFD_PROFILE • Why? • Set the values of global variables defined in the Master File for use in Master and/or Access File Descriptions. • Create a lookup file for Master File DEFINE commands or DBA attributes. • Create a DBAFILE, which can be derived from an external data source and used to restrict access during execution of a request that references the Master File. • Issue FOCUS commands such as JOIN or FILTER FILE.
MFD_PROFILE What and When • FOCEXEC (.fex) file executed EACH TIME is opened for: • TABLE • TABLEF • GRAPH • MATCH FILE • CHECK, ?f, ?ff • Multiple MFD_PROFILES may be executed • JOIN or Cross-References • MORE • MATCH FILE
MFD_PROFILE Global Variables VARIABLE NAME=[&&]var, USAGE=Aln, [DEFAULT=defvalue,][QUOTED={OFF|ON},] $ • Master Attributes which may be parameterized include: • POSITION • OCCURS • REMARKS • DESCRIPTION • TITLE • HELPMESSAGE • DBA USERID and VALUE • Access Attributes which may be parameterized include: • CONNECTION • TABLENAME • DIRECTORY • EXTENSION
MFD_PROFILE: Global Variables FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL VARIABLE NAME=LTD, USAGE=A30, DEFAULT='LTD or ETD',$ SEGNAME=GRPPOL,SEGTYPE=S0 FIELD=GROUP_CODE,GCODE,A8,TITLE='Group Code',$ FIELD=GROUP_NAME,,A30,TITLE='Group Policy Holder',$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE='Contract Number',$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE='Effective,Date' ,$ • -IF &1 NE ‘GRPPOL’ GOTO NOVAR1; • -SET &<D = IF &&TEAM_NAME EQ ‘GM’ THEN ‘Extended Term’ ELSE • ‘Long Term’; • - NOVAR1
Create or Point to Files MFD_PROFILE FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL VARIABLE NAME=LTD, USAGE=A30, DEFAULT='LTD or ETD',$ SEGNAME=GRPPOL,SEGTYPE=S0 FIELD=GROUP_CODE,GCODE,A8,TITLE='Group Code',$ FIELD=GROUP_NAME,,A30,TITLE='Group Policy Holder',$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE='Contract Number',$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE='Effective,Date' ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; • -IF &1 NE ‘GRPPOL’ GOTO NOVAR1; • -SET &<D = IF &&TEAM_NAME EQ ‘GM’ THEN ‘Extended Term’ ELSE • ‘Long Term’; • NOVAR1 • FILEDEF TEAMRESP DISK c:\userapp\teamresp.dat
Security MFD_PROFILE FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL SEGNAME=GRPPOL,SEGTYPE=S0 VARIABLE NAME=&<D, USAGE=A30, DEFAULT='LTD or ETD',$ VARIABLE NAME=&&UID, USAGE=A8, DEFAULT=‘ ‘,$ VARIABLE NAME=&&DBAVAL,USAGE=A50, DEFAULT=GROUP_CODE EQ ‘X’ AND GROUP_CODE EQ ‘Y’;,$ FIELD=GROUP_CODE,GCODE,A8,TITLE='Group Code',$ FIELD=GROUP_NAME,,A30,TITLE='Group Policy Holder',$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE='Contract Number',$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE='Effective,Date' ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; END DBA=DBA,$ USER=&&UID,ACCESS=R,RESTRICT=VALUE_WHERE, NAME=GRPPOL,VALUE=&&DBAVAL,$
MFD_PROFILE: Security • -IF &1 NE ‘GRPPOL’ GOTO NOVAR1; • -SET &<D = IF &&TEAM_NAME EQ ‘GM’ THEN ‘Extended Term’ ELSE • ‘Long Term’; • NOVAR1 • TABLE FILE TEAMS • PRINT GRP_RESP • WHERE TEAM EQ &&TEAM_NAME • ON TABLE SAVE AS TEAMRESP • END • -ALL • -SET &&DBAVAL= SELECTGRPS;
MFD_PROFILE: Security FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL VARIABLE NAME=&<D, USAGE=A30, DEFAULT='LTD or ETD',$ SEGNAME=GRPPOL,SEGTYPE=S0 FIELD=GROUP_CODE,GCODE,A8,TITLE='Group Code',$ FIELD=GROUP_NAME,,A30,TITLE='Group Policy Holder',$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE='Contract Number',$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE='Effective,Date' ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; END DBA=DBA,DBAFILE=MYFILE,$
MFD_PROFILE: Security DEFINE FILE SYSCOLUM LINENO WITH TBNAME = LINENO + 1; LINED/A80 = IF LINENO EQ 1 THEN 'FILE=MYFILE,SUFFIX=FIX' ELSE IF LINENO EQ 2 THEN ' SEGNAME=ONE,SEGTYPE=S0' ELSE IF LINENO EQ 3 THEN ' FIELDNAME=ONE,,A1,A1,$' ELSE IF LINENO EQ 4 THEN 'END' ELSE IF LINENO EQ 5 THEN 'DBA=DBA,$' ELSE IF LINENO EQ 6 THEN 'USER='' '',ACCESS=R, RESTRICT=VALUE,NAME=SYSTEM, ' | ' VALUE= RECORDLIMIT EQ 5,$' ELSE IF LINENO EQ 7 THEN ' RESTRICT=VALUE,VALUE=' | 'SELECTGRPS,$' ELSE IF LINENO EQ 8 THEN 'USER=NORM,ACCESS=R,' | 'RESTRICT=VALUE,NAME=SYSTEM,' | 'VALUE=SELECTGRPS,$' ELSE ' '; END TABLE FILE SYSCOLUM PRINT LINED ON TABLE SAVE AS MYFILE WHERE LINENO LE 8 END
Prerequisites MFD_PROFILE FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL SEGNAME=GRPPOL,SEGTYPE=S0 … FIELD=EFFECT_DATE,,YYMD,TITLE='Effective,Date' ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; • NOVAR1 • TABLE FILE TEAMS • PRINT GRP_RESP • WHERE TEAM EQ &&TEAM_NAME • ON TABLE SAVE AS TEAMRESP • END • FILTER FILE GRPPOL • DAYS/I5 = DATEDIFF(EFFECT_DATE,'&YYMD','D‘);NAME=CURRENTWHERE DAYS LE 5END • SET FILTER = CURRENT IN GRPPOL ON
Application Requirements • Validate all user access to the files. • Only Managers have access to orders > 1 week old. • Corporate users have access to • GGORDERS and GGPRODs for all stores/regions. • Store users have access to GGORDERS only for their • store. • Regional personnel have access to GGORDERS for all • stores within the Region.
GGORDER FILENAME=GGORDER, SUFFIX=FOC,MFD_PROFILE=GGPROF,$ SEGNAME=ORDER01, SEGTYPE=S1,$ FIELD=ORDER_NUMBER, ALIAS=ORDNO1, FORMAT=I6, TITLE='Order,Number', DESC='Order Identification Number',$ FIELD=ORDER_DATE, ALIAS=DATE, FORMAT=MDY, TITLE='Order,Date', DESC='Date order was placed',$ FIELD=STORE_CODE, ALIAS=STCD, FORMAT=A5, TITLE='Store,Code', DESC='Store Identification Code (for order)',$ FIELD=PRODUCT_CODE, ALIAS=PCD, FORMAT=A4, TITLE='Product,Code', DESC='Product Identification Code (for order)',$ FIELD=QUANTITY, ALIAS=ORDUNITS, FORMAT=I8, TITLE='Ordered,Units', DESC='Quantity Ordered',$ SEGNAME=ORDER02, SEGTYPE=KU, PARENT=ORDER01, CRFILE=GGPRODS, CRKEY=PCD, CRSEG=PRODS01 ,$ FILTER CURRENT = DATEDIF(ORDER_DATE,'&YYMD','D') LE 5;,$ END DBA=DBA,DBAFILE=GGPROFP,$
GGPRODS FILENAME=GGPRODS, SUFFIX=FOC,MFD_PROFILE=GGPROFP,$ SEGNAME=PRODS01, SEGTYPE=S1 FIELD=PRODUCT_ID, ALIAS=PCD, FORMAT=A4, INDEX=I, TITLE='Product,Code', $ FIELD=PRODUCT_DESCRIPTION, ALIAS=PRODUCT, FORMAT=A16, TITLE='Product', $ FIELD=VENDOR_CODE, ALIAS=VCD, FORMAT=A4, INDEX=I, TITLE='Vendor ID', $ FIELD=VENDOR_NAME, ALIAS=VENDOR, FORMAT=A23, TITLE='Vendor Name', $ FIELD=PACKAGE_TYPE, ALIAS=PACK, FORMAT=A7, TITLE='Package‘,$ FIELD=SIZE, ALIAS=SZ, FORMAT=I2, TITLE='Size', $ FIELD=UNIT_PRICE, ALIAS=UNITPR, FORMAT=D7.2, TITLE='Unit,Price', $ END DBA=DBA,DBAFILE=GGPROFP,$
GGREGION FILENAME=GGREGION, SEGNAME=SALES01, SEGTYPE=DKU,CRFILE=GGSALES, CRINCLUDE=ALL ,$ FOLDER=GGREGION,$ FIELD=REGION, ALIAS=E05, FORMAT=A11, INDEX=I, TITLE='Region', DESC='Region code',$ FIELD=STCD, ALIAS=E08, FORMAT=A05, INDEX=I, TITLE='Store ID', DESC='Store identification code (for sale)',$
Human Resources File FILENAME=HR, SUFFIX=ORASQL,$ SEGNAME=HR1, SEGTYPE=S0 FIELD=EID, ALIAS=employeeid, FORMAT=A09, A09,$ FIELD=JOBCODE,jobcode,A8,A8,$ FIELD=DIVISION, ALIAS=division, FORMAT=A23, A23, DESC=CORP or Region name,$ FIELD=STORENUMBER, ALIAS=storeno, FORMAT=A5, A5,$ END DBA=pO02_can,$ USER=pOc02_an,ACCESS=R,$
GGPROFP.fex -DYNAM ALLOC F HR DA PMSNMR.HR.FOCUS SHR REU -RUN SET MSG=OFF SET DBACSENSITIV = ON SET COLLATION=SRV_CI -RUN TABLE FILE HR PRINT * WHERE EID EQ '&&LOGON_ID' ON TABLE SAVE AS HR1 FORMAT ALPHA END -RUN -SET &LNES = &LINES; -RDIT -SET &FOUNDIT = IF &LNES EQ 0 THEN 'N' ELSE 'Y';
GGPROFP.fex(cont) -SET &JOBCODE = '________'; -IF &FOUNDIT EQ 'N' GOTO WRITIT; -READ HR1 &EID.9. &JOBCODE.A8. &DIVISION.A23. &STNMBR.A5. -* could use –READFILE (RELEASE 7.7) -* Only build for current user, -SET &USER = 'USR' | &MDYY | EDIT(&JOBCODE, '$$$9'); -* rules based on last 2 digits of JOBCODE -SET &JOBL = EDIT(&JOBCODE,'$$$$$$99'); -RUN -PASS &USER
GGPROF.fex (cont) FILEDEF OUTFI DISK TEMP/GGPROFP.mas -RUN -WRITIT -* CREATES THE DBAFILE GGPROFP.MAS -WRITE OUTFI FILE=GGPROFP,SUFFIX=FIX -WRITE OUTFI SEGNAME=ONE,SEGTYPE=S0 -WRITE OUTFI FIELDNAME= ONE,,A1,A1,$ -WRITE OUTFI END -WRITE OUTFI DBA=DBA,$ -*ET &ECHO=ALL; -SET &RST = 'ACCESS = R,'; -WRITE OUTFI USER = &USER , &RST -IF &FOUNDIT EQ 'N' GOTO NOG;
GGPROF.fex (cont) -* CORP MANAGERS HAVE NO RESTRICTIONS -IF &DIVISION EQ 'CORP' AND &JOBL GE '09' GOTO END1; -* CORP NON-MANAGERS ARE RESTRICTED ONLY ON CURRENT -IF &DIVISION EQ 'CORP' GOTO NOST; -* ALL OTHERS ARE RESTRICTED ON STORE CODES -SET &RST2= 'RESTRICT=VALUE_WHERE,NAME=SYSTEM,'; -WRITE OUTFI &RST2 -WRITE OUTFI VALUE=STORE_CODE IN FILE STRS; ,$ -* NON-MANAGERS RESTRICTED TO CURRENT INFORMATION -NOST -SET &RST2= 'RESTRICT=VALUE_WHERE,NAME=SYSTEM,'; -IF &JOBL GE '09' GOTO END1; -WRITE OUTFI &RST2| VALUE=CURRENT;,$ -GOTO END1;
GGPROF.fex (cont) -NOG -SET &RST2= 'RESTRICT=VALUE_WHERE,NAME=SYSTEM,'; -WRITE OUTFI &RST2 -WRITE OUTFI VALUE=STORE_CODE EQ 'A' -WRITE OUTFI VALUE= AND STORE_CODE EQ 'B';,$ -END1 -WRITE OUTFI ,$ -CLOSE OUTFI
GGPROF.fex (cont) -* DBAFILE WRITTEN, BUT STORE_CODES SHOULD BE IN FILE -IF &DIVISION EQ 'CORP' GOTO NOM; TABLE FILE GGREGION PRINT STCD -IF &JOBL GE '06' GOTO REGT; WHERE STCD EQ '&STNMBR' ; -GOTO FINTEST -REGT WHERE REGION EQ '&DIVISION' ; -FINTEST ON TABLE SAVE AS STRS END -RUN
Output: Regional User USER = USR05032012X , ACCESS = R, RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=STORE_CODE IN FILE STRS; ,$ RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=CURRENT;,$ ,$ Store Order Ordered Code Date Units ----- ----- ------- R1019 04/30/12 5230 05/01/12 5203 R1020 04/28/12 6660 04/29/12 6644 04/30/12 1762 05/01/12 2031 R1250 04/28/12 6540 04/29/12 7372 04/30/12 1864 05/01/12 2423
Output: Regional Manager USER = USR05032012X , ACCESS = R, RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=STORE_CODE IN FILE STRS; ,$ ,$ Store Order Ordered Code Date Units ----- ----- ------- R1019 04/02/12 6285 04/03/12 8259 04/04/12 6907 . . . 04/08/12 5006 R1020 04/02/12 2326 04/15/12 4994 . . . 04/19/12 5305 R1250 04/02/12 1558 04/15/12 4536 . . .
Output: Store User USER = USR05032012X , ACCESS = R, RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=STORE_CODE IN FILE STRS; ,$ RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=CURRENT;,$ ,$ PAGE 1 Store Order Ordered Code Date Units ----- ----- ------- R1019 04/30/12 5230 05/01/12 5203
Output: Corporate Manager USER = USR05032012X , ACCESS = R, RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=CURRENT;,$ ,$ Store Order Ordered Code Date Units ----- ----- ------- R1019 04/30/12 5230 05/01/12 5203 R1020 04/28/12 6660 04/29/12 6644 04/30/12 1762 05/01/12 2031 R1040 04/30/12 5104 05/01/12 5090 R1041 04/28/12 6409 04/29/12 7439 04/30/12 2465
Output: Invalid User USER = USR050320120 , ACCESS = R, RESTRICT=VALUE_WHERE,NAME=SYSTEM, VALUE=STORE_CODE EQ 'A',$ VALUE= AND STORE_CODE EQ 'B';,$ ,$ (FOC047) THE USER DOES NOT HAVE SUFFICIENT ACCESS RIGHTS TO THE FILE: GGORDER