Exception handling for a standard SAP Function Module - the OO way

Hello,
I was wondering what is the correct way to call a standard SAP function module inside a method of global class.
I want to display the error via the:
get_text( ) and get_longtext( ) methods.
I don't want to use the sy-subrc check. Is this possible?
My example doesn't seem to work...
See example bellow:
DATA: ex_object_cx_root TYPE REF TO cx_root,
      ex_text TYPE string,
      ex_text_long TYPE string.
TRY.
      CALL FUNCTION 'L_TO_CONFIRM'
        EXPORTING
          i_lgnum                        = i_lgnum      " Warehouse number
          i_tanum                        = i_tanum      " Transfer order number
          i_quknz                        = '1'          " '1' - confirm withdrawal only (picking )
          i_commit_work                  = 'X'          " Indicator whether COMMIT WORK in function module
        TABLES
          t_ltap_conf                    = it_ltap_conf " Table of items to be confirmed
        EXCEPTIONS
          to_confirmed                   = 1    " Transfer order already confirmed
          to_doesnt_exist                = 2
          item_confirmed                 = 3
          item_subsystem                 = 4
          to_item_split_not_allowed      = 51
          input_wrong                    = 52
          OTHERS                         = 53.
    CATCH cx_root INTO ex_object_cx_root.
      ex_text = ex_object_cx_root->get_text( ).
      ex_text_long = ex_object_cx_root->get_longtext( ).
      " Error:
      RAISE EXCEPTION TYPE zcx_transfer_order
        EXPORTING textid = zcx_transfer_order=>zcx_transfer_order
             err_class = 'ZCL_WM_TRANSFER_ORDER'
             err_method = 'CONFIRM_TO_2STEP_PICKING'
             err_message_text = ex_text
             err_message_text_long = ex_text_long.
  ENDTRY.
Thank you very much in advance

Hello Marko,
If i understand correctly you've enclosed the call to the FM 'L_TO_CONFIRM' inside the TRY ... CATCH ... ENDTRY block.
CATCH cx_root INTO ex_object_cx_root.
      ex_text = ex_object_cx_root->get_text( ).
      ex_text_long = ex_object_cx_root->get_longtext( ).
You can't do this because the FM 'L_TO_CONFIRM' doesn't propagate OO exceptions!
Your approach is almost correct, what you've to do is goes like this:
CALL FUNCTION 'L_TO_CONFIRM'
  EXPORTING
    i_lgnum                        = i_lgnum      " Warehouse number
    i_tanum                        = i_tanum      " Transfer order number
    i_quknz                        = '1'          " '1' - confirm withdrawal only (picking )
    i_commit_work                  = 'X'          " Indicator whether COMMIT WORK in function module
  TABLES
    t_ltap_conf                    = it_ltap_conf " Table of items to be confirmed
  EXCEPTIONS
    to_confirmed                   = 1    " Transfer order already confirmed
    to_doesnt_exist                = 2
    item_confirmed                 = 3
    item_subsystem                 = 4
    to_item_split_not_allowed      = 51
    input_wrong                    = 52
    OTHERS                         = 53.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
          INTO ex_text. "Get the ex_text by this technique & not by CX_ROOT->GET_TEXT()
ENDIF.
I'll have to check how to fetch the long text of the message
BR,
Suhas

