<?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: Print each record into a string in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344241#M15675</link>
    <description>&lt;P&gt;Thanks! This has gotten me &lt;EM&gt;almost&lt;/EM&gt; all of the way there. One more issue though - The running tally adds an entry for each record, and if there's multiple errors on a given order number (which happens often) it'll add multiple entries of the same order number.&lt;/P&gt;&lt;P&gt;To combat this I've modified your suggestion to:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WhilePrintingRecords; 
StringVar stringOutput;
stringVar toAddToOutput;
Stringvar currentOrderNum := ToText({eOrder Number});
    IF
        INSTR (stringOutput, currentOrderNum) &amp;gt; 0
    THEN
        stringoutput
    ELSE
        toAddToOutput := Cstr({eWRServiceOrders.Order Number},0,"") + ToText(" ");
        stringOutput := stringOutput + toAddToOutput;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The idea being it searches the stringOutput for the current order number and skips adding it again if it's already in the string. Apparently the INSTR() doesn't work with two variables. &lt;A href="http://stackoverflow.com/questions/15262711/how-to-use-2-variables-in-vbscript-for-instr-function-in-vbscript"&gt;This stackoverflow question&lt;/A&gt; points out that, for VBA at least, this compares the binary, so it's better to do a textual comparison. So I've tried using alternative options like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;currentOrderNum IN stringOutput&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;with no avail.&lt;/P&gt;&lt;P&gt;What operators are out there can look for a string variable value inside another string variable?&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2016 19:12:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2016-12-07T19:12:47Z</dc:date>
    <item>
      <title>Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaq-p/344239</link>
      <description>&lt;P&gt;Hello world!&lt;/P&gt;&lt;P&gt;I've been fighting with this for &lt;EM&gt;hours&lt;/EM&gt; at this point and am finally going to ask - I haven't been able to find this answer anywhere online:&lt;/P&gt;&lt;P&gt;I need some way to select each &lt;EM&gt;visible &lt;/EM&gt;record in my report in a loop, something like {OrderNumber}[i]&lt;I&gt;. Here's my code:&lt;/I&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;local NumberVar i := 0;
local NumberVar recordCount := Count({eWRLocations.Location Code});
global StringVar stringOutput := "";
local stringVar toAddToOutput;
local NumberVar currentrecord;

WHILE recordCount &amp;gt;= i DO
    (
    currentrecord := ***{Order Number}[1]***;
    toAddToOutput := Cstr(currentrecord, 0, "") + ToText(" ");
    stringOutput := stringOutput + toAddToOutput;
    i := i + 1
);

IF stringOutput = "" THEN "Nope, you messed up"
ELSE
    stringOutput
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Everything I've tried up to this point (like &lt;EM&gt;RECORDNUMBER) &lt;/EM&gt;just repeats the total count of records, as in, 861 repeated 861 times. &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Two other things to consider&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;This report is an aggregate of several reports&lt;/EM&gt; and has 6 different details sections, so using a counter for the detail lines doesn't work &lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;EM&gt;there's a bunch of hidden rows&lt;/EM&gt; so I'd like to only include visible (non-suppressed) rows in the final string output.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The End Goal &lt;/STRONG&gt;is&lt;STRONG&gt; &lt;/STRONG&gt;to compile a list of &lt;EM&gt;visible&lt;/EM&gt; order numbers into a single string field in my report. It's odd, I know, but makes an audit process much faster. In the end, I'd like to turn something like this:&lt;/P&gt;&lt;P&gt;10001    A&lt;/P&gt;&lt;P&gt;10002    B&lt;/P&gt;&lt;P&gt;10003    B&lt;/P&gt;&lt;P&gt;10004    C&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;10100   AA&lt;/P&gt;&lt;P&gt;to something like:&lt;/P&gt;&lt;P&gt;10001 10002 10003 ... 10100&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 20:07:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaq-p/344239</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-06T20:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344240#M15674</link>
      <description>&lt;P&gt;Hi Matt, &lt;/P&gt;&lt;P&gt;Using a loop won't work here because Crystal executes a formula in the section you place it in.  What you need is a running total and not a loop.  &lt;/P&gt;&lt;P&gt;Try this, in the Detail section have a formula like: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WhilePrinintRecords; 
StringVar stringOutput;
stringVar toAddToOutput;

toAddToOutput := Cstr({OrderNumber},0,"") + ToText(" ");
stringOutput := stringOutput + toAddToOutput;
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the Report Footer have a formula like: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WhilePrinintRecords; 
StringVar stringOutput;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You don't have to show this formula but it will run for each row in the detail section.  This way you don't need the loop at all.  &lt;/P&gt;&lt;P&gt;You will have to include an If in the detail formula to exclude the suppressed rows.  Other than that, this should work.  &lt;/P&gt;&lt;P&gt;Good luck, &lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 22:17:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344240#M15674</guid>
      <dc:creator>former_member292966</dc:creator>
      <dc:date>2016-12-06T22:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344241#M15675</link>
      <description>&lt;P&gt;Thanks! This has gotten me &lt;EM&gt;almost&lt;/EM&gt; all of the way there. One more issue though - The running tally adds an entry for each record, and if there's multiple errors on a given order number (which happens often) it'll add multiple entries of the same order number.&lt;/P&gt;&lt;P&gt;To combat this I've modified your suggestion to:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WhilePrintingRecords; 
