IBM Security Z Security

 View Only

 show a fixed string when a (lookup) value is not missing

Rob van Hoboken's profile image
Rob van Hoboken IBM Champion posted Thu April 10, 2025 03:38 AM

We have a RACF profile report where we need to print BASE segment fields and print the text string TSO if the user has a TSO segment.  Easy, except:

  • we cannot use SUMMARY because the BASE segment values needed require the used of MERGELIST
  • we must take the BASE segment because the output uses SELECT conditions on the BASE fields
  • we really prefer not to have an external (DEFTYPE) file

Here is the straw man code:

mergelist
newlist type=racf
  select class=user segment=base not(protected) ljdate<>never special
  sortlist profile(8,"Userid") ljdate($date,10) passdate($date,10) :tmsize /* many many more fields */
newlist type=racf
  select class=user segment=base protected ljdate<>never special
  sortlist profile(8,"Userid") ljdate($date,10) "NOT USED"(10) :tmsize

/* 2 more newlists printing "NEVER USED" when LJDATE=NEVER */
endmerge

You can see a TSO MAXSIZE value if there is a TSO segment, and a missing value when there is no TSO segment.  All I need is a trick to print a blank if the value exists or a string "TSO" if it is missing, not unlike the BLANK$STR format for flag fields.  However:

  • you cannot convert :TMSIZE into a flag because DEFINE .. WHERE missing(:TMSIZE) obviously doesn't accept :TMSIZE in a SELECT context
  • :tmsize(blank$str('TSO')) only works for FLAG fields
  • using a preceding newlist name=tsoseg outlim=0; select segment=tso, and duplicating the 4 (reporting) newlists with PROFLIST=TSOSEG and NOT(PROFLIST=TSOSEG) cases adds a lot more duplicated code
  • if the DATE$STR format was not limited to the DATE format ( 9 Apr 2025) but instead supported more date formats, I could do away with the MERGELIST block and use the standard SUMMARY solution to this conundrum

Is there a format or trick that I overlooked, to print a literal when a field (value) is missing, and nothing when it is not?

Rob van Hoboken's profile image
Rob van Hoboken IBM Champion

Converting from TYPE=RACF to TYPE=ID offers more flexibility, in that ID combines info from BASE and TSO segments, thus obviating the need for SUMMARY or tricks with TMSIZE:

mergelist
newlist type=id
  select class=user not(id:protected) id:ljdate<>never id:special
  sortlist id("Userid") id:ljdate($date,10) id:passdate($date,10) tso /* many many more fields */
newlist type=id
  select class=user id:protected id:ljdate<>never id:special
  sortlist id("Userid") id:ljdate($date,10) "NOT USED"(10) tso

/* 2 more newlists printing "NEVER USED" when LJDATE=NEVER */
endmerge

I suppose it will become second nature to use lookups like id:protected, but the select and define functions do the job, so far.

ID needs a CKFREEZE file, that will provide some more challenges compared to just reporting from the active RACF db, now we have to add an ALLOC command for the appropriate CKFREEZE dsn too.  So the questions from the OP remain, though at a lower level of urgency.