Problem in summing up inside loop

Hi Experts..........
The below is my loop code , the problem is suppose if i have 2 line items for one purchase order
i need to sum up the quantity amount etc, displaying the purchase order number only ones,
in order i have made a loop at ekpo where i have the line  items , but still i am not able to
sum up , instead all the line items appearing ,
if i give the statmt
delete adjacent duplicates from it_ekpo comparing ebeln.
only first line item is displayed...pls help me out in this issue
sort it_ekpo by ebeln.
sort it_bkpf by belnr.
loop at it_ekpo into wa_ekpo  .
    read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.
                  wa_final-ematn = wa_ekpo-ematn.
                  wa_final-txz01 = wa_ekpo-txz01.
                  wa_final-menge = wa_ekpo-menge.
                  wa_final-netwr = wa_ekpo-netwr.
        QTY =  QTY + WA_FINAL-MENGE.
        move qty to wa_final-qty.
*******FOR TAX CODE 46 for
If wa_ekpo-mwskz = '46'.
wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
   tot2 = tot2 + wa_final-zbed.
      move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
    tot3 = tot3 + wa_Final-zex1.
    move tot3 to  wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
    tot4 = tot4 + wa_final-zex2.
      move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
    tot5 = tot5 + wa_final-jipc.
    move tot5 to wa_final-t5.
Endif.
              loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.
        loop at it_bseg into wa_bseg where ebeln = wa_ekpo-ebeln."belnr = wa_bkpf-belnr.
             wa_final-ebeln =  wa_bseg-ebeln.
    read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
          if sy-subrc = 0.
              wa_final-name1 = wa_lfa1-name1.
            wa_final-ort01 = wa_lfa1-ort01.
          Endif.
    read table  it_J_1IMOVEND into  wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
           if sy-subrc = 0.
                wa_final-J_1ILSTNO =  wa_J_1IMOVEND-J_1ILSTNO.
           endif.
     Endloop.
  Endloop.
append wa_final to it_final.
clear :wa_bkpf, wa_ekpo,wa_ekko,qty, wa_final.
delete adjacent duplicates from it_ekpo comparing ebeln.
Endloop.
Endif.
Thanks in advance
Rachel

hi,
write the code delete adjacent duplicate outside the loop endloop.... it should not be within the loop.
this will resolve your issue
something like the code given below....
sort it_ekpo by ebeln.
sort it_bkpf by belnr.
loop at it_ekpo into wa_ekpo  .
    read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.
                  wa_final-ematn = wa_ekpo-ematn.
                  wa_final-txz01 = wa_ekpo-txz01.
                  wa_final-menge = wa_ekpo-menge.
                  wa_final-netwr = wa_ekpo-netwr.
        QTY =  QTY + WA_FINAL-MENGE.
        move qty to wa_final-qty.
*******FOR TAX CODE 46 for
If wa_ekpo-mwskz = '46'.
wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
   tot2 = tot2 + wa_final-zbed.
      move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
    tot3 = tot3 + wa_Final-zex1.
    move tot3 to  wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
    tot4 = tot4 + wa_final-zex2.
      move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
    tot5 = tot5 + wa_final-jipc.
    move tot5 to wa_final-t5.
Endif.
              loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.
        loop at it_bseg into wa_bseg where ebeln = wa_ekpo-ebeln."belnr = wa_bkpf-belnr.
             wa_final-ebeln =  wa_bseg-ebeln.
    read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
          if sy-subrc = 0.
              wa_final-name1 = wa_lfa1-name1.
            wa_final-ort01 = wa_lfa1-ort01.
          Endif.
    read table  it_J_1IMOVEND into  wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
           if sy-subrc = 0.
                wa_final-J_1ILSTNO =  wa_J_1IMOVEND-J_1ILSTNO.
           endif.
     Endloop.
  Endloop.
append wa_final to it_final.
clear :wa_bkpf, wa_ekpo,wa_ekko,qty, wa_final.
Endloop.
delete adjacent duplicates from it_ekpo comparing ebeln.
Endif.
Regards,
Siddarth

