Read stament insted of loop

Hi,
   Iam woking one exit.My requirement is
1. Check if operating concern (I_ERKRS) is 0001 than go to step 2 else go to   
    step  4.
2. Read CE10001 table and verify value for Item Category (CE10001-PSTYV).
3. If Item Category(CE10001-PSTYV) is TAS Than change Warehouse cost value 
    field(CE10001-VV504)  value to 0.00 irrespective of its current value.
    else don’t change value of warhouse cost value field(CE10001-VV504)
4. exit from function module.
    This logic should be implemented for all line items in each billing document. E.g. if 5 line items are generated into COPA for one billing document step 1-4 need to be execute 5 times. Number of line items can be determined from T_ITEM table.
i implement the logic is
IF i_erkrs EQ '0001'.
    LOOP AT t_item INTO wa_item.
IF wa_item-pstyv = TAS.        
         wa_item-vv504 = c_0 .          
      ENDIF.
      MODIFY t_item FROM wa_item.
    ENDLOOP.
  ELSE.
    EXIT.
  ENDIF.
How to implement the same logic using READ statement( Check 2nd point in the requirement) .It is very urgent.Pleae help me.
Thanks,
sudhakar

Hi,
Here you can use field symbols.
Field symbols are declared like this.
Filed-symbols: <fs_item> type ty_item.
Then write the read statement like this, it not necessary to be a key field, just you must have this field in the structure.
then write code like this.
read table t_item assigning <fs_item> with key pstyv = 'TAS'.
Then directly write <fs_item>-filed = value.
It will directly change the value.
No need to append and every thing.
With regards,
Srinivasu Reddy.
Message was edited by:
        Srinivasu Reddy

