<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Using a parameter in a command in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050986#M2873058</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured out that for commands the parameters have to be entered via Database Expert/Command Edit. &lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; This is true. You do have to add the parameter to the parameter list in order to reference it in the command SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot create the parameter the normal way. &lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Not true. You have 2 options...&lt;/P&gt;&lt;P&gt;-- 1) Create the parameter in the "normal manner" then simply retype the parameter name in parameter list (making sure to use the exact same spelling).&lt;/P&gt;&lt;P&gt;-- 2) Create the parameter in the command's parameter list, then edit it from the design view/field explorer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is unfortunate as the options for a paramter in command edit are sparse. &lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; The parameter list is only there to create the reference. Use the parameter designer, from the report design view to set the parameter details. (see above)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you use the parameter in the SQL you do have to use the quotes as you suggested ...&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Not necessarily true... CR does a VERY cool thing when it comes to passing parameters to commands. It actually does a direct substitution of the parameter value into the command SQL. So it simply depends on the syntax of the database you are using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... because apparently the value is determined before the SQL command is evaluated.&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Yes, and this is a good thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- For example (Using SQL Server syntax), all of the following are valid&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
-- Exact text match

SELECT *
FROM TableName
WHERE TextColumn = '{?TextParameter}'
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;
-- Exact numeric match

SELECT *
FROM TableName
WHERE NumberColumn = {?NumberParameter}
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;
-- Wildcard match

SELECT *
FROM TableName
WHERE TextColumn LIKE '%{?TextParameter}%'
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can even pass entire blocks of SQL through a parameter, giving the effect of dynamic SQL without having to write dynamic SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For exmple... Say you want to make a parameter that allows the user to select "FirstName LastName" or "LastName, FirstName"...&lt;/P&gt;&lt;P&gt;Create a parameter like this...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Value 1
t.FirstName + ' ' + t.LastName AS Name
Desc 2
First then Last

Value 2
t.LastName + ', ' + t.FirstName AS Name
Desc 2
Last then First
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now write your SQL like this...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT
{?NameParameter},
t.Column2,
t.Column3
FROM TableName AS t
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The only limitation to using parameters in commands is your imagination. I've even passed entire select statements through commands.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Aug 2011 01:29:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-08-10T01:29:06Z</dc:date>
    <item>
      <title>Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaq-p/8050982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running Crystal Reports XI against an Oracle database. I created a command which initially used a static value for one of the where comparisons. Now I have created a parameter with static values and I want the command to make the comparison against the entered selection for the parameter.  After searching the internet, I tried many variations but so far none of them work. HERe is the where clause from the command with the last thing I tried (a like statement):&lt;/P&gt;&lt;P&gt;WHERE   U.INSTRUMENT_TYPE_CD IN ('Future EFP Unposted')&lt;/P&gt;&lt;P&gt;        AND (U.TRADE_NUM = S.TRADE_NUM AND U.TRADE_NUM = A.TRADE_NUM AND U.TRADE_NUM = T.TRADE_NUM AND U.TRADE_NUM = X.TRADE_NUM)&lt;/P&gt;&lt;P&gt;        AND (U.TRADE_NUM = TTU.TRADE_NUM)&lt;/P&gt;&lt;P&gt;        AND (S.EXTERNAL_KEY = A.CASHFLOW_NUM AND S.ITEM_STATUS_IND = 1 AND S.REPLACED_ITEM_HDR_NUM IS NULL)&lt;/P&gt;&lt;P&gt;        AND S.COST_TYPE_CD = 'Primary Settlement'&lt;/P&gt;&lt;P&gt;        AND U.STRATEGY_NUM = O.STRATEGY_NUM &lt;/P&gt;&lt;P&gt;        AND O.PROCESS_GROUP_CD like {?LOB}&lt;/P&gt;&lt;P&gt;        AND O.PARENT_STRATEGY_NUM IN (1080,1078,1081,1084,1007,2343)&lt;/P&gt;&lt;P&gt;        AND (I.IND_NAME = 'buy_sell_ind' AND U.BUY_SELL_IND = I.IND_VALUE)&lt;/P&gt;&lt;P&gt;        AND S.LOCATION_NUM = L.LOCATION_NUM&lt;/P&gt;&lt;P&gt;        AND U.COUNTERPART_COMPANY_NUM = C.COMPANY_NUM&lt;/P&gt;&lt;P&gt;        AND T.BROKER_COMPANY_NUM = C1.COMPANY_NUM&lt;/P&gt;&lt;P&gt;        AND U.TRADER_PERSON_NUM = P.PERSON_NUM&lt;/P&gt;&lt;P&gt;        AND (X.EXCH_CONTRACT_NUM = E.EXCH_CONTRACT_NUM AND X.QUOTE_DEF_NUM = E.QUOTE_DEF_NUM)&lt;/P&gt;&lt;P&gt;        AND U.MTM_QUOTE_DEF_NUM = Q.QUOTE_DEF_NUM&lt;/P&gt;&lt;P&gt;ORDER BY FUTURE_EXPIRATION_DT, RISK_PERIOD_CD, QUOTE_DEF_CD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The line in question is AND O.PROCESS_GROUP_CD like {?LOB}. I've treid equals and IN's for the like. I've tried {?@LOB}.  This should be so easy.  Where am I going wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 16:19:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaq-p/8050982</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-09T16:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050983#M2873055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to tell you that the error message says that there is an invalid  character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last thing I tried was   AND O.PROCESS_GROUP_CD IN ({?LOB})&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 16:56:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050983#M2873055</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-09T16:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050984#M2873056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you try placing the parameter within single quotes. Here's what I mean:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND O.PROCESS_GROUP_CD = '{?LOB}'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh and I'm not too sure if IN would work with Crystal Reports XI. I believe multi-value command parameters were not supported until CR 2008.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Abhilash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 20:55:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050984#M2873056</guid>
      <dc:creator>abhilash_kumar</dc:creator>
      <dc:date>2011-08-09T20:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050985#M2873057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is almost it. I figured out that for commands the parameters have to be entered via Database Expert/Command Edit. You cannot create the parameter the normal way. That is unfortunate as the options for a paramter in command edit are sparse. When you use the parameter in the SQL you do have to use the quotes as you suggested becuase apparently the value is determined before the SQL command is evaluated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 21:36:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050985#M2873057</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-09T21:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050986#M2873058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured out that for commands the parameters have to be entered via Database Expert/Command Edit. &lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; This is true. You do have to add the parameter to the parameter list in order to reference it in the command SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot create the parameter the normal way. &lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Not true. You have 2 options...&lt;/P&gt;&lt;P&gt;-- 1) Create the parameter in the "normal manner" then simply retype the parameter name in parameter list (making sure to use the exact same spelling).&lt;/P&gt;&lt;P&gt;-- 2) Create the parameter in the command's parameter list, then edit it from the design view/field explorer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is unfortunate as the options for a paramter in command edit are sparse. &lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; The parameter list is only there to create the reference. Use the parameter designer, from the report design view to set the parameter details. (see above)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you use the parameter in the SQL you do have to use the quotes as you suggested ...&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Not necessarily true... CR does a VERY cool thing when it comes to passing parameters to commands. It actually does a direct substitution of the parameter value into the command SQL. So it simply depends on the syntax of the database you are using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... because apparently the value is determined before the SQL command is evaluated.&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Yes, and this is a good thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- For example (Using SQL Server syntax), all of the following are valid&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
