Example program for returninng and importing with value addition

HI ,
I want few example programs on how to use the abap oops with returning addition and importing with value addition as Im getting syntax error for the Program when Im declaring them with these additions
Thnaks .

Hello,
This statement declares a general instance method meth. Use additions ABSTRACT and FINAL to make the method abstract or final.
The additions IMPORTING, EXPORTING and CHANGING define the parameter interface of the method. After every addition, the corresponding formal parameters are defined by a specification of the list parameters.
The other additions determine which exceptions the method can propagate or trigger and determine whether the method is abstract or final.
Note
Within a method, you can use the logical expression IS SUPPLIED to check whether an actual parameter was assigned to an optional formal parameter at the call.
Addition 1
... IMPORTING parameters PREFERRED PARAMETER p
Effect
IMPORTING defines input parameters. When calling the method, you need not specify an appropriate actual parameter for every non-optional input parameter. During the call, the content of the actual parameter is passed to the input parameter. The content of the input parameter - for which the reference transfer is defined - cannot be changed in the method.
Use PREFERRED PARAMETER to identify an input parameter p1 p2 ... of list parameters after IMPORTING as a preferred parameter. This specification makes sense only if all input parameters are optional. When calling the method with the syntax
CALL METHOD meth( a ).
the actual parameter a is assigned to the preferred parameter if you have appropriate use of a functional method at an operand position.
Addition 2
... EXPORTING parameters
Effect
EXPORTING defines output parameters. When calling the method, you can specify an appropriate actual parameter for every output parameter. The content of the output parameter - which is defined for value transfer - is passed to the actual parameter at the call after the method has been completed successfully.
Note
An output parameter that is defined for the reference transfer is not initialized when the method is called. Therefore, no read access to it should take place before the first write access.
Addition 3
... CHANGING parameters
Effect
CHANGING defines input/output parameters. When calling the method, you must specify an appropriate actual parameter for every non-optional input/output parameter. The content of the actual parameter is passed to the input/output parameter at the call, and after the method has been completed, the content of the input/output parameter is passed to the actual parameter.
Example
The method read_spfli_into_table of this example has an input and an output parameter, which are typed fully by reference to the ABAP Dictionary.
CLASS flights DEFINITION.
  PUBLIC SECTION.
    METHODS read_spfli_into_table
       IMPORTING VALUE(id)  TYPE spfli-carrid
       EXPORTING flight_tab TYPE spfli_tab.
ENDCLASS.
Addition 4
... RAISING exc1 exc2 ...
Effect
Use addition RAISING to declare the class-based exceptions exc1 exc2 ... that can be propagated from the method to the caller.
For exc1 exc2 ..., you can specify all exception classes that are visible at this position and are subclasses of CX_STATIC_CHECK or CX_DYNAMIC_CHECK. You must specify the exception classes in ascending order corresponding to their inheritance hierarchy.
Exceptions of the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be declared explicitly, otherwise a propagation results in a violation of the interface. An interface violation results in a treatable exception CX_SY_NO_HANDLER. Exceptions of category CX_NO_CHECK are always implicitly declared.
Notes
The declaration of exceptions of category CX_STATIC_CHECK is checked statically at the syntax check. For exceptions of category CX_DYNAMIC_CHECK, the check is executed at runtime.
In a method in which class-based exceptions are declared with the addition RAISING, you cannot use the statement CATCH SYSTEM-EXCEPTIONS. Instead, handle the relevant treatable exceptions in a TRY control structure.
Example
In class math, you can propagate all exceptions represented by class CX_SY_ARITHMETIC_ERROR and its subclasses from within method divide_1_by. If, for example, the input parameter operand is filled at the call with the value 0, then the exception CX_SY_ZERODIVIDE is triggered, propagated, and can, as shown in the example, be handled by the caller in a TRY control structure.
CLASS math DEFINITION.
  PUBLIC SECTION.
    METHODS divide_1_by
       IMPORTING operand TYPE I
       EXPORTING result  TYPE f
       RAISING   cx_sy_arithmetic_error.
ENDCLASS.
CLASS math IMPLEMENTATION.
  METHOD divide_1_by.
    result = 1 / operand.
  ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA oref TYPE REF TO math.
DATA exc  TYPE REF TO cx_sy_arithmetic_error.
DATA res  TYPE f.
DATA text TYPE string.
CREATE OBJECT oref.
TRY.
    oref->divide_1_by( EXPORTING operand = 4
                       IMPORTING result = res ).
    text = res.
  CATCH cx_sy_arithmetic_error INTO exc.
    text = exc->get_text( ).