Similar Messages

  • XSL-How to get value of a variable from inside loop-- to the outside loop?

    Pls help
    hi im currently working on this xsl file..
    This works on generating a txt file,my problem right now is
    ' how can i get the value of a variable generated from the inside forloop,
    i have to get the total,sum value of this variables after performing the loop
    ***this is the for loop
    <xsl:for-each select="OutboundPayment">
    <xsl:variable name='id' select='generate-id(OutboundPayment)'/>
    <xsl:sort select="PaymentNumber/CheckNumber" data-type="text" />
    <xsl:variable name='PValue' select='format-number(100*PaymentAmount/Value,"0000000000000")'/>
    <xsl:value-of select='$id'/>
    <xsl:text>D</xsl:text>
    <xsl:value-of select='$DDate'/>
    <xsl:value-of select='$Batch'/>
    <xsl:text>3</xsl:text>
    <xsl:value-of select='format-number(PaymentNumber/PaymentReferenceNumber,"0000000000")'/>
    <xsl:value-of select='format-number(PayeeBankAccount/BankAccountNumber,"0000000000")'/>
    <xsl:value-of select='substring(Payee/Name,1,20)'/>
    <xsl:value-of select='$PValue'/>
    <xsl:variable name='Addend' select='concat($DDate,substring($DAcct,5,5),$Batch)'/>
    <xsl:variable name="LHash">
    <xsl:call-template name="GetHash">
    <xsl:with-param name="A1" select="$PValue" />
    <xsl:with-param name="A2" select="$Addend" />
    </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="concat('[',$LHash,']')" />
    <!--LHash*i have to get the total amount of this one from the outside loop /---->
    <xsl:call-template name='NewLine'/>
    </xsl:for-each>
    <!--I have to put in here the total value of that LHash/---->
    <!--This is the template on how to get the value of that variable in the inside loop/---->
    <xsl:template name="GetHash">
    <xsl:param name='A1'/>
    <xsl:param name='A2'/>
    <xsl:variable name='TwoSum' select='format-number($A1+$A2,"000000000000000")'/>
    <xsl:variable name='Weight' select='317191314191112'/>
    <xsl:call-template name="WDigit">
    <xsl:with-param name="Cnt" select="15"/>
    <xsl:with-param name="Sum" select="$TwoSum"/>
    <xsl:with-param name="Wgt" select="$Weight"/>
    <xsl:with-param name="Tot" select="0"/>
    </xsl:call-template>
    </xsl:template>
    <xsl:template name='WDigit'>
    <xsl:param name='Cnt'/>
    <xsl:param name='Sum'/>
    <xsl:param name='Wgt'/>
    <xsl:param name='Tot'/>
    <xsl:choose>
    <xsl:when test="$Cnt > 0">
    <xsl:variable name='Multip' select='substring($Wgt,$Cnt,1)'/>
    <xsl:variable name='Factor' select='substring($Sum,$Cnt,1)'/>
    <xsl:variable name='Prduct' select='$Multip$Factor'/>
    <!--xsl:value-of select="concat($Tot,'[',$Cnt,']')"/-->
    <!--xsl:value-of select="concat($Multip,'x',$Factor,'=',$Prduct)"/-->
    <!--xsl:call-template name='NewLine'/-->
    <xsl:call-template name="WDigit">
    <xsl:with-param name="Cnt" select="$Cnt - 1"/>
    <xsl:with-param name="Sum" select="$Sum"/>
    <xsl:with-param name="Wgt" select="$Wgt"/>
    <xsl:with-param name="Tot" select="$Tot+$Prduct"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:variable name="Rem" select="$Tot mod 11"/>
    <xsl:variable name="Chk" select="11 - $Rem"/>
    <xsl:value-of select="format-number(concat($Tot,$Chk),'00000')"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:template name='GetTotal'>
    </xsl:template>
    Thanks in advance for those who are willing to help.
    -Leighya

    It would have helped if you had posted your code as CODE but as it is, I could hardly read it. My guess about what you are asking is, if you want a template to return a value, just write that value to the result stream inside the template.
    If that wasn't what you were asking, then please post your code in a readable format.

  • Can I put Read inside loop?

    Hi Folks
    Can I put Read inside loop?
    Performance wise is it acceptable?
    Regards,
    Sreeram

    Hi
    there is no problem to put READ statement inside the LOOP
    its a better way to put
    to avoid SELECT in a LOOP
    see this example
    i had used that in my program
    in the performance point of view it is a good method
    LOOP AT IT_SOBID INTO WA_SOBID." where otype eq s_otype and objid eq s_objid.
        READ TABLE IT_HRP1026 WITH KEY OBJID = WA_SOBID-SOBID OTYPE = WA_SOBID-SCLAS INTO WA_HRP1026.
        IF SY-SUBRC EQ 0.
          READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.
          WA_OUTPUT-OBJID = WA_HRP1026-OBJID.
          WA_OUTPUT-BEGDA = WA_SOBID-BEGDA.
          WA_OUTPUT-ENDDA = WA_SOBID-ENDDA.
          WA_OUTPUT-AEDTM = WA_HRP1026-AEDTM.
          WA_OUTPUT-UNAME = WA_HRP1026-UNAME.
          WA_OUTPUT-STEXT = WA_HRP1000-STEXT.
          READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.
          WA_OUTPUT-CANCRT = WA_REASON-CANCRT.
          CLEAR WA_REASON-CANCRT.
          READ TABLE IT_LOCATION1 WITH KEY OBJID = WA_HRP1026-OBJID INTO WA_LOCATION1..
          READ TABLE IT_LSTEXT WITH KEY OBJID = WA_LOCATION1-SOBID OTYPE = 'F' INTO WA_LSTEXT.
                 WA_OUTPUT-LSTEXT = WA_LSTEXT-LSTEXT.
                 CLEAR WA_LSTEXT-LSTEXT.
          APPEND WA_OUTPUT TO IT_OUTPUT.
          CLEAR WA_OUTPUT.
          CLEAR WA_OUTPUT-CANCRT.
        ENDIF.
      ENDLOOP.
    <b>Reward if usefull</b>

  • New object inside loop condition

    I would like to create new object inside loop condition and use in its body
    while(new File(localization).exists()){
         //now would like use File object created above
    }What's the notation for that?

    YoungWinston wrote:
    TheGreatEmperor wrote:
    I would like to create new object inside loop condition and use in its body
    while(new File(localization).exists()){
    //now would like use File object created above
    }What's the notation for that?Encephalopathic gave it to you, but I'd worry about ending up with a never-ending loop. What about
    if ((myFile = new File(fileString)).exists()) { ...instead?
    Winston1) Same thing I put (except change the name "f" with "myFile")
    2) you could get a never-ending loop with your answer (depending on the body)
    3) The previous answer by Encephalopathic would NOT give a never-ending loop unless there was a never-ending listing of files with the name:
    "Foo" + fileCounter + ".txt"; where "fileCounter" is incrementing (as done in his code)

  • Problem using SUM BY

    I need to count the number of jobs by year and nature of the job.
    I need to calculate also the number only by year (to calculate, later, the percentage). To do this, I tried to use the SUM BY statement:
    SUM("- Misure"."Numero Lavori" by "- Inizio Lavoro"."Anno Inizio Lavoro")
    Note that the number of jobs is calculated with the COUNT DISTINCT aggregation rule.
    Here's the query generated by BI:
    WITH
    SAWITH0 AS (select count(distinct T6686.CD_LAVORO) as c1,
    T6906.ANNO as c2,
    T6842.CD_RITORNO_LAVORO as c3
    from
    L_RITORNO_LAVORO T6842,
    L_DATA T6906 /* L_DATA_INIZIO_LAVORO */ ,
    F_LAVORO T6686
    where ( T6686.ID_RITORNO_LAVORO = T6842.ID_RITORNO_LAVORO and T6686.ID_DT_INIZIO_LAVORO = T6906.ID_DATA )
    group by T6842.CD_RITORNO_LAVORO, T6906.ANNO),
    SAWITH1 AS (select sum(SAWITH0.c1) as c1,
    SAWITH0.c2 as c2,
    SAWITH0.c3 as c3,
    SAWITH0.c1 as c4
    from
    SAWITH0
    group by SAWITH0.c1, SAWITH0.c2, SAWITH0.c3)
    select distinct SAWITH1.c2 as c1,
    SAWITH1.c3 as c2,
    SAWITH1.c4 as c3,
    SAWITH1.c1 as c4
    from
    SAWITH1
    I suspect the part painted in bold shouldn't be there. Anyone can help me?

    hi,,,,,,
    When processing an internal table in a block starting with LOOP and concluded by ENDLOOP , SUM calculates the control totals of all fields of type I , F and P (see also ABAP/4 number types ) and places them in the LOOP output area (header line of the internal table or an explicitly specified work area).
    You can use the SUM statement both at the end and the beginning of a control group (see also AT FIRST/LAST ).
    Example
    Display the table T with sub-totals:
    DATA: BEGIN OF T OCCURS 100,
    CODE(4),
    SALES TYPE P,
    DISCOUNT TYPE P,
    END OF T.
    LOOP AT T.
    AT FIRST.
    SUM.
    WRITE: /4 'Grand Total:',
    20 T-SALES, 40 T-DISCOUNT.
    ULINE. SKIP.
    ENDAT.
    WRITE: / T-CODE,
    20 T-SALES, 40 T-DISCOUNT.
    AT END OF CODE.
    SUM.
    WRITE: / T-CODE, 10 'Total:',
    20 T-SALES, 40 T-DISCOUNT.
    SKIP.
    ENDAT.
    ENDLOOP.
    Notes
    When you use SUM in a LOOP with an explicitly specified output area, this output area must be compatible with the line type of the internal table.
    When using LOOP to process a sorted extract (see SORT ), the control total of f at the end of the group appears in the field SUM(f) - - if f is type I , F or P .
    Thanks
    Saurabh

  • Submit Statment inside Loop - Problem in display O/P

    Hi All,
              Iam Using Submit statment inside the Loop with Return , when the first line in the loop completes the O/P gets display and the Second line is not processed and get in O/P.Can any one let me know why this problem occurs?...
    Regards,
    Veera

    when You submit for a report it starts a parallel process and it is O/P then if you are doign it in loop it may be over writing the existing O/P that may be the reason you are not seeing the out put properly as it is written across different internalk sessions

  • Finding sum inside Loop

    Hi Experts,
    here i am printing report output.
    in my internal tab there are 10 fields, inthat last field is CURRENCY (amt).
    now i want to sum that field at end of first field.
    my pease of code is below:
    LOOP AT it_display INTO wa_display.
        IF wa_display-amount NE 0.
          WRITE: /05 wa_display-pspid,
                 15 wa_display-pspnr1,
                 35 wa_display-vornr,
                 45 wa_display-post1,
                 70 wa_display-verna,
                 85 wa_display-plfaz,
                 97 wa_display-plsez,
                 110 wa_display-gjahr,
                 125 wa_display-versn,
                 135 wa_display-wrttp,
                 140 wa_display-beltp,
                 145 wa_display-vorga,
                 152 wa_display-twaer,
                 160 wa_display-period,
                 180 wa_display-amount.
        ENDIF.
        AT END OF pspid.
        WRITE: /160 'TOTAL AMOUNT',wa_display-pspid COLOR 3.
          SKIP 2.
        ENDAT.
      ENDLOOP.
    how calculate the sum for last field (wa_display-amount).
    Thanks in advance,
    sudharsan.

    Hi friends thank u for ur help.
    i got it and i ve rewarded.
    and i ve one more issue on this.
    in my table suppose there are 3 fields. like below
    field1         field2        field3
    100          100.01        40
    100          100.01.01    50
    200          200.01        30
    200          200.01.01    70
    but iwant output like below
    field1         field2        field3
    100          100.01       40
    100          100.01.01   50
        Total is -
       90
    200          200.01        30
    200          200.01.01    70
    Total is -
            100
    now am getting output like below:
    field1         field2        field3
    100          100.01       40
        Total is -
       40
    100          100.01.01   50
        Total is -
        50
    200          200.01        30
    Total is -
            30
    200          200.01.01    70
    Total is -
            70
    i want sum at end of field1, but am getting every end of field2.
    but in my display loop i ve done like
    AT END OF field1 only but why am getting like this.
    any help...
    Thanks in advance,
    sudharsan.

  • Problem aggregating sums in a while loop

    I'm relatively new to java. In my latest project, one part of the project is to translate this equation:
    [http://img.photobucket.com/albums/v281/molotov001/rt01.jpg]
    into java.
    Retaining what little knowledge I have of Calculus, this basically means that I should start with i=0, run through that function and increase i by 1 until it reaches a final number yearsWorked-1, all the while adding the functions with respect to different values of i.
    This is what I have so far
    int i = 0;
    double aime = (income * Math.pow(1.02, i) * Math.pow(1.04, (year - incYear - i)))/420;
              while (i <= (yearsWorked-1))
                   ++i;
                   double aime1 = (income * Math.pow(1.02, i) * Math.pow(1.04, (year - incYear - i)))/420;
                   aime = aime + aime1;
              }I know this is wrong because it outputs a number that is incorrect, but not by much. Also assume that income, incYear, yearsWorked and year are already defined doubles.
    Any help you might be able to offer is greatly appreciated.

    {color:#000080}Use an integer type like int or long for yearsWorked. When using double, yearsWorked - 1 may not be the exact value you expected.
    Why do you need a double value for a variable that you compare integrally anyhow?
    db{color}

  • Problem with cfhttp in a loop

    Hi,
    I am reading an xml file that contains emails with attachments (one email per item/node, but may contain multiple attachments).  I am trying to save the attachments to our server.  So I'm looping over the multiple attachments of a single email and using cfhttp to GET the attachments from another server and save them with the same filename on our server.
    The problem is that it works for the first attachment - it's saved to the server, status code is 200 OK - awesome!  But for any attachments after that, it does not save them and throws a Conection Failure error.  No matter what attachments they are.
    In trouble shooting I tried several things.  First, inside of my loop of attachments, I can hardcode the cfhttp calls with the url and filename of the attachments - one right after the other - and all is perfect everytime!!  But it obviously needs to be dynamic.  I also tried to save a list of the attachment urls from the loop, and then call a separate cfhttp tag for each attachment in the list (so again, was in a loop) and it works for the first attachment in the list and not for the others (same errors as above).
    Here's a simplified version of the code.  I can't put in the real xml url, and when I set the "attachmentFilename" I left out that code because it works and is too much code.  Also, the XML works fine.  Please let me know if you have any suggestions, and of course, if you need more info from me!!
    Thanks so much,
    Kirsten
    <cfoutput>
    <cfhttp url="https://www.myxml.com/example.xml" method="get" resolveurl="no" />
    <cfset myXML = trim(cfhttp.FileContent)>
    <cfset myXML = xmlParse(myXML)>
    <cfset theRoot = myXML.XmlRoot>
    <cfset numChildren = arrayLen(theRoot.XMLChildren[1].XmlChildren)>
    <cfloop index="i" from="6" to="#numChildren#">
        <cfset attachments = theRoot.XMLChildren[1].XMLChildren[i]["attachments"].XmlText>
        <cfif ListLen(attachments, "|^|") gt 2>
            <cfset loop_unid = theRoot.XMLChildren[1].XMLChildren[i]["unid"].XmlText>
            <cfset counter = 0>
            <cfset attachmentArray = ListToArray(attachments, "|^|")>
            <cfloop from="1" to="#ArrayLen(attachmentArray)#" index="k">
                <cfset counter = counter + 1>
                <cfset attachmentURL = attachmentArray[k]>
                <cfset attachmentFilename = Replace(attachmentArray[k],"strip the url from the filename in the url","")>
                <cfhttp url="#attachmentURL#" method="get" resolveurl="no" timeout="120" path="D:\my_servers_path\attachmentFolder\" file="#attachmentFilename#">
                attachment counter: #counter#<BR />
                cfhttp.statusCode: #cfhttp.statusCode#<BR />
                cfhttp.errorDetail: #cfhttp.errorDetail#<BR />
            </cfloop>
        </cfif>
    </cfloop>
    </cfoutput>
    Output Results:
    attachment counter: 1
    cfhttp.statusCode: 200 OK
    cfhttp.errorDetail:
    attachment counter: 2
    cfhttp.statusCode: Connection Failure.  Status code unavailable.
    cfhttp.errorDetail: I/O Exception: peer not authenticated
    attachment counter: 3
    cfhttp.statusCode: Connection Failure.  Status code unavailable.
    cfhttp.errorDetail: I/O Exception: peer not authenticated

    We've seen the peer not authenticated error quite a bit on our CFHTTP calls - are you trying to access the URLs via HTTPS?  It seems the SSL certificate keystore that CF ships with does not contain all the vendor SSL certificates out there - when CF can't authenticate a cert, it throws that "Connection Failure / Peer not authenticated Error".  In order to fix the issue, you have to import the SSL certificate of the site you are trying to access into the CF cert store on your server(s).  If you are using multiple servers, you will have to import the cert on each server.
    I'm sure a google search will turn up a step by step guide on how to do this, but the basic steps are:
    Go to a page on the SSL server.
    Double-click the lock icon.
    Click the Details tab.
    Click Copy To File.
    Select the base64 option and save the file.
    Copy the CER file into ColdfusionDir\runtime\jre\lib\security
    Run the following command from the same directory (keytool.exe is located in ColdfusionDir\runtime\jre\bin) ..\..\bin\keytool.exe -import -keystore cacerts -alias UniqueName -file filename.cer
    Restart Coldfusion
    Hope that helps!
    - Michael

  • Problem with  AT command in LOOP

    Hi Experts,
    here i ve a problem like, in my table there are 3 PSPHI(projects) values,
    if i loop n calculate the sum it is getting total amt for 3 PSPHI values,
    but i want every end of PSPHI i need sum.
    the below code is working fine if there is no AT coomand, if i put AT END OF PSPHI it is giving 00.00 values.
      LOOP AT it_final into it_output.
       AT END OF PSPHI.
        if it_final-wrttp = '04'
           AND it_final-vorga = 'COIN' 
           AND it_final-beltp  = '02'
           AND it_final-versn = '000'.
       t_pla_rev = t_pla_rev + it_output-wlp01.
        MOVE it_output-wlp01 TO pla_rev.
        sum = sum + pla_rev.
          if sy-subrc EQ 0.
            else.
            write:/10 ' u r not ok'.
        endif.
    e  ndif.
    append it_output.
    *ENDAT.
    ENDLOOP.
    write:/10 'total amt is', sum.
    could anybady check where i gone wrong pls...
    Thanks in advance,
    sudharsan.

    Hi,
    What is your table structure.
    The command  AT ........ENDAT  work in sequential order.
    Let me explain with example.
    if your table itab has two column  column1 and column2
    loop at itab into wa.
    at new column2.
    // This will execute when the Value of column 1 change or column2
    // change.
    endat.
    endlloop.
    The solution of your problem is.
    Change your internal table column order ,
    Put the column first for which you want to calculate the sum.
    Thanks & Regards
    Kulvendra Kumar

  • Problem using image grabbing in loop

    Hi,
    We're currently building a machine vision application using 4 cameras at the same time and tried to implement some sort of passthru of all 4 by using a while loop with inside it a sequence to switch channels and grab the images. Somehow this only gives us completely weird images with several black lines through them. It looks like something to do with other system activity because when you move windows or use other programs it gets worse. However, that must be something I'm doing wrong, working on a P4 1.5GHz...
    If someone could give me a hint or has any ideas, they would be very welcome.
    Thanks

    Are you reading the images from a buffer or directly from the device? It's possible you're doing software timed acquisition which is not reliable -- you are at the mercy of Windows and the software speed to properly acquire your images.
    Without a small example it's difficult to determine the cause of the problem....
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • Problem with building array inside a case statement

    I have a problem with my build array.
    Iam trying to construct a build array when ever I see a new element in my parent array during run time.
    Using shift registers, search array and If- case structure, inside a while loop. Iam implementing this logic (I dont want to use Event structure).
    Iam able to achieve most part of it, but have a problem with the first element. Except the first element of my parrent array, every thing is appending in to the build array. Can any one look at my vi and suggest me what Iam doing wrong here.
    Thank you
    Attachments:
    debug.vi ‏12 KB

    I think you need to replace the tunnels (carrying the array) in the for loop with a shift register.
    Lynn

  • Problem with two parallel While loops

    I have a serious problem with controlling two parallel While Loop. Here is the deal:
    I have written a VI to send a series of commands called Cycle through Serial Port to a custom hardware. One of these commands is setting motor pressure by sending it's command and changing it's voltage. After setting desired pressure I have to read and control motor pressure, again through serial port in a parallel loop. There is a Pressure Sensor in system and I can obtain current's motor pressure by sending a command and receiving pressure value. In the first While loop I send some commands to hardware including Pressure Setting Command trough a state machine. In the second While Loop I read pressure value and then decide to increase motor voltage or decrease  it. Now the problem is in communicating these two loops. In cycle after "Init" state when state reaches "Pressure 2 Bar" motor voltage will increase. Meanwhile I have to control this voltage in parallel While Loop. As you can see I used Local Variable to communicate between these two loops. The problem is that loops are not synchronized. Specially when I switch to "Pressure 3.8 Bar" state during cycle running control loop (second while) is still working based on "Pressure 2 Bar" state not 3.8 bar. Because of this motor pressure goes to 3.8 bar for a sec (becuase of  "Pressure 3.8 Bar" state) and comes back to 2 bar (because the second while still has not gotten that new state,most probably cause of all the delays in the loop)  and after couple seconds it goes back to 3.8 bar.
    I really don’t know what to do. Is there a way to fix this? Or I should consider a better way to do this?
    I went through Occurrence Palette but couldnt figure out how to embed that in the VI. 
    Sorry for my poor English. I attached VI and it's subVIs as a LLB file. I can explain more details if somebody wants. 
    Attachments:
    QuickStartCycle.llb ‏197 KB

    I make it a point to NEVER have a WAIT function inside a state machine.
    It sort of defeats the purpose, which I define as "Examine current state; decide whether you've met the conditions to advance to another state, then get out".
    For example, I have a single state machine VI controlling four identical instruments, via TCP connections.
    For some functions, that means issuing a command, waiting 60 seconds, then reading results.
    If I waited INSIDE the state machine, then it's tied up waiting on one device and cannot handle any others.
    Not a good plan.
    To handle this, I have a loop which calls the state machine.  After issuing the command, the state goes to "Waiting on Response", and there is a target time of 60 seconds from now.
    It's called over and over in that state, and each time merely compares NOW to the target time.  If NOW is past the target, then we read the results.
    the state machine can tell the caller when to call back; that's how I distinguish between an urgent need and nothing-to-do.
    By having the CALLER do the waiting, instead of the state machine itself, the state machine is free to handle another device, or do something else on the same device.
    You should be calling the state machine over and over and over anyway.  So, have the state machine "control the pressure" on every call, and THEN examine whatever state it's in.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Confusion in loop inside loop

    Hi Experts,
    i have some confution in below code:
    here am trying to calculate  Actual Billing and Planned Revenue. but here for each value am looping it_final table inside the main loop.
    but the prob is if i loop it_final for one value it is giving value, but if i try to loop 2 times for 2 values, it is not giving first value also.  
    i.e if i comment loop for Planned Revenue then Actual Billing is displaying, if i try for 2 values, then its giving zeros for 2 values.
    so could anyone check is there any mistake i did.
    CLEAR: it_prps, it_final, wa_final, wa_it_prps.
      LOOP AT it_prps.
        CASE month.
          WHEN '08'.
      ACTUAL BILLING
            LOOP AT it_final INTO wa_final
             WHERE posid = it_prps-posid
                AND wrttp = c_04
                AND beltp = c_02
                AND versn = c_0
                AND ( vorga = c_coin OR vorga = c_rku2 ).
              CLEAR act_billing.
              IF sy-subrc IS INITIAL.
                MOVE wa_final-wlp08 TO t_act_billing.
                act_billing = act_billing + t_act_billing.
              ENDIF.
              CLEAR: it_prps, it_final.
            ENDLOOP.
    *************PLANNED REVENUE
            LOOP AT it_final INTO wa_final
                             WHERE posid = it_prps-posid
                             AND wrttp = c_01
                             AND beltp = c_02
                             AND versn = c_0
                             AND ( vorga = c_sdor OR vorga = c_rkp5 ).
              CLEAR plan_rev.
              IF sy-subrc IS INITIAL.
                MOVE wa_final-wlp08 TO t_plan_rev.
                plan_rev = plan_rev + t_plan_rev.
              ENDIF.
              CLEAR: it_prps, it_final.
            ENDLOOP.
    ENDCASE.
    ENDLOOP.
    WRITE:/10 'Actual Billing is',act_billing.
    WRITE:/20 'Actual Cost is........', actu_cost.
    Thanks in advace,
    sudharsan.

    Hi SUDHARSAN RAO
    U r clearing the headers and tables. So u cannot use the values on the nested loops  as u have cleared the values. There wont be anything in the workare ur using in where clause.
    Please see the below comments that I kept.
    LOOP AT it_prps.
    ACTUAL BILLING
    LOOP AT it_final INTO wa_final
    WHERE posid = it_prps-posid
    AND wrttp = c_04
    AND beltp = c_02
    AND versn = c_0
    AND ( vorga = c_coin OR vorga = c_rku2 ).
    CLEAR act_billing.
    IF sy-subrc IS INITIAL.
    MOVE wa_final-wlp08 TO t_act_billing.
    act_billing = act_billing + t_act_billing.
    ENDIF.
    CLEAR: it_prps, it_final.
    Here IT_FINAL is cleared by u... should not be cleared
    ENDLOOP.
    *************PLANNED REVENUE
    LOOP AT it_final INTO wa_final
    WHERE posid = it_prps-posid
    AND wrttp = c_01
    AND beltp = c_02
    AND versn = c_0
    AND ( vorga = c_sdor OR vorga = c_rkp5 ).
    CLEAR plan_rev.
    IF sy-subrc IS INITIAL.
    MOVE wa_final-wlp08 TO t_plan_rev.
    plan_rev = plan_rev + t_plan_rev.
    ENDIF.
    Again ur clearing both tables.
    CLEAR: it_prps, it_final.
    ENDLOOP.
    ENDCASE.
    ENDLOOP.
    WRITE:/10 'Actual Billing is',act_billing.
    WRITE:/20 'Actual Cost is........', actu_cost.

  • Problem with DAQ in while loop and Graphs

    Hello,
    I'm new here so I apologize if I posted this on the wrong board  
    This is my "situation":
    I need to make a simple PID controller which takes information (process variable) from an outside source (a NI's DAC connected through the USB port ) which is accomplished using NI-DAQ as an input, and the PID's output goes to the second NI-DAQ which is also connected using DAC to an actuator which in my case regulates the air pressure. (VI attached)
    My problem is the following.
    Both of the NI-DAQ I placed using DAQ Assist, require to be in a while loop.
    -If I place them in separate loops, I have the problem of passing information between the Input NI-DAQ and the PID, and also between the PID and the Output NI-DAQ.
    -If I place them both in one big loop, an error occurs saying that the selected buffer size is too small (Error -200609).
    The timing settings for the DAQ's N samples, 100 samples to read at the rate of 1k (I also tried with Continuous samples and many different combinations of Samples to Read an Rate but without success).
    Should I wire them with the same dt(s)?
    The other thing I need to do (I'm also writing it here in order not to open new topics) is show the following 3 signals on a Graph (process variable (dynamic data type)(range 4mA - 20mA), PID output (double)(range 4mA - 20mA), and the Set Point (double)(range 0 to inf))
    Firstly, is it possible to show the first two on a scale from 0 to 100 without changing the PID's output which needs to be 4-20?
    Secondly, which graph should I use if I have different data types? (I tried the Waveform Chart, and succeeded in showing the first two; the third just messes everything up)
    I would also have to make a legend explaining which signal is which (I see that this is possible with the Mixed Signal Graph).
    I know this is probably too much to ask, but I'd be grateful for any help
    Thank you in advance
    Attachments:
    PID while.vi ‏100 KB

    My problem is the following. Both of the NI-DAQ I placed using DAQ Assist, require to be in a while loop.
    -If
    I place them in separate loops, I have the problem of passing
    information between the Input NI-DAQ and the PID, and also between the
    PID and the Output NI-DAQ.
    This is the best option---Use QUEUE or Functional global or something else to tranfer the data to and fro
    How  do I make that QUEUE or Functional global?
    -If I place them both in one big loop, an error occurs saying that the selected buffer size is too small (Error -200609).
    Have
    you tried increasing the buffer? Is the acquisition happening
    parallelly (means to say the first DAQ not wired (error terminal) to
    second DAQ)
    Well the buffer is, at least how I understood it, the option Number of Samples when in Continuous Samples mode. Concerning the parallel acquisition, do you mean I should wire the error ports of both of the DAQs?

Maybe you are looking for

  • Problem while creating ADF Table

    When I drag view object from data control palette and place it on jspx page as a ADF Table then it does not show any table fields in Edit Table Columns dialog box. I am using JDeveloper 10.1.3.2 Please Help, its urgent. Thanks in advance.

  • "Error in message monitoring in runtime workbench"

    Hello All,     I have an error in message monitoring in runtime workbench. We have installed PI7.0 and it should run on port 50000.But it is running on port 50100. Please suggest what are the steps involved to resolve this problem. Thanks and Regards

  • Final invoice indicator for Service based IV

    Hello, For invoice verification based on Service entry, the system proposes the final invoice indicator checked.  I'm trying to uncheck this indicator as in our case, vendors usually sends partial invoices. We have FM implemented and applied Link: [n

  • How can I localize the alert "error: PANIC: fatal region error detected..."

    My application may corrupt and the operations therefore may fail and post the alert "error: PANIC: fatal region error detected; run recovery ...", and this alert is directly printed in the main process's window. My question is how can I do to localiz

  • Some of my video thumbnails don't show

    I triple back up my photos and videos on external hard drives. Recently, I went back to look at some of my May 2012 home videos on my back ups. Three of the videos didn't seem to work. The thumbnails didn't show an image from the video. Went I went t