More the 1 return in a method, Good or Bad?

Hello, quick question. Is it bad programming, and maybe even dangerous to have more that 1 return in a class. for example which of these code would be correct?
int value = 0;
if(one==true)
value = 1;
else if(two==true)
value = 2;
else if(three==true)
value = 3;
else if(four==true)
value = 4;
else if(five==true)
value = 5;
return retValue;
------------------------OR
f(one==true)
return 1;
else if(two==true)
return 2;
else if(three==true)
return 3;
else if(four==true)
return 4;
else if(five==true)
return 5;

As a general rule, yes. Returning a value from the
middle of a for-loop inside an if-statement would not
be good style. But I do find myself writing methods
that get the trivial cases out of the way first,
before getting into the real code.
Example:public String extractNames(NodeObject
node) {
if (node == null) return null;
// complex code follows on here
I agree with you in practice and in general. In fact, I also do the same thing although I would throw in a comment like //exit method if no valid processing possible due to null parameter or just invoke another method to do the complex logic part and have a member variable that is null or what is returned from the complex logic method.
I try to have one return for several reasons :
1) as listed above - for ease of debugging
2) multiple returns reminds me of the code that used "goto exit" to get out of a loop because the programmer could not figure out any better way to get out without overly complex code.
3) standards of only one point of entry and exit from a method.
The only reason I can see for the complex code not to be in another method (at least in the simple example above) would be for performance reasons.

