Print Page | Close Window

For Next Loops

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22855
Printed Date: 25 Apr 2024 at 7:22pm


Topic: For Next Loops
Posted By: cbaldwin
Subject: For Next Loops
Date Posted: 07 Jan 2020 at 3:52am
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)



Replies:
Posted By: hilfy
Date Posted: 23 Jan 2020 at 10:41am
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

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window