Crystal Report Loop

Carla van Zyl

Good day, 

I don't know if this is the correct forum, I am building a Crystal report that is linked to a Boyum Button in SAP. 

Now I am trying to do a formula in Crystal but it is currently only looking at first row. I tried to do a loop, but its keep on saying there is something wrong. Please can you advise how I can fix this or create a loop. Here is my formula. 

 

It needs to loop through all rows in Line sequence

 

NumberVar i;
StringVar foundLocation := "-";

// Loop through each row of the SP_CARLA_TruckPlanningReport dataset
for i := 1 to Count({SP_CARLA_TruckPlanningReport;1.u_prodloc}),
    // Check if the current row's line sequence matches 2
    if {@linesequence}[i] = 2 then 
        // Set foundLocation to the corresponding location
        foundLocation := {SP_CARLA_TruckPlanningReport;1.u_prodloc}[i]
        // Exit the loop if a match is found
    Exit For;
    else 0;
Next i;

//foundLocation

 

Comentarios

0 comentarios

Iniciar sesión para dejar un comentario.