Looping Clarification

Hi, I'm new to the whole Java game and need some clarification and help understanding some of this code I've adapted.
Firstly I think I understand how the 'for' loops and their parameters work, however I'm unsure how "i" is being used, it doesn't seem to be declared anywhere?
Secondly, the "return prime" function, what exactly does it do? I thought prime was a boolean? What is it returning? Is it simply resetting the above boolean status to the current one?
Thirdly 'int num' is an object in the 'isPrime' class? What is it being used for? Where does it get it's value from?
Finally and probably most importantly, by calling the the class "IsPrime(i)" in the main, what does the "i" parameter depict? I was thinking "i" is simply a counter used for the 'for' loop?
import java.util.Scanner;
public class PrimeTest{
  // This method tests whether a given number is prime or not.
     public static boolean isPrime ( int num ){
     boolean prime = true;
   int limit = (int) Math.sqrt ( num ); 
   for ( int i = 2; i <= limit; i++ ){
          if ( num % i == 0 ){
               prime = false;
               break;
     return prime;
public static void main(String[] args){
     Scanner input = new Scanner(System.in);
     System.out.print("Enter the number: ");
     int number = input.nextInt();
     // This loop writes out all the prime numbers less than given number.
   for ( int i = 2; i < number; i++ ){
          if ( isPrime ( i ) )
               System.out.print ( i+"," );
}Any help would be greatly apreciated!
Thanks, Dan.

Dan.Cody wrote:
Firstly I think I understand how the 'for' loops and their parameters work, however I'm unsure how "i" is being used, it doesn't seem to be declared anywhere?It is declared inside the for loop. The following two pieces of code are (mostly) identical:
int i;
for (i = 0; i < SOME_MAXIMUM; i++) {and
for (int i = 0; i < SOME_MAXIMUM; i++) {Not that the second piece of code has the "int i" embedded inside the for-statement.
Secondly, the "return prime" function, what exactly does it do? I thought prime was a boolean? What is it returning? Is it simply resetting the above boolean status to the current one?prime is a boolean. isPrime(int) is a method that should return a boolean. "return prime" leaves the method and sets the return value to that of the variable prime.
Thirdly 'int num' is an object in the 'isPrime' class? What is it being used for? Where does it get it's value from?No, "int num" is a parameter in the isPrime method. by calling isPrime(3) you are basically asking the method "is the number 3 a prime number?" and the method "answers" (returns) true (if it's implemented correctly).
You only define a single class in your code and that's PrimeTest.
Finally and probably most importantly, by calling the the class "IsPrime(i)" in the main, what does the "i" parameter depict? I was thinking "i" is simply a counter used for the 'for' loop?i is the counter of the loop, that's correct. Calling the method isPrime with the parameter i is basically asking "is the number stored in the variable i a prime number?". If that method returns true (i.e. the value in i is a prime number), then the next line will print it.
Again: isPrime (note the lower-case i, Java is case sensitive and so should you be, when writing about Java) is a method and not a class.
You can call methods.
You can instantiate classes to get objects.
You can't call a class, but you can call a method on an object.

Similar Messages

  • Need motion menu with audio song "loop" clarification

    Hi guys, I have a feeling my answer will be "that's the way it works" but I thought I'd double check anyway.
    I have a menu with a motion video as the background. It is 30 seconds in length. I added a song that is 3 minutes in length. "loop forever". The result is that the motion video plays to completion and the song plays but then BOTH song and video start over. Is there any way to have the song keep playing in entirety while the motion video loops ? I have a feeling No.
    If that's the case, I'm forced into choosing a video that is the same length as the song; true?
    thanks in advance!

    Just set the length of the motion menu to the length of the audio.  The video should freeze on the last frame for the extra duration. But accor4ding to problems reported here, this often does not work correctly.
    Best results use a video and audio that are the same length.

  • Need Clarification on Looping in Message Mapping.

    Hi All,
      I'm trying to implement the Dynamic emailing as explained in the Michals blog.
    /people/michal.krawczyk2/blog/2005/03/07/mail-adapter-xi--how-to-implement-dynamic-mail-address
    I have this partially working for the scenario I have.
    XI will be receiving a ORDRSP IDoc from an external system and XI needs to do the following.
    1) Check the value of <b> E1EDP01-ABGRU </b> equals to Z2. If any of the E1EDP01-ABGRU has a value of Z2, it should do the following
             a) Get the email address from the E1EDKA1-ILNNR and map it to the TO field as shown in the blog.
              b) Get the values of BELNR-E1EDK01, MENEE, VPREI, POSEX, PEINH, ABGRT from the E1EDP01 segment and concatenate them all and map it to the Content tag as explained in Michals blog.
      I have this process partially working. The XI interface is only mapping for the first occurrence of E1EDP01 and not the subsequent occurrences of E1EDP01 which matches the criteria ( E1EDP01-ABGRU = Z2)
    Any help in getting fixing this problem??
    Thanks

    Make sure to define multiple target messages in your message and interface mappings, for the mail package message definition (occurrence = 0...unbounded).
    Also, in the logic of your message mapping, you need to create a new mail package message only if  E1EDP01-ABGRU = 'Z2'. Use it like this:
    ABGRU   ---   EqualS   ---   createIf   ---   Mail
    Constant[Z2]
    Regards,
    Henrique.

  • How to refresh/initialize sy-tabix in a loop?????

    Dear all,
    Please do let me know how to refresh/initialize 'sy-tabix' for every new document in a loop statement.
    Thanx in advance.
    Alok.

    Never try to refresh or initialize system variable. It shall always lead to errors in the programs. For this I have an alternative way below.
    Please declare a variable for e.g
    data: <b>l_count</b> type sy-tabix.
    Inside loop you can write the code like this:
    say for eg. you need to refresh l_count for every new material.
    Loop at itab.
    on change of itab-material.
    clear : l_count.
    endon.
    l_count = l_count + 1.
    endloop.
    Hope this clarifies your issue.
    Lakshminarayanan

  • Endless "You must restart your computer" loop caused by wireless?

    System Version: Mac OS X 10.4.5 (8H14)
    Kernel Version: Darwin 8.5.0
    Machine Name: PowerBook G4 15"
    Machine Model: PowerBook5,6
    CPU Type: PowerPC G4 (1.2)
    Number Of CPUs: 1
    CPU Speed: 1.5 GHz
    L2 Cache (per CPU): 512 KB
    Memory: 1.5 GB
    Bus Speed: 167 MHz
    Boot ROM Version: 4.9.1f1
    Network
    Type: AirPort
    Hardware: AirPort
    BSD Device Name: en1
    IPv4:
    Configuration Method: DHCP
    IPv6:
    Configuration Method: Automatic
    AppleTalk:
    Configuration Method: Node
    Proxies:
    Proxy Configuration Method: Manual
    ExcludeSimpleHostnames: 0
    FTP Passive Mode: Yes
    Auto Discovery Enabled: No
    Ethernet:
    Media Options:
    Media Subtype: autoselect
    Synopsis
    Problem: Endless Black Box "You Must Restart You Computer..." loop
    Cause: Printing certain documents (so far one specific pdf file and a text file) through the wireless network at school initiates the problem and then all wireless networks perpetuate the problem thereafter
    Steps Taken: Unplugged wireless network - this allows me to log in
    -Warning box about fatal crash appears but "Send Report" does not produce any data
    -Restarting wireless after login causes no problems
    -Waking computer from sleep with wireless enabled causes black box to reappear
    -Permissions repair did not resolve anything
    -A complete reinstall solved everything until the other day when printing initiated the problem again, after having successfully printed numerous documents wirelessly over the past month
    Other strange things my computer does:
    -Makes very quite chirping sound with every key stroke (except arrows)
    -Usually sits at the grey startup screen with the spinning wheel for a long time and then speeds through login process
    -Only restarts successfully every second time after a hard-restart (the first time it just sits there spinning endlessly)
    More Details
    Problem: Black box appears notifying me "You need to restart your computer" (Kernel panic I believe?) I restart my computer once, and it sits forever at the grey screen with the little wheel spinning. I hard-restart my computer a second time and it logs me in and then the black box reappears... and then the whole process starts over again..
    Circumstances: I had this exact same problem occur about a month ago and it happened again under the exact same circumstances. I recently installed a Korean wireless router, some other foreigner had left behind, in my school here in Korea. The first time it happened I was trying to print PDF document wirelessly from my classroom and the black box appeared. Then the whole endless loop began...
    That night I tried to fix the problem at home. I was able to log into safe mode but the endless loop persisted when I tried a normal log in normally again. I finally did a reinstall from my external drive using the most up to date image I had created with Carbon Copy Cloner.
    The following day I went to school and couldn't resist trying to reprint the suspect document. My freshly installed computer crashed and I was ****** at myself for experimenting so early in the day. Then I tried unplugging the wireless router and restarting and it worked! Then I plugged the router back in and everything was running smoothly again.
    Now I have a new problem. If my computer wakes from her sleep with the wireless enabled I get the black box both at school and at home. I'd really like to avoid doing another reinstall... please help!
    Thanks in advance!
    PowerBook G$   Mac OS X (10.4.5)  

    Hey Rich,
    Think my computer healed herself while I was away this weekend
    What I am wondering is if
    a Safe Boot will always get you logged in when the
    other problems are occurring.
    This question prompted me to try starting up in safe mode. I wanted to make sure the problem still persisted so I:
    1. Plugged in ethernet cable
    2. Turned on Airport
    3. Ensured WAN was functioning
    4. Shut Down my computer with just like I used to, with all network connections enabled
    5. Power ON -> Flawless start up, no black box!
    6. Put computer to sleep -> Woke up -> No black box!
    Weird eh?
    So the only way I can answer your question is based on previous experience. Logging in using safe mode did work the three or four times I used it the first time this problem occurred.
    I did nothing to my computer since this error, no updates, no permissions repairs and no sudo daily, weekly, monthly house keeping. When classes were finished Friday night, I came home, put my computer to sleep with Airport off and ethernet unplugged and the following morning I shut her down, hid her in my sock drawer, and left for the weekend!
    My only explanation is that somehow reconnecting to the wireless network at school allowed my computer to resolve unresolved issue it was having with that network, the same network that instigated the problem. That's my best guess.
    Thanks for taking the time to try and help me out with this issue. The clarification you sought definitely helped us get a more refined picture of the problem. I'm sure this issue will rear its ugly head again in the near future... that is, unless you or anyone else have some ideas about what I could do to prevent this from happening again.
    -Greg
    FU,
    Here's the info you wanted:
    -Only restarts successfully every second time after a hard-restart (the first time it just sits there spinning endlessly)
    This might indicate a dying backup battery (the one that keeps your PRAM healthy)
    My PowerBook isn't even a year old yet, could it be that my battery has died this quickly? Hmmm, another thing I have experienced is that my Mac wont wake from sleeping if I have let the power get so low that she has been forced to sleep.
    1. "10 minutes of battery power remaining" box appears
    2. Battery depletes and computer enters sleep mode by default
    3. I go home and plug computer into power adaptor
    4. Computer fails to wake up no matter how long I wait -->power adaptor light does indicate the battery is charging
    5. I am forced to unplug my computer, remove the battery and hold down the power switch.
    6. Power on -> Date and time settings have changed and need to be set again
    Does this sound like the symptom of a low backup battery?
    make sure that "Set time & date automatically" in the Date & Time System >Preferences is unchecked.
    I've never tried this so I'll give it a shot and see if performance improves.
    now it seems almost obvious: 99% looks like a network fault and nothing >to do with your Tiger installation...
    Perhaps, I'm no networking specialist, but I have flawless network performance until printing some random document at school over wireless triggers the whole series of events I mentioned above. My home router has never triggered this problem... although I have never tried to print wirelessly at home because I have no printer.
    1) how big is your network? (how many wireless and how many wired Macs >access your Router)
    At Home: Very small, 1 PowerBook 64 and one iBook G3
    At School: Small: Two Windows machines and my PowerBook G4. Wireless box is plugged into the existing router that was there. I have windows printer sharing checked in the "sharing" section of "system prefs"
    2) make/model of your router
    D-Link DI-624 (Home)
    Some crazy old dilapidated korean box (at school)
    3) how do you configure your router (via the browser (Safari) or via a >utility/application provided by the vendor)?
    I believe I configure it manually... I access the router via web browser and configure my settings
    4) make sure DHCP is set to Off/Disabled and set your IPs for both your >Macs and the Router manually
    Check, Check
    5) If you're familiar with network settings like hosts file, post back your >configuration / make sure your IP addresses are assigned correctly
    Not familiar
    btw your PowerBook has an AirPort Extreme card or a 3rd party Wireless card?
    AirPort Extreme card
    Thanks for trying to help FU, hope this information helps you.
    -Greg
    PowerBook G$   Mac OS X (10.4.5)  

  • Switching loop question

    Hello everyone!
    I need some clarification of the switching loops. I apologise if my question is too simple, but i really cannot find answer in books, internet. Thanks in advance!
    Please look at the attached topology. This is my test lab for switching loops learning. For simplification purpose IPs, MACs and interface's names were shortened (FF=FF:FF:FF:FF:FF:FF).
    Initial conditions:
    SW-1:
    Cisco Catalyst 3750-V2, 12.2(50)SE5 IPServices, with default, factory config.
    For an unmanaged switch simulation purpose, interfaces 1/1, 1/2, 1/3, 1/4 were configured with switchport host macros and spanning-tree bpdufilter enable command (additional to default factory config).
    Interfaces 1/2 and 1/3 were interconnected with straight through patch cord specifically for creating a switching loop. Just booted up, not learned any MAC-address.
    SW-2:
    Cisco Catalyst 3750-V2, 12.2(50)SE5 IPServices, with default, factory config.
    Just booted up, not learned any MAC-address.
    Both PCs:
    Have a clear ARP-cache.
    Test:
    PC-1 sent ICMP-echo to PC-2. SW-1 received an ARP-request from MAC A (MAC-address of PC-1's NIC) to MAC FF (L2 broadcast as mentioned before) on its 1/1. Because of the initial conditions there is broadcast storm now. MAC A is flapping between 1/2 and 1/3. Next, PC-2 received an ARP-request from MAC A and sent ARP-reply. That ARP-reply arrived at SW-1 and started unicast storm additional to broadcast storm.
    This is clear for me.
    Question:
    What i don't understand is why the SW-1 sends ARP-reply from PC-2 back to the SW-2 (interface 2/1)?
    P.S. apologise for my english. Thanks again!

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    If there's only one or two non-STP switches, in a full mesh, you'll be okay.  Once you have at least three non-STP switches, in a full mesh, you have a loop between them.

  • Question about using for-loop to generate array from DAQmx. Thanks!

    I have a laser system with a frequency of 1kHz, I am using this 1kHz signal to trigger the DAQmx and get the data from a photodetector, e.g. I will get 1000 data points during 1 second from DAQmx, but I need to separate this 1000 data points into the even and odd list, which is two list of 500 data points, e.g.. The 1st, 3rd, ... 99th data is one array, the 2nd, 4th,... 10th data is another array, then I will do further calculations based on these two arrays.
    To seperate the even and odd data, the only way I can find is put these 1000 points into an array and then seperate them afterwards.
    Can I do things like this pic?
    I don't know the speed of the for loop, because the 1kHz trigger is always there, once it is triggered, the DAQmx read will give a data point, if the speed of the for-loop( the time from the end of a loop to the beginning of the next loop) is slower than the 1kHz trigger, then the for-loop will miss data point, then the ordering of the 1000 points in 1 second will be changed.
    Or I need to put everything, e.g. AI Voltage, Trigger, sample clock, into the for-loop and then return a Y? Thanks! 

    Clarification:
    The VI you have posted will work as following:
    1) The task will read 2 analog inputs (ai0, ai3).
    2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
    3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
    4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
    5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
    6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel"  number of samples.
    You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
    I hope it is clear now.
    regards,
    stefo

  • Calculate Days between same date field in multiple records, looping for each record

    Be patient as I am a newbie to Sql Server (using 2008 R2) and SSIS.  I have looked at multiple solutions in this and many other forums before submitting the question.
    I am looking at records to identify the number of days between two dates.  We review drug information.  A member uses drug A (Code identifies this called GPI) and has refills throughout time.  The goal is to calculate the days between Refill
    1 and refill 2, then refill 2 to refill 3, etc.  When that member record set is complete, we move to the next member record set.
    The basic data would be as follows.  Each record shown below would be a separate record in a single table :
    Member
    Drug Code
          DateService
             Days Between
    1
    A
    3/1/2012
    0
    1
    A
    3/27/2012
    27
    1
    A
    4/21/2012
    26
    1
    A
    6/15/2012
    56
    1
    F
    2/25/2012
    0
    1
    F
    3/20/2012
    25
    1
    F
    4/17/2012
    29
    1
    F
    8/1/2012
    107
    5
    B
    2/15/2012
    0
    5
    B
    3/10/2012
    25
    5
    B
    4/10/2012
    32
    5
    B
    6/28/2012
    80
    5
    B
    7/10/2012
    13
    5
    B
    8/20/2012
    42
    The days between is the value I am looking to calculate.  The First record for the grouping of Member and Drug Code will be zero ( 0 ) as there is no preceding date to calculate against.  The process would then loop through the records at the grouping
    (Member and Drug Code) until those records are calculated.  It would then move on to the next group of Member/Drug records.
    Any assistance would be greatly appreciated.  Any clarification I can provide, I would be more than happpy too.  Thank you in advance!

    TSQL- Finding the difference in days of multiple records in SQL ServerWITH OrderDates AS (
    SELECT
    ROW_NUMBER() OVER (ORDER BY OrderDate DESC) AS RowNumber,
    OrderDate
    FROM OrdersTable
    WHERE SKU = 'AA0000'
    SELECT
    AVG(DATEDIFF(DD, O2.OrderDate, O1.OrderDate)) AS AverageFrequency
    FROM OrderDates O1
    LEFT JOIN OrderDates O2
    ON O2.RowNumber = O1.RowNumber + 1
    Fabio Bilicki

  • IMAQ user palette not updating outside video loop

    I'm trying to implement a program with a separate video loop and am having issues with changing the user palette. I'm not sure right now, but I think it might be because I'm changing it in another non-video dedicated loop. Does LabVIEW have a problem with copying an image from an IMAQ buffer and trying to simultaneously change the user palette for an image control? My initial guess would be no, but then I don't think I'd be having this problem. Here's a little example of what I mean. Off-line, you can change the image palette to any of the default palettes, but trying to change to the custom user palettes (which do work under any other circumstances) while running video and it does nothing.
    Any ideas as to why the property nodes aren't working?
    Attachments:
    PaletteTest.llb ‏178 KB

    dear lanmat,
        I may need some clarification on what your application is, and what is not behaving as expected.  I'm assuming that by "separate video loop" you mean that there's a secondary loop in your program acquiring video.  What kind of video is it acquiring?  I also am assuming that your user palette is not being used to effect the video, but another image display entirely, is that correct?  I can see some of these in your program, but I want to be sure.
        LabVIEW should have no trouble copying from a buffer while changing the image control.  Are they for different images or the same image?  Also, you say that "off-line" you can change the image palette to any of the defaults -- what do you mean by off-line?  Any more specifics you can give me as to your application and what exactly is going wrong would be helpful, thank you.
    -Allison S.
    Applications Engineering
    -Allison S.
    Calibration Services
    Product Support Engineer

  • How do I create an xy chart using two independent while loops?

    Hi everyone,
    I am trying to develop a data acquisition program. In this program, I have two independent while loops that each output a number of type double each iteration of the loop. I am able to successfully create two independent waveform charts (data vs. time) for each of the loops when it is placed inside. However, I now want to create an xy chart of the live data (the output of one loop is x and the output of the other is y).
    I am having trouble doing this because of the separate nature of the loops...when I try to pull data outside of the loops it (naturally) doesn't refresh with each loop iteration causing the xy chart to not work in the way I intend. Is there an easy way to fix this? If more clarification is needed, please let me know!
    David
    Solved!
    Go to Solution.

    Yes, more clarification is needed. Please attach your code to clarify.
    I'll take a wag at it, though. It sounds like you are trying to pair X and Y data which happen during a single time chunk, then repeat, is this right? (If not, don't bother to read on.) If so, why not just use a single loop. If your VI is getting too big/complicated for comfort, just put the data-generating stuff into subVIs which run to generate a single data point, then stop, put them into a while loop and send the putputs to a graph or chart inside the loop. That way you won't extend your data trace until you get one and only one point from each subVI and things will stay synchronized.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • Looping and Grouping at segment level

    Hi Friends,
    Scenario: JDBC to IDOC
    PRODID     ORDERNUM                          TRUCKNO     DISTANCE               BANS         ABANS     BBANS         CRMSID
    100001     230001          4578     540          10     00     10     IC1201
    100001     230001          4578     500          20     00     30     IC1201
    100001     230001          4578     520          20     00     40     IC1201
    100001     230001          4578     510          30     00     50     IC1201
    100001     230001          4578     570          40     00     60     IC1201
    100001     230001          4578     560          50     00     10     IC1201     
    100001     230001          4578     440          10     00     10     IC1203
    100001     230001          4578     540          60     00     80     IC1203
    100001     230001          4578     640          70     00     10     IC1203
    100001     230001          4578     940          40     00     10     IC1208
    100001     230001          4578     640          80     00     40     IC1208
    100001     230001          4578     840          00     00     10     IC1208
    100001     230001          4578     740          10     00     40     IC1205
    100001     230001          4578     540          70     00     10     IC1205
    Requirement:
    I want to create an IDOC basing upon CRMSID. So, am able to create it using this below logic.
    CRMSID --> RemoveContext --> SORT --> SplitByValue(ValueChange) --> CollapseContext --> IDOC
    So, there are 4 IDOC's to be generated. But, each IDoc will have multiple segments to be generated since the other fields (DISTANCE     BANS     ABANS     BBANS) data is changing.
    Can some one provide exact grouping and looping for this as got stuck with this.
    Thanks.
    Swarna.

    Hi Swarna,
    For individual fields   use the below logic... for example field BANS,
    formatByExample-splitByEachValue--TargetBANS
    FormatByExample:
    input1:resultOfSortByKey
    input2:CRMSIDremovecontext-sort--splitByValueChange
    SortByKey:
    input1:CRMSID--removecontext
    input2:SourceBANS--remove context
    Please try this logic and let me know on further clarification.
    Thanks
    Priyanka

  • Clarification on Update Rule Enhancement

    Folks,
    Would appreciate clarification on the following scenario
    I have an infocube being updated with data from R/3
    There are fields in that infocube which needs to be updated with data from a custom table which is maintained in BW
    To be specific.... the cube have entries with cost center and cost element
    Each combination of cost center and cost element is assigned a specific value (a characteristic)
    This specific value is not in R/3, has to be seperately maintained in BW
    What I require is while the data is being updated in the cube, the custom table with the combination of cost center and cost element should be read for the specific value which has to be then written in the cube
    Would appreciate inputs on how I could accomplish this... can this be done with a regular enhancement of update rule in the routine
    Thanks for your time
    Regards

    hi,
    e.g your custom table is ztable1 with 3 fields costctr, costelem, and charval(specific value), and the characteristic to be assigned is zchar, try start routine in update rules and following code.
    hope this helps.
    *put in global area.
    tables : ztable1.
    data : l_ztable1 like ztable1 occurs 0 with header line.
    select * from ztable1
    into table l_ztable1.
    local area
    loop at data_package.
       read table l_ztable1 with key costctr = data_package-costcenter costelem = data_package-costelem.
    if sy-subrc = 0.
       data_package-zchar = l_ztable1-charval.
       modify data_package.
    endif.
    endloop.

  • PCH database program loop?

    Hi there,
    Have anybody seen before a GET OBJEC looping indefinetelly? We have a PCH program to handle some training management.
    The EV PATH is L-D-E-E.
    We always start the execution with an L object. If the L object is not on one of the highest levels, the program works and ends fine, but from a certain level up, the GET OBJEC start looping and the program never stops.
    Once the last E object of the catalog has been reached, for some reason, the next GET OBJEC execution starts again from the original L object.
    Any idea why?
    The obviuos work around is to flag the first L object and exit the program when reached for the second time, but I was looking for an ellegant solution
    Other question (hope stupid one): How can you exit a GET OBJECT loop and continue processing at the END-OF-SELECTION command?
    Thanks in advance
    Message was edited by:
            Miguel Guardo

    I think slowly I understand your point.
    You get the same ID more than once, correct?
    If these objects are more than once in the evaluation period in the structure, this is correct.
    E.g. the department Sales migh occur twice in an Org.structure if it  was reorganized during the year and you start from the BOard with evaluation period complete year. It will appear under Orgunit Europe and Global with different dates (only as an example)
    That's also something you can check using RHSTRU00.
    Normally this vanishes if you use a key date as evaluation pariod.
    Maybe this clarifies it?
    If you only want each object ID only once, collect them at GET OBJEC. and do all the rest of the processing in END-OF-SELECTION. after throwing away the duplicates.
    Regards,
    Michael

  • Check Scan for NI435X and elapsed time doesn't run in loop

    Dear all Labview Experts
    i have 2 questions
    (1) i written program with Check Scan for NI435X (input to no of scan to NI 435X read ) and one with only NI435X read( to read in voltage) with constant input to no of  scan,
    the data i obtained is attached in 2 doucments; With Check Scan and without check scan ( the left column is temperature read in ( a formula is used to convert volt to temperature, right column is time)
    strangely the program with check scan shows values in negative ==> Voltage read in is 0, strange, why is this so??? and why is there a diff?? Hope u understand my question
    (2) For elapsed time, i want to find the total elapsed time for the whole program as well as individual cases,  there is no "running"  elapsed time or individual running time,
    what happen is that when the each case end, the time will jump (e.g. from 0 at start, it will change to 5.35 at end of case) , is there any where to make the time run, i need it because some case required
    c
    ondition such as case will move to next after 5 seconds, but if above case happen, the vi will only stop if i put >= 5 rather than just place = 5
    hope u understand,
    does it help if i placed the condition as another loop , will it mean the same things
    Attach are vi and some doucments, however as my vi contains PID tool kit as will as ni435x ni DC power which cannot be opened if you do
    not have these kits.......however mayb u can help to look at the portion of timing as this is the main problem i faced now.........
    Hope it is not too confusing for you to understand me...........
    i can only attach max 3, the next post i will attach 2 vis...........
    Attachments:
    Picture of check scan and without.rtf ‏15 KB
    With Check Scan.txt ‏4 KB
    Without Check Scan.txt ‏1 KB

    Thks Brian
    Attached are 3 VIs
    1.the first vi is the one with the check scan
    2. the next two vi the only diff is the placement of the where i put the elapsed time and time of each case.........(without check scan)--the first
    one is within the big loop, the other outside  big loop -- the purpose i did this is because when i run the vi with the timing in the big loop, the timing does not run continuously but "skip". for e.g. Denature time: from 0 . it jump to 5.15s without showing the running.............
    i will attached another 2 vi s in my next attachment
    Hope this clarifies a bit
    your help is really appreciated
    thks
    Attachments:
    PCR Control_State Machine_4 channel_Timing within Loop.vi ‏438 KB
    PCR Control_State Machine_4 channel_with_check scan.vi ‏443 KB
    PCR Control_State Machine_4 channel_Timing outside of loop.vi ‏442 KB

  • Clarifications please

    Hi
    i require some clarifications
    1)
    The application is in servlet and jsp
    There is arequirement to report errors to system administrator
    by writing errors in a log file
    to do that in the catch block i am writing to a text file
    my doubt is if many people are accessing concurrently
    and get errors then writing to the log file concurrently may
    corrupt the log file so synchronization has to be used for the method
    writing to the log file
    is that correct on any better solution to report errors to administrator
    2)
    consider
    String str = "hey" + "hello";
    should stringbuffer be used in this
    case or does the compilier compiles with stringbuffer usage
    and we need not use stringbuffer
    3)
    when we use servlet as a controller we use getRequestDispatcher().forward()
    to transfer control to different pages
    here the problem is that the url at the top of browser
    will not have the actual url of the
    page dispalyed and we have to use request.getRequestURI()
    to get the actual url of the page displayed
    is that not a disadvantage
    regards
    Javid

    1) JavaIO is synchronized all by itself. You don't have to worry about this. (Java 1.4 changes this somewhat.)However, you should carefully consider what and how much you are logging to this text file. JavaIO is relatively slow (due to synchronization) meaning the more you log, the slower your application. In addition, have you considered things like rolling files? How large will you let your log file get? If it runs for a year (or 6 months or whatever) you could end up with a VERY large log file. This means slower access and less disk space. Consider looking at an existing log pacakge (such as log4j by the jakarta group).
    2) In general the "+" operator is slower than using a StringBuffer. For just one concatentation, i.e. "this" + "that", it doesn't matter which you use. Any more than one and you should probably use StringBuffer. For repetitive concatenation, i.e. in a for loop, you should definately use StringBuffer.
    3) I will refer you to another topic and an answer I posted there for this point: http://forum.java.sun.com/thread.jsp?thread=226695&forum=33&message=803659. In short, no this is not a disadvantage and yes this is what it's supposed to do.
    Hope this helps.

