Screen programming - Return statement

Hi,
In the middle of a user exit, I have called a screen in which two buttons are there "SAVE and Exit".
If save button is pressed, data should update the value is table and  continue with the user exit.
If exit button is pressed, nothing should happen and continue with the user exit.
My problem is, i have called this screen in the middle of the user exit. Exit button works fine, it continues with the next line of the code in the user exit.
But for save button, after updation, it returns to the first line of the user exit. But it should continue with the next line in the user exit.
Which statement will bring the control to next line of the user exit after updation.
Thanks in advance,
Ezhil.

Hi,
Screen is a custom screen.
Below is the code for SAVE and exit button.
*&      Module  USER_COMMAND_0100  INPUT
      text
MODULE USER_COMMAND_0100 INPUT.
IF sy-ucomm = 'SAVE'.
    PERFORM confirm_data.
     LEAVE PROGRAM.
  ELSEIF sy-ucomm = 'EXIT'.
    LEAVE PROGRAM.
  ENDIF.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  CONFIRM_DATA
      text
-->  p1        text
<--  p2        text
FORM confirm_data.
  TYPES : BEGIN OF ty_data,
            sfakn TYPE vbrk-sfakn,
           END OF ty_data.
  DATA :  wa_vbrk TYPE vbrk,
          it_upd TYPE STANDARD TABLE OF vbrk WITH HEADER LINE,
          it_vbrk TYPE STANDARD TABLE OF vbrk WITH HEADER LINE,
          ok_code TYPE sy-ucomm,
          it_data TYPE STANDARD TABLE OF ty_data,
          wa_data TYPE ty_data.
  IF sy-ucomm = 'SAVE'.
    CLEAR : wa_data.
    REFRESH : it_data.
    IMPORT it_data FROM MEMORY ID 'VF11'.
    READ TABLE it_data INTO wa_data INDEX 1.
    SELECT SINGLE * INTO wa_vbrk FROM vbrk WHERE vbeln = wa_data-sfakn.
    wa_vbrk-zrbdc = ztsd_inv_cancel-zrbdc.
    APPEND wa_vbrk TO it_upd.
    CALL FUNCTION 'ENQUEUE_E_TABLE'
      EXPORTING
        mode_rstable   = 'E'
        tabname        = 'VBRK'
        varkey         = 'VBELN'
      EXCEPTIONS
        foreign_lock   = 1
        system_failure = 2
        OTHERS         = 3.
    IF sy-subrc EQ 0.
      CALL FUNCTION 'DB_UPDATE_TABLE'
        EXPORTING
          tablename      = 'VBRK'
        TABLES
          inttab         = it_upd
        EXCEPTIONS
          db_error       = 1
          not_found      = 2
          wrong_param    = 3
          internal_error = 4
          OTHERS         = 5.
      IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'DEQUEUE_E_TABLE'
        EXPORTING
          mode_rstable = 'E'
          tabname      = 'VBRK'
          varkey       = 'VBELN'.
    ENDIF.
  ENDIF.
ENDFORM.                    "confirm_data}

