I am attempting to use a WHILE loop in the TI process to go through the parameters and if they're not empty, then add the elements to the dimension and populate the caption.
If I write it like this, the PAW TI editor recognizes pAdd1 as a parameter being provided and adds the desired element:
DimensionElementInsertDirect(DimName, '', pAdd1, 'N');
However, when I put it in the WHILE loop and attempt to concatenate the number to the end of pAdd to get the equivalent of pAdd1, it does what I would expect (but not what I want) and literally adds the element pAdd1 to my dimension... rather than picking up the pAdd1 parameter.
DimensionElementInsertDirect(DimName, '', 'pAdd'|NumberToString(Counter), 'N');
So the question is whether it is possible to use the counter to add the elements specified by pAdd1, pAdd2, pAdd3, ..., pAdd20?
The only option I've come up with is to start with 20 lines (and 20 more for the caption) saying if Counter = 1, pAddMe = pAdd1 and if Counter = 2, pAddMe = pAdd2, etc. and then the information inside the WHILE loop would just deal with pAddMe. It is a bit sloppy to have 40 lines (20 for the elements and 20 for the parameters) just to do what I'm trying to do with concatenating the counter to pAdd.
I know it is doing exactly what I'm asking but I can't figure out how to achieve what I'm trying to do. I've done my sloppy, non-scalable workaround for years and I'm sure there is a better way.
Code: Select all
#Section Prolog DimName = 'siteEmployees'; MaxCounter = 20; if (pExecute=0); ProcessQuit; endif; #Section Metadata DimensionSortOrder(DimName, 'ByInput','Ascending', 'ByName', 'Ascending'); Counter = 1; WHILE(Counter <= MaxCounter); IF('pAdd'|NumberToString(Counter) @<> ''); DimensionElementInsertDirect(DimName, '', 'pAdd'|NumberToString(Counter), 'N'); DimensionElementComponentAddDirect(DimName, pCostCentre, 'pAdd'|NumberToString(Counter), 1); ENDIF; Counter = Counter + 1; END; DimensionUpdateDirect(DimName); #Section Data # If I can get the above working then I'll repeat the WHILE loop here to populate the caption. # AttrPutS('pCaption'|NumberToString(Counter), DimName, 'pAdd'|NumberToString(Counter), 'Caption'); #Section Epilog SecurityRefresh;
Admin Note: Please use the Code tag to surround code blocks for readability.