Similar Messages

  • How do I print out the value returned by a method in main??

    I'm a total newbie at java, I want to know how I can print out the value returned by this function in the "Main" part of my class:
    public int getTotalPrice(int price)
    int totalprice=price+(price*0.08);
    return totalprice;
    I just want to know how to print out the value for total price under "public static void main(String[] args)". thanks in advance,
    Brad

    Few ways you could do it, one way would be to create an instance of the class and call the method:
    public class Test
        public double getTotalPrice(int price)
            double totalprice = price + (price * 0.08);
            return totalprice;
        public static void main(String[] args)
            Test t = new Test();
            System.out.println(t.getTotalPrice(52));
    }Or another would be to make getTotalPrice() static and you could call it directly from main.

  • Problem with image returned from getGeneratedMapImage method

    I'm a newbie as far as map viewer and Java 2D goes....
    My problem is the java.awt.Image returned from the getGeneratedMapImage method of the MapViewer API. The image format is set to FORMAT_RAW_COMPRESSED. The image returned is of poor quality with colors not being correct and lines missing. I'm painting the Image returned from this method onto my own custom JComponent by overriding the paint() method...
    public void paint( Graphics g )
    Image image = map.getGeneratedMapImage();
    if ( image != null )
    g.drawImage( image, getLocation().x, getLocation().y, Color.white, this );
    If I take the xml request sent to the application server and paste it into a "sample map request" on the map admin website (along with changing format to PNG_STREAM) my image renders exactly how I expect it to.
    Anyone have any idea what I need to do to get the java.awt.Image with format set to FORMAT_RAW_COMPRESSED to render correctly. I was hoping to get back a BufferedImage or a RenderedImage from the getGeneratedMapImage call but I'm getting back a "sun.awt.motif.X11Image".
    Will downloading the JAI (java advanced imaging) from sun help me at all?

    Joao,
    Turns out it is related to colors. I'm dynamically adding themes, linear features and line styles. I ran a test where I changed the color being specified in the line style from magenta (ff00ff) to black. When I changed the color the linear feature would show up. It was being rendered as white on a white background when I was specifying it to be magenta. I'm specifying another linear feature to be green and it is showing up in the java image as yellow. This doesn't happen when I take the generated XML from the request and display it as a PNG_STREAM.
    Any clue what is going on there?
    Jen

  • Placing a PDF file in an InDesign Doc and PDF again for a vendor- Good or Bad?

    Current debate in the graphics department is
    Is it good or bad to place a PDF (general Press Quality) into an InDesign document and then creating a new PDF file with print vendor settings from that document?
    My thought is that you in some cases are double compressing, lower dpi images getting compressed, RGB color mode images okay on layout but now are converted to CMYK and shift in the PDF.
    Are there other issues and if so what are they.
    Also is there an easy way to check ppi, color mode and compression of an acrobat PDF? I mean other than doing a preflight and searching into each image folder twenty levels deep. FlightCheck and Enfocus are not options,
    too many vendors and not enough time.
    Thank you all in advance for your words of wisdom.

    Dov, I just got off the phone with a trusted professional in the Prepress field at a quite reputable print house, and he said "Dov is the guru of PDFs, ask him this...Will the InDesign CS3 preflight see the characteristics of a PDF (color mode, dpi(ppi), compression) if the original placed PDF is created as a pdf .X4 (1.7)? Ask him also if you were to use one form of compression (say lossless) in the original PDF, and then another form(say lossy) in the vendor PDF would it hold both or convert the first PDF compression to the second form?"
    Any other responses are also welcomed.

  • Return from a method at the end of a thread

    Hi all,
    I've written a slideshow in a class implementing Runnable, overriding the run() method.
    I want that my a method "startSlideShow()" returns when the task of the thread ends (the thread mainly display images).
    I've tried the the join() method (see code below) but the displaying of the images doesn't occurs any more.
    public class SlideShow extends JPanel implements Runnable {
        //The  main thread to run the slideshow
        Thread slideShowThread = new Thread(this);
         * Launch the slideshow
        public void startSlideShow() {
            //launch the slide show
            slideShowThread.start();
            //build and launch the listening of the end of the slideshow
            //prob : it freeze the displaying
           try {
                slideShowThread.join();
                System.err.println(" thread ENDED");
            } catch (InterruptedException ex) {
                System.err.println(ex+" thread was stopped");
            //this method SHOULD returns when the slideshow ended
    public void run(){
    //here is the slideshow code...
    }I've tried several other piece of code but I didn't succeed to makes my startSlideShow() method returns when the run() method end.
    Could you help ?
    thank you

    SlideShow slideShow = new SlideShow();
    slideShow.setCompletionListener(new
    ew CompletionListener() {
    public void executionComplete(SlideShow source) {
    //Execution will continue here when slideshow is
    w is complete...
              Thread t = new Thread(slideShow);
              t.start();
    /Kajok, thank you a lot for this. This fit my needs as the parent class of slideshow shouldn't be of a specific structure now. I will use this technic.
    However, just a general remark about the threads and my wish to have a modal function.
    You said that :
    "As I told you, you should never ever block the AWT thread so you can't make it modal. UI programming is event driven.
    and I agree. the point is that I wanted to do something like the JOptionPane set at modal.
    Let's consider the jOptionPane as a metaphor (I don't want to implement my slideshow using optionPane, obviously...)
    When we call a jOptionPane, we wait for an user action, then the jOptionPane returns (usually returning the results of the user action) :
    value = JOptionPane.showOptionDialog(
                        contentPane,
                        "my question is",
                        "my title",
                        JOptionPane.YES_NO_OPTION, // need answer
                        JOptionPane.QUESTION_MESSAGE,
                        null, // default icon for message type
                        options,
                        options[1]); //default selected value);So I was thinking that it should have been possible make a class which display the slideshow and then retunrs, after a specific event, which is the end of the slideshow...like the structure of the JOptionPane do.
    Thank for your useful answers,

  • Sales return process and receiving the inbound return goods

    hi,
    Standard SAP allow a return order (RE) to incurs an invoice billing at SD side without the need of a inbound dlivery creation (to receive the incoming goods return) AND a goods-receipt creation.
    question:
    1 - why standard SAP allows a invoice billing to take  place of a return order without the need to perform a Inbound delivery and goods receipt?
    2 - can i setup in the system to make the inbound delivery and goods receipt part of the indispensable process before a billing invoice can take place? if possible, what setup I need in the system?
    tuff

    Dear Tuffy,
    1 - why standard SAP allows a invoice billing to take place of a return order without the need to perform a Inbound delivery and goods receipt?
    There might be cases, where is actually no goods return.
    For example, we have invoiced a customer some materials, which are broken.
    Now imagine the transportation cost for bringing back the broken things to our plant is higher.
    In that case, we wont take the glass return.
    However we will have to show it as return.
    2 - can i setup in the system to make the inbound delivery and goods receipt part of the indispensable process before a billing invoice can take place? if possible, what setup I need in the system?
    It depends on your copy control.
    If you maintain the copy control properly, we can control this.
    In your case, do not maintain copy control between RE order and RETURN INVOICE.
    Instead maintain copy control from return order to return delivery first
    then maintain the copy control from return delivery to return invoice.
    Hope it clarifies your doubt!
    Thanks & Regards,
    Hegal K Charles
    Edited by: Hegal . K . Charles on Aug 19, 2011 3:20 PM

  • How to return more than one varibles from a method?

    can you use the codes:
    return var1, var2,var3;
    If not, what is the correct way to do so? thanks.

    You can only return 1 object from a method in Java.
    However, this 1 object can contain multiple other objects. For example, a Vector object:
      public Vector someMethod() {
        Vector v = new Vector();
        v.add("abc");
        v.add("xyz");
        v.add("123");
        return v;
      }If these multiple objects are the same type, you can also use array to achieve want you want.
      public String[] someMethod() {
        String ss = new String[3];
        ss[0] = "abc";
        ss[1] = "xyz";
        ss[2] = "123";
        return ss;
      }--lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can I know what is the process for us to do Good Return from customer?

    Can I know what is the process for us to do Good Return from customer?

    hi
    this ques need to be posted in sd forum..
    to answer this u can use order type RE to create Return order and then u can do the goods receipt..
    or u can use the process mentioned in first reply.
    regards
    CMM

  • The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting th

    The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting the particular pattern.
    The problem does not appear, if PH Elements 13 is executed in the administrator mode.
    The available computer resources are rather  large enough: CPU INTEL i7 4 cores,  16GB RAM, 1TB HDD + 32GB SSD, Windows 8.1.
    Please, advice how to solve this problem? Maybe, there is patch or updating available?

    Dear n_pane,
    Thank you for the quick answer. In the meantime I found other way to pass by the problem. I increased the cache level up to the maximum value 8.
    The errors reported as "No more virtual tiles can be allocated" vanish, but I still do not understand, why PSE 13 cannot work properly by the lower cache levels, having available maximum resources it needed (10443 MB RAM and 26.53GB SSD space for scratches), or cannot collaborate with the fast SSDs properly.
    I wish you all the best in the New Year 2015!

  • SAP Web Service error text : The database returned a value containing an error , type  CX_SY_OPEN_SQL_DB

    Hello Guru's,
    we are creating sales order in SAP from a quote created in .NET,  through Web Service created in SAP, and consumed in .NET.
    When ever a order is created in SAP for a given quote, SAP returns the sales order number to .NET.
    Orders are getting created as expected, but once in a while we are getting the following error from webservice :
    Web service processing error; more details in the web service error log on provider side (UTC timestamp 20140609173429; Transaction ID 4DFCEFE33301F1EBB5CE00155D0B4530)
    But the problem is order is getting created in SAP for the perticular quote for which we are getting the above error and this order number is not getting returned to .NET.
    Upon analysis in TCODE  SRT_UTIL for the above transaction ID, has the following details , which are hardly help full to resolve the error.
    ----TYPE                                  CX_SY_OPEN_SQL_DB
    ----ERROR_TEXT                   The database returned a value containing an error
    ----CX_SY_NO_HANDLER
    -----CLASSNAME                     CX_SY_OPEN_SQL_DB
    This Exception raised by Web Service application
    Could you please help in resolving this issue or alteast provide an approach for the same.
    Thank you,
    Suresh.

    Thank you Bhaskar,
    How can we clarify whether the error is from SAP or Web part.
    I have checked ST22, but there is not entry for the perticular  exception transaction ID
    My exception time stamp is
    -------------------START-------------6/9/2014 1:34:33 PM
    Error :Web service processing error; more details in the web service error log on provider side (UTC timestamp 20140609173429; Transaction ID 4DFCEFE33301F1EBB5CE00155D0B4530)
    -------------------END-------------6/9/2014 1:34:33 PM
    In al11, i found the following for the perticular exception time stamp
    **** Trace file opened at 20140609 133431 Eastern Daylight Time, by disp+work
    **** Versions SAP-REL 720,0,500 RFC-VER U 3 1442251 MT-SL
    XRFC> Begin of user trace
    XRFC> ---------------------------------------------------------------------
    XRFC>                                                                     <
    XRFC> TRACE SOAP RUNTIME - header                                         <
    XRFC>                                                                     <
    XRFC> ------------------------------------------------------------------  <
    XRFC> REQ_SIZE   : 2685                                                   <
    XRFC> RESP_SIZE  : 0                                                      <
    XRFC> PARENT_ID  : ROOT_CALL_ID                                           <
    XRFC> TRC_KEY    : 40FCEFE3BD6EF184B5CE00155D0B4530                       <
    XRFC> REQ_BASED  :                                                        <
    XRFC> SESSION_ID : 0003925540FCEFE3BD6EF17DB5CE00155D0B4530               <
    XRFC> TS_CALL    : 20140609173408.2880000                                 <
    XRFC> SY_UNAME   :                                            <
    XRFC> HOSTNAME   :                                              <
    XRFC> SY_SID     : PRD                                                    <
    XRFC> SY_MANDT   : 300                                                    <
    XRFC> SYS_NR     : 19                                                     <
    XRFC> APPLSERVER :                                      <
    XRFC> ISPRESCHED : X                                                      <
    XRFC> DURATION   : 21810                                                  <
    XRFC> NETHDRTIME : 21810                                                  <
    XRFC> CALL_STATE : 2                                                      <
    XRFC> ERRORTYPE  : APPLFAIL                                               <
    XRFC> ERRORAREA  : APPL                                                   <
    XRFC> CTXDP_TYPE : SOAP_RUNTIME                                           <
    XRFC> SYNC_ASYNC : S                                                      <
    XRFC> LOCATION   : P                                                      <
    XRFC> DIRECTION  : I                                                      <
    XRFC> REQ_ID     : 91C57815916E421CA9F3D652FFACE9C7                       <
    XRFC> RESP_ID    : 00155D0B45301EE3BBFF89A0267EB5CE                       <
    XRFC> MSG_STATE  : 114                                                    <
    XRFC> IF_NAME_I  : ZSD_CS_CREATE_SALESORDER_SERVI                         <
    XRFC> IF_NS_E    : urn:sap-com:document:sap:soap:functions:mc-style       <
    XRFC> IF_NAME_E  : ZSD_CS_CREATE_SALESORDER_SERVI                         <
    XRFC> ISSHORTCUT :                                                        <
    XRFC> TRC_PATT   : WSTEST                                                 <
    XRFC> TRC_SSID   : PRD_19                                                 <
    XRFC> TRC_USER   :                                           <
    XRFC> TRC_TS     : 20140609173409                                         <
    XRFC> TRC_COUNT  : 99                                                     <
    XRFC> TRC_EXT    :                                                        <
    XRFC> COMPLETE   : OK                                                     <
    XRFC> CALLEDPROG : ZSD_CS_CREATE_SALESORDER_SERVI                         <
    XRFC> SOAP_APPLI : urn:sap-com:soap:runtime:application:rfc:710           <
    XRFC> CONF_ID    : 00155D0B45301EE3AEFDAD78756555CE                       <
    XRFC> BIND_ID    : 00155D0B45301EE3AEFDAD787565B5CE                       <
    XRFC> OP_NAME    : ZsdCsCreateSalesorder                                  <
    XRFC> COMM_PATRN : Method:ZsdCsCreateSalesorder                           <
    XRFC> OP_NS      : urn:sap-com:document:sap:soap:functions:mc-style       <
    XRFC> REMADDRESS : 172.16.11.43                                           <
    XRFC> DT_OBJ     : ZSD_CS_CREATE_SALESORDER_SERVI                         <
    XRFC> MEMCONSUMP : 296291                                                 <
    XRFC> WSHOST     :                                                        <
    XRFC> WSPORT     :                                                        <
    XRFC> WSPROT     :                                                        <
    XRFC> WSCLIENT   :                                                        <
    XRFC> WSPATH     :                                                        <
    XRFC> PXYHOST    :                                                        <
    XRFC> PXYPORT    :                                                        <
    XRFC> USEDRFCDES :                                                        <
    XRFC> BONAME     :                                                        <
    XRFC> PROCCOMP   :                                                        <
    XRFC> DEPLOYUNIT :                                                        <
    XRFC> ------------------------------------------------------------------  <
    XRFC>                                                                     <
    XRFC> TRACE SOAP RUNTIME - trace records                                  <
    XRFC>                                                                     <
    XRFC> ------------------------------------------------------------------  <
    XRFC> E SOAP_RUNTIME 20140609173429.7400000 : CL_SOAP_RUNTIME_SERVER      <
    XRFC> ->EXECUTE_PROCESSING Exception handling for IF "ZSD_CS_CREATE       <
    XRFC> _SALESORDER_SERVI" OP name "ZsdCsCreateSalesorder" MSG ID           <
    XRFC> "91C57815916E421CA9F3D652FFACE9C7" user "STULZWEBSERV"              <
    XRFC>                                                                     <
    XRFC>                                                                     <
    XRFC> E SOAP_RUNTIME 20140609173429.7240000 : CL_SOAP_RUNTIME_SERVER      <
    XRFC> ->EXECUTE_PROCESSING CX_SOAP_ROOT : An exception has occurred. |    <
    XRFC> program: CL_SOAP_RUNTIME_ROOT==========CP include: CL_SOAP          <
    XRFC> _RUNTIME_ROOT==========CM004 line: 120                              <
    XRFC>                                                                     <
    XRFC>                                                                     <
    XRFC> E SOAP_RUNTIME 20140609173429.7400000 : CL_SOAP_RUNTIME_SERVER      <
    XRFC> ->EXECUTE_PROCESSING CX_SY_NO_HANDLER : An exception with the type  <
    XRFC> CX_SY_OPEN_SQL_DB occurred, but was neither handled locally, nor    <
    XRFC> declared in a RAISING clause | program: SAPLSTXD include: LSTXDFDB  <
    XRFC> line: 200                                                           <
    XRFC>                                                                     <
    XRFC>                                                                     <
    XRFC> E SOAP_RUNTIME 20140609173429.7400000 : CL_SOAP_RUNTIME_SERVER      <
    XRFC> ->EXECUTE_PROCESSING CX_SY_OPEN_SQL_DB : The database returned a    <
    XRFC> value containing an error | program: SAPLSTXD include: LSTXDFDB     <
    XRFC> line: 227                                                           <
    XRFC>                                                                     <
    XRFC> ---------------------------------------------------------------------
    XRFC> End of user trace

  • Reference to a local variable object returned by a method is alive?

    I have an instance method getEmployee().
    This method forms a local variable, Employee and returns it.
    public Employee getEmployee()
    Employee e = new Employee();
    e.setSNo(sNo+=);
    e.setMailBox();
    return e;
    There's another instance method in the same class that calls getEmployee() in this manner:-
    Employee newEmployee = getEmployee();
    newEmployee.printDetails();
    I want to know whether the employee returned by getEmployee() is still alive when we are doing newEmployee.printDetails().
    I am confused because in C, the lifetime of a local variable is limited only to the life time of the function. Once the function finishes, the local variable is considered garbage.
    How does it work in case of Java?

    No, It rarely has any use but can be used to unload things (from a cache for example). However I have never needed to do this. All I know is that finallizers can only be relied on to clear up memory. How or why you would do this is another question.
    The GC runs when memory is low (not any other resource). It calls finalizers when it clears up objects. Therefore the only thing you can reliably release in a finalizer is memory. Other resources can become depleted without heap being depleated so you can't use finalizers to relialy clean up non-memory resources.
    Anyway.
    some more info on escape analysis
    a compile time escape analysis
    http://www.excelsior-usa.com/pdf/StackAlloc.pdf
    This can handle some finalizers
    This does not handle finalizers (marks them all as GLOBAL_ESCAPE
    http://delivery.acm.org/10.1145/330000/320386/p1-choi.pdf?key1=320386&key2=0718563811&coll=Portal&dl=ACM&CFID=15151515&CFTOKEN=6184618
    bit more recent and about runtime optimization (finalizers not handled)
    http://ssw.jku.at/Research/Papers/Ko05/Ko05.pdf
    I don't think that not handling finalizers is too much of a problem. Most objects that will benifit from stackability are small objects anyway (especially the built in wrapper types). Most objects that have custom finalizers tend to be pretty complicated.
    matfud

  • What are the parameters in Call transaction method?

    Hi ABAPER'S,
        Please give me what are the parameters in call transaction method?
    Thanks,
    Prakash

    Processing batch input data with CALL TRANSACTION USING is the faster of the two recommended data transfer methods. In this method, legacy data is processed inline in your data transfer program.
    Syntax:
    CALL TRANSACTION <tcode>
    USING <bdc_tab>
    MODE  <mode>
    UPDATE  <update>
    <tcode> : Transaction code
    <bdc_tab> : Internal table of structure BDCDATA.
    <mode> : Display mode:
    A
    Display all
    E
    Display errors only
    N
    No display
    <update> : Update mode:
    S
    Synchronous
    A
    Asynchronous
    L
    Local update
    A program that uses CALL TRANSACTION USING to process legacy data should execute the following steps:
    Prepare a BDCDATA structure for the transaction that you wish to run.
    With a CALL TRANSACTION USING statement, call the transaction and prepare the BDCDATA structure. For example:
    CALL TRANSACTION 'TFCA' USING BDCDATA
    MODE 'A'
    UPDATE 'S'.
    MESSAGES INTO MESSTAB.
    IF SY-SUBRC <> 0.
    <Error_handling>.
    ENDIF.
    The MODE Parameter
    You can use the MODE parameter to specify whether data transfer processing should be displayed as it happens. You can choose between three modes:
    A Display all. All screens and the data that goes in them appear when you run your program.
    N No display. All screens are processed invisibly, regardless of whether there are errors or not. Control returns to your program as soon as transaction processing is finished.
    E Display errors only. The transaction goes into display mode as soon as an error in one of the screens is detected. You can then correct the error.
    The display modes are the same as those that are available for processing batch input sessions.
    The UPDATE Parameter
    You use the UPDATE parameter to specify how updates produced by a transaction should be processed. You can select between these modes:
    A Asynchronous updating. In this mode, the called transaction does not wait for any updates it produces to be completed. It simply passes the updates to the SAP update service. Asynchronous processing therefore usually results in faster execution of your data transfer program.
    Asynchronous processing is NOT recommended for processing any larger amount of data. This is because the called transaction receives no completion message from the update module in asynchronous updating. The calling data transfer program, in turn, cannot determine whether a called transaction ended with a successful update of the database or not.
    If you use asynchronous updating, then you will need to use the update management facility (Transaction SM12) to check whether updates have been terminated abnormally during session processing. Error analysis and recovery is less convenient than with synchronous updating.
    S Synchronous updating. In this mode, the called transaction waits for any updates that it produces to be completed. Execution is slower than with asynchronous updating because called transactions wait for updating to be completed. However, the called transaction is able to return any update error message that occurs to your program. It is much easier for you to analyze and recover from errors.
    L Local updating. If you update data locally, the update of the database will not be processed in a separate process, but in the process of the calling program. (See the ABAP keyword documentation on SET UPDATE TASK LOCAL for more information.)
    The MESSAGES Parameter
    The MESSAGES specification indicates that all system messages issued during a CALL TRANSACTION USING are written into the internal table <MESSTAB> . The internal table must have the structure BDCMSGCOLL .
    You can record the messages issued by Transaction TFCA in table MESSTAB with the following coding:
    (This example uses a flight connection that does not exist to trigger an error in the transaction.)
    DATA: BEGIN OF BDCDATA OCCURS 100.
    INCLUDE STRUCTURE BDCDATA.
    DATA: END OF BDCDATA.
    DATA: BEGIN OF MESSTAB OCCURS 10.
    INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF MESSTAB.
    BDCDATA-PROGRAM = 'SAPMTFCA'.
    BDCDATA-DYNPRO = '0100'.
    BDCDATA-DYNBEGIN = 'X'.
    APPEND BDCDATA.
    CLEAR BDCDATA.
    BDCDATA-FNAM = 'SFLIGHT-CARRID'.
    BDCDATA-FVAL = 'XX'.
    APPEND BDCDATA.
    BDCDATA-FNAM = 'SFLIGHT-CONNID'.
    BDCDATA-FVAL = '0400'.
    APPEND BDCDATA.
    CALL TRANSACTION 'TFCA' USING BDCDATA MODE 'N'
    MESSAGES INTO MESSTAB.
    LOOP AT MESSTAB.
    WRITE: / MESSTAB-TCODE,
    MESSTAB-DYNAME,
    MESSTAB-DYNUMB,
    MESSTAB-MSGTYP,
    MESSTAB-MSGSPRA,
    MESSTAB-MSGID,
    MESSTAB-MSGNR.
    ENDLOOP.
    The following figures show the return codes from CALL TRANSACTION USING and the system fields that contain message information from the called transaction. As the return code chart shows, return codes above 1000 are reserved for data transfer. If you use the MESSAGES INTO <table> option, then you do not need to query the system fields shown below; their contents are automatically written into the message table. You can loop over the message table to write out any messages that were entered into it.
    Return codes:
    Value
    Explanation
    0
    Successful
    <=1000
    Error in dialog program
    > 1000
    Batch input error
    System fields:
    Name:
    Explanation:
    SY-MSGID
    Message-ID
    SY-MSGTY
    Message type (E,I,W,S,A,X)
    SY-MSGNO
    Message number
    SY-MSGV1
    Message variable 1
    SY-MSGV2
    Message variable 2
    SY-MSGV3
    Message variable 3
    SY-MSGV4
    Message variable 4
    Error Analysis and Restart Capability
    Unlike batch input methods using sessions, CALL TRANSACTION USING processing does not provide any special handling for incorrect transactions. There is no restart capability for transactions that contain errors or produce update failures.
    You can handle incorrect transactions by using update mode S (synchronous updating) and checking the return code from CALL TRANSACTION USING. If the return code is anything other than 0, then you should do the following:
    write out or save the message table
    use the BDCDATA table that you generated for the CALL TRANSACTION USING to generate a batch input session for the faulty transaction. You can then analyze the faulty transaction and correct the error using the tools provided in the batch input management facility.

  • Appropriate use of "return" in a method

    Migrating to Java quite some time back now I still haven't found the appropriate use of the 'return'-statement in a method.
    In procedual languages there has always been an unwritten rule saying that a function should not have more than one 'return'-statement and that the 'return'-statement should always be the last line to be executed in the function.
    Having seen a lot of source code by other Java programmers I was puzzled to see that a lot of programmers uses multiple return statments and furthermore use them to terminate loops, etc.
    Example, binary search find method
    while ( current.key != key ){
        if ( key < current.key){
            current = current.leftChild;
        else{
            current = current.rightChild;
        if (current == null){
            return null;
    return current;As you can see in the example, 'return' is used in the middle of the loop to both return a value and to stop the rest of the processing in the method.
    Is there any recommended practise on using 'return'? Personally I don't like the idea of having more than one return statement in my code as the code can end up being irrational.
    What do guys think in the forum?
    Kind regards,
    Allan

    Sylvia is probably right about the origin of that practice, memory leaks were a huge problem (and are to a lesser extent in Java). You really shouldn't avoid doing multiple returns to avoid memory leaks in C++ even. Usually when you allocate memory that you're expecting to simply disapear at the end of a function, you're going to allocate it as a stack variable, rather than using new, and it will be removed when it falls out of scope. There are some functions, like strcpy, and strdup, to name a few, that will allocate memory, and it's possible you could return out without removing that data. I find if this is likely to happen, the user probably wasn't thinking about releasing the data to begin with, and could just as easily return at the end of the function without releasing the memory, as he/she would at any point inside the function. I'd hope that you'd be using this newly created memory for some purpose before returning, so I would assume it's use would be complete before you left that function, and definitely it would be ready to be deleted.
    -Jason Thomas.

  • Returning Internal Table as Returning Parameter of Method (by Value).

    When you return an internal table as the returning parameter of a method, it is passed by value.  I understand the concept of passing by value vs. passing by reference, but exactly what this means in this case is ambiguous.
    1)  It could mean that the entire table, including data, is copied from the local table in the method into the parameter provided by the calling code.
    2)  Alternatively, it could mean that only the pointer to the table is passed by value and the data is not literally copied from one place in memory to another.  This would <b>not</b> be the same as passing by reference.  For instance, I believe this is how object references are passed by value.
    I want to know how it works, so that I know if there is an efficiency problem with returning a huge table.  The returning parameter is wonderful for getter methods, and I prefer to use it over exporting parameters, but I have some concern about passing tables as returning parameters since I don't know how this works.
    Can anyone either explain this, or at least make it clear to me whether or not there is an efficiency issue?
    Thanks, in advance,
    -Chris

    Thanks to those who tried to help me with this question, but I finally had to just figure it out on my own.  I just realized today that there is a way to find the answer using the debugger's <i>Go To->Status Display->Memory Use</i> option.  This shows how variables are stored in memory.
    The answer:
    First of all, if you set one internal table equal to another like:
      i_tab1 = i_tab2.
    or like:
      i_tab1[] = i_tab2[].
    both will simply set <i>i_tab1</i> to point to the same memory that <i>i_tab2</i> is using.  It does <b>not</b> make a copy.  Now, if you attempt to change <i>i_tab1</i>, with an <i>append</i> statement for instance, a copy of <i>i_tab2</i>'s memory is made <b>then</b>!  The requested change to <i>i_tab1</i> is then applied to the copied data.  <b>AHA!!!</b>  This means that even if you think you are copying a table, you are not really doing it until it becomes necessary due to a divergence in values.
    I specifically tested a returning parameter to see how memory is handled, and it is basically just like an '<i>=</i>' statment.  No copy of the data is performed at first.  The memory that is allocated for the local variable in the method is simply pointed to by the variable used in the calling code to recieve that value.
    What if you then change the value in the calling code after the method has finished executing?  The answer depends on the situation.  If the value that you returned from the method is still being pointed to by another variable somewhere, then a copy is made when you attempt to change the returned table in the calling code, but if there is no longer another variable pointing to this memory, you can change the table in the calling program all you want without causing a copy in memory.
    For instance, if you have a getter method that returns the value of an attribute, at first no copy will be made, but when you try to change the table in your calling code, a copy will be made then.  However, if you just fill a local table in your getter method and return that table, there will never be a copy made, because the local variable that originally pointed to that memory expired when the method completed.  That means that after the method completes, the only variable pointing to the allocated memory is the one in the calling code that recieved the returning value.
    This is fantastic!!  This behaives in a way that seems to provide maximum efficiency in most cases.  Also, the table copies are <b>never</b> a waste, since they only happen upon changing of one of the table variables that point to the common memory, and in this case you would <b>want</b> to make a copy to avoid corrupting the other variable.
    Also, even if you did return your table as an exporting parameter by reference, you would not gain any significant efficiency.  There would still be no table copy if you don't change the returned table.  Also, if you did change the returned table, you <b>would</b> still produce a table copy if there was another variable, like an attribute, still pointing to the memory that you set your exporting paramter from before.
    The only situation that I can see resulting in a needless efficiency problem is if someone used a getter method to return the value of a table attribute, then changed the returned table in the calling program, and then used a setter method to set the whole table attribute equal to the changed table.  This would be a waste, so maybe this should be accomplished in another way.
    In conclusion, there is essentially no reason to hesitate returning a whole internal table as a returning parameter from a method call, even though it is pass by value.
    Kudos to the ABAP development team for their good design!

  • Solving the ipod crisis - Nick Moss Method

    "PLZZZZZ Help me people. I recently bought a 1GB Ipod Shuffle and even though I've added songs and such, every time i attempt to play on my shuffle, the buttons flash green and orange for about 5 seconds. I've tried everything, someone must help me I'm going insane!!!!!!!!!"
    -Every Ipod Shuffle User
    I had the same problem as you and sooooooo many others. You add songs, reset it, restart and reinstall programs, and get to a point where you simply can't take it any longer, however, i have found a method that helped me (Thankfully), and I'm hoping will help you to , so you don't end up throwing the shuffle out the window.
    My successful, yet simple technique is this :
    *1. Plug in your shuffle and go on to itunes, then restore it.*
    *2. Once it is restored and you've renamed it, (make sure it doesn't automatically add songs) find it in the left hand bar.*
    *3. MANUALLY add about 5 songs to your shuffle, any length, but the smaller the better (not too small =D)*
    *4. Once they've all been uploaded and in the status bar it the top of the itunes window it says "Ipod sync complete, OK to disconnect", select the first song on your shuffle and then click the shuffle header in the left nav bar so it is highlighted blue.(shown in below picture in step 5)*
    *5. Finally, go down to the bottom left of your itunes browser and left click the shuffle icon (two arrows interweaving), so it highlights blue , but only after you've selected the Shuffle icon in the nav bar. Image in link :*
    http://i26.tinypic.com/t66yxh.png
    After that is highlighted, wait for the OK to disconnect at the top status bar and eject the ipod using the button in the nav bar next to the header. After, turn it on and HOPEFULLY it should play, if it has, no need to thank me, just spread the word, if it hasn't i am very sorry and sorry for generating any false hope you may of experienced.
    -Nick Moss
    Message was edited by: Nick Moss

    _*2ND METHOD*_
    1. Load in your shuffle and restore and add 5 songs, but DON'T click the shuffle button yet, just add some songs and eject as normal.
    2. Download the most recent version of itunes (currently 7.6) from here : http://www.apple.com/itunes/download/ - don't unintsall your current one, just download and install this one straight away.
    3. Once installed, go on to itunes, and once on itunes, plug in your shuffle 2nd gen, then select it in the devices section and click the shuffle button and eject.
    I'm both hoping and assuming that'll catch you more luck than the above method, thanks.
    _*3RD METHOD*_
    1. Download the most recent version of itunes (currently 7.6) from here : http://www.apple.com/itunes/download/ - don't unintsall your current one, just download and install this one straight away.
    2. On the newly installed itunes, plug in your shuffle and restore.
    3. After add some songs, highlight your shuffle in the devices section and turn on the shuffle button at the bottom left.
    Eject.
    Good Luck!
    Message was edited by: Nick Moss

Maybe you are looking for

  • How to make shape rotation at it's center point?

    I draw a shape,like follows: var shape1:Shape; shape1=draw(); addChild(shape1); shape1.rotation=50; private function draw():Shape{    var shape:Shape = new Shape();    shape.graphics.beginFill(0x00FFFF);    shape.graphics.moveTo(200,200);    shape.gr

  • 2013 haswel macbook pro problem downloading

    my new i7 haswell macbook pro 13' has problem with WIFI and downloading. Does anybody experience strange downloads? for example updating iphoto took 2 hours, size of the file was blinking from 700mb to 60mb every second and when it crashes I must sta

  • Java Applet in a Windows Vista/7 Sidebar Gadget?

    Hello, I have written a Java Applet which should show a timetable. It's running very well. But my question is if it would be possible to include this in a sidebar gadget. Using a <Applet> tag in the html file doesn't work. I have searched on the Inte

  • No digital signature

    I can't download iTunes as at the very end of the Download, it reports the software has no digital signature, even though it has come from the official website. Also, Internet Explorer and iTunes malfunction each time I try to access iTunes store in

  • I get an error when I try to forward e-mails with attachments.  Advice?

    I have tried many different ways to forward e-mails with attachments to no avail.  I sometimes get a question if I want to include attachment or not.  When I answer yes, I sometimes get an error message and at other times the forward goess through, b