How to use subroutine in user-exit program

Hi Experts,
    I have a requirement in user-exit where i have to use some lines of code in several times. So i want to use Perform and perform inside the exit (i.e. Include ZXXX). But it is not recognizing the form part of the ubroutime and gives error.
             Please let me know how to use the Perform and form statement in the exit or is there any way to  write repeated code once but used no of times in exit program.
Thanks
Ajit

I'm sorry, I was overly harsh there. Please accept my apologies.  But I do despair sometime!
Consider the structure of a function group and it should be clear - you need to remember that INCLUDES are just repositories of code. If you take the contents out of the include and put them into the main program, then this is what you get:
function-pool xrsr.        
* Global data definition.
function exit_saplrrs0_001.
* the source code within the zxrsru01 include.
endfunction.
Now, what you're trying to do, is create a form in your include. You can't do that, because you end up with:
function-pool xrsr.        
* Global data definition.
function exit_saplrrs0_001.
  perform xyz.
  form xyz.
  endform.
endfunction.
And you can't have a FORM defined inside a function module definition. The solution is to put it outside the function module. If you follow the process suggested above, you end up with
function-pool xrsr.        
* Global data definition.
function exit_saplrrs0_001.
  perform xyz.
endfunction.
form xyz. " This will be in LXRSRF01
endform.
Do you see how it works now?