Similar Messages

  • Replacement for fuction CONVERSION_EXIT_ALPHA_INPUT SAP Function module

    hi folks..
    do we have any replacement in terms of codes for the fuction CONVERSION_EXIT_ALPHA_INPUT SAP Function module.. i know the use of this fuction module as it converts data in numeric format to character format which is only accpetable in SAP.. cant we do it manualy using the abap codes.. or else it is the only option to do so????

    Hi Ram,
    I guess Isaac got a little confused, anyways try the below code, forgot to add...just curious to know the reason behind your post...any specific reason why you want to avoid the FMs.
    DATA: l_vbeln TYPE vbeln VALUE '12345',
          l_overlay TYPE vbeln VALUE '0000000000'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input         = l_vbeln
    IMPORTING
       OUTPUT        = l_vbeln.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        input         = l_vbeln
    IMPORTING
       OUTPUT        = l_vbeln.
    * Code to replace Conversion exit alpha input
    SHIFT l_vbeln RIGHT DELETING TRAILING space.
    OVERLAY l_vbeln WITH l_overlay.
    * Code to replace Conversion exit alpha output
    SHIFT l_vbeln LEFT DELETING LEADING '0'.
    IF sy-subrc EQ 0.
    ENDIF.
    Regards,
    Chen
    Edited by: Chen K V on Jun 2, 2011 2:17 PM
    Edited by: Chen K V on Jun 2, 2011 2:18 PM

  • How to find the Access Key of Standard SAP Function Module

    Hi Experts,
    I have to change one sap standard function module.
    so how can i know the access key for that function module.......
    Regards,
    DS

    Contact the Basis Consultant in your project.
    The access key for standard SAP objects can be obtained from service.sap.com under Keys and Requests.
    Note 86161 - Registering developers and objects

  • How to CATCH error from call to standard SAP Function Module

    Please, is it possible to catch the following error with the TRY CATCH ENDTRY construct?
    From a custom program, am calling CS_BOM_EXPL_MAT_V2.
    Several nested calls in, Form STL_DATEN_HOLEN (LCSS4F1I) calls FM CS_ALT_SELECT_MAT. 
    However, that call is missing the CALL_INVALID Exception. 
    CS_ALT_SELECT_MAT is raising CALL_INVALID, but since it was not included in the FM call, the RAISE_EXCEPTION runtime error is issued.
    I added a TRY CATCH ENDTRY construct around the call in the custom program using CATCH cx_root, but the program is still short dumping.
    All the research I have done has been misleading...some articles indicate all errors should be caught, some indicate only catchable runtime errors can be caught, others are not quite clear.
    So, I would like to find out if, in this scenario, it is even possible to catch this error and avoid the short dump.
    I will open a message to see about having the SAP code fixed as soon as I get authorization to do so, (as well as fix the data causing the issue in the first place), but in the meantime, I would like to handle it in my code if possible.
    ECC 6.0
    Thanks for any information!
    Kind Regards,
    Deb
    Edited by: Debra Garner on Jan 26, 2012 5:19 PM

    Hi Debra,
    You cannot catch non class based exceptions using the TRY/ENDTRY.  You might also find no luck with help from SAP since the FM in question 'CS_BOM_EXPL_MAT_V2' is not released for customer use.  The best bet is to examine why the error is occurring and figure out what needs to be done to fix it and/or avoid it in the future.
    Regards,
    Ryan Crosby

  • SAP Functional Module for authorization tables

    I would like to know are there any standard SAP Functional Modules which could update the Authorization Tables, like AGR_1251.
    Thank you

    Hi Prabhu,
    Other than function modules with role, I had also tried to look for function modules with AuthObject*.
    Because, I would like to update remove one of the authorization object from the system. For example, remove all data which AUTHORIZATION OBJECT = S_SCD0 and ACTIVITY = 06 in the system.
    I got the list of functions from the search, but all of them are without proper documentations. So is very hard for me to understand their functionalities and purposes.
    Kindly advice.
    Thank you.

  • Standard remote function module (HR)

    Hi all,
    I'm looking for a standard remote function module to get data from Actions (0000) infotype (Employement Status).
    where/how can I find it?
    thx

    To be honest, if your only requirement is to get data out of Infotype 0, then it would be very easy to create your own Z function module on R3, flag it to be RFC enabled and select the data straight out of PA0000.

  • Exception Handling for a function module

    There is a function module the program in which exceptions are handled. When the program is ran as a background job and when there is a exception arises does the background job fails or the exception gets handled ??? Pls help me out.....

    it raises an exception you can catch it.
    cx_root is the root class for exceptions.
    DATA: ex TYPE REF TO CX_ROOT.
    TRY.
    call fm.
    CATCH cx_root INTO ex.
    ENDTRY.
    message = cx_root->get_text( ).
    this way your program will not stop..
    regards,
    Aparna

  • Module pool / Screen Prog is there any standard SAP functionality ?

    Hi I am creating a Module pool / Screen Prog. On this screen I have nearly 100 fileds , now I want to take print out of all the information shown on the screen for the same is there any standard SAP functionality ?
    Does SAP provides any standarar ready made functionality for the same. ?

    No, there is no standard functionality for this.  dynpros are not designed to "print out".  This is what list displays are for.  That said, you will need to write your logic to kick off  a list display with all of your field values there,  then the user can print.
    Regards,
    Rich Heilman

  • Documentation for SAP function modules??

    Hello,
    is there any documentation for the SAP function modules available?
    I need documentation for SJ01 (SAP Objects). If I try to view the documentation in SE80, I get the error message: "Document OJ_XXX(whatever I selected) is not available in language DE"
    Where can I get this documentation?
    Is there an overview+documentation available somewhere of all SAP functions which may be used for own programs? Or how do I know what's already available and how to use it?
    Thanks
    Steffi

    Hi,
    Go thru this links
    http://sap.ittoolbox.com/topics/t.asp?t=303&p=449&h2=322&h1=303&h3=449
    http://www.erpgenie.com/abap/functions.htm
    Thanks
    Sunil

  • SAP Function Module Converting Stock UoM to the Billing UoM of the material

    Hi Guys,
    I'm looking for an SAP Function Module that can handle the automatic conversion of a material's Stock Unit of Measure into its Billing Unit of Measure.
    Any idea? 
    Thank you in advance.
    -allex

    Hi,
         Check this Function module
    OIU_QCI_CALC_BILLING_QUANTTIES
    Regards
    Bala Krishna

  • How to find CUSTOMER EXIT for a Standard SAP program

    How to find CUSTOMER EXIT for a Standard SAP program

    Hi
    To introduce the techniques of enhancement in standard SAP system. SAP creates customer exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.
    They do not affect standard SAP source code.
    When you add new functionality to your SAP System using SAP’s exits, you do not alter the source code of standard SAP programs in any way. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but exist separately from SAP’s standard software package.
    They do not affect software updates.
    When you add new functionality to your SAP System using SAP’s exits, your objects (called customer objects) must adhere to strict naming conventions. When it comes time to upgrade a to a new software release, customer objects’ names ensure that they will not be affected by any changes or new additions to the standard software package.
    Customer exits are not available for all programs and screens found in the SAP System.
    Any change made to an SAP object in a customer system is called a modification. Customers usually modify their systems for one of two reasons. Either they make changes to the SAP standard in order to adjust the R/3 System to their specific business needs (actual modifications), or they alter individual SAP objects in order to correct an error (as recommended in an SAP error note).
    You should only modify the SAP standard if the modifications you want to make are absolutely necessary for optimizing work flow in your company. Be aware that good background knowledge of application structure and flow are important prerequisites for deciding what kind of modifications to make and how these modifications should be designed.
    SAP application programmers create SAP enhancements in transaction SMOD using function module exits, menu exits, and screen exits.
    Customers are given a catalog containing an overview of existing SAP enhancements. They can then combine the SAP enhancements they want into an enhancement project using transaction CMOD.
    SAP enhancements are made up of component parts. These components include function module exits, menu exits, and screen exits. A specific component may be used only once in a single SAP enhancement (this guarantees the uniqueness of SAP enhancements).
    Customer enhancement projects consist of SAP enhancements. Each individual SAP enhancement may be used only once in a single customer enhancement program (this guarantees the uniqueness of a customer project).
    SAP application programmers preplan function module exits, menu exits, and screen exits for their applications and combine them to create useful enhancements for the R/3 System.
    Customers create their own enhancement projects for their systems using SAP enhancements. You can customize the individual components of an enhancement project by creating your own include programs (for function module exits), texts (for menu exits), and subscreens (for screen exits).

  • Reading SAP function modules using FromSAPIdentity pass

    Hi,
    We have SAP NW IDM 7.2 SP7 environment
    And I have been using FromSAPIdentity pass to read SAP function modules.
    A typical configuration will looks like below
    Above works like a charm and everything is as expected :-)
    Now i am trying to fetch data from another function module.
    Here the challenge is import parameter entry need to be provided with selection criteria say something like below for PARAMETER1
    SIGN=E
    OPTION=EQ
    LOW=<Value>
    HIGH=<Value>
    Does FromSAPIdentity pass accepts selection criteria input for "PARAMETERS" ?
    If yes, which format should i follow to provide those values ?
    Thanks
    Karthik

    Use DD03L table .
    Also use this FM.
    F4_DD_TABLE_FIELDS
    DD_GET_DD03P

  • Crystal Reports Charting Issue with SAP Function Module

    I created a custom SAP Function module that returns 2 tables. The first table (summary table) contains two columns, column "a"  contains a grouping and column "b" is a quantity.  The second table is the detail and is linked to the first table by the grouping, column "a" , in both tables.  I can bring the function module into Crystal Reports, but cannot create a drill down using a pie chart off the summary table.  When I go into the Chart Expert - Data Tab only the Advance button is active and the Group, Cross-Tab, and OLAP buttons are deactivated.  First of all, is it possible to do this using a SAP Function Module, if yes, what am I doing wrong.

    hello Jhess,
    i am not sure if you found an answer for your question yet. if you have a Group and a Summary on your report (i.e. the Sum of your Quantity field) then group charts should be enabled.
    cheers,
    jamie

  • Create BW datasource on standard ECC function module MCEX02_02_SCL_GR

    Hello Experts,
    I plan to use standard ECC function module MCEX02_02_SCL_GR to get the GR dates for the PO Schedule Lines. I copied this function module with the BW function group and tried to create a datasource in RSO2. However I receive the following error
    ZMM_PO_GR: TABLES-paramter E_T_DATA for extractor MCEX02_02_SCL_GR is missing
    I understand that the template for BW function modules is RSAX_BIW_GET_DATA_SIMPLE. However is there any way I can use the standard ECC function module OR else how would I incorporate the code in MCEX02_02_SCL_GR into the RSAX_BIW_GET_DATA_SIMPLE template.
    Thanks for your help.
    Alnick

    create a DS based on FM and call MCEX02_02_SCL_GR into that FM using call funcation XXX destination.
    or
    create a table in BW with fields Client, Source system and FM..and then do select statement toa take source system and give in palce of destination.

  • Crystal reports from SAP function module

    Hi,
    How to create report based on SAP function module...
    I tried it and succeeded for one function module... but i need single report for 3 function modules.
    Please let me know i can get them,,, please....!!
    When i select all 3, it showing links, what about Links??
    Thank You!

    No one answered it so far...!!

