Problem in calling ABAP Subroutine from SAPSCRIPT

Hi,
I need to get the reason for cancellation of a Business Even in Training & Event Management module, so I am passing Emp_id.
But the reason(CAAATRT) is returned with blank by the code.
please help.
/:DEFINE &EMP_ID&= &PPVAR-TOBJD&
/:PERFORM HR_REASON_PRINT IN PROGRAM ZHR_REASON_PRINT
/:USING &EMP_ID&
/:CHANGING &CAATRT&
REPORT  ZHR_REASON_PRINT.
DATA : BEGIN OF in_par OCCURS 10.
        INCLUDE STRUCTURE itcsy.
DATA : END OF in_par.
DATA : BEGIN OF out_par OCCURS 0.
        INCLUDE STRUCTURE itcsy.
DATA : END OF out_par.
DATA:   TOBJD TYPE PPVAR-TOBJD,
        ADATANR TYPE HRP1001-ADATANR,
        CAATR TYPE HRPAD25-CAATR,
        CAATRT TYPE T77CART-CAATRT,
        EMP_ID TYPE C.
TABLES     : PPVAR,
         HRP1001,
         HRPAD25,
         T77CART.
FORM HR_REASON_PRINT TABLES input output.
in_par[] = input[].
out_par[] = output[].
READ TABLE in_par INDEX 1.
CHECK sy-subrc = 0.
TOBJD = in_par-value.
MOVE in_par-value TO TOBJD.
SELECT ADATANR
into ADATANR
FROM HRP1001
WHERE OBJID EQ TOBJD.
ENDSELECT.
SELECT CAATR
into CAATR
FROM HRPAD25
WHERE ADATANR EQ ADATANR.
ENDSELECT.
SELECT CAATRT
INTO CAATRT
FROM T77CART
WHERE CAATR EQ CAATR.
ENDSELECT.
REFRESH out_par.
  out_par-name = 'DREASON'.
  move CAATRT To out_par-value.
  MODIFY out_par INDEX 1.
APPEND out_par.
  output[] = out_par[].
Thanks
Ramakrishna

Hi ramakrishna,
1. while calling subroutines from sapscripts,
there is a special technique,
which has got its own limitations.
2.
FORM abc
TABLES
in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
ENDFORM.
3. The perform in se38 program should be of the
above format only.
4. We cannot pass internal tables.
5. Rather we need to pass
VARIABLE NAME
VARIABLE VALUE
(see the structure of itcsy in se11)
6. In this form, we have to read
the internal table in_tab
to capture the variable name and its value.
7. Similary, to return the values,
we have to put one record (for each variable)
in out_tab.
regards,
amit m.