ENDTRY.
MESSAGE text TYPE 'I'.
Addition 5
... EXCEPTIONS exc1 exc2 ...
Effect
Use addition EXCEPTIONS to define a list of non-class-based exceptions exc1 exc2..., which can be triggered with the statements RAISE or MESSAGE RAISING in the method. You specify identifiers exc1 exc2 ... for the exceptions to be defined at will and directly. Exceptions defined in this way are bound to the method - similar to formal parameters - and cannot be propagated.
If such an exception is triggered in a method and no return value has been assigned to it in the addition EXCEPTIONS of the CALL METHOD statement in the method call, then a runtime error occurs.
Note
The additions RAISING and EXCEPTIONS cannot be used simultaneously. For new developments starting at release 6.10, we recommend to use class-based exceptions, which are independent of the respective method.
Example
In the class math, for method divide_1_by an exception arith_error is defined, which is triggered in the method with the RAISE statement if an arithmetic error occurs. If, for example, the input parameter operand is filled with value 0 at the call, the exception arith_error is triggered in the method-internal handling of exception CX_SY_ZERODIVIDE and handled after the call of the method by evaluating sy-subrc.
CLASS math DEFINITION.
  PUBLIC SECTION.
    METHODS divide_1_by
       IMPORTING  operand TYPE I
       EXPORTING  result  TYPE f
       EXCEPTIONS arith_error.
ENDCLASS.
CLASS math IMPLEMENTATION.
  METHOD divide_1_by.
    TRY.
        result = 1 / operand.
      CATCH cx_sy_arithmetic_error.
        RAISE arith_error.
    ENDTRY.
  ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA res  TYPE f.
DATA oref TYPE REF TO math.
CREATE OBJECT oref.
oref->divide_1_by( EXPORTING  operand = 4
                   IMPORTING  result  = res
                   EXCEPTIONS arith_error = 4 ).
IF sy-subrc = 0.
  WRITE res.
ELSE.
  WRITE 'Arithmetic error!'.
ENDIF.
Regards.