StringVar stringOutput;
stringVar toAddToOutput;
Stringvar currentOrderNum := ToText({eOrder Number});
    IF
        INSTR (stringOutput, currentOrderNum) &amp;gt; 0
    THEN
        stringoutput
    ELSE
        toAddToOutput := Cstr({eWRServiceOrders.Order Number},0,"") + ToText(" ");
        stringOutput := stringOutput + toAddToOutput;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The idea being it searches the stringOutput for the current order number and skips adding it again if it's already in the string. Apparently the INSTR() doesn't work with two variables. &lt;A href="http://stackoverflow.com/questions/15262711/how-to-use-2-variables-in-vbscript-for-instr-function-in-vbscript"&gt;This stackoverflow question&lt;/A&gt; points out that, for VBA at least, this compares the binary, so it's better to do a textual comparison. So I've tried using alternative options like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;currentOrderNum IN stringOutput&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;with no avail.&lt;/P&gt;&lt;P&gt;What operators are out there can look for a string variable value inside another string variable?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 19:12:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344241#M15675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-07T19:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344242#M15676</link>
      <description>&lt;P&gt;Hi Matt, &lt;/P&gt;&lt;P&gt;Rather than do this in the Detail section, can you create a group based on {eorder Number}?  Then move this formula in the Group Footer?  This will make sure only the unique orders are processed and not duplicate them.  &lt;/P&gt;&lt;P&gt;You can remove the InStr part of the formula as well.  &lt;/P&gt;&lt;P&gt;BTW, I used the InStr function with two variables and it did work.  &lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 21:48:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344242#M15676</guid>
      <dc:creator>former_member292966</dc:creator>
      <dc:date>2016-12-07T21:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344243#M15677</link>
      <description>&lt;P&gt;Grouping by order number would make this much easier, and I would love to do just that. However there are loads of order numbers that are suppressed that create 'blank' groups. For context, this report looks at all orders from the previous day and flags abnormal values. What is/isn't abnormal is determined by 5 very long and complex formula fields, so there's way too many criteria  to simply exclude orders with normal values via the original query. &lt;/P&gt;&lt;P&gt;If I suppress the group headers I still have the blank group detail lines, which just gums up the appearance of the report. Like this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/10267-groups.png" /&gt;&lt;/P&gt;&lt;P&gt;If you know how to &lt;STRONG&gt;completely&lt;/STRONG&gt; suppress blank group headers &lt;EM&gt;&lt;STRONG&gt;and&lt;/STRONG&gt; &lt;/EM&gt;their blank detail lines I would be extremely grateful. I've scoured the web and haven't found a way to do this. It would be an excellent solution for this and another report we're working on. &lt;/P&gt;&lt;P&gt;Edit: Fixed some bad grammar&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 18:21:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344243#M15677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-08T18:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344244#M15678</link>
      <description>&lt;P&gt;Hi Matt, &lt;/P&gt;&lt;P&gt;When you right-click the section in the left margin and go to Section Export, you should have the option to Suppress Blank Section.  Put a check in there and see if that works.  If not, then you can click the formula button beside Suppress Blank Section and create a formula that also checks if a field or formula is equal to an empty string or space like:  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;{table.FIELD} = "" or {table.FIELD} = " "; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Good luck, &lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 22:55:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344244#M15678</guid>
      <dc:creator>former_member292966</dc:creator>
      <dc:date>2016-12-08T22:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Print each record into a string</title>
      <link>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344245#M15679</link>
      <description>&lt;P&gt;Brian, with your help as well as &lt;A href="http://stackoverflow.com/questions/34322340/alternate-colors-on-only-visible-details-in-crystal-reports"&gt;this article&lt;/A&gt;, I finally got a solution that works. For others out there who may be struggling with similar issues, here's what I learned.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Printing Each Record To A String&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Create a formula field called ff_myRecNo:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WhilePrintingRecords;
Global numbervar recNo;
    IF
        [Suppressed line formulas]
    THEN
        //Ignore suppressed records
        -1
    ELSE
        IF recNo &amp;gt; -1
            THEN 
                //Count visible records
                recNo := recNo +1
            ELSE
                1
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Put this field somewhere in each detail section, and you'll see it create an index for only the visible records. Suppress this field so it's out of your way, then create another formula field, OrderNumbers:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WhilePrintingRecords; 
StringVar stringOutput; 
stringVar toAddToOutput := Cstr({Order Number},0,"") + ToText(ChrW(13));
//ToText(ChrW(13) inserts a line break after the order number.

IF
    {@ff_MyRecNo} &amp;lt;&amp;gt; -1
THEN
            stringOutput := stringOutput + toAddToOutput; 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then simply put your &lt;EM&gt;OrderNumbers &lt;/EM&gt;variable somewhere in the report and you're done. &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Two Important Side Notes&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. This solutions works to color alternating visible lines as well. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Use the ff_myRecNo formula to create the line index, then go to Section Expert &amp;gt; Details &amp;gt; Color (tab), and enter the formula:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;select {@ff_MyRecNo} mod 2
case 0: crWhite
case 1: color(222,246,252) &lt;/P&gt;// or use another RGB color
&lt;P&gt;&lt;STRONG&gt;2. For comparing numbers as strings, be sure they're being formatted properly&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I had to use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Cstr(OrderNumber, 0, "")
//This outputs a clean number, like '123456'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;not &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;toString()
//This outputs a decimal number, like '123456.00', ruining the string comparison&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Dec 2016 19:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/print-each-record-into-a-string/qaa-p/344245#M15679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-09T19:21:47Z</dc:date>
    </item>
  </channel>
</rss>