-- Exact text match

SELECT *
FROM TableName
WHERE TextColumn = '{?TextParameter}'
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;
-- Exact numeric match

SELECT *
FROM TableName
WHERE NumberColumn = {?NumberParameter}
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;
-- Wildcard match

SELECT *
FROM TableName
WHERE TextColumn LIKE '%{?TextParameter}%'
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can even pass entire blocks of SQL through a parameter, giving the effect of dynamic SQL without having to write dynamic SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For exmple... Say you want to make a parameter that allows the user to select "FirstName LastName" or "LastName, FirstName"...&lt;/P&gt;&lt;P&gt;Create a parameter like this...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Value 1
t.FirstName + ' ' + t.LastName AS Name
Desc 2
First then Last

Value 2
t.LastName + ', ' + t.FirstName AS Name
Desc 2
Last then First
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now write your SQL like this...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT
{?NameParameter},
t.Column2,
t.Column3
FROM TableName AS t
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The only limitation to using parameters in commands is your imagination. I've even passed entire select statements through commands.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 01:29:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050986#M2873058</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-10T01:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050987#M2873059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;WOW! That is an awesome description. Thank you so much for information.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 14:58:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050987#M2873059</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-10T14:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050988#M2873060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your posting it helps a lot, but still I am not able to pass parameters to select statement. Please refer the below screen shot and details. Could you please help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote the below query in Add Command - but getting an error - when I pass hard coded value, it is working fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not working:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SUM(XXXXX) from XXXX_YYY where ZZZZZ_TYPE in (1,3,4,6,10,12,13,21,23,30,31,2,11,20,22,32,33) and DATE &amp;gt; ({@Interpreted Start Date})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Working :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SUM(XXXXX) from XXXX_YYY where ZZZZZ_TYPE in (1,3,4,6,10,12,13,21,23,30,31,2,11,20,22,32,33) and DATE &amp;gt; '09/17/2011'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI... I have already created Interpreted Start Date formula.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Veer Jetta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 06:35:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050988#M2873060</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-19T06:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050989#M2873061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Veer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dates &amp;amp; Times present their own special pains in the back side when working with commands and parameters. The problem is that the formatted value that CR passes isn't necessarily compatible with the acceptable date formats of your RDBMS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to figure out the solution is to build a quick test report, add a table (in the Database expert, not a command) that has a data or datetime column, create a data or datetime parameter and add that parameter to the selection criteria in the Selection Expert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure the report executes and that it is in fact being filtered on the date column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now that you know it works, open the "Show SQL Query..." under Database in toolbar. This will give you the syntax that CR is using to successfully pass the date parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 13:54:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050989#M2873061</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-19T13:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using a parameter in a command</title>
      <link>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050990#M2873062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason's right about the format of dates. The DB is picky. I'm running ORacle 10g and it likes 'YYYYMMDD'. The other thing I noticed is that you did not enclose the parameter in quotes. You have to do that for strings and dates. Notice that in your hard-coded example you ahve the date enclosed in quotes. I'd try that first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 15:07:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/using-a-parameter-in-a-command/qaa-p/8050990#M2873062</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-19T15:07:47Z</dc:date>
    </item>
  </channel>
</rss>

