Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help to reset array when a flag changes

Status
Not open for further replies.

unknownly

Programmer
Jul 7, 2003
181
US
Hi All,

One of the expert as posted this solution(below) for my problem and it is exactly what I wanted. I but have another little issue when there are two different input list which will read into one database field and is difference can be figure through a another field which is a flag field.

How can I use this formula and reset the rows reading into the arrays when the flag field changes.....

Any help is greatly appericated very much....

Thanks,

Sweetie




Also, the sample only shows using 3 arrays. If your list of accounts was greater than 254 * 3, then you'd need additional array(s).

Create 5 formulas:

Formula: VariableDeclarations
--------------------
BeforeReadingRecords;
global NumberVar x;
global NumberVar y;
global NumberVar z;
global NumberVar w;
Global StringVar Array arCustomerID;
Global StringVar Array arCustomerID2;
Global StringVar Array arCustomerID3;
global NumberVar StringLength;

Formula: CustomerList
---------------------WhileReadingRecords;
Global NumberVar x;
Global NumberVar y;
Global NumberVar z;
Global NumberVar w;
Global StringVar Array arMaster;
Global StringVar Array arCustomerID;
Global StringVar Array arCustomerID2;
Global StringVar Array arCustomerID3;
Local StringVar strCustomerID := Cstr({Customer.Customer ID},"0",0);
Global NumberVar StringLength;

If Not (strCustomerID in arMaster) then
(x := x + 1;
Redim Preserve arMaster[x];
arMaster[x] := CStr({Customer.Customer ID},"0",0);
StringLength := StringLength + Length(strCustomerID) + 1; //add one to allow for comma separation
SELECT StringLength
CASE 0 to 254:
(w := w + 1;
Redim Preserve arCustomerID[w];
arCustomerID[w] := CStr({Customer.Customer ID},"0",0);)
CASE 255 to 508:
(y := y + 1;
Redim Preserve arCustomerID2[y];
arCustomerID2[y] := CStr({Customer.Customer ID},"0",0);)

CASE 509 to 782:
(z := z + 1;
Redim Preserve arCustomerID3[z];
arCustomerID3[z] := CStr({Customer.Customer ID},"0",0);)

DEFAULT:

//do nothing
"0";
)

Formula: ShowArray1
--------------------
whilePrintingRecords;
Global StringVar Array arCustomerID;
Join(arCustomerID, ",")

Formula: ShowArray2
--------------------
whilePrintingRecords;
Global StringVar Array arCustomerID2;
Join(arCustomerID2, ",")

Formula: ShowArray3
--------------------
whilePrintingRecords;
Global StringVar Array arCustomerID3;
Join(arCustomerID3, ",")

Place the first formula in the report header. Put the 2nd Formula in the details section. Create a text box in the report header and place the remaing formulas in the textbox.
 
Hi Guys,


Please suggestion any idea and make my day, Please. I have tried so many thing but doesn't work.


Thanks,

Sweetie
 
The above formula resolved this problem mented below
When my users run the report thru peoplesoft, they enter the input/or pick from a list of values as an input values for a parameter. All these parameter input values are stored in a special table (selectvalues field) in database.
I had to show this users input values on the repport page header as the choose parameter values.
For ex: User inputs for the ?BU //could be 1 value or multiple values.
10203
10543
10605
96540.. so
?period : Jan2004

in report page header i had to show it as

BU:10203,10543,10605,96540
Period:JAn2004

the array formula worked.

The trouble I am having now is that I have a new parameter ?Aff
users input would be same as like BU.

say: a user input 2 values for ?BU and 3 values for ?AFF as
?BU : 10543
14503

?Period: JAn2004

?AFF: 19653
19876

In the report I should be displaying it as below in PH
BU:10543,14503
Period:Jan2004
AFF:19653,19876

But my report displays as this

BU:10543,14503,19653,19876
Period:Jan2004
AFF:10543,14503,19653,19876


becuase whatever the user inputs for BU, AFF, OU, GE, AT,PD parameters it will be stored in a special table in database and will be different by a Flag field.

I hope I made myself clear...any help is greatly apperciated

Thanks in advance,

Sweetie






 
Sweetie,

Instead of trying to reset this formula, copy it and then change the names of the variables. An easy way is to add an "x" to the name of each variable, e.g., numbervar x becomes numbervar xx. Then I think you only need to add a clause defining the flag condition in the first clause of the formula, as in:

If Not (strCustomerID in arMaster) and
{table.flag} = true then//etc.

Or something like this. Add the appropriate flag clause to your first formula as well.

-LB
 
Hi LB,

A of now we have 6 flags. So, do I need to add 6 six times or can I it be approched diferent?

Thank you,

Sweetie
 
You only mentioned the two parameters that were sharing the same field, but conditionally based on a flag. Are there more parameters? Or are you saying that the "flag" is not boolean, but has multiple results?

-LB
 
yeah 'Flag' type is not a boolean.
It has 6 values for now in Database. Going futher they may have more or may not.

So I will have to write 6 formulas use different variable names and change the flag type
@1
If Not (strCustomerID in arMaster) and
{table.flag} = 'BU' then//etc.

@2
If Not (strCustomerID in arMaster) and
{table.flag} = 'AFF' then//etc.


so on for the flag = OU, GE, AT,PD (@3,@4,@5,@6)

I thank you again for your response.

Sweetie




 
If you are planning to use all six as parameters, then yes, create one formula per parameter, changing the variable names and the flag result. It's easy enough, since all you need to do is copy and paste. You can use search and replace to change the variable names, too. There might be an easier method that someone else can suggest, but this is what I'd try.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top