Maybe you are looking for

  • Dvd Player Won't Play Copies Of Or Self-Made DVDS

    Macbook Pro 2.5Ghz with 10.5.5, and DVD player 5.0.1. Dvd player will play commercial dvds, but not any that I or anyone else has made. The same ones will play in my Mac Pro with the same settings. I tried many, but the common denominator is that it

  • I have Adobe Reader X. I can open a pdf on my Windows PC but the contents will not display.

    I have Adobe Reader X.  I can open a pdf on my Windows PC but the contents of the file will not display.

  • Enhancing FI_GL_1

    Hi friends I have a requiement to enhance the FI_GL_1 extractor. Now the extractor is bringing in only the local currencies. Now i neeed to populat the Group currencies as well . I looked into GLT0 table where these currencies are maitained and the e

  • Weblogic 10 jsp compliation thread block problem

    hi i am using weblogic 10 and jdk1.5. My application is deployed in ear format, with 2 wars, and 20 ejbs. The ear works ok with weblogic 8.1. In the application , one war passes the request to another war, that's the workflow.... Now when the request

  • VLOOKUP finds only one match

    Hi, I can successfully find a match using VLOOKUP: =IFERROR(VLOOKUP(KLARTEXT(F5);'table1'::sheet1::A:B;2;0);"") (I don`t know the English term for KLARTEXT = it turns a formulabased value into a string as 'table1'::sheet1::A contains strings) But the