Similar Messages

  • Query regerding Sapscript : Calling abap subroutines

    Hello everybody
    Hope everyone is doing fine.
    I've a small query. Whenever we require to call an abap subroutine from an abap sapscript we do the same using PERFORM statement. The syntax for the same is as below:
    PERFORM SUBROUTINE_NAME IN PROGRAM PROGRAM_NAME
    USING &VARAIABLE&
    CHANGING &VARAIABLE&
    ENDPERFORM
    Here we are passing the varaiables to the subroutine and getting back values in varaibles. In the actual program we then read values from in_tab and out_tab having structures similar to itcsy.
    The above mentioned is as per my understanding. My query is as follows:
    If in the above statement instead of passing varaibles abnd getting back variables can be pass/get back an internal table?
    I had read somewhere that it is possible using structures. If anyone is aware of how to do the same can you please give me the syntax. Actually how to get value from subroutine into an internal table. What will be the structure? Will it be same as itcsy?
    Thanks a lot to everybody in advance.
    Thanks & Regards
    Kabir Radhakrishnani

    hi check this program!!!
    REPORT Z_TEST_VBBE .
    types : begin of t_vbap ,
             VBELN like vbap-VBELN,
             posnr like vbap-posnr,
             concat(18),
            end of t_vbap.
    tables : vbap .
    select-options : s_vbeln for vbap-vbeln .
    data : it_vbap type table of t_vbap ,
           wa_vbap type t_vbap.
    select vbeln posnr from vbap into table it_vbap
    where vbeln in s_vbeln .
    " group by vbeln.
    loop at it_vbap into wa_vbap .
      perform select_data using wa_vbap-vbeln
                                wa_vbap-posnr
                       changing wa_vbap-concat      .
      modify it_vbap from wa_vbap .
    endloop .
    *&      Form  select_data
    *form select_data using vbeln type vbap-vbeln
                          posnr type vbap-posnr
                          concat.
    *endform.                    " select_data
    *&      Form  select_data
    form select_data using    p_wa_vbap_vbeln
                              p_wa_vbap_posnr
                     changing p_wa_vbap_concat.
             concatenate p_wa_vbap_vbeln
                         p_wa_vbap_posnr
                    into p_wa_vbap_concat
                    separated by '|' .
    endform.                    " select_data

  • How to call a subroutine from sap script

    hi friends,
    Can anybody tell me How to call a subroutine from sap script .
    thanks n regards .
    Mahesh

    hi..
    Calling ABAP Subroutines: PERFORM 
    You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
    PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
    The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
    Syntax in a form window:
    /: PERFORM <form> IN PROGRAM <prog>
    /: USING &INVAR1&
    /: USING &INVAR2&
    /: CHANGING &OUTVAR1&
    /: CHANGING &OUTVAR2&
    /: ENDPERFORM
    INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
    OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
    The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
    FORM <form> TABLES IN_TAB STRUCTURE ITCSY
    OUT_TAB STRUCTURE ITCSY.
    ENDFORM.
    The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
    The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
    From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (‘First page’, ‘Next page’, ‘Last page’) is printed as local variable symbol.
    Definition in the SAPscript form:
    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
    /: USING &PAGE&
    /: USING &NEXTPAGE&
    /: CHANGING &BARCODE&
    /: ENDPERFORM
    / &BARCODE&
    Coding of the calling ABAP program:
    REPORT QCJPERFO.
    FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
    OUT_PAR STRUCTURE ITCSY.
    DATA: PAGNUM LIKE SY-TABIX, "page number
    NEXTPAGE LIKE SY-TABIX. "number of next page
    READ TABLE IN_PAR WITH KEY ‘PAGE’.
    CHECK SY-SUBRC = 0.
    PAGNUM = IN_PAR-VALUE.
    READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
    CHECK SY-SUBRC = 0.
    NEXTPAGE = IN_PAR-VALUE.
    READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
    CHECK SY-SUBRC = 0.
    IF PAGNUM = 1.
    OUT_PAR-VALUE = ‘|’. "First page
    ELSE.
    OUT_PAR-VALUE = ‘||’. "Next page
    ENDIF.
    IF NEXTPAGE = 0.
    OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
    ENDIF.
    MODIFY OUT_PAR INDEX SY-TABIX.
    ENDFORM.
    regards,
    veeresh

  • Calling ABAP Subroutines: PERFORM  example

    hi friends,
    Can any one give me an example on Calling ABAP Subroutines: PERFORM   or provide any links for that example already posted in sdn ...
    points will be awarded
    regards and thanks
    Vijaya

    hi
    With the PERFORM statement, you can call subroutines which are coded in the same ABAP program (internal calls), or subroutines which are coded in other ABAP programs (external calls).
    You can also specify the name of the subroutine dynamically at runtime, and call subroutines from a list.
    Internal Subroutine Calls
    To call a subroutine defined in the same program, you need only specify its name in the PERFORM statement:
    PERFORM <subr> http://USING ... <pi>...
    http://CHANGING... <pi>... .
    The internal subroutine can access all of the global data of the calling program.
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db978335c111d1829f0000e829fbfe/content.htm
    reward point if helpful.
    thanks

  • Call ABAP RFC From mapping

    HI Guys,
    I have a requirement to call ABAP RFC from Message Mapping.
    Can any one pls share the document links or ideas with me.
    Thanks,
    MS

    Hi
    u can use RFC LoopUp
    if PI 7.0 / 3.0 -- need to write the UDF to execute
    link
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70d90a91-3cf4-2a10-d189-bfd37d9c3231
    if PI 7.1 then u have functionality in MM itself to do so
    rgds
    srini

  • Calling ABAP report from BEx query

    Good day!
    I want to call ABAP report from BEx query by right-clicking on the field and using context menu. I know that transaction RSBBS is used (sender-receiver connecting), but I don't know how to transfare data to ABAP program
    In ABAP program I want to know at least data from those cell in BEx query, that was right-clicked.

    Depending on your requirement and environment, you have the following options:
    1. Use an info spoke and make selections as you would in a query.
    2. USe FM RS_VC_GET_QUERY_VIEW_DATA_FLAT to send the data to a file and your ABAP can read this file.
    Ravi Thothadri

  • Calling ABAP Code From BSP

    Hello all,
    I dont have much idea of BSP ans would like to have some inputs from you all.
    I would like to know that can I call ABAP transaction from BSP page ?
    I have got a set of column entries just as an ALV column on my BSP page and I would like to provide hotspot or double click functionality so that for each of the entries in the table , the BSP page navigates to ABAP tcode and back to BSP page.Is this functionality possible?
    any help would highly be appreciated.
    Regards
    Amruta

    Hi Amruta ,
    You can't call an R/3 transaction directly from BSP.
    But you can achieve all the functionalities it does .
    for ex ..if an r/3 transaction is a report , u hav to code in BSP editor .u can call function modules from BSP .
    But one thing u hav to concern is ,,in BSP Apllication logic is seperatd from Business logic .
    U hav to move all your results into an itab / params and display that inside HTML tables .
    Start ur journey from here .......
    http://help.sap.com/saphelp_erp2004/helpdata/en/e6/e23fd8c47e11d4ad320000e83539c3/frameset.htm
    All the best .
    Regards,
    J

  • Calling subroutines from SAPScript

    Hi all,
    I have added a piece of code in my MAIN window which calls a subroutine in another program. This works just fine. However, when I moved the code from one <b>window element</b> of MAIN to another, the code is no longer triggered.
    What causes this to happen? Is it related to the calling of function module WRITE_FORM in the application program? Any ideas?
    All helpful answers will be rewarded!
    Regards,
    M.V.

    Hi,
    In some case we need to do some mathematical operations in scripts !! Those things we cant do in Script Editor !! thats y the subroutines are there in scripts !!
    You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
    PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
    Syntax in a form window:
    /: PERFORM <form> IN PROGRAM <prog>
    /: USING &INVAR1&
    /: USING &INVAR2&
    /: CHANGING &OUTVAR1&
    /: CHANGING &OUTVAR2&
    /: ENDPERFORM
    INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
    OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
    The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
    FORM <form> TABLES IN_TAB STRUCTURE ITCSY
    OUT_TAB STRUCTURE ITCSY.
    ENDFORM.
    Regards
    Rama.Pammi

  • Problem with calling a report from a function module. Please help! URGENT!

    Hi Experts,
       I have a scenarion like this:
      XI -
    > Function Module -
    > ABAP Report
      From XI I am callingf a function module in another R/3 system. This function module inturn calls a ABAP report using SUBMIT statement. The function module and the report reside in the same R/3 system.
      I am calling the report like this:
    SUBMIT yseg_save_bp_data WITH SELECTION-TABLE rspar
                                 AND RETURN.
    The problem is when I run the function module directly in the R/3 system then it calls the report without any problem.
    On the other hand, when I call the function module from XI then the report is not called. On debug mode I found that the program exits just at the Submit statement. Why is this strange problem?
    What mistake am I doing? Is there any limitations or restrictions with SUBMIT statement.
    What is the correct way of using submit statement in this scenario?
    Kindly help me!
    Thanks
    Gopal

    Hi Rao,
       I have created the FM as remote RFC. Infact XI is able to call the FM. Only problem is when it reaches the point where the report is called via SUBMIT it exits.
    Help me please!
    Thanks
    Gopal

  • Calling ABAP method from JCo

    Hi All,
    I need to invoke a static method of an ABAP class from JCo. Is this possible? I am new to JCo. Any help in this regard is highly appreciated.
    Thanks,
    Praneeth

    Hello Praneeth,
    i'm not sure about calling ABAP class method from JCo directly, but there is a possibility to call function module from SAP R3. And the shortest way to do so is described in Re: Accessing SAP backend from j2ee without entrprise portal thread, answered by me.
    I guess there is no problem to call an class method from an function module.
    Please consider rewording points if helpfull.
    regards,
    mz

  • Call ABAP program from a Feature - PE03

    We are in process of upgrading from 4.6 C to ECC 6.0.  One feature (CSTV1) will not activate because there is a limit on generated programs to under 10,000 ABAP statements.  SAP told me to call an ABAP program from the feature to reduce the number of ABAP statements in the generated program.  Has anyone created a feature that called an ABAP program?  I searched SAP help and I can't find any information about calling a ABAP program.
    Thanks in advance,
       Mark Ashabraner

    Hi Mark,
    You can try it this way.. Get the name of the ABAP Program generated by the feature from its attributes. it will be something like '1PAPA/FEAT020Z0106'...May be you can change this program ie  put a substantial chunk of this code in a subroutine in another program & call that with a PERFORM from this Program..
    ~Suresh

  • Call abap commands from oracle enviorment

    Hello experts,
    i have quite no experience with SAP but i have this problem:
    in oracle db we have datas which are in variables to one ABAP function. And we need call this func with this parameters. From our SAP experts i get information that our SAP support Bussines Connector. I think that BC is some server component which allows comunicate me with sap via xml. And my questioin is how connect to sap using this BC from pl/sql if it is possible. Or what are other possibilities comunicate with sap and call abap function. I hope my scenario is clear, if not i will describe it in more details.
    thanx for help.
    Jakub.

    Hello,
    i think i will use BC because our SAP expert send it to me as possible way. I understand their msg as that BC server is ready. But i dont know if i  understand this architecture well: BC is server which allows comunicate with sap and use abap function. And i need any client application to connect to BC and send abap statements using any sap-bc's xml files. is this right? If it is how i can connect to BC from pl/sql if it is possible if not can i use java?
    Jakub.
    Edited by: An Organic on Mar 6, 2008 4:35 PM

  • Calling a subroutine from BSP application

    Hi
    i want to know how to call a subroutine/form in another package in same R/3 system in my BSP application.
    Is there any way to implement this. ?
    What if the subroutine has furhter LOCAL forms called inside it. will they be used as well while calling from my BSP application.
    PLease help.

    you can do that.
    perform p1 IN PROGRAM ('Y_P_TEST') IF FOUND  .
    do you have problem in doing this? what issues are you facing.
    Regards
    Raja

  • Problem while calling a report from the report

    Hi
    i want call a report from the report, i have written URL in the Hyperlink and its working
    but
    1) i want open it in the diffrent window.
    2) suppose if u have a report called emp it should call antoher 2 report at a time.
    ( how to put 2 URL in the hyperlink?).
    i,e if i press a hyperlink it should open emp1 and emp2
    Please help me.
    thanks and regards

    Thanx,
    I have solved this problem.
    Regards,
    Hafeez

  • Problem regarding calling a program from another program

    Hi,
    I have a requirement that i need to call a program from another program and in that case the called program should be executed with a value in the selection screen coming from the first program..i.e.
    a standard report to view the user Notes for annual leave is RPTARQDBVIEW. Can we create a report to display all the users under a manager as a hyperlink and run the report(RPTARQDBVIEW), with the pernr of the employee selected
    Regards,
    saumik

    Submitting a report using ranges for select-options
    * Define range for ltak-tanum
    RANGES: r_tanum FOR ltak-tanum.                                                                               
    * Read values from database tabel into the range
    * These values are later used for select-options in the report
    SELECT * FROM ltak                                                   
      WHERE lgnum =  w_lgnum AND           "Warehouse number/complex    
            vbeln = w_screen1000-io_vbeln.       "Transfer order number
      MOVE ltak-tanum TO r_tanum-low.                                    
      MOVE 'I' TO r_tanum-sign.                                          
      MOVE 'EQ' TO r_tanum-option.                                       
      APPEND r_tanum.                                                    
    ENDSELECT.                                                                               
    * Submit report with range                  
    SUBMIT zmm00100 WITH p_tanum IN r_tanum.   
    or
    Submitting a report from ABAP with selection criterias
      TYPES: tt_selection TYPE STANDARD TABLE OF rsparams.
      DATA: l_iblnr        TYPE st_iblnr,
    *     Define internal table and work area for select-options
            l_selection    TYPE rsparams,
            li_selection   TYPE tt_selection.
    * Create selectIon table
      LOOP AT gi_iblnr INTO l_iblnr.
        CLEAR l_selection.
        l_selection-selname  = 'IM_IBLNR'.    "Option name
        l_selection-kind     = 'S'.           "S= select options P=Parameters
        l_selection-sign     = 'I'.           "Sign
        l_selection-option   = 'EQ'.          "Option
        l_selection-low      = l_iblnr-iblnr. "Value
        APPEND l_selection TO li_selection.
      ENDLOOP.
    * Submit report
      SUBMIT rm07idif WITH SELECTION-TABLE li_selection AND RETURN.
    Regards,
    Prabhudas

Maybe you are looking for

  • How do I sync my iPhoto library on my mac to my iPad

    How do I sync photos from my Iphoto library to my iPad 2? Any help would be great!

  • BLACKBERRY DESKTOP SOFTWARE 7.1 WONT COMPLETE INSTALLATI​ON

    I use windows 7 32bit.. the problem i'm having is BlackBerry desktop software 7.1 won't finish installing.. a pop-up keeps coming up wen it's almost finished installing. the pop-up says "Error 1723. There is a problem with this windows installer pack

  • HELP - My website works on everyone else's computers but not my Mac.

    I am having a terrible time trying to access my website - www.missjonesdesign.com I could access it last week, but this week its stopped working on all my browsers, Safari, Firefox and Chrome. I am also having problems with my email, sometimes mail s

  • The not so distance future of computing.

    These are just some things in  the future I feel like writing about for whatever reason.   Some is stuff that will happen others are just my hopes. What do you look forward to in the future? Also let me know if some of my points are completely off. H

  • Handling servlet errors

    I know its not the proper place to ask servlet questions, but I am really left thinking. I am developing a login application and I wanto to display the error messages in the login.jsp, which are thrown by the LoginServlet. I justw ant to display my c