Similar Messages

  • Does apple have program for kids and adults with learning disabilities

    My daughter has learning disabilities and we were wondering if Apple has program that supports adults with disabilities. We thought that the gps function and Siri would be a wonder tool to help her if she gets lost.  We want to teach her independence and so that means letting her do things on her own. We want to get her an Iphone but have to wait untill our contract comes due. Any suggestions on who to contact at Apple?

    I don't believe that Apple makes any specific programs for "people with disabilities". That is term covers such a broad range of issues! People who are blind have different needs than people with autism or people with spinal cord damage. Apple does include various accessibility options as part of the iOS.
    However, just because Apple doesn't create such apps doesn't mean they don't exist. I would start be looking around the App Store (which you can do by downloading iTunes to your computer). There will no doubt be general purpose apps that can be useful as well as apps designed for specific needs. Also, contact a support group for whatever specific disabilities your daughter has. They may have a forum or blog where useful apps are discussed. Do an Internet search for apps and her specific issues.
    Best of luck.

  • One program for pc and mac with different imports

    I am trying to port my Java program from the PC to the MAC. I would like to have one program that works on both, the PC and the MAC. So I am using the
    if (System.getProperty("mrj.version") == null) //PC
    else //MAC
    condition to see if I am on the PC or MAC for making sure that the About menu is at the Help menu on top of the application window (PC) or at the Program menu on top of the screen (MAC) and the Control key (PC) or Command key (MAC) is used.
    However, the Mac also uses additional imports, such as
    import com.apple.laf.*;
    import com.apple.mrj.*;
    import com.apple.eawt.*;
    I cannot make an if statement before the imports. How can I make sure that the imports are only used on the MAC?
    Thanks for your time!

    >
    ..my program has a GUI...>Cool. OK - if you have not tried applications launched by JWS (Java Web Start) it is usually handy to get a feel for how they work for the end user. The biggest difference is between sandboxed applications, and ones that request extended permissions in the form of either j2ee-application-client-permissions or all-permissions. The first removes the warning banner from the bottom of windows, and adds a few other allowable actions, while the latter is, as it implies - all permissions.
    Examples of all-permissions/sandboxed can be seen in this [demo of the JNLP fileservice|http://pscode.org/jws/api.html#fs].
    >
    .. It is a computer graphics program, and it has a Tools palette where you can specify what and how you want to draw or select or move, and it has a Measurements palette, where you can use numbers for your drawing.>Does it offer to export the resulting graphics (e.g. save them to disk)? Does the program load graphic objects from disk? The reason I pointed to a demo of the differences between sand boxed and trusted apps., is because if the app. wants to 'access the local disks' it will either need to request all-permissions or as demonstrated in the example, use the [JNLP API|http://java.sun.com/javase/6/docs/jre/api/javaws/jnlp/index.html] (a group of classes only available to apps. launched by webstart) to do common things like access disks or printer, or take control of downloads...
    If you click the [Launch File Service (sandboxed) demo|http://pscode.org/jws/filetest-sandbox.jnlp] link, you can see what the experience would be like for the end user if the app. were converted to use the JNLP API for file I/O and was delivered entirely sandboxed.
    Of course, if your app. could work entirely sand boxed, like an applet - no code signing or extra permissions would be necessary, but that is uncommon for a desktop application.
    >
    So could you please give me some explanation or reference how to do launching it using webstart, and putting the mac specific resources into a resource section flagged for the Mac? >Launching an app. via webstart is not entirely 'simple', especially if you are new to it. OTOH it is well worth the effort - for the sake of the end user.
    The very basics of webstart is that you create a JNLP file to launch the app., I guess it is similar to the Mac .plist (or whatever they are) that you are discussing in another thread. Java JNLP files are a form of XML. Here is an example of what one might look like for an app. that provides different resources to different OS.
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0"
          codebase="http://ananya.com/lib"
          href="ananyacurves.jnlp">
      <information>
        <title>Ananya Curves</title>
        <vendor>Ananya Systems</vendor>
        <description>Ananya Curves - Computer Graphics</description>
        <offline-allowed/>
        <shortcut online="false">
          <desktop/>
          <menu submenu="AnanyaSystems"/>
        </shortcut>
      </information>
      <security>
           <all-permissions />
      </security>
        <resources>
          <j2se version="1.6+" />
          <jar href="AnanyaCurves.jar" main='true' />
        </resources>
        <!-- This is it! Supply the mac specific classes ONLY to Macintosh OS. -->
        <resources os='Mac'>
          <jar href="mac-specific.jar" />
        </resources>
      <application-desc />
    </jnlp>
    >
    ..Well, I am a complete beginner at this.>It can be a steep learning curve to first use JWS successfully, but it is well worth it.
    There is a good [overview of webstart|http://java.sun.com/developer/technicalArticles/Programming/jnlp/], but I also find it handy to keep the documentation on the [JNLP file syntax|http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html] nearby.
    Unfortunately many IDEs (and people) are not that competent at writing JNLP files, so I provide a JNLP XSD and [YAX-V|http://pscode.org/xml/xmltools.html#yaxv] to validate them.

  • Need an example program for function module

    Hi ,
    I am new to ABAP. Can you please give a simple example program to extract the data from a table using Function module.
    Thanks for your help in advace.
    Regards,
    Vishnu

    hi vishnu,
    See the following Sample Program;
    REPORT demo_mod_tech_fb_read_spfli.
    PARAMETERS carrier TYPE s_carr_id.
    DATA: jtab TYPE spfli_tab,
          wa   LIKE LINE OF jtab.
    CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
         EXPORTING
              id        = carrier
         IMPORTING
              itab      = jtab
         EXCEPTIONS
              not_found = 1
              OTHERS    = 2.
    CASE sy-subrc.
      WHEN 1.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
      WHEN 2.
        MESSAGE e888(sabapdocu) with 'Error in  function module'.
    ENDCASE.
    LOOP AT jtab INTO wa.
      WRITE: /  wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
    ENDLOOP.
    Also you can find example programs for all in tcode ABAPDOCU in your SAP system itself, explore ABAPDOCU to find more sample programs....
    Regards
    Karthik D

  • Where can we find the standard program for scripts and smartform for vl02

    where can we find the standard program for scripts and smartform for vl02
    regard,
    anil

    If it is a standard Script Output see that all config in NACE tcode was done correctly and in the Application document the output type was properly defined and attached to a medium, partner and all communication related things like printer name, when to print the output and number of messages etc are entered in the document
    the go to the related application Tcode
    (for sales order goto VA02 or VA03)
    (delivery -VL02N or VL03N)
    for Invoice VF02 or VF03
    for PO -goto ME9F
    enter doc number, Issue Output to -> screen/printer
    then see the output
    step 1 : copy the z layout into testing client thru SCC1.
    step2 : go to se71 and check modified layout.
    step3 : if it is under logistics.. go to TCODE "NACE".
    u will see various applictions for each business process.
    there u have configure ur related layout according to requirments,
    for example u consider for Request fo Quatation..
    there is APPLICATION called "EA"
    click and enter into it. configure it with ur requirments, for help consult with ur functonal consaltant, and save it.
    step 4 : goto tcode ME9A for requst for quatation(RFQ).
    step 5 : enter test data avalable and check it with message display.
    it is same for other applications like Contract agreament --> ME9k
    invoice --> vl02n
    and goes on..
    Reward points for useful Answers

  • Process for Trading and Imports in CIN

    Dear Friends,
    The main business of our client is manufacturing and selling. For that they have a separate excise license. Along with that they do some trading activity of imported goods and for that they have different license. While imports there is a portion of Customs duty which is creditable and non creditable. Recoverable portion of customs duty is passed to the customer.
    To map this in SAP we are proposing a dummy plant with different registration number as a Depot. which can directly procure the imported goods and sell with the additional recoverable duty to the customer with other taxes like Education cess, H & S Education cess and VAT.
    Now I have following questions
    1)     Whether this set up is OK
    2)     Whether this new plant can procure imported materials directly and sell to the final customer with excise transactions?
    3)     If yes, whether this will update RG23 D register correctly?
    4)     If no, what process need to be set up for this in SAP?  (e.g stock transfer from main plant to the dummy plant i.e. do we need to take the imported goods stock in the manufacturing plant, Transfer the same to the Dummy plant with all Excise implications and then sell the goods from Depot?)
    5)     With this will the RG23D register  be updated during Sales?
    Can anyone please guide me so as to how to map this in SAP with RG23D register updation.
    Regards,
    Harsh

    Hey there Ashish,
       There are a couple of things to know about this:
     - AFAIK - this feature isn't available in Project Online
     - For on-premise Project Server 2013 you need to go to Central Administration->General APplication Settings->Manage PWA->Operational Policies->Alerts and Reminders and switch it on there.  If you can't see the setting make sure you
    have already configured the outgoing SMTP sever settings for your installation.
    Cheers,
       James.
    James Boman BSc. MCP:EAD -

  • Terms of Payment for Local and Import Purchase Order

    Hello Experts,
    I am SAP FICO Consultant, I am given a task of maintaining payment terms for local and import purchase order, I would highly appreciate your help in this regard. I know I can maintain payment terms via OBB8 but I am not sure that how to cover the following scenarios.
    1. 100% Advance
    2. 50% Advance, Balance in 07 Days (usually balance immediate with delivery is accepted but it is paid in 07 days for the record)
    3. 25% Advance, Balance in 07 Days
    4. 10% Advance, Balance in 07 Days
    5. 30 Days Credit
    6. 15 Days Credit
    7. 07 Days Credit
    IMPORTS
    1. 100% Irrevocable LC in advance
    2. 100% TT in Advance
    3. 50% TT in advance & 50% before shipment.
    Looking forward to hear from you.
    Regards
    Muhammad Yousuf Ali

    Hi
    <b>All the Local as well as the R/3 data gets stored in the SRM tables ->
    BBP_PAYTERM (Terms of Payment, Backend-Dependent)
    BBP_PAYTERM_TEXT ( Texts for Terms of Payment, Backend-Dependent)
    BBP_TQ02B ( QM System)
    BBP_TQ02U (Description QM system)
    Also refer to Transaction SLG1 for the log created in this case.</b>
    Hope this will help.
    Please reward suitable points.
    Regards
    - Atul

  • Guide me for exporting and importing data from oracle 10g to oracle 9i

    I have been trying export and import options in oracle but m not very clear about the procedure..
    Also when i am logging in as Scott/tiger i am facing an error
    ORA 1542 - tablespace 'USER' is offline and cannot allocate space in it.how to resolve it

    Hello,
    I see two questions.
    ORA 1542 - tablespace 'USER' is offline and cannot allocate space in it.how to resolve it About the error ORA-01542 you have to bring the Tablespace USERS online:
    http://www.error-code.org.uk/view.asp?e=ORACLE-ORA-01542
    If you cannot bring it online you may have to Recover it first.
    I have been trying export and import options in oracle but m not very clear about the procedure..About the Export in 10g and Import in 9i (9.2 or 9.0.1 ?), you have to export with the Export utility of the Target Database (the lowest Database version here: 9.0.1 or 9.2) then, you have to Import to the Target Database using its Import utility (in 9.0.1 or 9.2).
    The following Note of MOS may guide you:
    Compatibility Matrix for Export And Import Between Different Oracle Versions [Video] [ID 132904.1]
    NB: You cannot use here the DATAPUMP.
    Hope this help.
    Best regards,
    Jean-Valentin

  • What's the best approach/program for finding and eliminating duplicate photos on my hard drive?

    What's the best approach/program for finding and eliminating duplicate photos on my hard drive? I have a "somewhat" older version of iPhoto (5.0.4), and it doesn't seem to offer anything like that except during the importing phase of syncing my phone...

    I wonder, is there room to transfer them to your phone, & then back to filter them?

  • ABAP program for BAPI and convert DB into XML

    ABAP program for BAPI and convert DB into XML
    Thank you,
    Regards,
    Jagrut BharatKumar Shukla

    Refer the link -
    give an example of bapi coding?
    how can we transfer huge amount of data from database server to xml format
    Regards,
    Amit
    Reward all helpful replies.

  • Need a perfect example program for ALV GRID LIST

    first hi to all,i am new to this community.i am still in learning process of SAP.one of my friend suggeted this community and i think this is the perfect place to learn and excel my skill in SAP.so my requirement is a perfect example program for ALV GRID LIST DISPLAY.while i am trying another program,the sysntax is ok but i am not getting any output and it is not showing any error also.hope i will get an answer asap.thank you.

    Check [OO ALV Guide Simple|http://wiki.sdn.sap.com/wiki/display/ABAP/OBJECTORIENTEDALV+Guide] and [Easy Reference to ALV|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907]

  • Is it possible to export contacts  from Outlook 2011 for Mac and importing this file back into Mac Address Book.? please reply me its urgent

    Is it possible to export contacts  from Outlook 2011 for Mac and importing this file back into Mac Address Book.? please reply me its urgent

    Is it possible to export contacts  from Outlook 2011 for Mac and importing this file back into Mac Address Book.? please reply me its urgent

  • How to create schema for Header and Footer with pipe delimiter file BPEL11g

    Hi all,
    I have issule creating Schema for Header and Footer with body file .The file format is Pipe delimiter.The following format below like is...
    Softeware Components:File Adapter(Read) 11g,
    1|1211|000|577|5444
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|4544|000|yted
    I hope get the sollution for this from this Forum..Please help me out..Thankyou.

    You mean how many rows or columns..?
    If coloumns means 5 and rows only one(1).

  • Duplicates.  I use iTunes match.  When I run exact duplicates, I get duplicates that say uploaded for one and uploaded with a cloud for the other.  Which one do I delete?

    Duplicates.  I use iTunes match.  Two questions:
    When I run exact duplicates on the library on my Mac Air, I get duplicates that say uploaded for one and uploaded with a cloud for the other.  Which one do I delete?
    Some of the duplicates say matched and matched with a cloud.  Same question - which one should I delete?

    I'm not sure I understand the question.
    First I would update your iTunes match.  iTunes match will tell you what is duplicates and then you can just delete them from the library. 
    Second, the course in a situation like this is to delete ONE duplicate and see what happens.  Make sure you have that song backed up somewhere just incase it deletes it completely.  But usually I'd delete one and then see if it deletes both or just the one you pressed. 
    Thirdly, update iTunes match.  It usually does a good job of locating actual duplicates.

  • Hello, I want to make DPS magazin for IOS and Android with a lot of text footnotes. There is about 200 footnotes per article. The idea is to make pop-up windows like in EPUB 3.0. Please help.

    Hello, I want to make DPS magazin for IOS and Android with a lot of text footnotes. There is about 200 footnotes per article. The idea is to make pop-up windows like in EPUB 3.0. Please help., Hello, I want to make DPS magazin for IOS and Android with a lot of text footnotes. There is about 200 footnotes per article. The idea is to make pop-up windows like in EPUB 3.0. Please help.

    Remember you can only build an iPad app using your Single Edition solution (which is included in your CC membership). So you'd need a Pro or Enterprise version of DPS to be able to create the Android version.
    You can create pop-ups in InDesign using the slideshow options and a multi-state object. But it's all manual labour so you'll spend a lot of time on this, also depending on the layout of your design.

Maybe you are looking for