For Next Loops

Printed From: Crystal Reports Book — Forum Name: Technical Questions

I understand the general concept of For Next Loops, I just have no idea how to execute them on a Command table in Crystal. Is there a good basic resource to build my knowledge on this subject.

My present problem is that i have a parameter with multiple values. I would like to use the code below and loop through each of the values in my parameter to have them be equal to the equipment_id ('D40110' AS equipment_id). My goal is to generate a complete set of dates associated with each parameter value(equipment_id) for graphing purposes. This is to avoid having missing dates on the x-axis for each equipment_id. Any thoughts are greatly appreciated.

For the sake of discussion the parameter of multiple equipment ids is called {?equip_list}


SELECT

TRUNC(cia.activity_datetime) as dt,
'D40110' AS equipment_id,

FROM COMPONENT_INV_ACTIVITY cia

WHERE
cia.activity_datetime>={?START_DRAW_DATE} AND
cia.activity_datetime<{?END_DRAW_DATE}+1

GROUP BY

TRUNC(cia.activity_datetime)
You can't do this in a For Next loop in the report. Based on the query you posted, it looks like you're using Oracle. I'm also going to assume that this query is a Command in the report.

To use a multi-select parameter in a Command, you'll do something like this:


and cia.equipment_id in {?Equipment ID}


If you need to make this parameter dynamic, see this blog post: https://blogs.sap.com/2015/04/01/best-practices-when-using-commands-with-crystal-reports/

-Dell