Maybe you are looking for

  • Apple Mini-DVI to Video Adapter Question

    I want to hook up my macbook (late 2008 model) to my tv. Will the Apple Mini-DVI to Video Adapter work? If it will work on my tv then what else do I need to get? It looks like you need other wires to hook up to your tv? Thanks in advance for your hel

  • Purchased Acrobat 9 some time ago, on new install asking for an upgrade password

    Why is my Acrobat 9 not installing on my computer, i have enterd the password that came with the installation but i am being asked about an upgrade password, why, and i am being offerd a 30 day trile Can anyone help?

  • How to digitally record audio? (iPad to MAC)

    Hello, I am generating sounds internally in my iPad 3 and I play it through the earphones. The thing is that I would like to record the generated samples in its digital form using a MAC Book Pro. We are doing it doing in its analog form but we are no

  • EA6500 WAN IP Release Problem

    To all I need to switch back to my old router currently I am using the EA6500 in the GUI of the latest firmware there is no longer a button "Release IP Address" but it has been replaced with "Release and Renew" button this is causing that the IP addr

  • Why do 200 radio buttons in a form cause 8 second rendering delay

    We have an online questionnaire containing 36 questions, each with 6 radio buttons (216 in total) in a single form. Although the page appears to render quickly, there is then a delay in Firefox of up to 8 seconds before it will register a radio butto