Similar Messages

  • RETURN STATEMENT IN A PROC PROGRAM

    HI,
    I have written a small program in proc which is supposed to pick
    up records from a table matching a certain criteria.The records
    will be displayed in the screen one after the other. For every
    record displayed there is an option to perform certain
    operations such as
    (1) authorise the record which will update certain values to
    certain fields in the table
    (2) skip the record which would display the next record from the
    cursor
    (3) Reject the record which will delete it from the table and
    then fetch the next record from the cursor
    (4) quit - which should return control out of the function to
    the place where the function was called. This has been done by
    way of a return statement.
    There are only two ways to come out of the function
    (1) one is when the quit option is chosen as explained above
    (2) when the control goes past the last record in the cursor
    (when 1403 is raised)
    However, when the above two conditions are met (for eg I skip
    all the records and the reach the end of the cursor) or when i
    explicity choose the quit option, the control does not come out
    of the function, but keeps calling the function repeatedly .
    The only time when it comes out is when the cursor does not
    fetch any records.
    The program works perfectly fine in a solaris machine (oracle
    version 8.1.7). The problem is faced in a DEC ALPHA machine
    with an oracle 8.0.6 version.
    Has this anything to do with the machine set up, compilation
    script etc...or pls suggest what could be the other
    possibilities.
    Please note that the return statements used in the sub functions
    are working properly.
    Regards...Rajee

    If nothing strange hapens in the try code, the return
    statement will be achieved. In this case, what will
    hapen ? The code in the finally block will be executed
    ??Yes. Hence the word "finally".

  • How do I view data from OLAP DML program or statement?

    Hi
    I'm struggling to find any information on this topic anywhere on the net:
    How to view data produced by an Oracle OLAP DML program or statement.
    Background :
    I am using the latest AWM to create and maintain dimensions, cubes and measures. However, I've noticed that AWM, Discoverer OLAP, BI Beans, Excel Plug-In et al only provide a fixed set of formula and expressions.
    For example, I wanted to created a Standard Deviation (STDEV) on measure. After much searching I learnt that I could do this by creating a custom measure in AWM by importing a measure defined in an XML dcoument as it's not provided by AWM. The output in Discoverer OLAP on the surface seems to give the correct results, however when drilling from high level to lower level of time time dimension hierarchy Discoverer includes the parent value in the calculation and renders the values incorrect.
    My alternative is to use OLAP DML, as it provides a richer range of formuale and calculations possibilities and I was hoping to use this functionality to do create the measures. I have the distinct impression, however, that OLAP Worksheet is the only interface out there to do this.
    It seems very primitive and limited with regards to data output, almost like SQL*Plus in many ways.
    The burning questions I have are :
    1) Do I need to write DML programs to perform these custom measure calculations and add them to cubes or do I import the custom measures via AWM and XML?
    2) If the answer to question 1 is DML programming, is there a way of viewing the OLAP data output through a GUI interface without embedding the statements in SQL.
    3) Has anyone experienced or noticed the same problem with Discoverer OLAP, AWM Viewer that I mentioned above? i,e, statistical functions performed on whole dimension hierarchy rather than lower levels.
    I'm hoping someone out there knows what I am trying to do or get at. Keith, any ideas or suggestions?
    Thanks
    Kind Regards
    Greg

    Hi Greg,
    There are two ways to achieve what you want. Both require the use of custom calculations which cannot be created via the calculation wizard within AWM. To do this the easiest way is step outside of AWM and use the Excel Calculation utility that is on the OLAP OTN home page:
    Creating OLAP Calculations using Excel
    http://download.oracle.com/otn/java/olap/SpreadsheetCalcs_10203.zip
    Readme
    http://www.oracle.com/technology/products/bi/olap/OLAP_SpreadsheetCalcs.html
    (Oracle OLAP DML Reference contains a list of all the OLAP functions that can be used to create a custom calculation. http://www.oracle.com/technology/products/bi/olap/OLAP_DML_10.2.zip)
    The Excel tool lets you assign your own formula to a measure and then uploads that measure definition into your AW. It is possible to import a custom calculation template into AWM using the menu option on the Calculated Measure node of each cube, but it is safer to use the Excel Worksheet as this directly uses the public XML API and is always best to use a public API rather than hacking XML templates.
    There are two types of custom calculation:
    1) Formula: using a formula you can directly call any of the OLAP functions. For example to create a measure that returns the standard deviation for a measure then you would enter the following as the formula for your calculated measure:
    stddev(sales_revenue, time)
    The easiest way to test if the measure is working as expected is to use the data viewer within AWM.
    2) Programs - if the function you need is not provided or you want to do special processing to return a result you can create an OLAP DML program which can return a result. To do this use OLAP Worksheet to define the program and add a datatype to the DEFINE statement, such as :
    DEFINE PRG_SD_SALES PROGRAM DECIMAL
    In the program return the value you have calculated within your program. Within the program you can do just about anything but be aware that your program is going to fire for every cell within your virtual cube so it must be efficient and fast to execute. For a measure then you would enter the following as the formula for your calculated measure:
    prg_sd_sales(time, products, geographies, channels).
    The actual program code would look something like this:
    DEFINE PRG_SD_REVENUE PROGRAM DECIMAL
    PROGRAM
    argument T_TIME TIME
    argument T_PRODUCT PRODUCTS
    argument T_GEOGRAPHY GEOGRAPHIES
    argument T_CHANNEL CHANNELS
    variable D_RETURN decimal
    TEMPSTAT TIME, PRODUCTS, GEOGRAPHIES, CHANNELS
    do
    limit PRODUCTS to T_PRODUCT
    limit CHANNELS to T_CHANNEL
    limit GEOGRAPHIES to T_GEOGRAPHY
    limit TIME to T_TIME
    limit TIME add descendants using TIME_PARENTREL
    limit TIME keep TIME_LEVELREL 'CAL_MONTH'
    D_RETURN = stddev(SALES_REVENUE)
    doend
    return D_RETURN
    END
    This code computes a standard deviation the all months within the specified time range, at year level for all 12 months, at quarter level for the three months within the quarter ans returns NA at the month level.
    As the code executes within a implicit loop you can only change the status fo dimensions that for part of that implicit by using the TEMPSTAT command. To test the program at the command line use the OLAP Worksheet and the SHOW command to just return one cell of data, DO NOT SIMPLY USE THE RPR COMMAND because you will have to wait for the whole cube to be returned. If you want to use the RPR command make sure you limit your base dimensions first! You can use PRGTRACE to debug your program code it is not working as expected. Again, the easiest way to test if the measure is working as expected is to use the data viewer within AWM, although this will not return debug information so send all your debug output to a file to capture any errors and/or trace the execution flow.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • "missing return statement" error code

    well... i feel like such a n00b... I can't seem to figure out what the problem is with my code, if someone could help me, that would be great. I get an error saying 'missing return statement'. I know that I have some things in here that I don't need but I will need them as I go on making this program.
    with this code:
    import java.io.*;
    import java.math.*;
    public class Tester
         public static int time = 0;
         public static void main(String[] args) throws IOException
              System.out.println("Welcome to the 2008 Java Games!!!");
              time=1000;
              delay(100);
              //Method Name: delay
              //Method Arguments: used to wait for a given time
              //Goal of Method: Delay for a given time
         public static int delay(int time)
              try {
                   Thread.sleep(time);
              catch(InterruptedException ex) {}
              time++;
    }

    What does the error say? "Missing return statement"? Then I'm going to venture a guess and say that you're missing a return statement. If you don't know what a return statement is, then you have some learning to do:
    http://java.sun.com/docs/books/tutorial/java/javaOO/returnvalue.html
    Read that, then look at your delay() method and how you call it. And notice that you've made delay() of type "int".
    Edit: Or just have someone else give you the answer :P
    Edited by: newark on Feb 27, 2008 3:20 PM

  • Return statement in catch block !

    Hello Java Gurus,
    The code is not compiling when i remove return from the catch block
    i dont really understand the essence of return statement in catch block
    any help is greatly appreciated !
    Thanks in advance !
    import java.io.*;
    public class fileinputstream  {
       public static void main(String arg[]) {
            FileInputStream fin ;
            FileOutputStream fout;
           try  {
                 fin =new     FileInputStream("input_file.txt");
                 int bytes_av = fin.available();
                 System.out.println("bytes available the input file "+bytes_av);
           catch(FileNotFoundException e)
               System.out.println("The input file is not present");
               return;
           catch(IOException e)
               System.out.println("error while giving bytes available the input file");
               return;
           try
                     fout =new FileOutputStream("output_file.txt");
           catch(FileNotFoundException e)
               System.out.println("The output file cannot be created");
               return;
           int data=0;
           try  {
               data =(int)fin.read();
           catch(IOException e) {
               System.out.println("Exception while reading from file");
            while(-1!=data)      {
                       try
                       fout.write(data);
                       catch(IOException e)
                           System.out.println("Error while writing to file");
                       try
                           data =(int)fin.read();
                       catch(IOException e)
                           System.out.println("Exception while reading from file");
            try  {
                   fin.close();
                   fout.close();
            catch(IOException e)  {
               System.out.println("Error while closing files");
    }

    You do understand what "return" means, don't you? It
    exits the method, main() in this case.
    So the return statements in the catch blocks end the
    program. If you remove the return statements, the
    program will continue with the code after the catch
    blocks. It needs the variables "fout" and "fin"
    there, and these must be initialised.
    If there are no return statements in the catch
    blocks, the variables "fin" and "fout" will be not
    initialized when you get to the code that uses them,
    and that's an error. The java compiler is telling you
    that you must always initialise the variables (you
    can set them to "null", for example).Great explanation !!!
    Thanks !

  • Doubt on Return statement

    Hi,
    IN the code below,
    I need to return a Double value. That Double value is declared and calculated with in IF condition.
    But, If i keep return statement with in if condition, i get "MIssing return statement error". IF i keep Return statement outside if(), I get "symbol c not found error".
    How do i fix this?
    private Double calculate(Double a, BigDecimal b) {  
            if(!((null == a)&&(null == b))){  
            //do some calculation  
            Double c = Double.valueOf(b.doubleValue());  
            return c; ---> Getting error right here.  (Can't find symbol c error.)  
       }  please help

    gimbal2 wrote:
    900637 wrote:
    Is there any solution for this?Perhaps you need two return statements.This depends whether <tt>a</tt> and <tt>b</tt> can be null because of business rules or programming errors.
    If the latter I'd not care for the NPE or just throw my own NPE from the else path telling which parameter has been null .
    If business rules forcs you to handle null values these rules must provide a solution for that case to be implemented in the else path.
    bye
    TPD

  • Return statement inside a catch block???

    If you put a return statement inside of a catch block, what statements will be executed next? I.e., what happens to the flow of control?

    If you put a return statement inside of a catchblock, what statements will be executed next? I.e.,
    what
    happens to the flow of control?If you write a short testing sample, compile it and
    run it, what do you get as a result ?
    Eek! That actually involves effort! Are you kidding?Kidding ? Me ?
    I'd better waste my time writing programs for lazy OPs !
    ;)

  • Return statement error and java.lang.noclassDefFoundError?

    public class Calculation
         public static void main (String[] args)
              int a[]=new int [12];
              int iNum=0;
              MainPrompt();
         static public int MyInput()
         return MyInput.readInt();
         public static boolean MainPrompt()
              System.out.println("\n This program will show you the times table [1-12] of any number between 1 & 100 inclusive.");
              int a[]=new int [12];
              int iNum = 0;
              do
                   do
                        System.out.print("\n Enter your number [1-100] or 999 to exit: ");
                        iNum = MyInput();
                        while ((iNum>=1)&&(iNum<=100));
                             if (iNum==999)
                                  System.out.println("\n Goodbye \n");
                        while (!(((iNum>=1)&&(iNum<=100))||(iNum==999)));
                             if ((iNum>=1)&&(iNum<=100))
                                  Calculation(a,iNum);
                                  TimesTable(a,iNum);
         public static void Calculation(int a[], int iNum)
              for(int j=0;j<a.length;j++)
              a[j]=iNum*(j+1);
         public static void TimesTable(int a[], int iNum)
              for(int i=0;i<a.length;i++)
              System.out.println((i+1)+"     *"+iNum+"     ="+a);
    In build output it says missing return statement line 42 "}"
    and also when I try to execute the program it gives me the Exception in thread "main" java.lang.NoClassDefFoundError: calculation
    In the folder I have placed the myinput.java and myinput.class file where my calculation.java is, but still no go.
    can anyone here help me out here?
    thanks in advance

    public class Calculation
         public static void main (String[] args)
              int a[]=new int [12];
              int iNum=0;
              MainPrompt();
         static public int MyInput()
         return MyInput.readInt();
         public static void MainPrompt()
              System.out.println("\n This program will show you the times table [1-12] of any number between 1 & 100 inclusive.");
              int a[]=new int [12];
              int iNum = 0;
              do
                   do
                        System.out.print("\n Enter your number [1-100] or 999 to exit: ");
                        iNum = MyInput();
                        while ((iNum>=1)&&(iNum<=100));
                             if (iNum==999)
                                  System.out.println("\n Goodbye \n");
                        while (!(((iNum>=1)&&(iNum<=100))||(iNum==999)));
                             if ((iNum>=1)&&(iNum<=100))
                                  Calculation(a,iNum);
                                  TimesTable(a,iNum);
         public static void Calculation(int a[], int iNum) //This part doesn't execute
              for(int j=0;j<a.length;j++)
              a[j]=iNum*(j+1);
         public static void TimesTable(int a[], int iNum)
              for(int i=0;i<a.length;i++)
              System.out.println((i+1)+"     *"+iNum+"     ="+a);

  • Return statement on a void?

    Theres a part that i dont understand, and if its possible i'd like to be helped a bit with it ^_^.
    This class is part of a program that uses threading to display a consistent "Tick Tock", but the part that i dont get is why is there a return statement on the method that is on bold, isn't void supposed to mean that it doesnt return a value, is the return statement just used to get out of the if loop?, or maybe something else! help is appreciated!
    class TickTock {
    synchronized void tick(boolean running) {
    if(!running) { // stop the clock
    notify(); // notify any waiting threads
    return;
    System.out.print("Tick ");
    notify(); // let tock() run
    try {
    wait(); // wait for tock() to complete
    catch(InterruptedException exc) {
    System.out.println("Thread interrupted.");
    synchronized void tock(boolean running) {
    if(!running) { // stop the clock
    notify(); // notify any waiting threads
    return;
    System.out.println("Tock");
    notify(); // let tick() run
    try {
    wait(); // wait for tick to complete
    catch(InterruptedException exc) {
    System.out.println("Thread interrupted.");
    }Message was edited by:
    Rix87

    A simple return statement means that you are just exiting that function. A function can use the return statement even if it is declared a void. It is just that from a void function you can not return a value.
    In your code the function is doing some condition checking (if statements) and based on that decides whether to exit the function or to continue going forward.
    Additionally, the if-construct is not a loop. If statements provide conditional branching mechanism.
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html
    You probably will never need to break out of an if statement. If you do need it, then perhaps your if condition is suspect.
    http://java.sun.com/developer/TechTips/2000/tt0613.html
    You can use labeled breaks if you need to break out of nested if statements but it is very rare that you will need them and the code can perhaps be written in another way which is much more readable than labeled breaks.

  • Return statement : Not exactly it

    I have a method that returns an Element and thru the method I have 3 for loops where I create and populate the elemet, now that the return statement is not withing the for loops I only get one Element., even though the program has 2 or more elements that it's printed.
    Here's part of the method just to demo what I mean
    public Element show() throws Exception {
    Element activitySummary = null;
      try {
        String act[] = new String [6];
        String so[] = new String [9];
        String rac[] = new String [4];
          for(int b = 0; b < act.length; b++){
            if (act[b] != null) {
              activitySummary = new Element("ActivitySummary");
              Element activityType = new Element("ActivityType");
              activityType.setText(act);
    activitySummary.getContent().add(0, activityType);
    for(int c= 0; c < so.length; c++){
    if(so[c] != null){
    Element socLine = new Element("SOCLine");
    Element soc = new Element("SOC");
    soc.setText(so[c]);
    socLine.addContent(soc);
    activitySummary.addContent(socLine);
    for (int d = 0; d < rac.length; d++) {
    if (rac[d] != null) {
    Element raceRow = new Element("RaceRow");
    Element race = new Element("Race");
    Element maleT = new Element("MaleTotal");
    maleT.setText(" " +MaleTotal[b][c][d]);
    Element femaleT = new Element("FemaleTotal");
    femaleT.setText(" "+ FemaleTotal[b][c][d]);
    Element disabledT = new Element("DisabledTotal");
    disabledT.setText(" "+DisabledTotal[b][c][d]);
    race.setText(rac[d]);
    raceRow.addContent(race).addContent(maleT);
    raceRow.addContent(femaleT).addContent(disabledT);
    socLine.addContent(raceRow);
    XMLOutputter outputter = new XMLOutputter();
    outputter.output(activitySummary, System.out);// printing the activitySummary where I get 3 activitySummary Element
    }catch (NullPointerException ex) {
    System.out.println(ex);
    }catch (Exception e) {
    throw e;
    }finally {
    return activitySummary; // it only returns the last activitySummary Element
    Please advice on how can I position my return statement so it works.

    Nomatter where you put your return statement it always will return only 1 thing.
    If you want your return method to return multiple elements you will have to return an array of Elements or some other Object that contains all the elements

  • Return statement at the end of try or after catch blocks

    Hi
    Can anyone tell me which is the better practice - to put the return statement at the end of try block or after all the catch blocks ie at the end of method.
    Eg
    Method A()
    String str;
    try{
    str= [some code]
    return str
    catch(Exception e)
    System.out.println("Exception");
    } // end of method
    OR
    Method B()
    String str;
    try{
    str= [some code]
    }catch(Exception e)
    System.out.println("Exception");
    return str
    } // end of method

    I always try to work with only one exit point for each method.
    For readability I always put the return statement as close to the end of the method as possible.
    In this particular question,
    I think you should put the return at the end of the method (for readability, since this is what you are
    familiar with), but when I have a try-catch clause, I usually have an unrecoverable error and
    should throw this further down the tree, so it usually becomes
    try{
       return   
    }catch(...){
       // write out some logging information
       rethrow exception or throw another exception
    }I think you should NEVER reflect the occurence of an error in the return-value of the
    method when an unrecoverable exception occurs. Just rethrow this exception or throw another method.
    Other methods look like
       Object result = new...
       return result;As for the specific case of a repetitive if-case:
    This is possible in two versions:
    With one return and a result-object
    Object result = new ...
    if(..)
       result = ...
    else if(..)
       result = ...
    return result;With every time a return
    if(...)
       return ...;
    else if(...)
       return ...;For me the above two possibilities make no difference,
    but I find the second version (which I hated when I began programming)
    to be somewhat more of a (self-made) standard nowadays.
    But I do not think this particular case makes much of a difference.
    kind regards,

  • Submit program & return

    I m having 2 programs separately.
    in the first program i m calling the second program via submit .
    If i use submit program & return means the control comes back to first program form second one .
    But wat i need is i want to get values from the second program to first program through Internal table
    Is this possible..
    If yes maens can any one help me to solve this.
    Thanks in advance.
    Kalpanashri Rajendran

    Hi Kalpanashri,
    You can use EXPORT and IMPORT statement.
    Please check this sample code.
    Program A :
    SELECT-OPTIONS: S_BELNR FOR BKPF-BELNR.
    EXPORT S_BELNR TO MEMORY ID 'ZXC9'.
    Program B :
    DATA: BEGIN OF S_BELNR OCCURS 10.
    INCLUDE STRUCTURE STRUC1.
    DATA: LOW LIKE BKPF-BELNR,
    HIGH LIKE BKPF-BELNR.
    DATA: END OF S_BELNR.
    IMPORT S_BELNR FROM MEMORY ID 'ZXC9'.
    For EXPORT: http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/export01.htm
    For IMPORT: http://www.geocities.com/siliconvalley/campus/6345/import01.htm
    Hope this will help.
    Regards,
    Ferry Lianto

  • Help with return statements

    Can someone explain to me what a return statement does exactly and how I would use it to return a value in the follwoing type of program.
    Its a array making program that allows up to 25 values with the value 0 stopping the method. I need to be able to display the how many usable values the user input (anywhere from 1-25).
    To do this I need to use a return statement, correct? if so, how do utilize it correctly if it is nesasary I will post the code itself.

    Heres what I have for the code...
    To simplify amounbt of typing(I wrote program in telnet) The beginning is a set of options using switch statement. 4 choices, 1)new data. 2) list the data 3) change the data and 4) exit.
    For the new data I need to have the user input up to 25 values or stop at any time by entering 0. the values also cannot be greater than 12000 or less than -12000. it should also return the number of usable values in the array. The return statement is what I am having trouble with.
    Code...
    static int NewData(double a[]) //This part is not changeable
    {   int 1;
    for(i=0; i<25; i++)
    {  System.out.print("Enter Element"+(i +1)+ "- ");
    a=MyInput.readDouble();
    if (a[i]>12000 || a[i]<-12000)
    {System.out.println("the last value is not valid");
                                 break;}
    if (a[i]==0)
    break;
    } return i;
    As of right now the method functions as is but two things need to be changed or added. If possible the program should now break if the user inputs an element greater than 12000 or less than -12000, it should just reset to the integer they were on. Also, how do I get the return value to display something? have i used it correctly to show the number of usable values ithe user entered?

  • Compile Error: missing return statement

    anyone knows why the following program yields compile error "missing return statement??"
    class LengthTest
         public int stringLength(String s)
         {     int len = s.length();
              if (len <= 5) return 5;
              else if (len <= 10) return 10;
              else if (len <= 20) return 20;
    //          else return 30;
    If I add "else return 30" statement, then it can stop the error. Any ideas??

    You might know that the string length will never be more than 20, but the compiler does not. So it forces you to supply a return statement that will be executed no matter what the string length is.

  • Procedure with Return statement

    Hi,
    Below is my code. Am trying to return a value without a out parameter in the procedure. Is out parameter is mandatory to return a value in a procedure. Please help.
    CREATE OR REPLACE
    PROCEDURE P123(
        PID NUMBER)
    AS
      VCOUNT NUMBER;
    BEGIN
      SELECT COUNT(*) INTO VCOUNT FROM EMP WHERE EMPNO=PID;
      IF (VCOUNT=1) THEN
        RETURN 1;
      ELSE
        RETURN 0;
      END IF;
    END;Thanks

    Hi,
    When a procedure encounters a RETURN statement, it Returns the control, back to the calling program. In the below example, P1 is calling P2. When P2 encounters a RETURN statement, control is passed back to P1 procedure and "Out of p2 procedure" message is printed as per below example.
    Note: No further execution happens in P2 procedure when return is encountered.
    create or replace procedure P1
    as
    Begin
    p2;
    dbms_output.put_line('Out of the p2 procudure");
    end;
    create or replace procedure P2
    as
    begin
    dbms_output.put_line('calculation 1");.......
    return;
    dbms_output.put_line('calculation 2");
    end;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for