Calling subroutine from scripts

I am calling a subroutine form a standard text, the subroutine is getting called but the input table is comming empty.
can any one please advise me what could be the problem.
/:PERFORM GET_APP_DATA IN PROGRAM YHR_APP_DATA
/:USING &P0001-PERNR&
/:CHANGING &GRADE&
/:ENDPERFORM

Check this sample code...may be it will help u to identify the prob...
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 u2018PAGEu2019.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018NEXTPAGEu2019.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018BARCODEu2019.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = u2018|u2019. "First page
ELSE.
OUT_PAR-VALUE = u2018||u2019. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = u2018Lu2019. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Regards,
JOy.

Similar Messages

  • Error while calling Subroutine from Script

    HI Friends,
    I am getting a short dump whilecalling a suboutine from Script.
    Please suggest if am wrong with below code
    /: PERFORM GET_ADDRESS IN PROGRAM ZSUBROUTINES
    /: USING &MHND-KUNNR&
    /: CHANGING &ADRS-LINE0&
    /: CHANGING &ADRS-LINE1&
    /: ENDPERFORM
    All above fields are available in script window
    In the program
    FORM get_address    TABLES in_tab STRUCTURE itcsy
                                       out_tab stucture itcsy.
    ENDFORM.
    Thanks

    HI,
    Your code is correct, in the FORM and ENDFORM in the program, read the INPUT table and get the values and write your logic using these values and send back the values to the SCRIPT using the OUTTABLE. here you need to use the MODIFY statment for the outtable using Sy-TABIX.
    Regards
    Sudheer

  • Passing Currency field to external subroutine from script

    Hi,
                I am passing one currency field to external subroutine from script. In subroutine we can get that currency in character format. I want to convert that into currency format. how can i do that?
    thnk u

    easy conversion:
    number = character_parameter

  • Calling java from scripting

    Hello,
    I would like to integrate some scripting capability in my web application.
    The main purpose is to cover the following scenario :
    - I develop a web app with JSP technology, packaged in a MyAPP.WAR file containing my application and another file (MyCustomer.RAR?) containing installation specific informations. I want the MyApp.WAR to be the same for all my customers, just having the RAR file specific to each customer (installation).
    - In this ressource file, there could be some scripting functions that will be called from my JSP Pages to change the default presentation with some customer particular informations.
    Those informations would be extracted from my java data model. The purpose is to enable the customer to code some little script, and to avoid coding those in Java.
    The question I have on that are :
    1/ is it possible to call java instances from scripting language (I read on apache that the answer was yes for some of them), but I would like to know if javascript can do that.
    2/ Can I recover the "result" of the script in JSP ?
    An example :
    1/ The class containing a marvellous property
    class MyClass {
    public String myProperty;
    2/ The JSP page :
    <stlLib:callScript(Customer.RAR, "ScriptToCall",anInstance) />
    <stlLib:getResult ???>
    3/ A user script (pseudo-code)
    Customer 1 :
    Function ScriptToCall(object) {
    variable iwanttoshowsquareroot;
    iwanttoshowsquareroot = squareroot(object.myProperty);
    return iwanttoshowsquareroot ;
    Customer 2 :
    Function ScriptToCall(object) {
    variable mychoiceisdifferent;
    mychoiceisdifferent= object.myProperty / 2;
    return mychoiceisdifferent;
    According to what ScriptToCall looks like the result on page would be different
    Thanks in advance for your advises
    Olivier.

    1) The script will be running in the browser, not the server, yes? So in Netscape you can load Java objects via Javascript, but IE doesn't seem to support this. Although in either, you can call methods on an applet in the page. But you can't call a JS function from the Java code in the JSP page, since that is only executed on the server.
    2) Only if the "result" is submitted back to the server.

  • Calling subroutine from SAP script

    I am using the below code within my SAP script form that prints GR/GI Slips but its not working.  And the only way I can issue the output is from MB02 whcih doesn't seem to allow to call the debuger, so I'm at a lost as to what to do.
    Code in SAP script
    /:           PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS                                                                               
    USING &MSEG-MATNR&
    /:                                                           USING &MSEG-LGNUM&
    /:                                                           CHANGING &MABDR-LGPBE&
    /:           ENDPERFORM
    CODE from my subroutine program:
    FORM get_bins TABLES input_table STRUCTURE itcsy
                         output_table STRUCTURE itcsy.
      DATA: lc_matnr    TYPE matnr,
            lc_lgnum    TYPE lgnum,
            lc_lgpla    TYPE lgpla,
            lc_index    TYPE sy-tabix.
    * Material no
      READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
      MOVE input_table-value TO lc_matnr.
    * Warehouse number
      READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
      MOVE input_table-value TO lc_lgnum.
    * Get BIN
      SELECT SINGLE lgpla INTO lc_lgpla
             FROM mlgt
             WHERE matnr = lc_matnr
             AND   lgnum = 'CPT'  "lc_lgnum
             AND   lgtyp = '001'.
      IF sy-subrc = 0.
        READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
        lc_index = sy-tabix.
        MOVE lc_lgpla TO output_table-value.
        MODIFY output_table INDEX lc_index.
      ENDIF.

    /:           PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS
    /:                                                              USING &MSEG-MATNR&
    /:                                                           USING &MSEG-LGNUM&
    /:                                                           CHANGING &MABDR-LGPBE&
    /:           ENDPERFORM
    FORM get_bins TABLES input_table STRUCTURE itcsy
                         output_table STRUCTURE itcsy.
      DATA: lc_matnr    TYPE matnr,
            lc_lgnum    TYPE lgnum,
            lc_lgpla    TYPE lgpla,
            lc_index    TYPE sy-tabix.
    Material no
      READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
      MOVE input_table-value TO lc_matnr.
    Warehouse number
      READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
      MOVE input_table-value TO lc_lgnum.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = lc_matnr
      IMPORTING
       OUTPUT        = lc_matnr         .
    Get BIN
      SELECT SINGLE lgpla INTO lc_lgpla
             FROM mlgt
             WHERE matnr = lc_matnr
             AND   lgnum = 'CPT'  "lc_lgnum
             AND   lgtyp = '001'.
      IF sy-subrc = 0.
        READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
        lc_index = sy-tabix.
        MOVE lc_lgpla TO output_table-value.
        MODIFY output_table TRANSPORTING VALUE WHERE NAME = 'MABDR-LGPBE'.
      ENDIF.

  • 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

  • Calling events from scripts in UIX

    Hi,
    I am able to call the ordinary events in the UIX from the script. But I am not able to call the
    <ctrl:event .. >
    from the script.
    Could anyone please tell me how to call them.
    Thank you
    Velpandian

    Velpandian -
    Assuming your page contains a form, you can trigger an event on the server from a JavaScript handler by calling submitForm(). The following sample shows how to send an event both by using the ctrl:event attribute as well as from a JavaScript handler:
    <?xml version="1.0" encoding="UTF-8"?>
    <page xmlns="http://xmlns.oracle.com/uix/controller"
          xmlns:ui="http://xmlns.oracle.com/uix/ui"
          xmlns:data="http://xmlns.oracle.com/uix/ui"
          xmlns:ctrl="http://xmlns.oracle.com/uix/controller">
    <content>
      <form name="foo" xmlns="http://xmlns.oracle.com/uix/ui">
      <contents>
        <!-- Import the submitForm() function -->
        <importScript names="submitForm()"/>
        <stackLayout>
        <contents>
          <!-- This link sends an event using a ctrl:event attribute -->
          <link text="Send Event" ctrl:event="test"/>
          <!-- This link sends an event using a JavaScript event handler.
               We use submitForm() and specify the event name using
               a parameter.  Note that this means that we need to be
               sure that we also have an "event" hidden field - which
               we add via a formParameter element below -->
          <link text="Send Event from JavaScript"
                onClick="if (confirm('Send event')) submitForm(0, 0, {'event':'test'}); else return false;"
                destination="#"/>
          <!-- Need a form value to contain the event name -->
          <formParameter name="event"/>
        </contents>
        </stackLayout>
      </contents>
      </form>
    </content>
    <handlers>
      <!-- Use a null event handler to set up a session variable -->
      <event name="test">
        <go name="nextPage"/>
      </event>
    </handlers>
    </page>I couldn't find the documentation for submitForm() online anywhere... Here is a copy of the documentation from our source code:
    * Attempts to submits the form, potentially firing validation and notifying
    * any Cabo onSubmit handlers registered on the form, returning
    * <code>true</code> if the submission actually occurred.
    * <p>
    * If the <code>doValidate</code> parameter is false, no validation will
    * be performed, and the form is guaranteed to be submitted.  Otherwise,
    * the form will be submitted if both the validation succeeds and any
    * registered Cabo onSubmit handlers do not return <code>false</code>.
    * <p>
    * @param form The form to submit.  This can either be the name of the form
    *             in the current <code>document</code>, the index of the form
    *             in the current <code>document</code> or the form itself.
    * @param doValidate boolean value specifying whether validation should
    *   occur before the form is submitted.  (As per a common Javascript
    *   idiom, it is acceptable to pass true/false as well as 0/1).  If
    *   this parameter is ommitted, it defaults to true.
    * @param parameters a single Javascript object that specifies
    *   all the additional key-value pairs to submit.  There must be
    *   pre-existing &lt;input type="hidden"&gt; elements as targets
    *   for each of these parameters.
    function submitForm(
      form,
      doValidate,
      parameters
      )Andy

  • 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.

  • Subroutine in script. REWARDED

    Hi All,
    Please give me a sample and easy code
    for calling subroutine in script
    subroutine defination zprogram which is having a select statement.
    every helpful answere is rewarded surely.

    hi priyanka,
    sample code for routines in script.
      /: PERFORM FORM_TEST IN PROGRAM ZTEST
    /: USING &VAR1&
    /: USING &VAR2&
    /: USING &VAR3&
    /: USING &VARN&
    /: CHANGING &VAR_OUT1&
    /: CHANGING &VAR_OUTN&
    in the program ZTEST...
    FORM FORM_TEST tables in_tab structure itcsy
    out_tab structure itcsy.
    Get value of VARN
    data: varn like ....
    read table in_tab with key name = 'VARN'.
    if sy-subrc = 0.
    move in_tab-value to varn.
    endif.
    Update the value of VAR_OUTN
    read table out_tab with key name = 'VAR_OUTN'.
    if sy-subrc = 0.
    move <value> to out_tab-value.
    modify out_tab index sy-tabix.
    endif.
    ENDFORM.
    check this link too...
    http://help.sap.com/saphelp_erp2005/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm
    Regards...
    Arun.
    Reward points if useful.

  • 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

  • HOw can we Call Subroutine in Sap Script?

    HOw can we Call Subroutine in Sap Script?

    Hi
    *You have to call sub routine from script like this.
    /:   PERFORM DATE_FORMAT IN PROGRAM &SY-REPID&
    /:   USING &RM06P-LFDAT&
    /:   USING &PEKKO-LFDAT&
    /:   CHANGING &VALUE_OLD&
    /:   CHANGING &VALUE_NEW&
    /:   ENDPERFORM
    *In print program write code.
    FORM date_format TABLES in_tab STRUCTURE itcsy
    out_tab STRUCTURE itcsy.
      DATA : date TYPE char10.
      DATA : date2 TYPE char10.
      DATA : l_dmbtr TYPE char10.
      READ TABLE in_tab WITH KEY 'RM06P-LFDAT'.
      IF sy-subrc = 0.
        "Your code goes here
        CLEAR l_dmbtr.
      ENDIF.
      READ TABLE in_tab WITH KEY 'PEKKO-LFDAT'.
      IF sy-subrc = 0.
        l_dmbtr = in_tab-value.
        "Your code goes here
        CLEAR l_dmbtr.
      ENDIF.
      READ TABLE out_tab WITH KEY 'VALUE_NEW'.
        IF sy-subrc EQ 0.
            out_tab-value = date2.
            MODIFY out_tab INDEX sy-tabix.
        ENDIF.
      READ TABLE out_tab WITH KEY 'VALUE_OLD'.
        IF sy-subrc = 0.
            out_tab-value = l_dmbtr.
            MODIFY out_tab INDEX sy-tabix.
        ENDIF.
    ENDFORM.            "DATE_FORMAT

  • Can any one tell me how can i call a shell script from pl/sql

    i like to call shell script from pl/sql procedure.
    can any one suggest how can i do this

    Have you not mastered in asking the same kind of question ?
    First do write a script...
    no one will spoon feed you.
    How can i call a shell script from procedure
    How to call Shell Script from pl/sql block
    -Sk

  • How can i call a shell script from procedure

    I have a shell script.now i am i a situation to call that shell script from one of my procedures and need to get a value from that script.
    can u suggest me that how can a call the shell script from pl/sql?

    Is the same question you asked here
    How to call Shell Script from pl/sql block
    -SK

  • How to call a python script from a TestStand sequence?

    Please tell me how is it possible to call a python script from a TestStand sequence.
    Thank for your help in advance.
    Imre

    Here you can find some information about Python and LabVIEW:
    http://forums.ni.com/ni/board/message?board.id=170​&message.id=124424&query.id=149647#M124424
    If you have LabVIEW, you could use LabVIEW steps to call your Phyton Scipts.
    Another solution would be, to do, what is decriibed in the thread directly in TestStand:
    You can call a dll or .NET assemblies directly from teststand, or use the "Call Executable" TestStep.

  • How to call a Shell Script from Report 6i

    Hi All,
    Can anybody tell, how to call a Shell Script from Report 6i.
    Thanks in Advance,
    Bala

    try the SRW.USER_EXIT (user_exit_string CHAR);

Maybe you are looking for

  • Error in Background Jobs After Client Copy

    Hi, We had performed a system refresh from a production client(with client no 300) to a quality server (client no: 200). The post processing steps were performed ok. Later the client 300 on the quality server was dropped. However, the scheduled user

  • Re-setting password

    I've forgotten my admin password how do I re-set it? The original set up disk does not show utilities option.

  • Setting up final cut pro studio after fault

    Hi I installed final cut pro studio a few months ago but my mac then had to go in for repair. I have since had it back but when trying to run any of the studio applications, when asked to enter my serial number again it says it cannot run application

  • How do I turn my iphone into something not useless?

    Hi i'm starting to get very frustrated.  I bought an iphone 5 off craiglist the other day and was not aware of the whole needing the other person to be signed out of the account for the phone not to be complete garbage business.  I thought it would w

  • Youtube 3D not working in 3D when uploading from Sony HDR-TD30V

    I have two 3D camcorders Sony HDR-TD30V and Panasonic HDC-SDT750. Video's uploaded from Panasonic HDC-SDT750 play fine using mozilla's html5 format in 3D But uploading video's from my Sony HDR-TD30V only displays 3D in Red/Blue format. when I switch