Similar Messages

  • Read table inside a loop

    Hi,
    I would like to seek advice on this.
    I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
    why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
    LOOP AT it_itab1 INTO wa_itab1.
        READ TABLE it_itab2 INTO wa_itab2
                                  WITH KEY glla   = wa_itab2-glia
                                           cctrla = wa_itab2-cctria
                                           anln1  = wa_itab2-anln1
                                           anln2  = wa_itab2-anln2.
       IF sy-subrc = 0.
    Thanks

    Dear Please check the below code
    same as urs but small mofications
    >
    Ask_que wrote:
    > Hi,
    > I would like to seek advice on this.
    > I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
    > why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
    >
    > LOOP AT it_itab1 INTO wa_itab1.
    >     READ TABLE it_itab2 INTO wa_itab2
    >                               WITH KEY glla   = wa_itab1-glia
    >                                        cctrla = wa_itab2-cctria
    >                                        anln1  = wa_itab2-anln1
    >                                        anln2  = wa_itab2-anln2.
    >    IF sy-subrc = 0.
    >   
    >
    > Thanks
    LOOP AT it_itab1 INTO wa_itab1.
        READ TABLE it_itab2 INTO wa_itab2
                                 WITH KEY glla   = wa_itab1-glia
    IF sy-subrc = 0.
                                            cctrla = wa_itab1-cctria
                                            anln1  = wa_itab1-anln1
                                            anln2  = wa_itab1-anln2.
      ENDIF.
    ENDLOOP.
    Thanks
    Surendra P

  • Adobe Reader X won't loop a slideshow.

    I generate a slideshow in Serif PagePlus and one of the options when I publish to pdf slideshow is "Loop Slideshow". This has worked fine for years, until, by the look of it the installation of  AR X. In AR X the slideshow just hangs at the end of the show so my rolling message board no longer works. Setting the Edit > Preferences > Full Screen - "Loop after last page" option in AR enables the slideshow to loop OK. However this isn't needed in previous versions of AR and I can't reckon on all users having this option set.
    Is it a bug?
    Art

    I did the following and it fixed the problem...
    Let us assign permissions to the C drive(or the drive where you have installed the OS) and then check.
    To apply permissions to a file or folder for a user:
    a. Right-click on the C drive and then click Properties.
    c. Click the Security tab, and then click Edit.
    d. Do one of the following:
        i. To set permissions for a user that is not listed under Group or user names, click Add, type the name of the user or group, click OK, select the permissions, and then click OK.
        ii. To change or remove permissions from an existing group or user, click the name of the group or user, select the permissions, and then click OK.

  • How do I exit a while loop which has a 'read from spreadshee​t' pop up in it?

    I have a while loop which calls 'read from spreadsheet'. My problem is that after entering a filename the loop repeats too quickly for me to hit the end loop button. How do I exit the loop without adding a delay after the read thereby slowing the loop when I don't want to exit. If I select cancel I get 'error 43'. Is there a way to to use an error handler to prevent this from popping up and use it to end the loop?

    It's the error handler inside Read From Spreadsheet that creates the message. Specifically, one of the VIs called is Read Lines From File. The last VI in there is General Error Handler. You can delete it and save it with a different name. You should also modify it to return the error cluster. You'll also want to modify Read From Spreadsheet to return the error cluster so that you can trap the error in your VI. When cancel is selected, error code 43 is generated. Stop the loop when you see 43.

  • I have a loop made to read temperature 30 times and averages it down to one value which is then displayed on the screen.

    My problem is that this loop is not permitting me to abort instantly because I have to wait until the for loop is done. I am using event structure which is allowing me to interrupt at any time and jump to something else in the software but nothing stops the for loop and I really need to calculate temperature by taking at least 20-30 points. I have been moving this part of the software all over the software and if I solve one problem wherever I put this vi it slows down that part of the software where I put it. I need to read te temp. all the time whle software is running.
    Do you have any ideas how to speed up this VI so that it doesn't take t
    his long to execute or how to build this software so that read temp.vi doesn't affect software. Thanks for your time. Here is the read temp. vi
    Attachments:
    Read_temperature.vi ‏50 KB

    Hello,
    Here is a simple VI (saved in LabVIEW 7.0) that uses a control reference to pass a front panel control's value into a subVI. You can run the VI, then press the "Start SubVI" button, which will cause the subVI to start running. It waits until you press the "Abort SubVI" button, at which point the "Value" property of the boolean inside the subVI is read, and terminates the loop. I am then resetting the boolean value after the subVI returns a value (this is because you cannot use the Value property on latch booleans). This should be enough to get you started.
    Keep in mind that you cannot perform this operation inside an event case of an event structure, since the UI is locked while the event structure is processing the event...t
    hus, you wouldn't even be able to press the abort button. In your case, you should probably have a loop handling the UI events, and a separate loop handing the data acquisition.
    For more examples on using Control References, check out examples\general\cntrlref.llb. There is also extensive help on them in the LabVIEW On-line Help.
    Good luck,
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    ctrlref.llb ‏29 KB

  • 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>

  • Sy-index / sy-tabix wrong within loop

    Hi friends,
    i do a loop over a a table and am writing out the field contents like this:
    LOOP AT <dyn_table> INTO <dyn_wa>.
            do.
          assign component sy-index
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    * Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
          endif.
      ENDLOOP.
    What now doesnt work is, that whenever i have the read statement uncommented the loop doesnt increment so i only get the first row but that n-times.
    any idea where the error is  ?
    thank you! i am awarding points generously

    LOOP AT <dyn_table> INTO <dyn_wa>.
            do.
          assign component sy-index
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
          endif.
      ENDLOOP.
    If i gt you rite..i would suggest this
    Data: l_tabix type sy-tabix.
    LOOP AT <dyn_table> INTO <dyn_wa>.
      l_tabix - sy-tabix.
          assign component l_tabix
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX l_tabix.
          endif.
      ENDLOOP.
    santhosh

  • Why cant we used sy-subrc in loop and endloop?why?where exactly it  is used

    hi
    can u help me for this

    sure you can use sy-subrc inside a loop, for example for checking READ statement inside the loop.
    Checking sy-subrc (return code) is done to determine is 'something' was successfull (return code = 0) or not (return code <> ).

  • Delete records in itab1 where key fields does not exit in itab2 w/o Loop

    Hi,
    I am trying to find the most efficient way to compare two internal tables and filter out (delete) the entries in Internal Table 1 (ITAB1) where the key fields does not exist in internal table 2 (ITAB2).
    Here is the codes using the Loop.
    Loop at itab1.
      read table itab2 where field1 = itab1-field1 and field2 = itab1-field2.
      if sy-subrc ne 0.
       delete itab1 where field1 = itab1-field1 and field2 = itab-field2.
      endif.
    endloop.
    Instead of looping thru each record of ITAB1, is there a way to use the "DELETE" or other efficient way? This is in ECC 6.0.
    Thanks for any advice in advance.

    Not sure if its possible without using even a single loop. Though you can avoid the read statement this way
    loop at itab2.
    delete itab1 where field1 NE itab2-field1 and field2 NE  itab2-field2.
    endloop.

  • Apple Loops from Regions problem...

    Greetings,
        Having a problem when I add a region to Apple Loops in Logic Express 8....
          I've read some similar threads, but nothing that answers these issues..
        After creating a region using the Ultrabeat or a synth (all internal), I'll select the region and go up
           to the 'Region' drop down menu and select the first option, 'Add to apple loops library'...
         I came across this process naturally and it seemed to work fine, but then some of the loops created
             acted differently than others.  When I drag some of them into the Arrage area, and press play,
                they will playback no matter what position they are at.
            For example if I have a beat that starts at 1., but I have the recently added 'problem' loop at 4.,
              this 'problem' loop will play back from 1 as well, no matter if it's at 4, or 24...
           I'm not sure why this is happening to some and not others....???
              Did i accidentally do something to these that I didn't do to the others?
           Also, I figured I'd just delete them and create new ones, but then I couldn't find them ANYWHERE
              on my harddrive!!!???   I really don't get this one...
             I've read about the Apple Loops Utility now and I guess i should use that for future loop creation?
                I really don't understand how the loops I made are no where to be found, not even in the
                     Apple Loops/User Loops folder....
             Would really, really appreciate if someone could help w/ this conundrum!

    Ouch.... That's a real bummer.
    I would recommend trying the "re-conversion" with just a few loops and seeing how it works for you. I've had to do this before as well. I had a library from L7 that I had converted using ALU inside L8's arrange window. For some reason, the loops that I had never used in that project that I had converted were not converted after I deleted the project that I used them in... make sense? not to me either....
    The whole Apple Loop Utility is awesomely useful sometimes and buggy to the point of frustration at others....
    Also, is there any consistent pattern to the "off-timeiness" of the loops? (i.e: only midi loops, only audio loops, only slows down, only speeds up, "choppy", etc...)

  • Data acquisition loop with queue

    What I would like to do is have a data acquisition loop that samples a load cell at 500Hz and have another loop that runs much slower to run a state machine and display some data in real time.  The reason I want to sample the load cell so fast is to filter out some noise.  Making producer/consumer loops with a queue kind of makes sense but I don't really care about all of the samples, I just want to be able to read a real time filtered signal at certain times.  I looked at having just two parallel loops, one to acquire the data and the other to run a test and retrieve a real-time signal when I want but not sure how to pass data between the loops without using a queue.  You can do it with local variables but you are at risk of a race condition.  I hope this make sense.  I am sure this is a simple problem I just don't know what direction to go.  Thanks

    Good Evening secr1973,
    It sounds like you are on the right track.  You already know about the producer/consumer architecture; this is almost always the first step to the separation that I think you are after.
    The step that I think you are missing is a Case Structure around the enqueue element VI.  You likely have some event or specific pattern that you are looking for in the input signal.  You can have the output from this algorithm (likely a boolean) determine which case of the Case Structure to execute (Case 1: enqueue the element or Case 2: Do not enqueue the element).
    This, of course, leads to processing being done in the producer loop, which is quite the opposite of what you are trying to accomplish with the producer/consumer architecture.  You will have to decide if your processing is very simple or more complicated.
    If it is easy/fast, you can likely get away with doing this processing in the producer loop.  My guess is that your program falls under the category of do-it-all-in-the-producer loop because you are only acquiring at 500 Hz.
    If the application requires faster acquisition rates or if the logic is going to require some processing, you may want to implement a double layer producer/consumer architecture.  In this setup, you would pass all of the data from the DAQ producer to a second loop (using queue #1) that determines what to do with the data (to enqueue or not to enqueue...) and, if appropriate, write to a queue (queue #2) that the third loop can read.  The third loop would be where your state machine executes.
    If you have a quad core machine, each of these steps will execute on its own core.  If not, you will have a little more thread swapping; not a huge concern in most cases.  Here, we get into the art of programming more than the science.
    In any event, I think you will be OK with a little processing for the enqueue or not algorithm in the producer loop.
    Regards,
    Charlie Piazza
    Staff Product Support Engineer, RF
    National Instruments

  • How to use while loops to implement a simple climate control.

    Hi,
    I am currently a 4’th year computer systems engineering student in South Africa doing a primitive climate control project in LabVIEW 8.0. Although my knowledge and skill level of LabVIEW is far from that of an expert, I really enjoy working with it. The project consists of a motor driving some fan blades, a resistor heater and an analog temperature sensor. The basic functionality entails that a user specifies a desired temperature and then the program will heat if the current temperature is lower than desired or cool if the current temperature is above the desired temperature.
    What I want to add is an acceptable temperature difference so that the fan and heater do not switch constantly as the threshold temperature is reached. Rather leave the current temperature to linger between the maximum (current + acceptable difference) or minimum (current – acceptable difference) allowed temperature before heating or cooling it to the desired temperature once again.
    I have attached 2 VI’s:
    Final Assignment: I tried to achieve the sensible climate control by making use of a formula node. As soon as I substituted the if statements in the formula node with while statements, the VI did not respond. It did not give any errors, it just didn’t respond.
    Final Assignment2: I tried the same but by making use of while loop structures. The while where my Input DAQ is works fine, but none of the other while loops work.
    Please advise me on possible solutions for my problem/project.
    Thank you in advance.
    D. Weppenaar
    Attachments:
    Final Assignment1.vi ‏254 KB
    Final Assignment21.vi ‏256 KB

    1. Your VI does not respond because your formula node is trapped in an infinite loop and cannot exit if you're out of the deadband. Replace the words "while" with "if" (or similar) and you might be getting somewhere. Sorry, I don't have DAQ installed, but what determines the loop rate?
    2. You have a dataflow issue. Only the inner loop on the left will run. All other loops must wait because they depend on data from the first loop. data is only available at an output tunnel of a loop once the loop finishes and a loop cannot start until all input tunnels contain data. Also the first loop can never stop, because the stop button is outside the loop and will never get read once the inner loop starts. The stop button needs to be in the innermost loop.
    Most likely, all code segments should run synchronized, so delete all the inner loops. They serve no purpose. All yon need is the big outer loop as in the first code.
    There are many ways to directly observe what is going on. For example you could run the VI in execution highlighting mode while watching the diagram.
    Clearly, you need to become more familiar with LabVIEW basics. Maybe do a tutorial? Right now you might think that dataflow is a hindrance while in fact it is one of the most powerful advantages of dataflow programming. You simply need to be familiar with its logic.
    LabVIEW Champion . Do more with less code and in less time .

  • Selector in NIO notifies data to be read but bytes read 0

    Hi All,
    I am facing a problem in NIO which for which I have clue.
    The selector object notifies that data is ready to be read from a particular channel after which
    I execute the following to read the data into the buffer
    readBuffer.clear();
    int count = this.sockChannel.read(this.readBuffer);
    The value of count which i get is 0 after which which i return without any processing
    but this notification goes on and on as I can see in the logs which goes on logging
    Count received as 0 infinitely.
    Please help

    There's a few things here.
    1. I prefer to see only one read statement in these loops, like this:
    while ((count = in.read(readBuffer)) > 0)
      readBuffer.flip();
      // get() from readBuffer into somewhere
    // NB the 'len' to use is 'count'. You don't need to get it again via 'position()'.
    // it generally makes more sense to use compact rather than clear() here
      readBuffer.compact();
    }2. count < 0 doesn' t mean the socket is closed, it means the connection is closed. You have to close the socket, or the channel, yourself, and I don't see that:
    if (count < 0)
      logger.debug("connection closed" ...); // etc
      in.close();
    }3. You're testing bytes.length > 0 in a place where it can't possibly be zero.
    4. I hope you're not really ignoring exceptions as shown. If you are, that would explain the behaviour completely - never do that. If you get any kind of an IOException in this code, the connection is hosed and you must log the exception and close the channel. The only exception to this rule is SocketTimeoutException, which doesn't happen in non-blocking mode.
    5. Is there any possibility that the buffer is zero length? That would cause read() to return zero.

  • Using a DAQ value in a location outside of the While Loop it is placed in

    I am writing a program that records the speed of a car and then is supposed repeat the action through the use of an actuator.  I was able to write the program to the point where I am saving the data into a .txt file and will be able to read it back out.  My problem is that I need to use a dbl value that I am calculating from the output of a DAQ Assistant block that is contained inside a while loop in another part of the program to compare current speed vs. recorded speed then output an action.  Everytime I try to draw a connection outside of the while loop, the actual value is not read outside of the loop.  I cannot put the other part of the program into the while loop because the while loop only performs every .1 to 1 second and I need the output to the actuator to be a continous string delievered to the serial port.  I also cannot create another DAQ Assistant block that reads the same port outside of the while loop.  I have thought about using a jumper to another input on the input card, but I would prefer not to use the extra space.
    So generally speaking, I'm wondering if there is a way to read a value obtained from a DAQ Assistant block outside of the while loop it is contained in.
    Thanks to anyone that can help!!!
    Travis

    Cheers,
    I am not 100% sure what your problem is but how about writing the red value into the local variable and reading it outside of the loop? Or enqueue the value into the queue and dequeue it in the other loop (Producer/Consumer Structure (Data))?
    Br,
    Jick

  • Regarding looping of a table

    how can we loop a table with respect to the index values of the table i want to loop the table upto an index 5 how can i do it.
    thanks in advance

    hi
    Sample Code:
    READ TABLE T_MARC1 INTO WA_MARC WITH KEY WERKS = P_WERKS.
    IF SY-SUBRC EQ 0.
    L_TABIX = SY-TABIX + 1.
    ADD 1 TO COUNT.
    LOOP AT T_MARC1 INTO WA_MARC FROM L_TABIX.
    IF WA_MARC-WERKS NE P_WERKS.
    EXIT.
    ENDIF.
    ADD 1 TO COUNT.
    ENDLOOP.
    ENDIF.
    If you look at the above code, first we read the record which appears first in the list of records, hence the index of that entry is stored in a local variable, further records can be read using index from loop which is very fast in access.
    regards
    Satish

Maybe you are looking for

  • Artwork not modifiable, how to change this?

    I just downloaded a free song off of a website using Firefox. I chose "open with iTunes". The song went straight o my iTunes and is playing fine. Only problem is that there is no artwork. It says 'artwork not modifiable'. **When I right click and cho

  • Icloud storage delete process

    my email has shut down as my 'i cloud storage too full.' I dont use the cloud, never have and cannot locate it anywhere to delete storage - help please. I'm a noob as well. thanks for the help.

  • Output of SNP

    Hi gurus, recently i faced a question.The output of DP is demand Plan..Then,what is the output of SNP? Thanks in Advance.. Regards.. Yogi..

  • How to delete a domain safely?

    Is there any tool in weblogic which can remove a domain safely? Or just delete from disk is safe? Thanks.

  • Newby to Flash -- need help with Drag and Drop

    I have been trying to create a drag and drop in Flash where I have five different places for an instance of a mc to be dropped. I want to be able to drop only three instances to each place and these three instances are specific to one of the five "dr