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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Position of an Array revisited again

Status
Not open for further replies.

chuckyfiche

IS-IT--Management
May 20, 2004
5
CA
Well, I'm sorry to say I'm back once again with a report/array that still does not work. I can only find small blocks of time to work on this problem thus the lenght between posts.

Everyone has been very helpful with this block of code. The problem I seem to be having now, is the array is building, but only counting once then resetting.

Thus, the running total works for two parts in a row, then goes back to the original @available quantity.

I've removed all other tables, groups and paramaters. I've built three standard parts, put in quantities and created three orders as a sample to verify the script. I really can't see why it doesn't work.

The only 'glitch' and reason I feel there could be a problem with the script - is it needs the sCounter variable set in the header or Crystal reports a problem with the subscript needing to be between 1 and the size of the array.

Crystal 8.5; SQL Server.

I've tried removing the counter and changing the code to a redim preserve array [ubound(array)+1];

I've also changed the while to a for loop.

Same results all around.


List should look like this:

Part On Order Available Balance
1 50 100 50
2 25 30 5
1 40 50 10
2 5 5 0

I know the on-order column; the available and balance need to be calculated with the array;

Thank you all for any help on this seemingly impossible problem.

>>>>>>>>>>>>@AVAILABLE_QTY<<<<<<<<<<<<<<<< {PART.QTY_ON_HAND} - {CUST_ORDER_LINE.ORDER_QTY}
>>>>>>>>>>>
Code:
evaluateafter({@AVAILABLE_QTY});
stringvar array PART_Array;
numbervar array Qty_Array;
numbervar NewQty;
numbervar max;
numbervar sCounter :=0;
Booleanvar Flag;

        if not({CUST_ORDER_LINE.PART_ID} in PART_Array )then
            (
              sCounter := sCounter +1;
              Redim Preserve PART_Array[sCounter];
              Redim Preserve Qty_Array[sCounter];
              PART_Array[sCounter] := {CUST_ORDER_LINE.PART_ID};
              NewQty := {@AVAILABLE_QTY};
              QTY_Array[sCounter] := NewQty;
              Flag := False;

            )
        else

       (
              max := ubound(PART_Array);
           
              While sCounter <= max and Flag = false do 
          
            (
                  sCounter := sCounter+1; 

                  if{CUST_ORDER_LINE.PART_ID} = PART_Array[sCounter] then
                     
                  (                     
                        NewQty := QTY_Array[sCounter] - {CUST_ORDER_LINE.ORDER_QTY};
                        QTY_Array[sCounter] := NewQty;
                        Flag := True;
                
                   );

                );
       );

NewQty;
 
I think this is your problem

Booleanvar Flag;

it should be

Booleanvar Flag := False;

In your ELSE section on the first loop the value of FLAG is set to TRUE after the first execution.

On the next execution - if the partID already exists - the ELSE while loop will never be entered since Flag is set to TRUE ....hence this loop is only executed once/report.

there is your problem...you want that flag reset to false everytime you enter this formula


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Thanks Jim. I forgot I had taken that iteration out while testing.

I should explain a little further, perhaps my problem is the grouping.

If I select ONLY one part; the array builds successfully. I can keep a proper total throughout a dozen orders; each order is grouped by order #, customer # and order Date.

Once I select multiple part numbers, the arrays no longer build correctly and the numbers only work for a part that exists in consecutive group entries.

As I see it, the array counter is resetting with each part / group change. Otherwise, the totals would add consecutively all the time.

It's frustrating. Because I know it should work.

Thanks

Michael
 
Sorry - I wasn't clear in my last post - it still doesn't work, even with the booleanvar := false;

The rest of my post stands.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top