Include variables with minor difference in a loop

How can I include variables with minor change inside a loop instead of hard code each one?
For example
aList = ""A", "B", "C", "D"]
repeat with i = 1 to 4
  temp = aList[i]
  Variable[temp] = 1 (some calculation)
end repeat
The variables would be VariableA, VariableB, VariableC, VariableD...
It's similar to Actionscript's
   this["q" + i + "_mc"]._x = this["dragTxt" + i]._x - 20;
   this["q" + i + "_mc"]._y = this["dragTxt" + i]._y + 14;
then the instance is q1_mc, q2_mc etc..
I remember that I could do similar things in Director but forgot how!
Thanks for the help,

Wow. Talk about not seeing the forest through the trees. There's never any good reason to create variables at runtime like that, regardless if there are ways to do it in the scripting language (which there invariably are). Your "on test" handler above uses a whole slew of lists to set up and create a bunch of "dynamic" variables when you should be stopping at lists and property lists (arrays and associative arrays) to do what you want, which is to store your data. The method you currently have conjured up is excessive at best, and bad programming practice at worst (See this link for some good discussion on why it should be avoided: http://programmers.stackexchange.com/questions/103083/how-can-variables-be-created-at-runt ime)
So, I would do what you want like this:
-- initialize the property list (associative array, in other scripting languages)
gUserStatus = [:]
-- add an entry
gUserStatus["Bob"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-- print the property array to the message window
put gUserStatus
-- ["Bob": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
add a few more users:
gUserStatus["Mary"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
gUserStatus["Sue"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
gUserStatus["Paul"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-- get value from property list, based off name
put gUserStatus["Bob"]
-- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-- set value in value list, based off name, then put to message window
gUserStatus["Bob"][3] = 1
put gUserStatus["Bob"]
-- [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
so, I can add as many users as I want... as long as they're identified with unique properties (or keys, in other languages). I can even get the count or number of users:
put gUserStatus.count
-- 4
I can easily iterate through them and get/set information:
cnt = gUserStatus.count
repeat with i = 1 to cnt
  put "Name: " & gUserStatus.getPropAt(i) & ", Status: " & gUserStatus[i]
end repeat
In your example you don't know how many users you have because your variables are being dynamically created at runtime. You could create yet another variable to keep track of that, but why when you have lists and property lists that are perfect structures for this type of associative data?
There's a huge gap in your understanding how to structure, keep track of, and manipulate data, and it's important to fill it now by learning about lists and property lists (arrays and associative arrays). Doing it now will truly open up a whole new way of programming to you.

Similar Messages

  • How to call a variable with a loop count in it

    First - I have a variable called "stages" this is a number
    that can vary. Because it can vary I want to run things in a loop
    based on the number that comes up as the stages variable amount.
    Second is a loop
    <cfloop index="riderCount" from="1" to "9">
    Next, I have a query
    <cfquery name="getPts" datasource="#application.dsn#">
    SELECT *
    FROM fantasy_racers
    WHERE proName='#pro#''
    </cfquery)
    ** Note: variable pro is set before the query **
    I have colums in my table: pts1, pt2, pts3, etc. all the way
    to pts25 for each pro in the table.
    Now to the heart of the matter
    I want to get the amount in each column. EX.: #getPts.pts1#
    but since the number of stages can vary I don't want to hard
    code for 25 outputs when there may only be 7
    so how can I call the column amount but utilize a ridercount
    in place of the number
    #getPts.pts
    ridercount#

    You can reference query variables in an array-of-structures
    notation:
    myQuery["MyColumn"][row]
    so you could do something like this:
    #getPts["pts" & riderCount][1]#
    Combine that syntax with Query.CurrentRow and
    Query.recordCount and you should be able to put a loop together
    that solves your problem.

  • Inititating a variable with properties self vs. non self

    I have properties for my variables (all on retain) - the problem is, that if i am initiating it without self, my app is crashing. As mentioned in the docs, I should not init my variables with self.variable = but with variable =
    so, where is the difference and why is my app crashing?
    not crashing:
    - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle {
    self = [super initWithNibName:nibName bundle:nibBundle ];
    if (self)
    groupDict = [NSDictionary dictionaryWithObjectsAndKeys:
    @"true", HAS_AGE,
    @"true", HAS_GENDER,
    @"true", HAS_EMOTION,
    @"true", HAS_RELATIONSHIP,
    @"true", HAS_WEALTH,
    @"true", @"hasLanguages",
    nil];
    groupKeyArray = [groupDict allKeys];
    setableAttributeKeyArray = [NSArray arrayWithObjects: HAS_RELATIONSHIP,
    HAS_AGE, HAS_GENDER, HAS_EMOTION, HAS_WEALTH, HAS_LANGUAGE, nil];
    [self getAttributeKeys];
    prefs = [NSUserDefaults standardUserDefaults];
    isTextUsed = TRUE;
    [self loadUserProfile];
    return self;
    crashing:
    - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle {
    self = [super initWithNibName:nibName bundle:nibBundle ];
    if (self)
    groupDict = [NSDictionary dictionaryWithObjectsAndKeys:
    @"true", HAS_AGE,
    @"true", HAS_GENDER,
    @"true", HAS_EMOTION,
    @"true", HAS_RELATIONSHIP,
    @"true", HAS_WEALTH,
    @"true", @"hasLanguages",
    nil];
    groupKeyArray = [groupDict allKeys];
    setableAttributeKeyArray = [NSArray arrayWithObjects: HAS_RELATIONSHIP,
    HAS_AGE, HAS_GENDER, HAS_EMOTION, HAS_WEALTH, HAS_LANGUAGE, nil];
    [self getAttributeKeys];
    prefs = [NSUserDefaults standardUserDefaults];
    isTextUsed = TRUE;
    [self loadUserProfile];
    return self;
    interestingly, I have found out that the crash only depends on my groupDict variable.
    crash:
    groupDict = [NSDictionary dictionaryWithObjectsAndKeys: blabla
    no crash:
    self.groupDict = [NSDictionary dictionaryWithObjectsAndKeys: blabla

    Hi Alex -
    sommeralex wrote:
    so, where is the difference and why is my app crashing?
    @interface MyClass : NSObject {
    NSString *foo;
    @property (nonatomic, retain) NSString *foo;
    - (IBAction)doSomething:(id)sender;
    @end
    @implementation MyClass
    @synthesize foo;
    - dealloc {
    [foo release];
    [super dealloc];
    - (IBAction)doSomething:(id)sender {
    UIButton *button = sender;
    NSString *string = [NSString stringWithFormat:@"Button %d was pressed", button.tag];
    // Line 1 simply stores the address of the NSString instance in the ivar named foo:
    foo = string; // Line 1
    // Line 2 also stores the string address in the foo ivar, but does something else as well:
    self.foo = string; // Line 2
    // Line 2 is exactly equivalent to Line 3:
    [self setFoo:string]; // Line 3
    setFoo is the "setter" for the ivar foo which was declared by the @property directive and automatically implemented because of the @synthesize directive. Since the @property directive included the "retain" attribute, setFoo will retain the string object. Note that 'string' was created by a NSString convenience method which means it has been autoreleased. So if we use Line 1 to store the pointer to that NSString instance, the object will soon be deallocated, and if we try to use foo after that, we will crash. But either Line2 or Line3 will retain the NSString object, so it won't be released until another object's pointer is stored in foo, or the parent object is deallocated.
    Everything in the foo example applies to your groupDict ivar (assuming you declared a retaining property named groupDict). The object pointed to by groupDict was created by dictionaryWithObjectsAndKeys, which is a convenience method. So unless the setter (setGroupDict) is used, the address stored in groupDict will become invalid at the end of the current event cycle, and any attempt to use groupDict after that will crash.
    As mentioned in the docs, I should not init my variables with self.variable = but with variable =
    Can you point us to the doc that says that? I might've missed that Obj-C lesson, but up till now I've never heard of a reason not to call setter methods from an init method, provided you've executed [super init] first, and provided you aren't calling a custom setter method which requires the existence of another object. In any case, you could always take the code you posted out of init and put it in awakeFromNib or viewDidLoad.
    - Ray

  • Variable with Replacement Path

    Hi, I have two queries. The results of the first one should be the input for the second one. E.g. the first query shows a list of personnel numbers and additional information. These personnel numbers shall be overtaken by the second query. The personnel numbers belong to "Dimensions" in the Query Designer. I alread tried to create a variable with replacement path to the dimension personnel number. I implementet this variable in both the first and the second query (under: "rows"). It`s no "Formular variable" and no "Calculated Key Figure" but a "Characteristic Value Variable" of a Dimension. The problem is now that I cannot execute any of the two queries. The error "Abort the query cannot be released for OLE DB for OLAP. System error in programm CL_RSR_REQUEST and form PREPARE_VQUERIES:INVALID_
    What is my mistake? Thank you in advance! Eve

    Hi Eve,
    It is possible to connect the 2 queries using a Replacement Path characteristic variable. You would need to create the variable on the char whose values you want to pass from Q1 to Q2. The variable will be of type replacement path and you will need to enter the name of Q1 from which it will get the values. Make sure that you include this char in the query definition of Q1 and Q2. In Q2 you will restrict the characteristic using this variable. DO not use this variable (replacement path) in Q1.
    In your query properties check if you have turned on the checkmark for Release for OLE DB for OLAP (3rd tab). If the check mark is there, then remove it.
    We are using the scenario in a couple of places, and it works very well.
    Hope this helps...

  • Creating Variable with Replacement Path to get value from ANOTHER Variable

    Hi all,
        Is anyone has created the Variable with Replacement Path to get the value from another User Entry Variable, PLEASE ? 
    First created the User Entry Variable (ZV_X) and it accepts the date range like '01/01/2009 - 01/31/2009'. Next created the Characteristic variable (ZV_Y) of Replacement Path for which source variable will be ZV_X and we should get the 'FROM Date' (01/01/2009) from the selection (ZV_X) into it (ZV_Y).
    While creating the Characteristic variable (ZV_Y) of Replacement Path, I didn't find my newly created ZV_X variable in the list of available variables under 'Variable' header in 'Replacement Path' tab and it is causing the error 'Source to replace variable ZV_Y is not defined'. How could I create the Characteristic variable of Replacement Path for my requirement, PLEASE ?
    The following is from help.sap..com:
    Replace with Characteristic Value
    Text and formula variables with the processing type Replacement Path can be replaced with a corresponding characteristic value. In the variable editor, on the General tab page, you specify under Reference Characteristic the characteristic that is to be referenced by the replacement. On the Replacement Path tab page, you can choose whether the variable is replaced with the From or the To Value and with the Key or the Name of the characteristic value. You can also specify the Offset Start and Offset Length for the output.
    Replace with Variable
    Characteristic value variables, hierarchy variables, text variables, and formula variables with the Replacement Path processing type can take their values from a different variable.
    The following prerequisites need to be fulfilled:
    Variable
    ●      The variable must not be input-ready
    ●      The variable must represent a single value
    Source Variable
    ●      The source variable must not be a hierarchy node variable
    ●      The source variable must be input-ready
    ●      The source variable must be available in the query
    ●      The source variable must represent a single value or an interval
    In the variable editor, on the Replacement Path tab page, you specify the source variable from which the value is to be determined. The value is either determined from the key, the external attribute of the key, the description, or the attribute value. You can specify an Offset Start and an Offset Length for the output here. The variable is replaced on the variable screen upon each data release.
    Thanks,
    Venkat.

    Hi Eve,
    It is possible to connect the 2 queries using a Replacement Path characteristic variable. You would need to create the variable on the char whose values you want to pass from Q1 to Q2. The variable will be of type replacement path and you will need to enter the name of Q1 from which it will get the values. Make sure that you include this char in the query definition of Q1 and Q2. In Q2 you will restrict the characteristic using this variable. DO not use this variable (replacement path) in Q1.
    In your query properties check if you have turned on the checkmark for Release for OLE DB for OLAP (3rd tab). If the check mark is there, then remove it.
    We are using the scenario in a couple of places, and it works very well.
    Hope this helps...

  • Suggestions for most efficient way to create a second app or site with minor rebranding

    I've been asked to create a new Foundation 2010 ite that's going to be 90% the same site as one for another division. The current website uses custom masterpages and some other customization. My understanding is that the differences are going to be a different
    URL and some minor branding stuff. THey are external presence sites. I don't believe it's using search or much else in the way of services, custom wsps, etc. Very simple sites.
    I'm thinking of backing up the dbs, restoring using different mdf/ldf and db names, creating a new app and attaching, but not sure if the GUIDs will conflict. I'm also thinking that what the masterpages call in _layouts may need to be changed, which should
    be pretty simple.
    Anything I'm overlooking?
    Also, apologies for using apps and sites interchangeably, I'm aware of the differences. I was actually asked to create a new site and assign a new URL to it, but if that's doable it sounds more complex to me.
    Thanks,
    Scott

    Hi,
    According to your post, my understanding is that you want to create a second app or site with minor rebranding.
    I recommend to create a test environment for existing production enviroment.
    For more information, you can refer to:
    Moving content between SharePoint environments
    Copy SharePoint production data to a test environment
    Build a SharePoint 2010 Test/Development Farm
    Thanks,
    Linda Li                
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • Formula variable with replacement path on system date

    Hi Experts,
    I got a requirement to calculate "Days without payment" in report level.
    Days without payment = System Date - Payment Date.
    (Payment date field is available in CUBE, but system date field is not available in the CUBE)
    As we know, the difference b/w 2 dates is not possible directly.It can be possible by creating 2 formula variables with replacement paths on the dates and by writing aformula on these 2 formula variables.
    But the thing is I dont have system date readily available, and I tried by using SAP Exit. But we cant create formula variable replacement path on another variable (SAP EXIT).
    Do we have any SAP variable  for formula with replacement path readily avaliable to get system date (or) any other suggession.
    Please suggest me.
    Thanks,
    Sai Chand.S

    Hi Arminder,
    Thanks for your valuable answer.
    I tried doing the same previously.As u said we can get system date by creating customer exit variable.
    But the thing is to find difference b/w 2 dates, we cant do it directly, we need to create 2 formula variables with replacement path.
    1) Var1 = Formula variable with replacement path on system date(custoer exit variable).
    2) Var2 = Formula variable with replacement path on paymanet date.
    Number of days = var1 - var2.
    But as in 1st point, we cant create formula variable with replacement path on another variable, as system date is already a variable of type customer exit.
    We can create replacement paths only on characteristics.
    Please suggest me .
    Thanks,
    Sai Chand.S

  • Issue - Formula Variable with Replacement Path

    Hi,
    Is it mandatory to include the base characteristics in the rows on which the formula variable(replacement path) is based on. As long as the base char is in the rows the variable works fine. The moment I take that off, the variable doesn't produce any result. I know the char can be put in the rows and can be hidden, but then in that case I don't get the desired aggregation level.
    Has anybody come across this probelm and managed to sort this out? Kindly suggest any solution.
    Thanks,
    Anurag.

    Hi,
    a formula variable with replacement path only works if the replacement object is in the query in either the rows or colums. The data can never be aggregated on a higher level then the infoObject in the replacement path. If you want a higher aggregation you can add a new key figure as an attribute to your infoObject and fill it with the value you want in the loading process. You can use that key figure in your queries every way you want.
    Kind regards,
    Alex

  • How to use variables with

    I need to get the number of lines in internal table, which would
    be easy, using DESCRIBE TABLE itab LINES lines. But the problem
    is, that I get the name of this internal table in the field of
    another internal table, so I have to use the name of internal
    table as variable, but I don't know how to use variables with
    DESCRIBE TABLE (or if this is possible).

    Hi,
    REPORT ZPRUEBA782 .
    define two tables with diferent structures.
    data: begin of table1 occurs 0,
    registro type i,
    end of table1.
    data: begin of table2 occurs 0,
    registro type i,
    repid like sy-repid,
    end of table2.
    data: rows type i.
    start-of-selection.
    fill them with data
    do 1000 times.
    table1-registro = sy-tabix.
    append table1.
    enddo.
    do 1757 times.
    table2-registro = sy-tabix.
    table2-repid = sy-repid.
    append table2.
    enddo.
    call a form that receives as input the table and returns the number
    of rows as output.
    perform howmanyrows tables table2 changing rows.
    break-point. "evaluate the number of rows
    perform howmanyrows tables table1 changing rows.
    break-point. "evaluate the number of rows
    end-of-selection.
    form howmanyrows tables itable changing rows.
    rows = 0.
    loop at itable.
    add 1 to rows.
    endloop.
    endform.
    You can try it if you don't find a better solution.
    Cheers,
    Chaitanya.

  • Text Variable With Replacement Path : supported in Webi 4.0 or Not.??

    Hello to All WebI Gurus,
    We are on BO 4.0
    We are building WebI report on top of Bex query using the BICS connection from IDT.
    Our BW query is having some Text Variable with processing type "Replacement Path".
    Also its having fiscal year period in filter with user input variable.
    the text variables references Fiscal year period and are used in Key figure description,
    hence whatever value the input variable will capture the description of Key figure changes accordingly/dynamically.
    But when I try to use it in BO it throws me an error msg saying :
    Unknown error occured in SL Services
    I am Aware that text variable in this fashion were not supported in BO XI3.1
    Used of Sap text variable with replacement path in Bo designer
    So are Text variable Supported in BO 4.0 in this fashion.
    Any response will be highly appreciable.
    Thanks & Regards
    Neeraj

    Hi,
    Here's a great SDN article, which includes several slides covering u201CWhich BEx features are supported using BICS connectivityu201D : http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d056e1bc-2794-2e10-959e-8779c5623cc5
    Pages 8 -> 12 cover these topics.
    If your design choices are compliant (supported) then i'd avise opening a support case if this issue persist after checking again on Patch2.11 (release recently)
    Regards,
    H

  • How to include variable in the text column in report painter?

    Dear Expert,
    Would like to seek for your help to include How to include variable in the text column in report painter?Please advice.
    Thank you.
    Regards,
    Karen
    Edited by: Karen Swee Ping Ho on Jun 17, 2011 2:48 AM

    Hi,
    Thank you for the promt reply.
    1) How I include the variable in the column header to display fiscal year which I have selected from the selection screen?
    which variable should i use?
    2) Where can i find more information about the characteristic and which variable to be use base on the characteristic?
    For example: I would like to display the fiscal year from the selection screen/input screen when execute the report which also will reflected to the element definition and will display the fiscal year also in the column text?
    3) Kindly advise base on question 2, the variable that i use in element definition it will also display  in selection screen?
    4) When execute the report the first selection screen input parameter it obtain from where it is from element definition?
    5) Please advice how to be done when report execute with first screen input selection will also reflect the element definition of column and rom with the selection of the fiscal year?
    Please help.
    many thanks
    Edited by: KH on Jun 18, 2011 7:18 AM

  • User defined Variable with multiple value

    Hi Experts,
    customer requirement is the following:
    Build a layout in which to have in Lead Column the cost center characteristics, but not all cost center in master data but only those chosen by user with manual input. To achieve this goal i have created a variable of type characteristics (associatd to cost center CH) with replacement type "user defined values", then i have put this var in planning level. I have created a layout with Cost Center in Lead Column and set "all possible ch combination" in additional setting.
    Thanks to the varable created, the user can enter Cost Center value, but the problem is that he cannot select more than one single cost center value, for example:
    User want to see in layout CosCen1 and CosCen4, by now he can set variable in order to see the entire range from CosCen1 to CosCen4 (included all intermediate Cost Center) or to see only one between those 2 Cost Center, but it's not possible (or better i don't know how to..) to select both cost center and display the layout with ONLY those 2 Cost Center in Lead Column (CosCen1 and CosCen4).
    In other word, is it possible to set a variable with more than one single value without using range from-to?
    If not, does exist an alternative?
    Thanks in advance.
    Fabio

    Hi Fabio,
    It works as follows.
    let's say you have 3 multiple single lines for your cost center variable.
    once you are in the folder, select any single value & the layout is ready for planning with the corresponding cost center.
    now, select the "Cost center variable row" in the header of the folder within section "Name of Variable" & click on "Trash Can" icon to "Delete Selection" of variable.
    this basically deletes all the entered selections (3 entries) & displays for all.
    It works this way, because we don't have "resriction of values required by user".
    if am not wrong & correct me if am wrong,
    overall, this is nothing but equal to "planning level not restricted with any variable".
    I just tested this & the flaw in this is that, it is not only displaying for all the initially entered 3 lines but it displays for each & every cost center irrespective of the variable selections.
    hope it is clear.

  • Using collections / Bind variables with a PL/SQL functio returning a query

    I have this code, which is supposed to assign collection variables as column names
    FOR i in 1 .. Collection_count -1
    LOOP
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as ';
    vQuery:=vQuery || varholder || ', ' ;
    END LOOP;
    I've tried &P341_M1. , :P341_M1, ':P341_M1', varholder
    When I try '&P341_M1' it returns the whole SUM(decode... line as the label
    Basically Im having a hard time using bind variables with the PL/SQL returning a query...anybody?

    Ok so working through this problem more I have realized that the problem is using the for loop i as an index value
    This will get a value:
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
    But this won't
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    I'm in the for loop, and use the i variable in other places within this loop...Is there a reason why I can't compare seq_id to i?
    My new code as follows:
    FOR i in 1 .. Collection_count -1 --apex_application.g_f01.COUNT - 1
    LOOP
    varholder:=i;
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
    SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=4;
    vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as f';
    vQuery:=vQuery || :P341_M1 ||i||', ' ;
    END LOOP;

  • Best way to pre-populate material variable with values for users

    Hi,  I have a requirement to prepopulate a material variable with about 5 materials and that is the materials that will default when the query is called.  The users would also need the ability to change those values.
    My thought is to create a User-exit variable that derives the values from a user maintained table (infoobject). 
    Does anyone else have any suggestions or ideas on the best way to handle this?

    I don't know if there is a best solution...
    Infoobject
    With this option you have to create a new infoobject (ZMATERIAL) without attribute (you need only a list material codes) and then to set the authorization profile for the user in order to manage the content.
    The creation of an infoobject corresponds to a table creation, but you don't need any other specific options that belong to the infooject (as technical object)...
    Table
    With this option you have to create a Z table with only one field and then to allow the maintenance of the table by SM30....
    In the ending, if you want to be a purist use the table, otherwise use an infoobject (but there are no significant differences !
    Bye,
    Roberto

  • Whats the difference between a loop at where cndition and a read statmnt

    Hi.
    Whats the difference between a loop at where cndition and a read statmnt??
    The read statement fails but the loop at where cond works fine...
    READ TABLE t_stpo INTO wa_stpo
                                      WITH KEY idnrk = wa_keko-matnr
                                      BINARY SEARCH.
    LOOP at  t_stpo into wa_stpo where idnrk = wa_keko-matnr.
         endloop.
    Why is it so??

    Hi..
    Check out the Differences below.
    <b>SORT T_STPO BY MATNR.</b>
    <b>READ TABLE t_stpo INTO wa_stpo
    WITH KEY idnrk = wa_keko-matnr
    BINARY SEARCH.</b>
    The READ TABLE statement reads a single record from internal table.
    Binary search can be used to optimize the Search time based on key.
    But Sorting is must before using BINARY SEARCH.
    Always use READ TABLE When u need a single row from internal table.
    Bcoz it will not process all the records of internal table.
    <b>LOOP at t_stpo into wa_stpo where idnrk = wa_keko-matnr.
    endloop.</b>
    The above LOOP .. ENDLOOP statement using WHERE Condition is used when there can be multiple rows satisfying the Condition.
    It will actually Processes all the Records in internal table and returns only the records matching the condition.
    So it will always take more time.
    <b>Reward if Helpful</b>

Maybe you are looking for

  • Need to find out the list of objects under a Transport

    Hi , My requriement is to programatically find the list of objects under the Transport. I tried using the table E071 but no luck is there any FM or table which gives me the list of objects assigned to the transport request Regards, kk

  • Pass Dynamic Parameters to a iView

    Hi, We have a reuirement where we need to pass the URL iView Parameters dynamically..The link to access the URL iView needs to be constructed in R/3 with a parameter value(Example: Work Item ID), which is dynamic. This constructed link will be send a

  • Broadband Option 3/Router

    Have recently upgraded from Option 2 to Option 3 broadband with BT. Are you supposed to get a new router with this deal? It mentioned a welcome pack (don't know what the welcome pach was supposed to contain though) when I signed up online but nothing

  • Finder no longer opens after recent update

    Hi fellow mac enthusiasts. I sincerely hope someone can help me. After my most recent software update I can log in but the Finder does not open. I can open other applications that are in the dock. Fortunately I have Quicksilver and I can use it as a

  • Regardind shipping coditions

    Hi friends, Hope u all knows that shipping conditions copy into sales documents from sales documents or CMR sold to party.    but iam having 2 ship to partys with two diffrent shipping conditions for one sold to party..when iam processing a sales ord