As you may be aware, BMC Extract for IMS is a fast and flexible IMS data selection and formatting utility that comes with an extensive expression language which provides the capability to quickly extract and reformat IMS data. Besides being up to five times faster than an application program, API, or User Exit, BMC Extract for IMS also uses dramatically less CPU, eliminates the need for IMS programming skills, and requires much less time to develop, code, and test.

Many customers use BMC Extract for IMS to mask sensitive data as they “port” IMS production data over to their test and development environments. A common method is to simply plug sensitive data with constants. However, this approach removes variability for targeted fields and can have a downstream usability impact for key fields and secondary indexes.

BMC Extract for IMS comes with the capability to create “unique” fields during extract. This method can deliver desired field variability to target environments while protecting sensitive data. The key “expression” variable that provides the basis for uniqueness in outputted data is &SEGMENTCOUNT. This variable gets incremented by one for each segment. This variable can be used to create either complete uniqueness, or uniqueness with a degree of duplication.

Below is an example of a method that can be used to create “unique” Social Security numbers during extract. It assumes that the Social Security number is in “X” format and not numeric.

**/* */**

**/* E.G., UNIQUE CONTRIVED SOCIAL SECURITY # */**

**/* COLUMNS ARE FLIPPED TO CREATE “SEPARATION” */**

**/* THE “ONES” COLUMN AFFECTS THE “HUNDRED MILLIONS” COLUMN */**

**/* THE “TENS” COLUMN AFFECTS THE “TEN MILLIONS” COLUMN */**

**/* THE “HUNDREDS” COLUMN AFFECTS THE “MILLIONS” COLUMN */**

**/* ETC. */**

**/* NOTE: YOU CAN SHUFFLE THE SEQUENCE AND STILL HAVE UNIQUENESS */**

**/* */**

**FIELD ( ( 100000000 - ((&SEGMENTCOUNT-1) ) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 100000000 - ((&SEGMENTCOUNT-1) / 10) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 10000000 - ((&SEGMENTCOUNT-1) / 100) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 1000000 - ((&SEGMENTCOUNT-1) / 1000) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 100000 - ((&SEGMENTCOUNT-1) / 10000) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 10000 - ((&SEGMENTCOUNT-1) / 100000) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 1000 - ((&SEGMENTCOUNT-1) / 1000000) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 100 - ((&SEGMENTCOUNT-1) / 10000000) ) TRANSFORM (1:1 C) )**

**FIELD ( ( 10 - ((&SEGMENTCOUNT-1) / 100000000) ) TRANSFORM (1:1 C) )**

Below are the results of this expression. I am also including the &SEGMENTCOUNT field as a reference. Notice that I have flipped the positions of the field taking the low-order columns and placing them in the high-order columns. As such, this approach creates a balance of keys with the high-order position being nearly equally balanced between 0-9.

**New SS# &SEGMENTCOUNT**

**000000000 1**

**900000000 2**

**800000000 3**

**700000000 4**

**600000000 5**

**500000000 6**

**400000000 7**

**300000000 8**

**200000000 9**

**100000000 10**

**090000000 11**

**990000000 12**

**890000000 13**

**790000000 14**

**690000000 15**

**590000000 16**

**490000000 17**

**390000000 18**

**290000000 19**

**190000000 20**

**080000000 21**

**980000000 22**

**880000000 23**

It is easy to engineer in duplication by reducing the number of columns. For example, reducing the “plug” field to use only four columns (and constant-filling the rest of the columns) would create duplicates for every 10,000 occurrences. If the “plug” were reduced to two columns, every 100 occurrences would create duplicates.

Also, BMC Extract for IMS can be used to create unique “alpha” values as well. The method outlined below shows how to leverage &SEGMENTCOUNT to assign a letter in the alphabet. Here is an example below for one character position.

**/* */**

**/* E.G., UNIQUE CONTRIVED ALPHABETIC UNIQUENESS FOR ONE COLUMN */**

**/* */**

**FIELD ( ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 1) THEN (C’A’)**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 2) THEN (C’B’)**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 3) THEN (C’C’)**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 4) THEN (C’D’)**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 5) THEN (C’E’)**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 6) THEN (C’F’)**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 7) THEN (C’G’)**

**…**

**ELSE ( IF ((&REMAINDER (&SEGMENTCOUNT / 26)) EQ 25) THEN (C’Y’)**

**ELSE (C’Z’)**

**/* */**

**))))))))))))))))))))))))))**

Results:

**Alpha &SEGMENTCOUNT**

**A 1**

**B 2**

**C 3**

**D 4**

**E 5**

**F 6**

**G 7**

**H 8**

**I 9**

**J 10**

**K 11**

**L 12**

**M 13**

**N 14**

**O 15**

**P 16**

**Q 17**

**R 18**

**S 19**

**T 20**

**U 21**

**V 22**

**W 23**

It is also possible to build many character positions using the supporting calculations. One character position supports 26 unique letters of the alphabet. Two character positions 676 combinations, or actually 702, if you wanted to include “space/blank” as one of the characters to populate in the second sub-field. (Three character positions -17576 or four character positions-456976. etc.). Another example is below where I am defining a second alphabetic field that is space f or the first 26 iterations, then “A ” for the next 26, then “B,” and so on.

**/* */**

**/* E.G., UNIQUE CONTRIVED ALPHABETIC UNIQUENESS FOR A SECOND COLUMN. */**

**/* FIRST ITERATION OF 26 POPULATES SPACES. */**

**/* */**

**FIELD((IF (&SEGMENTCOUNT LE 26) THEN (C’ ‘)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 1) THEN (C’A’)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 2) THEN (C’B’)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 3) THEN (C’C’)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 4) THEN (C’D’)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 5) THEN (C’E’)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 6) THEN (C’F’)**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 7) THEN (C’G’)**

**…**

**ELSE(IF((&REMAINDER(&REMAINDER((&SEGMENTCOUNT-1)/676))/26)EQ 25) THEN (C’Y’)**

**ELSE (C’Z’)**

**))))))))))))))))))))))))))**

**))**

Results:

**Alpha &SEGMENTCOUNT**

**A 1**

**B 2**

**C 3**

**…**

**X 24**

**Y 25**

**Z 26**

**AA 27**

**BA 28**

**CA 29**

**DA 30**

**EA 31**

**FA 32**

**…**

**WA 49**

**XA 50**

**YA 51**

**ZA 52**

**AB 53**

**BB 54**

**CB 55**

**DB 56**

**EB 57**

It is possible to build a third, fourth, or character position. A third position character would then build off the work done for alpha position 2 and would cycle every 17,576 occurrences (more if using spaces like we did for the second alpha character).

As we have seen, BMC Extract for IMS is a fast and flexible IMS data selection and formatting utility that provides a capability to quickly extract and reformat IMS data. With these methods covered, it should be relatively easy for the implementer to mask data while maintaining uniqueness when extracting IMS data.

*Thanks to Bob Aubrecht, Principal Software Consultant, BMC Software for his contribution to this article. If you have any questions about the article, please feel free to contact Bob directly Robert_Aubrecht@bmc.com.*