Syntax of For Each Loop

Hi Friends,
I have two keyfigures  KF1 and KF2 .
I want to write the formula i.e (KF1KF2)/Sum(KF1KF2).
This formula is to be applied depending on the Characteristic Material.
Please guide me the syntax of this formula.
Regards,
Girish

Hello,
PLease try this code:
DATA Z_COM TYPE 0COMP_CODE.
DATA Z_MAT TYPE 0MATERIAL.
DATA SUM1 TYPE F.
DATA MUL1 TYPE F.
FOREACH Z_MAT,Z_COM.
MUL1 = {KF1, Z_COM, Z_MAT}* {KF2,  Z_COM, Z_MAT}.
SUM1= {KF1, Z_COM, Z_MAT}+ {KF2,  Z_COM, Z_MAT}.
{KF3, Z_COM, Z_MAT} = MUL1/SUM1.
*KF3 is the third key figure where the results are stored.
ENDFOR.
Please let me know if you need any further help.
Thanks.
With regards,
Anand Kumar

Similar Messages

  • For Each Loop in Jdev 10.1.2.17.84

    Is there anyway of using a for each loop in Jdev 10.1.2.17.84? I get errors for the standard syntax:
    for (int item : numbers) {
    System.out.println("Count is: " + item); }
    Am i missing something?

    Okay, i'm on 10.1.3 now and the syntax:
    for (int item : numbers) {
    System.out.println("Count is: " + item); }
    still doesn't work. What am I missing now?
    On compile I'm getting:
    Error(41,23): ; expected
    for the line with for (int item : numbers) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • "for each" loop - under the hood question

    Question about the for each loop. Is it optomized? I think this is a poor use of memory management -
    for (int i = 0; i < stop; i++) {
    Object obj = new Object();
    doSomething(obj);
    }And this is the ideal, using the same object -
    Object obj = new Object();
    for (int i = 0; i < stop; i++) {
    doSomething(obj);
    }So underneath the hood, which is the for each loop comparable to? I love the syntax, it's very clean-looking in the code, but at the same time I don't want to hurt performance.

    Question about the for each loop. Is it optomized? I
    think this is a poor use of memory management -
    for (int i = 0; i < stop; i++) {
    Object obj = new Object();
    doSomething(obj);
    }And this is the ideal, using the same object -
    Object obj = new Object();
    for (int i = 0; i < stop; i++) {
    doSomething(obj);
    }So underneath the hood, which is the for each loop
    comparable to? I love the syntax, it's very
    clean-looking in the code, but at the same time I
    don't want to hurt performance.That depends on YOU. You CANNOT write a for-each loop for the code you provided. A for-each loop requires an Iterable. (I think that's what it requires--it at least requires something to iterate over, not just an index variable as you have.)
    Consider the following, however:
    Object o1 = new Object();
    for (Foo foo : fooList) {
        Object o2 = new Object();
         foo.doStuff(o1, o2);
    } It will be equivalent to this:Object o1 = new Object();
    for (Iterator iter = foo.iterator(); iter.hasNext();) {
        Foo foo = (Foo)iter.next();
        Object o2 = new Object();
        foo.doStuf(o1, o2);
    } How could it be any different? It has to keep the behvior of the "old fashioned" iteration.

  • Usage of for-each loop inside another for-each loop

    Hi All,
    I have tried using a for-each loop inside another for-each loop as given below.
    <?for-each:G_1?>
    <Customer Details>
    <?for-each:G_2?>
    <Address>
    <?end for-each?>
    <?end for-each?>
    Its not getting inside the second loop.I have referred this link
    Re: Loop Question but it didn't help me much.Please let me know if am going wrong somewhere.
    Regards,
    Sudeep.

    Sudeep,
    The syntax of the for-each statements looks oke. but you have omitted some question marks after the < and before the >.
    Furhermore, there cannot be spaces in XML element names. So, "Customer Details" won't work. Change it to something like: "Customer_Details". Also be reminded that the element names are case-sensitive.
    try this:
    <?for-each:G_1?>
    <?Customer_Details?>
    <?for-each:G_2?>
    <?Address?>
    <?end for-each?>
    <?end for-each?>
    Regards,
    Kevin

  • How to use for each loop in XSLT when my source is a multilayout file and db

    How do I use a for each loop in XSLT when my source is multilayout file and db .
    My multilayout file is basically contain 2 kind of data one for employee and another for dependent.
    Now my requirement is I want to read each line of data whether it is it is employee or dependent do a join with db and write it in my target file.
    eg :  File content
    1 RichaKumari 311289 TCS INDIA
    2 KiarnKumar 456782 BRO RichaKumari 311289 INDIA
    2 Ravi            456882 BRO RichaKumari 311289 INDIA
    eg : db Content
    311289 RichaKumari TCS INDIA Bangalore [email protected]
    Now in Final File I need something like this :
    1 RichaKumari 311289 TCS INDIA
    2 KiarnKumar RichaKumari 311289 TCS INDIA
    2 Ravi            RichaKumari 311289 TCS INDIA
    here 1 and 2 are the identifier which will decide which layout to follow .

    Hi,
    I think you'll need two nested for-each's... Something like...
    <xsl:for-each select="$root/row[layout = 1]">
    <xsl:variable name="employee" select="."/>
    ... write employee ...
    <xsl:for-each select="$root/row[layout = 2 and dependentid = $employee/id]">
    ... write dependent ...
    </xsl:for-each>
    </xsl:for-each>
    Cheers,
    Vlad

  • Loading accdb file using for each loop in to single target table

    I have 3 accdb file as below in single folder, in control flow I have created a for each loop to loop through all the below file.  In dataflow task I have created oledb source using connection manager to point to first file a1.accdb. I am trying
    to load all the file into single below mentioned target table, here It is only loading first file it is not looping through other two file.
    This I have tried to load .txt files and csv files it is working perfectly but similarly when I try to load access db file table it is not working, can any one of you help me?
    1. a1.accdb contains only one table  a1tab ( col1 col2 col3 )  
    2. a2.accdb  contains only one table  a2tab  ( col1 col2 col3 )
    3. a3.accdb  contains only one table  a3tab   ( col1 col2 col3 )
    I have a target table with similar structure as source
    Target table <TargetTable> Col1 Col2 Col3
    aak

    Thanks Arthur, please find below response
    How do you handle the different table names?  Cant we handle it in a similar manner, how we handle the .csv/.txt files with different name and similar structure for sources(multiple files) and target (single table)
    Is it good to drop the idea of for each loop and create a separate task for each accdb file? to be loaded to same target table( performance wise etc.. any justification would be helpful)
    You must handle the connection string dynamically?
    Can you help me with the logic for handling connection string dynamically
    aak

  • How can I enable for-each loop in Creator update 1?

    I try to use for-each loop, but I got error message from compiler is
    " for-each loops are not supported in -source 1.4. (try -source 1.5 to enable for-each loops)"
    How can I switch my source to 1.5.. I am using jdk 1.5. Confusing.
    Thanks .
    Richard

    Hi!
    Actually Sun Java Studio Creator doesn't support Java EE 5 projects. If You want to create Java EE 5 project, try to use NetBeans with Visual Web Pack installed.
    Thanks,
    Roman.

  • For-each loop in OSB

    Hi,
    I have a senario where i have a varied length XMl is coming to me in response of a service callout, and I need to iterate over it to get the fieldvalue of a particular tag based on its fieldName(e.g FUNCTION_CODE) and assign to a tag of another xml for example
    THE XML Coming as response of service callout is
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <getDefaultValueResponse xmlns="http://data.transformation.nab.cz.fc.ofss.com">
    <getDefaultValueReturn>
    <fieldDefaultValue>F</fieldDefaultValue>
    <fieldName>FUNCTION_CODE</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>PAYMENT_TRANSACTION_ID</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>CHANNEL_ID</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue>CR</fieldDefaultValue>
    <fieldName>CREDIT_DEBIT_FLAG</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>BRAND</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue>001</fieldDefaultValue>
    <fieldName>ACCOUNT_STATUS</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue>Mr</fieldDefaultValue>
    <fieldName>NAME_TITLE</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue>Y</fieldDefaultValue>
    <fieldName>MAIL_RETURN_INDICATOR</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>ENTITY</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>TRANSACTION_CURRENCY</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>VERSION</fieldName>
    </getDefaultValueReturn>
    <getDefaultValueReturn>
    <fieldDefaultValue xsi:nil="true"/>
    <fieldName>TRANSACTION_RATE</fieldName>
    </getDefaultValueReturn>
    </getDefaultValueResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    and i want to assign that value to transactionType tag of
    <?xml version="1.0" encoding="UTF-8"?>
    <tns:sandstonetns xmlns:tns="http://sandstone.response.transactionHistory.app.nab.cz.fc.ofss.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sandstone.response.transactionHistory.app.nab.cz.fc.ofss.com Sandstone_Data_Transaction_History_Response.xsd ">
    <tns:listOfTransactions>
    <tns:transactions>
    <tns:clients>
    <tns:clientID>tns:clientID</tns:clientID>
    </tns:clients>
    <tns:timestamp>2001-12-31T12:00:00</tns:timestamp>
    <tns:sequenceNumber>tns:sequenceNumber</tns:sequenceNumber>
    <tns:description>tns:description</tns:description>
    <tns:amount>0</tns:amount>
    <tns:accountNumber>tns:accountNumber</tns:accountNumber>
    <tns:debitOrCreditFlag>tns:debitOrCreditFlag</tns:debitOrCreditFlag>
    <tns:*transactionType*>tns:transactionType</tns:transactionType>
    </tns:transactions>
    </tns:listOfTransactions>
    <tns:returnResponse>
    <tns:returnCode>0</tns:returnCode>
    <tns:returnDescription>tns:returnDescription</tns:returnDescription>
    </tns:returnResponse>
    </tns:sandstonetns>
    I want to achieve this using for-each loop...kindly help me as I dont have any idea about how to use for-each loop...

    i want to select a the tag fieldValue based on the data in tag fieldName for eg if i iterate over the whole response XML searching for fieldName=FUNCTION_CODE then I whuold get the value 'F' and then I would assign this value 'F' to the transactionType tag of the XML
    <?xml version="1.0" encoding="UTF-8"?>
    <tns:sandstonetns xmlns:tns="http://sandstone.response.transactionHistory.app.nab.cz.fc.ofss.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sandstone.response.transactionHistory.app.nab.cz.fc.ofss.com Sandstone_Data_Transaction_History_Response.xsd ">
    <tns:listOfTransactions>
    <tns:transactions>
    <tns:clients>
    <tns:clientID>tns:clientID</tns:clientID>
    </tns:clients>
    <tns:timestamp>2001-12-31T12:00:00</tns:timestamp>
    <tns:sequenceNumber>tns:sequenceNumber</tns:sequenceNumber>
    <tns:description>tns:description</tns:description>
    <tns:amount>0</tns:amount>
    <tns:accountNumber>tns:accountNumber</tns:accountNumber>
    <tns:debitOrCreditFlag>tns:debitOrCreditFlag</tns:debitOrCreditFlag>
    *<tns:transactionType>tns:transactionType</tns:transactionType>*
    </tns:transactions>
    </tns:listOfTransactions>
    <tns:returnResponse>
    <tns:returnCode>0</tns:returnCode>
    <tns:returnDescription>tns:returnDescription</tns:returnDescription>
    </tns:returnResponse>
    </tns:sandstonetns>

  • For each loop not working

    My trace statements inside my for each loop won't show.
    Please someone check my code. I"m getting no errors in flex
    builder. When i debug all vars are holding prober data. Thanks so
    much

    "essa tkinen" <[email protected]> wrote in
    message
    news:gr27rt$3sb$[email protected]..
    > yes there is data there a commas delimited list of
    keywords that are
    > catagorys. the selectedCatArray holds at list one
    element. I want to
    > return true if element is in that list
    For one thing, you're going to exit the function in the first
    iteration,
    because you return the result inside the loop. Return
    immediately exits the
    function. For another, I'd be tempted to switch it to
    something more like
    this:
    for (var i = 0; i<_item.cats.length; i++) {
    var iCat=item.cats
    //do your stuff here
    I have had really bad luck getting for each in to work the
    way I think it
    should.
    HTH;
    Amy

  • For Each Loop for XML Task

    Hello Everyone,
    Please assist with a step by step guide on how to setup a For Each Loop for XML Task
    I'm trying to convert XML to XSLT
    I have tried more than 10 times and i just do not know what i am doing wrong - no error, my package just runs for a few seconds but nothing happens
    Thanks in advance
    Dee

    I managed to get my XML to XSLT to work but now when i run my package to import the data into SQL table,
    it stops after a few records, i get the following error: 
    [XML Source [1]] Error: The component "XML Source" (1) was unable to process the XML data. The element "Errors" cannot contain a child element. Content model is text only.
    Please assist
    Check this:
    http://social.msdn.microsoft.com/Forums/en-US/80726e0c-9e85-43ca-87bc-7cf90fd7fb31/xml-source-data-flow-throws-cannot-contain-a-child-element-content-model-is-text-only-error?forum=sqlintegrationservices
    Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
    The climb is all there is.

  • For Each Loop

    As we know that For Each loop is more easy to use and iterate. I want to ask, is it possible to run for each loop in reverse order?
    Please help.
    I will be very much thank ful to you.

    Sure. did you notice that it's you who defines the
    running condition, the initial value and the
    (positive or negative) increment?He's talking about the new for loop.
    The for-each loop can't do everything the old one can. Try reading this explanation.
    http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html

  • For Each loop that iterates in reverse order

    Can I use the For Each loop to iterate in reverse order?

    Like this:
    int[] array=new int[10];
    for(int i=array.length-1;i<=0;i--)
         int j=array;

  • For-each loops

    while working in jbuilder2005 i want to use for-each loops i see following error;
    " for-each loops are not supported in -source 1.2 (try -source 1.5 to enable for-each loops) "
    i configured the jdk libraries source to jdk1.5 even then i found problem
    do any body know
    Message was edited by:
    citymodel

    What it says: Java 1.2 does not have for-each loops. You configured it to use 1.5, but you also configured the compiler to check for 1.2-code compliance. Read the JBuilder manual or help about how to find and change the setting. It's probably somewhere in the project settings.

  • For each loop and modification of a LinkedList

    When going thourhg my LinkedList with a for each loop, I want to do a modification. I just saw that it cast a ConcurrentModification Exception, so it seems I can't do that.
    How should I do then? I don't want to go through all the list each time an object is removed, I want it to restart where it stopped.

    Not the best solution but something like thisshould work:
    if( linkedList.get(i) == "modification")No: don't compare Strings with the == operator.
    http://access1.sun.com/FAQSets/newtojavatechfaq.html#9
    You are correct, must be .equals() my bad.

  • For Each Loop - Urgent

    Hi,
    I am trying to use a For each loop:
    FE Agreement_No
    Customer
    0.00
    0.00<?end for-each?>
    This does not work. Does the code FE need to be grouped?
    Can anyone help?
    Thanks

    Hi,
    I have created a repeating group:
    <?for-each-group:ROW;./Agreement_No?>
    This places an F in front of agreement_no field
    and places E in front of the following field customer.
    I would also like to add a condition where installment = 'Under 1'
    Would that be <?for-each-group:ROW;./Agreement_No[../Installments='Under 1']?>

Maybe you are looking for

  • Dynamic Subject Line not appearing in PO mail

    Hi Experts, In tcode ME28 when i get the list of POs to be released , I click on the release possible icon against the PO number. On clicking of this, a mail goes to the vendor of the PO. My requirement is to change the subject line of this mail. I h

  • Material reservation Change

    Hi All, There is a requirement for me regarding "Material Reserervation Change". But i have a BAPI  BAPI_RESERVATION_CREATE for creating reservation. Any one have any idea on the availablitly of BAPI for reservation change ? Any help is appreciated.

  • Finder bug

    I noticed this bug with excel and few other apps in Leopard: 1. double-click an excel file, foo.xls, to open 2. Do a Hide Others (optioncommandH or from the Excel menu). 3. Type something on the spreadsheet. 4. Save (apple+S or from the File Menu) Th

  • Okay, having problems again.

    so when i switched my ipod to automatically update, it seems i saw the album art i couldn't see before but now since i switched, all my songs are deleted and re-uploaded with songs from... the library? this i do not know for sure. and how can i edit

  • TS3367 Facetime aap is missing on my ipad 2 I have checked the restriction area also.. Could u please tell me how can I install it now

    Facetime aap is missing on my ipad 2