Similar Messages

  • How to find the exact user exit for our requirement?

    Dear Mr. keerthi,
    can you please explain me how to find the exact user exit for our requirement?

    Hi sandip
    There is more than one method in which you can check for user-exits.The following method is used very often.
    <b>How to find the exact user-exit for your requirement.</b>
    1.     You can check the user exists using transaction SE85.
    2.     Repository Information System -> Enhancements -> Customer exits
    3.     You can search the user-exits by package name.
    4.     Double click on each exit name to check the function module exits.
    <b>The procedure to find the package name.</b>
    Execute transaction SE93 
    Enter the tcode of the transaction for which you want to check the user exit.
    Example: if you want to find the user-exit for purchase orders while changing, enter ME22n  and press display.
    You will get to see the package name
    But you need to confirm that the user exit will get triggered at the appropriate event.
    ( example: you might want some validations to be done ON SAVE of a purchase order)
    <b>Checking if the user-exit is getting triggered or not.</b>
    1.     Open the user exit function module (that you have got in step 4) in Tcode SE37.
    2.     Click on where used button. In the pop up that immediately appears choose only programs .
    3.     You will get a list of programs. Double click on the program name.
    4.     You will get the list of location where this function module user exit is used.
    5.     Place session break points at each of these location ( at each CALL FUNCTION statement)
    6.     Now go to your transaction ( say change purchase order tcode:Me22n) and check if the user exit is getting triggered on appropriate event.
    regards,
    Prasad

  • How to find the ME29N 'USER EXIT' when our save the release PO after.

    How to find the ME29N 'USER EXIT' when our save the release PO after.
    which user exit will be used?
    thanks.
    alex.

    Hi,
      process :
        go to tranx code :   ME29N ,
           System---->Status , here copy the program name (SAPLMEGUI),
         go to abap editor and specify the program name SAPLMEGUI and find the package "ME".
         tranx code : CMOD ,  Utilites--->Sap Enanchement,
                                         specify the package name : ME
                                          and execute, displays a list of exits ,
                                 and find out our suitable exit based on requirement.
    check these :   EXIT_SAPMM06E_021
    reg
    Siva

  • How to find a correct User-Exit

    Hi All
          I need to make changes in the user exit and there are many user-exits in the standard program here my question is how to find the correct user-exit which suits our requirement.
    Thanks
    srini

    run this program by giving ur t code...and click the exit it will go to SMOD there u read the documentation of that exit..if ur requirement satisfies try to use that one..
    REPORT  ZUSEREXIT.
    *report zuserexit no standard page heading.
    tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
    tables : tstct.
    data : jtab like tadir occurs 0 with header line.
    data : field1(30).
    data : devclass like tadir-devclass.
    parameters : tcode like tstc-tcode obligatory.
    select single * from tstc where tcode eq tcode.
    if sy-subrc eq 0.
    select single * from tadir where pgmid = 'R3TR'
                      and object = 'PROG'
                      and obj_name = tstc-pgmna.
    move : tadir-devclass to devclass.
    if sy-subrc ne 0.
       select single * from trdir where name = tstc-pgmna.
       if trdir-subc eq 'F'.
         select single * from tfdir where pname = tstc-pgmna.
         select single * from enlfdir where funcname = tfdir-funcname.
         select single * from tadir where pgmid = 'R3TR'
                            and object = 'FUGR'
                            and obj_name eq enlfdir-area.
         move : tadir-devclass to devclass.
       endif.
    endif.
    select * from tadir into table jtab
                   where pgmid = 'R3TR'
                     and object = 'SMOD'
                     and devclass = devclass.
    select single * from tstct where sprsl eq sy-langu and
                                      tcode eq tcode.
    format color col_positive intensified off.
    write:/(19) 'Transaction Code - ',
          20(20) tcode,
          45(50) tstct-ttext.
    skip.
    if not jtab[] is initial.
       write:/(95) sy-uline.
       format color col_heading intensified on.
       write:/1 sy-vline,
              2 'Exit Name',
             21 sy-vline ,
             22 'Description',
             95 sy-vline.
       write:/(95) sy-uline.
       loop at jtab.
         select single * from modsapt
                where sprsl = sy-langu and
                       name = jtab-obj_name.
         format color col_normal intensified off.
         write:/1 sy-vline,
                2 jtab-obj_name hotspot on,
               21 sy-vline ,
               22 modsapt-modtext,
               95 sy-vline.
       endloop.
       write:/(95) sy-uline.
       describe table jtab.
       skip.
       format color col_total intensified on.
       write:/ 'No of Exits:' , sy-tfill.
    else.
       format color col_negative intensified on.
          write:/(95) 'No User Exit exists'.
    endif.
    else.
    format color col_negative intensified on.
    write:/(95) 'Transaction Code Does Not Exist'.
    endif.
    at line-selection.
    get cursor field field1.
    check field1(4) eq 'JTAB'.
    set parameter id 'MON' field sy-lisel+1(10).
    call transaction 'SMOD' and skip first   screen.

  • How can I find the USer Exit...

    Hi,
    How can I find the USer Exit...
    I need to do changes for this User Exit :EXIT_SAPLKEII_002
    In which T-code I can open this Exit
    Ex: Go to some Transcation code and then give the name of the Exit ato access this Exit
    ...any sugesstions will be apprecaited!
    Thanks & Regards,
    Kittu

    Hi,
        the EXIT : EXIT_SAPLKEII_002 is the exit,in this SAPLKEII is the standard Program.Copy this program and go to transactio SE38 and press Enter and then go for the option Where used list and check the check box Transaction. It displays the possible Transactions that the Exit triggers
    Regards,
    Vijaya Lakshmi.T

  • How to find out the user-exits?

    hi.
    how to find out the user-exits?
    regards
    eswar.

    Hi,
    *& Report  ZEXITFINDER
    *report  zexitfinder.
    *& Enter the transaction code that you want to search through in order
    *& to find which Standard SAP User Exits exists.
    *& Tables
    tables : tstc, "SAP Transaction Codes
    tadir, "Directory of Repository Objects
    modsapt, "SAP Enhancements - Short Texts
    modact, "Modifications
    trdir, "System table TRDIR
    tfdir, "Function Module
    enlfdir, "Additional Attributes for Function Modules
    tstct. "Transaction Code Texts
    *& Variables
    data : jtab like tadir occurs 0 with header line.
    data : field1(30).
    data : v_devclass like tadir-devclass.
    *& Selection Screen Parameters
    selection-screen begin of block a01 with frame title text-001.
    selection-screen skip.
    parameters : p_tcode like tstc-tcode obligatory.
    selection-screen skip.
    selection-screen end of block a01.
    *& Start of main program
    start-of-selection.
    Validate Transaction Code
    select single * from tstc
    where tcode eq p_tcode.
    Find Repository Objects for transaction code
    if sy-subrc eq 0.
    select single * from tadir
    where pgmid = 'R3TR'
    and object = 'PROG'
    and obj_name = tstc-pgmna.
    move : tadir-devclass to v_devclass.
    if sy-subrc ne 0.
    select single * from trdir
    where name = tstc-pgmna.
    if trdir-subc eq 'F'.
    select single * from tfdir
    where pname = tstc-pgmna.
    select single * from enlfdir
    where funcname = tfdir-funcname.
    select single * from tadir
    where pgmid = 'R3TR'
    and object = 'FUGR'
    and obj_name = enlfdir-area.
    move : tadir-devclass to v_devclass.
    endif.
    endif.
    Find SAP Modifactions
    select * from tadir
    into table jtab
    where pgmid = 'R3TR'
    and object = 'SMOD'
    and devclass = v_devclass.
    select single * from tstct
    where sprsl eq sy-langu
    and tcode eq p_tcode.
    format color col_positive intensified off.
    write:/(19) 'Transaction Code - ',
    20(20) p_tcode,
    45(50) tstct-ttext.
    skip.
    if not jtab[] is initial.
    write:/(95) sy-uline.
    format color col_heading intensified on.
    write:/1 sy-vline,
    2 'Exit Name',
    21 sy-vline ,
    22 'Description',
    95 sy-vline.
    write:/(95) sy-uline.
    loop at jtab.
    select single * from modsapt
    where sprsl = sy-langu and
    name = jtab-obj_name.
    format color col_normal intensified off.
    write:/1 sy-vline,
    2 jtab-obj_name hotspot on,
    21 sy-vline ,
    22 modsapt-modtext,
    95 sy-vline.
    endloop.
    write:/(95) sy-uline.
    describe table jtab.
    skip.
    format color col_total intensified on.
    write:/ 'No of Exits:' , sy-tfill.
    else.
    format color col_negative intensified on.
    write:/(95) 'No User Exit exists'.
    endif.
    else.
    format color col_negative intensified on.
    write:/(95) 'Transaction Code Does Not Exist'.
    endif.
    Take the user to SMOD for the Exit that was selected.
    at line-selection.
    get cursor field field1.
    check field1(4) eq 'JTAB'.
    set parameter id 'MON' field sy-lisel+1(10).
    call transaction 'SMOD' and skip first screen.
    Regards

  • How to find out appropriate user exit

    Hi,
    I want to know how to find out the user exit that matches to the requirement. Suppose for a material master program, there are so many include programs hence im unable to find call custer-function and even unable to debug an appropriate include. Please help me out how to learn user exits in a rightious way.
    Thanks
    Basu

    Look for program SAPICSS_ in your system and run it. This program can also be found under CMOD menu:  Utilities -> SAP enhancements.
    This will only give you the CMOD user exits.
    There is a program someone made that searches for all sorts of user-exits (including BADI's etc.). I remember that it was posted on sapfans.com
    Edited by: Maen Anachronos on Apr 6, 2009 3:22 PM

  • How to find the appropriate user exit for invoic02 idoc in idoc_output_invo

    Hi all,
    I am new to this community p
    i have issue regarding  the How to find the appropriate user exit for invoic02 idoc in idoc_output_invoic function module.........
    thanks,

    Hi ,
    welcome to SDN.
    You can select the appropriate Customer exit accrding to the available parameters .
    The list of exits available are 
    EXIT_SAPLVEDF_001
    EXIT_SAPLVEDF_002
    EXIT_SAPLVEDF_003
    EXIT_SAPLVEDF_004
    For Example , if you want  to modify the Idoc data(EDIDD) you have to use the EXIT_SAPLVEDF_002. accodingly you can select the user exit according to the avaialable parametres.Use Table MODSAP fto get the Enhancement name.
    Hope this Helps
    Rgds
    Sree
    Edited by: Sree on Jul 23, 2010 12:11 PM

  • How to call subroutines defined in ABAP program with type S

    how to call subroutines defined in ABAP program with type S? can you give an example?

    Normal executable program,
    REPORT  ZTEST_MAIN.
    perform sub1 in program ztest_sub.
    "you can call using in program addition
    Subroutine pool program
    PROGRAM  ZTEST_SUB.
    form sub1.
    endform.

  • Change MOT in purchase order using CIF Inbound user exit

    Hello APO Experts,
    Objective is to change start date of purchase order ( date at source location) in APO based on some date in R3.
    Planning to bring R3 date using CIF Outboud user exit( CIFPUR01)  in R3 and then further requirement is to a) calculate lead time in inbound user exit ( APOCF006) of purchase order in APO   b) compare it with lead time of all available Means of Transport in that particular TLane  and select  one MOT say XX which matches that lead time c) Next part is to change existing MOT in the Purchase order and replace it with the new XX MOT.
    For part c....I am wondering how can we change existing MOT in purchase order and replace it with a new one.Can it be achieved by the user exit APOCF006 in APO or something else is required.
    Will appreciate your quick reply on this issue.
    Thanks
    Best Regards

    Hi Nilesh
    We have a similar requirement. I know its way long for you to remember but i would appreciate if you could share what did you do to achieve this.  
    Thanks
    Abhishek Rai

  • User Exit Program works Differently

    I'm trying to sync user info from HCM system to a destination system. There is a limitation in SAP HCM system, which allows only full load and not incrememental load or sync up based on events(New Joinee, Position change, Employee Exit) to happen from source to destination. So, I thought User exit could fix this issue.
    When a person inserts or changes or changes the status of an employee to quit through PA30 and saves it, the user exit program should pass the personnel number (numbers) of the user(s) as input to the report RPLDAP_EXTRACT_IDM.
    I am trying to trigger a report(RPLDAP_EXTRACT_IDM) which exports the data from HCM to a destination system(IDM) with the help of a user exit program. Using PA30 when I change the user info and when I save it, through User exit program I'm passing the personnel number of the user(whose data has been changed) as an input to the report, which inturn will replicate the change to the destination.
    Problem:
                User Exit works differently here. After configuring User exit for this tcode(PA30), once I change a user's info and click save, without saving the data, it triggers the User exit program. Usaully while chanign user info, when I click 'SAVE', i get a message 'Recod changed', but now after sonfiguring User Exit program, since the program runs immediately as soon as i click SAVE, I see the following message' Successfully exported Data to the destination' . And the change that i make is not reflected.
    Shouldn't the User Exit program be triggerred after the data is saved?
    Is there a way where I can trigger the User Exit Program after saving the record.

    Not an ABAP expert, but I remember hearing something about PAI and PBO modules and separate user exit includes depending on where you are executing it. Is it worth investigating on these lines?
    Also is it worthwhile configuring Change Pointers to capture whether a change has been made instead of coding user exits in PA30. You could code uxerexits in the ALE data transfer program to analyse the data based on change pointers and transfer data pertaining to New Joinees etc.
    Again I am not ALE epxert, I am just giving my views For what they are worth. For better results perhaps you should post in ABAP forum.

  • How to use an authenticated user for a proxy call

    Dear all,
    I am currently working on a JEE application where the user needs to authenticate (for this I have configured the web.xml).
    Now inside this application I need to do a proxy call to a PI webservice.
    I would like to use the user credentials of the already logged in user in order to call the proxy.
    What I don't want to do is to use a service user for the proxy call.
    The code I am trying to call looks something like this:
         private IntegratedConfigurationIn getPort() throws Exception{
              IntegratedConfigurationIn port = null;
              try {
                   IntegratedConfigurationInService service = null;
                   service = new IntegratedConfigurationInService();
                   port = (IntegratedConfigurationIn) service.getIntegratedConfigurationIn_Port();
                  BindingProvider bp = (BindingProvider)port;
                  bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, user);
                  bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
                  if (url.length() != 0)
                       bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
              catch (Exception ex){
                   ex.printStackTrace();
              return port;
    The examples I found to retrieve the userdata pointed to codes similar to this one:
    public HttpServletRequest getHttpRequest() throws Exception {
              // Get runtime context
              Properties props = new Properties();
              props.put("domain", "true");
              Context initialContext = new InitialContext(props);
              ApplicationWebServiceContext wsContext = (ApplicationWebServiceContext) initialContext
                        .lookup(" /wsContext/ApplicationWebServiceContext");
              HttpServletRequest req = wsContext.getHttpServletRequest();
              return req;
    com.sap.security.api.IUser sapUser = com.sap.security.api.UMFactory.getAuthenticator().getLoggedInUser(getHttpRequest(), null);
              IUser ep5User = com.sapportals.wcm.util.usermanagement.WPUMFactory.getUserFactory().getEP5User(sapUser);
    Now I don't know how to bring it togehter and how to use an authenticated user for the BindingProvider.
    I would appreciate any hints or ideas.

    Peter,
    from the first screenshot, what I understood is that, you are calling an inbound PI web service that is intended to create an integrated configuration object (this is used for whole lot of other reason completely) but not actually calling a development web service.
    For this, you would have to generate your client classes from the WSDL provided by the PI developer for that particular service. Once you get those client classes generated, you could used the method provided in the other screenshot to extract the user and password and call the intended web service.
    Vijay Konam

  • How to find out all user exits edited

    Hi All,
    Would you know how to find out all user exits have been ever edited?
    Can we find out those user exit by some tcode or table?
    Thank you very much
    Best Regards,
    Calvin
    Edited by: Sam Sum on Mar 2, 2009 5:09 AM

    Hi,
    Just try this in your system.
    Go to SE38 and give ZX* and press F4.
    Have a look at table MODATTR to find the active projects in your system.
    Regards
    Edited by: Rajvansh Ravi on Mar 2, 2009 5:17 AM

  • How to use the admin user account in reports and dashboards?

    Hi Everyone,
    I want to use the admin user account in report and dashboard connections. But the Hyperion is automatically using the current user's credentials to fetch data.
    Hyperion 11.1.1.1
    Thanks
    Syantan

    This has been posted in the essbase forum > How to use the admin user account in reports and dashboards?
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Using Perfrom in User exit

    HI Gurus,
    can u use perform in user exit , say for example i am enhasing a data source 2LIS_11_VAITM , can i use the PERFORM xxxxxxx.
    FORM XXXXX.
    SOME CODE .
    ENDFORM.
    When i am trying to do this is am getting error sating
    " Incorrect nesting: Before the statement "FORM", the structure ,introduced by "LOOP" must be concluded by "ENDLOOP". -     "
    can any one suggest what is the probelm..

    Hi,
    Please check if you're used a LOOP somewhere and not closed it properly.
    In any case its better to go with a Function module in a user exit.
    Cheers,
    Kedar

Maybe you are looking for

  • [SOLVED] Problem with .htaccess and user dirs.

    Hi!.. I write here because i have a problem with .htaccess files and url rewrites. I deployed a Cakephp[1] app in my /home/~asmerkin/public_html/books directory. This folder contains a .htaccess file with the following directives: <IfModule mod_rewri

  • Can you have two itunes accounts on a single phone?

    Is it possible on an iphone 5s to have two itunes accounts? My child is getting to an age, where they should have their own itunes account.  We share music and applications and i do not want to have to re-buy everything?

  • Zero Apps Installed after update

    Hi, My creative cloud updated itself 2 days ago to version 1.2.1.260... just now I found out that it says I have no CC apps installed, whereas all the apps I installed previously are working properly. No real harm, but my concern is, if CC doesn't se

  • Create Contract from PR

    Hi All, When i am trying to create a contract from PR, i see two options in the screen "Create Contract : Selection List: Purchase Requisitions" 1) Adopt +Details 2) Adopt Can anybody tell what is the difference between option 1 and 2 above?

  • Name of connection in package name tab?

    Hello Is it possible to add the name of the connection in the tab name? When I have to open connections this would be handy. Something like : p_utils (user@dev) other tab: p_utils (user@tst) Kind regards Erik