Download presentation
Presentation is loading. Please wait.
Published byAustin Randall Modified over 7 years ago
1
Off to See the Wizard: Techniques and FOCWizard Tips for All
Art Greenhaus
2
FOCUS is Broken – Now What?
If everything works, does it matter? It’s like driving a car If you get in, start the engine, put it in gear, and it goes, IT DOESN’T MATTER what’s happening under the hood If it doesn’t go, knowing the mechanics can help If all you see, under the hood, is lots of ‘greasy dark things’, it’s no help If out of gas – get some If no lights – look to the battery It may not help, but it couldn’t hurt
3
FOCUS is Broken – Now What?
IBI Support You can always call Customer Support They don’t know your environment They don’t know your application They don’t know your schemas They don’t know your data They don’t know your procedure They don’t know what your desired goal is But you still want help Do some basic debugging Simplify – remove non-essential items Reproduce on ‘standard’ files Everyone (SE or programmer) can see the issue Increases likelihood of resolution by orders of magnitude Slimming a 27 step, 6 MFD procedure down to a single TABLE increase your chance of resolution many times over
4
FOCUS is Broken – Now What?
What is ‘Broken’? Define ‘Broken’ Not what you expect unexpected data Expecting a,b,c but got a,b,d Missing data Expecting a,b,c and got a,b Incorrect calculations Wrong display Overflow (***), or totals that don’t ‘add up’ Undesired edit options (i.e. ‘$’ on a percent) Error message NO Output “ I know you think you understand what you thought I said but I'm not sure you realize that what you heard is not what I meant” Alan Greenspan
5
FOCUS is Broken – Now What?
What’s Happening Process Overview – not IFM Server gets request for execution (is a client involved?) May call an interface (if needed) Interface calculations, testing and aggregation done As much passed to interfaces as possible Optimization – minimize retrieved data With PRINT/LIST, FOCUS does calculations Non-interface calculations done and tests applied Non-translatable (i.e. subroutines) Retrieved records are aggregated (if not already done) COMPUTEs, WHERE TOTALs and BY TOTALs are applied Result is formatted/styled Formatted output is sent to client for display Very high level – the exact process may differ, but this is for discussion IFM – It’s FOCUS MAGIC If we have to pass back every record, why add overhead of field calculations?
6
FOCUS is Broken – Now What?
Missing or Unexpected Data Missing or Unexpected Data Using the wrong table (test vs. prod) Does a simple request against the file work? Incorrect FILEDEF Wrong MFD being used (APP Path) selection on the wrong field Multi-table structures may have similarly named fields Is this the correct field to use for selection Testing on retrieved values, rather than aggregates Aggregates may need WHERE TOTAL vs. WHERE Testing on short paths Testing for MISSING may need SET SHORTPATH=SQL, ALL=ON Returns missing values for missing segments Testing on multi-path Do you want both child selection, or either SET MULTIPATH = COMPOUND | SIMPLE What you can do will be discussed later
7
FOCUS is Broken – Now What?
Incorrect calculations Incorrect calculations COMPUTE vs. DEFINE COMPUTE works after aggregation; DEFINE on details SUBTOTAL vs. RECOMPUTE add vs. recalculate (COMPUTEs only) Incorrect format (truncation vs. non-display) Worst case PCT. of an integer field Prefixes take the format of the field on which they act Using the incorrect field in a calculation Referenced field or implicit field (referenced in the calculation but not in the request) Wrong ‘universe’ – does calculation pertain to a subset or the entire answer set?
8
FOCUS is Broken – Now What?
Examples Examples: TABLE FILE CAR SUM SEATS COMPUTE CPROFIT/D12.2 = RCOST - DCOST; BY COUNTRY SUM SALES COMPUTE RPROFIT/D12.2 = BY COUNTRY BY CAR END COUNTRY SEATS CPROFIT CAR SALES RPROFIT ENGLAND , JAGUAR ,466.00 JENSEN ,466.00 TRIUMPH ,466.00 FRANCE PEUGEOT ITALY , ALFA ROMEO ,830.00 MASERATI ,830.00 JAPAN DATSUN TOYOTA W GERMANY , AUDI ,169.00 BMW ,169.00 TABLE FILE CAR SUM PCT.SEATS BY COUNTRY ON TABLE COLUMN-TOTAL END PCT COUNTRY SEATS ENGLAND 18 FRANCE 7 ITALY 14 JAPAN 11 W GERMANY 48 TOTAL 98 COMPUTE takes the ‘last’ reference of a field, and will insert a field, immediately prior to the COMPUTE, if not referenced
9
FOCUS is Broken – Now What?
Wring Format Wrong Format Allow for maximum value (usually TOTALs) i.e. percent should allow for 100% How many decimal places are needed? Dollars only or dollars and cents Is rounding desired, or truncation Does a value of 12.5 get treated as 12 or 13? Proportional font vs. non-proportional Character alignment (spot markers) vs. column alignment (HEADALIGN) HEADING component alignment
10
FOCUS is Broken – Now What?
No Output No Output/Error message Fatal error What does it mean? Looping Too many records (takes too long) Transmission from server to client Verbose formats (i.e. HTML or XML)
11
FOCUS is Broken – Now What?
Check the environment Check the environment Many piece Client Server Tomcat Relation server All must work together correctly Can an existing ‘known’ request work? Can you get ‘test data via the server console Adapters/right click/Test Has anything changed? i.e. New version of Java?
12
FOCUS is Broken – Now What?
What can you do?
13
FOCUS is Broken – Now What?
What can you do? Determine what you can ? FILEDEF – to where are you pointing WHENCE filename MASTER | FOCEXEC | ACCESS What APP contains the MFD/ACX/Procedure APP SHOWPATH See the current search path If SQL, run ‘native’ – are the results correct? Is Focus finding a like-named MFD, prior to the desired one, in the path?
14
FOCUS is Broken – Now What?
What can you do? Isolate and simplify the components Request Run with SET XRETRIEVAL=OFF Parses but doesn’t execute Errors are displayed SQL may be displayed SET TRACESTAMP = OFF | SLEFT SET TRACEUSER = ON SET TRACEOFF = ALL SET TRACEON = STMTRACE//CLIENT SET TRACEON = SQLAGGR//CLIENT Useful -SET &ECHO=ON; Displays commands executed by the Reporting Server HTML output lets you ‘view source’ TRACESTAMP is the time stamp. Turning it OFF allows a CUT/PASTE of the SQL.
15
FOCUS is Broken – Now What?
What can you do? Simple example: Did SUBTOTAL, rather than RECOMPUTE SUBTOTAL adds the COMPUTEd fields; RECOMPUTE redoes the calculation with the subtotal values
16
FOCUS is Broken – Now What?
App Studio How do I get to the code?
17
FOCUS is Broken – Now What?
WebFOCUS How do I get to the code?
18
FOCUS is Broken – Now What?
WebFOCUS - What you see
19
FOCUS is Broken – Now What?
Add –SET &ECHO=ON; What you see? Big difference, huh?
20
FOCUS is Broken – Now What?
What’s Different? Select ‘view source’
21
FOCUS is Broken – Now What?
View Source At the bottom, in GREEN, The Server request, HTML encoded HTML ENCODED means: & replaced by & < replaced by < > replaced by > “ replaced by "
22
FOCUS is Broken – Now What?
What can you do? Compound Reports Run components individually Charts Run as a report, so you can see the results Report formats Run as ‘HTML’ to see the request Examine the results HOLD the output (no output, so errors can be seen) Run from server console (eliminate client)
23
FOCUS is Broken – Now What?
What can you do? Run with a subset of data WHERE RECORDLIMIT EQ nn SET OUTPUTLIMIT = RECORDLIMIT When developing, always display all referenced fields They can always be NOPRINTed later Ensures that correct instance of field is used Fields referenced in a COMPUTE are made verb objects,NOPRINT, before the COMPUTE, if not previously referenced Comment out selection (-*) to see which selection, if any, is causing issues i.e. using only a date selection for a date-time field (time 0 – midnight is assumed)
24
FOCUS is Broken – Now What?
When all else fails When all else fails, try the ‘janitor’ method Explain to a person with NO KNOWLEDGE of what you’re doing, what you ARE doing and WHY Often, you can then see your own logic errors Other person may be able to see what you can’t Can’t see the forest for the trees
25
FOCUS is Broken – Now What?
Bottom Line Bottom line Get as much information as you can, and eliminate any non-essential code (comment or skip). Being able to pinpoint the issue is the first step to resolving problems.
26
Focal Point Tips and Techniques
27
DataTables.js Add-in Responsive Grid Options
Anthony Cool & David Briars
28
DataTables.js Add-in Responsive Grid Options
Started with a Focal Point post: For those interested, Datatables.js is a nice JavaSript plugin library with various extensions that will allow you to make your ordinary HTML or AHTML reports better and more usable in a mobile setting: it has search, sorting, pagination, styling abilities all built in. I've integrated a header into the mix by adding the following line into my JS: $("body").prepend("<b>For week ending !IBI.AMP.WKEND; !IBI.AMP.forMsg;</b>"); Here is my -HTMLFORM block for implementing DataTables.js.
29
<script> $("body").prepend( "<b>For week ending !IBI.AMP.WKEND; !IBI.AMP.forMsg;</b>"); $('.x1').addClass('stripe hover compact cell-border'); $('table').first().prepend('<thead></thead>'); -*$('colgroup').first().remove(); $("tr:first-child").prependTo($('thead')); $(document).ready( function () { var iStart = new Date().getTime(); var oTable = $('.x1').dataTable( "scrollY": true, "scrollX": "300%", "sScrollXInner": "100%", "scrollCollapse": false, -* responsive: true, "lengthChange": true, "lengthMenu": [[5, 20, 50, 100, -1], [5, 20, 50, 100, "All"]], "paging": true, "pagingType": "full_numbers", "info": true, "pageLength": 20, -* "autoWidth": false, fixedHeader: true, fixedColumns: { leftColumns: 3 }, "ordering": true, "columnDefs": [ { "type": "html-num-fmt", "targets": [ 0, 1, 3, 4, 5, 6, 7, 8, 9, 10 ] } -* { "orderable": false, "targets": [3, 4, 5, 6, 7, 8, 9, 10 ]} ] } ); </script> -HTMLFORM END -HTMLFORM BEGIN <script type="text/javascript" src="/ibi_apps/jquery/js/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href=" <script type="text/javascript" src=" <style> td { line-height: .8em; } th, td { white-space: nowrap; td, tbody th { vertical-align: middle; text-align: right; font-size: .7em; table thead th, table thead td { color: white; text-shadow: none; text-align: center; b { font-size: 1.05em; font-family: Trebuchet MS; .x5 { display:none; .x6 { display: none; .dataTables_wrapper { </style>
30
Things to note: You'll need to modify the columnDefs.type targets with the right number of indexes specific to your report(s) if you want sorting to work. Columns are 0 indexed. Also, setting sScrollXInner to something larger that 100% will cause reports to crash on iOS browsers. To get horizontal scrolling to work on Android for reports with fixed columns, you have to use 2 fingers to scroll. Just plug the above block into the bottom of any of your report fexes, but inspect the page source first to see what class your table was given and your total rows and the following empty rows td tags were given and switch out any instances above of .x1 with your table class, and any instances of .x5/.x6 with your total row td tag class generated or what class the following empty row was given. The .x5 and .x6 classes are for getting rid of the extra blank row that generates at the end of your report if you choose/don't choose a total row to be included. Was having troubles with total rows in tablesaw.js so that was why this was implemented.
31
Output
32
Get a List of Files by DATE and Delete Older Files
Gavin Landon
33
Get a List of Files by DATE and Delete Older Files
Started with a Focal Point post: So I ran into an issue where we audit reports and what users are doing in the reports, which is a bit more complex than what you get out of the WF box. Each audit is created by day, so our logs don't get too big. While doing that, we find our self with many files in our audit folder sitting on the app server. This code below will allow user interaction with the audit files, but also can be used within an automated tool as well. I added the ability to View and download the files. This required the ability to create a master file on the fly. When the day picker changes, the date changes under it to reflect what will be deleted without refreshing the page.
34
-SET &THENDTTMDISP = &MONTH | '/' | &DAY | '/' | &YEAR;
SET ASNAME=MIXED -*Set Defaults, accepting params -DEFAULTH &KEEPDAYS = 5; -DEFAULTH &DEL = 'N'; -DEFAULTH &DL = 'N'; -DEFAULTH &FILEN = _FOC_NULL; STATE foccache/tmpfile.mas -RUN -SET &FILEEXISTS = IF &RETCODE EQ 0 THEN 'Y' ELSE 'N'; -*If return code is zero, then try to delete file, else check to see if source file exists. -IF &FILEEXISTS EQ 'N' THEN GOTO SKIPDEL; APP DELETEF 'foccache' 'tmpfile' 'mas' -SKIPDEL -TYPE FILEN = &FILEN; -IF &FILEN EQ _FOC_NULL THEN GOTO SKIPREAD; -SET &CSVFILE = 'audit_logger/&FILEN.EVAL'; -TYPE CSVFILE = &CSVFILE; FILEDEF MASTERFILE DISK foccache/tmpfile.mas -WRITE MASTERFILE FILENAME=tmpfile, SUFFIX=TAB , DATASET=&CSVFILE, $ -WRITE MASTERFILE SEGMENT=SEG1, SEGTYPE=S0, $ -WRITE MASTERFILE FIELDNAME=ROWDATE, ALIAS=Date, USAGE=A10, ACTUAL=A10, $ -WRITE MASTERFILE FIELDNAME=ROWTIME, ALIAS=Time, USAGE=A12, ACTUAL=A12, $ -WRITE MASTERFILE FIELDNAME=ROWUSER, ALIAS=User, USAGE=A25, ACTUAL=A25, $ -WRITE MASTERFILE FIELDNAME=ROWIPADDR, ALIAS=IPAddr, USAGE=A20, ACTUAL=A20, $ -WRITE MASTERFILE FIELDNAME=ROWPAGE, ALIAS=Page, USAGE=A255, ACTUAL=A255, $ -WRITE MASTERFILE FIELDNAME=ROWINFORMATION, ALIAS=Information, USAGE=A1000, ACTUAL=A1000, $ -SKIPREAD -IF &DL = 'Y' AND &FILEN.LENGTH GT 1 THEN GOTO DOWNLOADFILE; -*Set fixed vars -SET &BASEURL = '/ibi_apps/rs/ibfs/WFC/Repository/Validation/ViewLogs.fex?IBIRS_action=run'; -SET &FileNM = _FOC_NULL; -SET &APPNAME = _FOC_NULL; -*Get the New -SET &THENDTTM = (DATECVT((DATEADD((DATECVT(&YYMD,'I8YYMD','YYMD')),D,-&KEEPDAYS)),'YYMD','I8YYMD')); -SET &YEAR = SUBSTR(&THENDTTM.LENGTH, &THENDTTM, 1, &THENDTTM.LENGTH, 4, 'A4'); -SET &MONTH = SUBSTR(&THENDTTM.LENGTH, &THENDTTM, 5, &THENDTTM.LENGTH, 2, 'A2'); -SET &DAY = SUBSTR(&THENDTTM.LENGTH, &THENDTTM, 7, &THENDTTM.LENGTH, 2, 'A2'); -TYPE YEAR = &YEAR; -TYPE MONTH = &MONTH; -TYPE DAY = &DAY; -*-SET &THENDTTMDISP = '<div id=mdy>' | &MONTH | '/' | &DAY | '/' | &YEAR | '</div>'; -SET &THENDTTMDISP = &MONTH | '/' | &DAY | '/' | &YEAR; -TYPE THENDTTM = &THENDTTM -TYPE THENDTTMDISP = &THENDTTMDISP -*Get a list of files in the audit_logger app folder. APP QUERY audit_logger HOLD -RUN -*build some new fields to view and query against. DEFINE FILE FOCAPPQ D/I2 = EDIT(GETTOK(DATE,10,1,'/',2,'A2')) ; M/I2 = EDIT(GETTOK(DATE,10,2,'/',2,'A2')) ; INTDATE/I9 = EDIT(GETTOK(DATE,10,3,'/',4,'A4') | EDIT(M) | EDIT(D)); FILEDATE/A8MDYY = EDIT(M) | EDIT(D) | GETTOK(DATE,10,3,'/',4,'A4'); SELECTDAYS/A255 = '<select id="KEEPDAYS" onchange="keepDayChanged()"><option>1</options><option>5</options><option>10</options><option>20</options><option>30</options><option>60</options><option>90</options></select>'; DELETEBUTTON/A255 = '<button id="deleteBtn" class="deleteBtn" onclick="runDelete()">Delete</button>'; THENDTTMDISP/A255 = '<div style="display: inline;" id="mdy">&THENDTTMDISP.EVAL</div>'; SHOWBUTTON/A255 = '<button id="showBtn" class="showBtn" onclick="runShow()">Show</button>'; VIEWFILE/A255 = '<button id="viewBtn" class="viewBtn" onclick=runView("'|FILENAME||'")>View</button>'; ISFILTERED/I2 = POSIT(FILENAME, 70, '.mas', 4, 'I3')+POSIT(FILENAME, 70, '.foc', 4, 'I3')+POSIT(FILENAME, 70, '.acx', 4, 'I3')+POSIT(FILENAME, 70, '.fex', 4, 'I3'); END
35
-HTMLFORM BEGIN <script> { var keepdays = document.getElementById('KEEPDAYS'); keepdays.value = '&KEEPDAYS'; } Number.prototype.pad = function(size) { var s = String(this); while (s.length < (size || 2)) {s = "0" + s;} return s; Date.prototype.addDays = function(days) { var dat = new Date(this.valueOf()); var ret = new Date(dat.setDate(dat.getDate() + days)); return ret; Date.prototype.subtractDays = function(days) { var ret = new Date(dat.setDate(dat.getDate() - days)); function keepDayChanged() { var result = new Date(); var newResult = result.subtractDays(keepdays.value); var month = (newResult.getMonth()+1).pad(2); var day = (newResult.getDate()).pad(2); var year = newResult.getFullYear(); var newDate = month + '/' + day + '/' + year; var mdy = document.getElementById('mdy'); mdy.textContent = newDate; function runView(fileName) { location.href='&BASEURL.EVAL&|FILEN='+fileName+'&|KEEPDAYS='+keepdays.value; function runDelete() { if(confirm('Are you sure you want to delete files older than ' + keepdays.value + ' days old?')) location.href='&BASEURL.EVAL&|DEL=Y&|KEEPDAYS='+keepdays.value; function runShow() { location.href='&BASEURL.EVAL&|KEEPDAYS='+keepdays.value; function runDownload(fileName) { location.href='&BASEURL.EVAL&|KEEPDAYS='+keepdays.value+'&|FILEN='+fileName+'&|DL=Y'; </script> -*put the list of files into a hold file, so they can be viewed or looped through and physically deleted. TABLEF FILE FOCAPPQ PRINT FILEDATE FILENAME AS 'FileNM'; APPNAME INTDATE SIZE SELECTDAYS DELETEBUTTON SHOWBUTTON VIEWFILE ISFILTERED THENDTTMDISP -IF &DEL EQ 'N' THEN GOTO SKIPWHERE; WHERE INTDATE LE '&THENDTTM'; -SKIPWHERE WHERE ISFILTERED EQ 0; ON TABLE HOLD AS FILELIST END -RUN -*? HOLD FILELIST -*-EXIT -IF &DEL EQ 'Y' THEN GOTO DELETEFILES; -*Display the files on the screen, coloring the files to be deleted in red. TABLE FILE FILELIST FileNM COMPUTE SIZE/A25V = FPRINT(ATODBL(SIZE, '12', 'D12C'), 'D12C', 'A25V'); AS 'Size(b)' VIEWFILE AS 'View File' HEADING "Delete files older than <SELECTDAYS days <SHOWBUTTON" "Delete files on or before <THENDTTMDISP <DELETEBUTTON" "Anything in red will be deleted." BY HIGHEST INTDATE NOPRINT ON TABLE SET PAGE-NUM OFF ON TABLE SET STYLE * TYPE=DATA, COLUMN=FileNM, COLOR=RGB( ), WHEN=INTDATE LE &THENDTTM, $ ENDSTYLE -*create function to call back and delete files.
36
APP DELETEF '&APPNAME' '&FileNM' '&Ext' -ENDLOOP
-HTMLFORM BEGIN </div> -HTMLFORM END -EXIT -DELETEFILES -*Loop through file list and delete them. -REPEAT ENDLOOP &LINES TIMES -READFILE FILELIST -*strip trailing spaces -SET &FileNM = TRUNCATE(&FileNM); -*find the extension -SET &loc = POSIT(&FileNM, &FileNM.LENGTH, '.', 1, 'I2'); -SET &Ext = TRUNCATE(SUBSTR(&FileNM.LENGTH, &FileNM, &loc+1, &FileNM.LENGTH, &FileNM.LENGTH, 'A&FileNM.LENGTH')); -TYPE Ext = &Ext; -*make sure there isn't more periods in the file. -SET &loc = POSIT(&Ext, &Ext.LENGTH, '.', 1, 'I2'); -IF &loc EQ 0 THEN GOTO GETFILE; -FINDEXT -*go to the next period found. -SET &Ext = TRUNCATE(SUBSTR(&Ext.LENGTH, &Ext, &loc+1, &Ext.LENGTH, &Ext.LENGTH, 'A&Ext.LENGTH')); -IF &loc GT 0 THEN GOTO FINDEXT; -GETFILE -*Get only the file name without extension by replaceing the extension with blank. -SET &FileNM = TRUNCATE(STRREP(&FileNM.LENGTH, &FileNM, &Ext.LENGTH+1, '.'|&Ext, 0, '', &FileNM.LENGTH, 'A&FileNM.LENGTH')); -TYPE FileNM = &FileNM; -*Delete file. APP DELETEF '&APPNAME' '&FileNM' '&Ext' -ENDLOOP -*reload page, displaying files left. <script> { location.href='&BASEURL.EVAL&|KEEPDAYS=&KEEPDAYS.EVAL' } </script> <style> button { margin-top: 2px; margin-right: 2px; float: right; width: 70px; } .deleteBtn { margin-bottom: 2px; .downloadBtn { </style> <div style="position: absolute; top: 8px; left: 450px;"> -HTMLFORM END -DOWNLOADFILE DEFINE FILE foccache/TMPFILE DLFILE/A255 = '<button id="downloadBtn" class="downloadBtn" onclick=runDownload("&FILEN.EVAL")>Download XLSX</button>'; END TABLE FILE foccache/TMPFILE PRINT ROWTIME AS '' ROWUSER AS '' ROWIPADDR AS '' ROWPAGE AS '' ROWINFORMATION AS '' -IF &DL EQ 'Y' THEN GOTO SKIPHEADING; HEADING "Viewing file: &FILEN.EVAL <DLFILE" -SKIPHEADING -IF &DL EQ 'N' THEN GOTO SKIPDOWNLOAD; ON TABLE PCHOLD FORMAT XLSX AS &FILEN -SKIPDOWNLOAD ON TABLE SET PAGE-NUM OFF ON TABLE SET LINES ON TABLE SET STYLE * TYPE=HEADING, COLOR=RGB( ), $ TYPE=DATA, COLOR=RGB( ), WHEN=ROWTIME EQ 'Time', $ ENDSTYLE -SKIPDISP -IF &DL = 'Y' AND &FILEN.LENGTH GT 1 THEN GOTO EXIT;
37
Output
38
Decimal to Hexadecimal Conversion
Daniel Braunschvig, SRL Products
39
Decimal to Hecadecimal Conversion
Started with a Focal Point post: One of our customers asked for the possibility to convert a decimal number to hexadecimal both in Dialog Manager and as a WebFOCUS function. Here is what we came up with:
40
WebFOCUS Function: -SET &ECHO=ALL; -* File f_dec2hex.fex DEFINE FUNCTION DEC2HEX (DEC/I9) H0/I9=DEC; HEX/A9=' '; -REPEAT #HLOOP FOR &I FROM 1 TO 9; -SET &J=&I-1; H&I/I9=H&J / 16; HN/I9=H&J - H&I * 16; HX/A1=DECODE HN(0 '0' 1 '1' 2 '2' 3 '3' 4 '4' 5 '5' 6 '6' 7 '7' 8 '8' 9 '9' 10 'A' 11 'B' 12 'C' 13 'D' 14 'E' 15 'F'); HEX/A9=HX | SUBSTR(9, HEX, 1, 8, 8, 'A8'); -#HLOOP DEC2HEX/A9=TRIM('L',HEX,9,'0',1,'A9') ; END -RUN TABLE FILE CAR SUM SALES COMPUTE HSALES/A9=DEC2HEX(SALES); BY COUNTRY Dialog Manager: -SET &ECHO=ALL; -* File dec2hex.fex -DEFAULT &DEC= ; -SET &HEX=' '; -SET &H0=&DEC; -#NXTHEX -SET &H1=&H0/16; -SET &HN=&H0 - &H1 * 16; -SET &HX=DECODE &HN(0 '0' 1 '1' 2 '2' 3 '3' 4 '4' 5 '5' 6 '6' 7 '7' 8 '8' 9 '9' 10 'A' 11 'B' 12 'C' 13 'D' 14 'E' 15 'F'); -SET &HEX = &HX | &HEX; -IF &H0 LE 15 GOTO #DONE; -SET &H0 = &H1; -GOTO #NXTHEX -#DONE -TYPE &DEC = &HEX
41
Output If the server has DMPRECISION set to anything other than the default 0, it might be worthwhile using INT function in the DM solution. -SET &H1=INT(&H0/16);
42
Distinct Count on a ROW Total
Benazir Mohammad & Anthony Alsford
43
Distinct Count on a ROW Total
Started with a Focal Point post: I am trying to pivot and get the unique PartKey count and Sales$. By Fields are Mfr and Type. Across is YearQtr. I can use count distinct and the Pivot is fine but struggling with ROW_TOTAL. ROW-TOTAL shows some of distinct PARTKEY and NOT distinct PARTKEY. Below is the Dataset, Current Result and Expected Result.
45
Current Result -* Start of data preparation A,2015-01,1A,193,1192,$
EX -LINES * EDAPUT MASTER,BMFILE,CV,MEM FILE=BMFILE,SUFFIX=FOC SEGNAME=SEG1 FIELD=MFR, ,A1 ,A1 ,$ FIELD=YearQtr, ,A7 ,A7 ,$ FIELD=Type, ,A2 ,A2 ,$ FIELD=PartKey, ,A10 ,A10 ,$ FIELD=SALES, ,D12M ,D12 ,$ EDAPUT* -RUN CREATE FILE BMFILE MODIFY FILE BMFILE FREEFORM MFR YearQtr Type PartKey SALES DATA A, ,1A,193,1192,$ A, ,1A,1934,812,$ A, ,1A,CAN00,66,$ A, ,4D,CAN00,115,$ A, ,4D,CAN00,1125,$ A, ,1A,F06,1215,$ A, ,1A,193,6556,$ A, ,1A,CAN00,66,$ A, ,4D,VGAS,140,$ A, ,4D,1934,138,$ A, ,4D,CAN,66,$ A, ,3C,VJ13,640,$ A, ,1A,193,3874,$ A, ,1A,VJ13,1080,$ A, ,2B,VJ13,558,$ B, ,1A,F06,1215,$ B, ,1A,193,6556,$ B, ,4D,CAN,66,$ B, ,3C,VJ13,64,$ B, ,1A,193,38,$ B, ,1A,193,64,$ END -RUN -* End of data preparation
46
Solution To achieve this you will have to handle the data twice, once to get your row totals and then the second to get your combined output. Because you are using ACROSS, there will be some title issues, but I am sure there will be many suggestions on how you might achieve this. As this is a situation that many can find an obstacle, here is some sample code using the data that you have shared.
47
Solution SET PAGE = NOLEAD SET ASNAMES = MIXED TABLE FILE BMFILE SUM CNT.PartKey AS 'Count' SALES AS 'Sum' BY MFR BY Type ACROSS YearQtr AS '' ON TABLE ROW-TOTAL AS 'Total' END -RUN SUM CNT.DST.PartKey AS DSTPARTS SALES AS TOTSALES ON TABLE HOLD AS BMTOTALS JOIN CLEAR * JOIN FILE BMFILE AT MFR TAG T1 TO UNIQUE FILE BMTOTALS AT MFR TAG T2 AS J2 WHERE T1.MFR = T2.MFR; WHERE T1.Type = T2.Type; END TABLE FILE BMFILE SUM MAX.T2.DSTPARTS NOPRINT MAX.T2.TOTSALES NOPRINT BY MFR BY Type SUM CNT.PartKey AS 'Count' SALES AS 'Sum' ACROSS YearQtr AS '' COMPUTE TotCount/I9 = C1; AS 'Count' COMPUTE TotSales/D12M = C2; AS 'Sum' -RUN The reason you would need to do two passes is that you cannot have a distinct operator in the first section of a multi-verb request.
48
Solution Output
49
Two Title Rows Michael Armento, BKFS and Steven Hall, Associated Food Stores
50
Two Title Rows Started with a Focal Point post: Is there a way to get 2 title rows on top of each other? I tried SUBHEAD, but it displays above the report header. DEFINE FILE CAR Error_Column/I3=IF SEATS EQ 2 THEN 1 ELSE IF SEATS EQ 4 THEN 3 ELSE 5; END TABLE FILE CAR PRINT Error_Column CAR.COMP.CAR CAR.CARREC.MODEL CAR.BODY.BODYTYPE CAR.BODY.SEATS CAR.SPECS.LENGTH CAR.WARANT.WARRANTY HEADING "Standard Report“ "ABC123 CAR“ "Company XYZ" ON TABLE SUBHEAD " <+0>1<+0>2<+0>3<+0>4<+0>5<+0>6" ON TABLE SET PAGE-NUM NOLEAD ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT EXL07 ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * INCLUDE = IBFS:/EDA/BIRS05/_EDAHOME/ETC/endeflt.sty, $ TYPE=TABHEADING, HEADALIGN=BODY, $ ENDSTYLE END
51
Solution: DEFINE FILE CAR Error_Column/I3=IF SEATS EQ 2 THEN 1
ELSE IF SEATS EQ 4 THEN 3 ELSE 5; END TABLE FILE CAR PRINT Error_Column CAR.COMP.CAR CAR.CARREC.MODEL CAR.BODY.BODYTYPE CAR.BODY.SEATS CAR.SPECS.LENGTH CAR.WARANT.WARRANTY HEADING "Standard Report" "ABC123 CAR" "Company XYZ" " <+0>1<+0>2<+0>3<+0>4<+0>5<+0>6" ON TABLE SET PAGE-NUM NOLEAD ON TABLE PCHOLD FORMAT EXL07 ON TABLE SET STYLE * TYPE=REPORT, COLOR=RGB( ), FONT='TREBUCHET MS', SIZE=9, SQUEEZE=ON, ARICONSET='WHITE', GRID=ON, $ TYPE=HEADING, HEADALIGN=BODY, $ TYPE=HEADING, LINE=1, COLSPAN=7, STYLE=BOLD, JUSTIFY=CENTER, $ TYPE=HEADING, LINE=2, COLSPAN=7, STYLE=BOLD, JUSTIFY=CENTER, $ TYPE=HEADING, LINE=3, COLSPAN=7, STYLE=BOLD, JUSTIFY=CENTER, $ TYPE=HEADING, LINE=4, COLSPAN=1, STYLE=BOLD, BACKCOLOR=RGB( ), COLOR=RGB( ), $ TYPE=TITLE, BACKCOLOR=RGB( ), COLOR=RGB( ), STYLE=BOLD, $ ENDSTYLE END This solution will output two title rows in Excel. By default, all heading lines in Excel are in one row.
52
Output:
53
Socialize to Win! Daily Prizes Awarded!
Tweet and tag #IBSummit during the event! in your #IBSummit pics! Check our Summit Facebook & LinkedIn pages for updates, photos, and announcements
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.