External subroutine in sapscript

hi all
can anyone explain me how to handle an external subroutine in a script with a simple example.
rg
sandeep

Hi Sandeep,
Try this :
Use PERFORM from SAPSCRIPT
/: PERFORM BIN_LOCATION IN PROGRAM Z_SAPSCRIPT_PERFORMS
/: USING &RESBD-MATNR&
/: USING &CAUFVD-IWERK&
/: USING &RESBD-LGORT&
/: CHANGING &MARD-LGPBE&
/: ENDPERFORM
REPORT z_sapscript_performs.
SUBROUTINES FOR CALLING FROM SAPSCRIPTS
FORM bin_location TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
get default bin location from MARD for this material/plant/storage *
location
DATA: l_matnr TYPE matnr, "material
l_werks TYPE werks, "plant
l_lgort TYPE lgort, "storage location
l_lgpbe TYPE lgpbe. "bin location
Get first parameter in input table.
READ TABLE in_tab INDEX 1.
WRITE in_tab-value TO l_matnr .
Get second parameter in input table
READ TABLE in_tab INDEX 2.
MOVE in_tab-value TO l_werks.
Get third parameter in input table
READ TABLE in_tab INDEX 3.
MOVE in_tab-value TO l_lgort.
read bin location
SELECT SINGLE lgpbe INTO l_lgpbe FROM mard
WHERE matnr = l_matnr
AND werks = l_werks
AND lgort = l_lgort.
IF l_LGPBE IS INITIAL.
l_LGPBE = 'NONE'.
ENDIF.
read & update only parameter in output table
READ TABLE out_tab INDEX 1.
out_tab-value = l_lgpbe.
MODIFY out_tab INDEX 1.
ENDFORM.
Regards,
Lanka

Similar Messages

  • Debuggin External subroutine in sapscript

    Hi Gurus,
    I need to debug external soubroutine written in sapscript.i am not getting how to proceed for this.please help me.
    Regards
    Sam
    Moderator message: sapscript debugging = FAQ, please search before posting.
    Edited by: Thomas Zloch on Oct 27, 2010 1:25 PM

    Hi,
          I think this may help
    Place a break point in your subroutine, now activate the sap script debugger.
    Press F5 and continue debugging in sap script once it reaches the statement where the routine is called it will take you to the code.
    regards

  • SAPscript external subroutine - select not pulling data

    Hi all,
    I am calling an external subroutine in my SAPscript. In this subroutine, I am using a simple select statement:
    * get sales order number
      SELECT vbelv posnv
        FROM vbfa
        INTO CORRESPONDING FIELDS OF TABLE it_so
         WHERE vbeln = gv_deldoc
           AND posnn = gv_posnr.
    The problem is no data is being pulled into it_so. I have confirmed in VBFA (through SE16N) that data exists in the system so this isn't the problem. Are there restrictions with using selects in SAPscript?
    Thanks,
    Edited by: pistols123 on Sep 8, 2011 9:11 PM

    Hi,
    Please refer below code.
    In SAP Script ,SE71: call the subroutine pool program with the below sysntax.
    /: PERFORM GET_DATA IN PROGRAM ZXXXX
    /: USING &XXXX-MATNR&
    /: CHANGING &V_YYYY&
    /: CHANGING &V_YYY2&
    /: ENDPERFORM
    Using Parameter will be the input in the subroutine pool to fetch the data.
    Changing Paramter will be the your output to pass the data into SAP Form.
    now goto SE38,and create a subroutine pool program with the name ZXXXX,follow the below code.
    FORM get_data TABLES tbl_in  STRUCTURE itcsy
                           tbl_out STRUCTURE itcsy.
    READ TABLE tbl_in INDEX 1.
      IF sy-subrc EQ 0.
        XXXX-Matnr = tbl_in-value.
    "Pass it through the conversion exit CONVERSION_EXIT_ALPHA_INPUT before SELECT."
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        input         = gv_deldoc
    IMPORTING
       OUTPUT        = gv_deldoc
    SELECT vbelv posnv
        FROM vbfa
        INTO (l_vbelv,l_posnv)
         WHERE vbeln = gv_deldoc
           AND posnn = gv_posnr.
    READ TABLE tbl_out INDEX 1.
      IF sy-subrc = 0.
        MOVE l_vbelv TO tbl_out-value.
        MODIFY tbl_out INDEX 1.
      ENDIF.
      READ TABLE tbl_out INDEX 2.
      IF sy-subrc = 0.
        MOVE l_posnv TO tbl_out-value.
        MODIFY tbl_out INDEX 2.
      ENDIF.
    Moderator message - Welcome to SCN. But please do not ask for "rewards"
    Regards,
    VSNM
    Endform.
    Edited by: Rob Burbank on Sep 8, 2011 4:18 PM

  • Script external subroutine for multiple fileds display

    Hi,
    can anybody tell
    how to write external subroutine in script.
    i want to display multiple fields data in script by using external subroutine.
    Regards,
    Kumar.

    HI,
    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.
    Definition in the SAPscript form:
    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
    /: USING &PAGE&
    /: USING &NEXTPAGE&
    /: CHANGING &BARCODE&
    /: ENDPERFORM

  • Using external subroutine

    my subroutine is written in one program.
    I m using it in another program.
    i checked with the breakpoint...
    The control goes to the subroutine fetches the data in the structure but when the control returns to the main program the structure is empty.
    Now wat should i do either write the routine in the same program or have to use import & export memory which is best based on performance.

    hi
    let us also the location of the subroutine..i mean in differnt client no or in the same. If the subroutine is in the same client no..then you can use the Perform statement in the sapscript to call the extra functionality from the print program or in any location but with in the same system(client).
    In case of external subroutine, i think you need to use the client-specified statement in the print program while selecting the data.
    eg.
    select f1
              f2
              f3
              from zzkna1
              into i_tab
              cleint-specified where mandt = <client no from where you are fetching the data>
    this may work.
    regards,
    shamim.

  • Installer LV7.1 - LabVIEW load error code 21: An external subroutine required for execution could not be found.

    Bonjour,
    Je cherche à créer un installer portatif utilisant les drivers NI-DAQmx 8.7.1 et NI-CAN 2.6.0.
    Je dispose d'un code LV 7.1 et j'ai installé l'application builder 7.1.
    Mais une fois l'application installé sur un PC vierge de Labview, j'obtiens le message suivant:
    load error code 21: An external subroutine required for execution could not be found.
    Ce message est répété plusieurs fois (pour différents VIs) puis le programme ne se lance pas.
    J'ai bien veillé à installer les drivers NI-CAN et NI-DAQmx correspondant au préalable sur la machine cible.
    En chercant sur le forum, plusieurs pistes m'ont été proposé:
    La version NI-DAQ
    L'intégration du Run time Engine
    Un problème de DLL
    J'ai vérifié ces 3 points mais cela n'a pas règlé mon problème.
    Résolu !
    Accéder à la solution.

    Bonjour,
    Merci de ta réponse.
    En fait, j'ai bien inclu le runtime engine de Labview qui était effectivement la source de l'erreur.
    L'installation de NI-DAQmx v 8.7.1 provoque la mise à jour de la version du runtime engine (passage de 7.1 à 7.1.1).
    J'ai donc désinstallé Le runtime engine 7.1.1 (ce qui a provoqué la désinstallation de labview et NI-DAQ).
    Puis je suis passé par une version plus ancienne de NI-DAQ (7.2) que j'ai adapté (inclusions de DLL et de VIs).
    Les messages d'erreurs ont alors tout simplement disparus!

  • Subroutine in sapscript for net due date

    Hi,
    This is the first time I am creating a subroutine for sapscript and I could not get it to work. I need to calculate the net due date using the baseline date plus cash discount days. But the form is just printing out 0000000. I am just trying to extract one due date here but I will have to get it for all line items then sort descending to get the latest one. Can anyone help me to see the gap why this is not working?
    In the sapscript I have the following:
    DEFINE &BASEDATE& = &REGUP-ZFBDT&
    DEFINE &PAYTERMS& = &REGUP-ZBD1T&
    PERFORM NET_DUE_DATE IN PROGRAM Z_SAPSCRIPT_FUNCTIONS
    USING &BASEDATE&
    USING &PAYTERMS&
    CHANGING &DUEDATE&
    ENDPERFORM
    In program Z_SAPSCRIPT_FUNCTIONS
    Thanks in advance!
    Cholen

    Hi Raju!
    I am really getting close! I did the conversion for all variables, however for VBLNR, it does not work. It gives leading zeroes but the value starts with a 'P' before the zeroes and the numeric value. I tried to remove that from the where clause and my select finally got something. However the output on the form is in the internal format. I suppose I should use CONVERT_DATE_TO_EXTERNAL which I tried doing after out_tab-value = lv_netduedate which is the variable I am passing to the form. 
    Raju Shrestha wrote:
    Hi Cholen,
    I believe your lv_laufd is a 10 character field in format MM/DD/YYY or DD/MM/YYYY. You should move that data to a 8 character variable (say lv_date) in YYYYDDMM format.
    Please try this conversion
        CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
          EXPORTING
            date_external            = lv_laufd
          IMPORTING
            date_internal            = lv_date
          EXCEPTIONS
            date_external_is_invalid = 1
            OTHERS                   = 2.
    Check in debug, you should get lv_date in YYYYMMDD. Now use lv_date in your WHERE clause.
    If you still do not get data after lv_date eq YYYYMMDD, check your LIFNR and KUNNR. They should be 10 charaters with leading zeroes if not 10 .
    If needed use the conversion for lv_lifnr and lv_kunnr.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            date_external            = lv_lifnr
          IMPORTING
            date_internal            = lv_lifnr.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            date_external            =  lv_kunnr
          IMPORTING
            date_internal            =  lv_kunnr.
    Cheers,
    Raju.

  • Select-options as a external subroutine

    hi all,
    plz solve my problem.
    this is my first program.
    tables vbak.
    select-options x for vbak-vbeln.
    types : beginf of ty,
    a tupe vbak-vbeln,
    b type vbak-ernam,
    end of ty.
    data : itab type table of ty,
             wa type ty.
    perform sub(znava) using x.
    this is my secomd program
    report znava.
    form sub using x.
    select vbeln ernam from vbak into table itab where vbeln in x.
    loop at itab into wa.
    write :/ wa-a,wa-b.
    endloop.
    endform.
    in the above two programs are separate,and i am using external subroutine but it will show some error how can i rectify.
    anyone plz guide me.
    thanks and regards,
    navneeth.
    Edited by: Navaneetha KRISHNAN on Feb 19, 2008 5:50 PM

    First of all SELECT-OPTIONS are TABLE type. 
    You just can't use USING  keyword, you've to use TABLES keyword.
    second point is,, in your second program are you defining ITAB and WA??? otherwise second program is not going to identify ITAB & WA... so I suggest you try like this..
    "program 1.
    TABLES vbak.
    SELECT-OPTIONS x FOR vbak-vbeln.
    PERFORM sub(znava) TABLES x .
    "program 2
      TYPES : BEGIN OF ty,
      a TYPE vbak-vbeln,
      b TYPE vbak-ernam,
      END OF ty.
      DATA : itab TYPE TABLE OF ty,
      wa TYPE ty.
    FORM sub TABLES x.
      SELECT vbeln ernam FROM vbak INTO TABLE itab WHERE vbeln IN x.
      LOOP AT itab INTO wa.
        WRITE :/ wa-a,wa-b.
      ENDLOOP.
    ENDFORM.                    "sub

  • Using HR_INFOTYPE_OPERATION in external subroutine for Dynamic Actions

    Hi,
    I am calling an external subroutine in the Dynamic Actions of an Infotype. In this external subroutine, I am using HR_INFOTYPE_OPERATION to modify OTHER records of the same Infotype number.
    However, when I tried to trigger the Dynamic Actions in PA30, the other infotypes get modified as intended. But when I refreshed the PA30 screen, the changes were reversed back as if the HR_INFOTYPE_OPERATION were not carried out at all. I have COMMIT WORK after the HR_INFOTYPE_OPERATION, refreshed the buffer. But it doesn't seem to work.
    My question is: Can i use HR_INFOTYPE_OPERATION in an external subroutine which is called during dynamic actions? As I have some complicated logic, I do not want to embed the coding in the Dynamic Actions. Is there a way for HR_INFOTYPE_OPERATION to work in the external subroutine with the changes being committed to the database?
    Thank you.

    Hi,
    I remember the same problem being faced by some of the forum members.
    Suresh Datti had replied that "Call the subroutine in a nother program using a SUBMIT statement. This will create two sessions and will update the DB". This was working fine for the users.
    Hope you can try this.
    Just call a program using SUBMIT statement and code your form routine inside that.
    Hope this helps you.
    Regards,
    Subbu.

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

  • Build Applicatio​n problem // external subroutine

    Hey,
    i was build an stand alone application (.exe) and i have a problem with external subroutine to subVi.
    I was trying to add the missing .llb as support file in Source Files but still doesnt work.
    It works on my computer, on another computer doesnt work (please look attached file)
    I have LV 7.1.
    I read on forum about this problem and i didnt find any solution for me.
    Thanks for help.
    Attachments:
    missingSubVi.JPG ‏12 KB

    crossrulz wrote:
    Mark, a lot of things changed going to LabVIEW 8.  LabVIEW 7 didn't have projects or the fancy build specs.  I don't have LabVIEW 7 anywhere, so I can't play around in the menus of the very old build dialog.
    I know a lot has changed. I don't recall myself exactly how LV 7 build specs looked. It should have some type of similar option though.
    If it doesn't the OP may need to be very specific with his paths for calling the dynamic VIs and makes sure he distributes them and place them into the correct directory where his application will access them.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Visibility of global parameters while working with external subroutines

    Hi all,
       I am trying to use external subroutines in my current report. But I am not able to access the global variable values of my calling program  through  the called external subroutines.Please let me know whether the accessibility of global parameters will be possible through the external subroutine calls.

    Hi Jaya,
    It is NOT Possible.
    Using the external Subroutine,
    1) We can only import some required result only (using the CHANGING option).
    2) Or, we can do some other execution on the DB based on the input which we gave as Export
        Parameters.
    Rgds,
    Ramani N

  • 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

  • External subroutine in script

    Hi,
    Could any one tell me is that possible to use external subroutine.  Actually my script is the output of ML83. Driver program which passing the info. to script is Std one.  Is there any filed relavent to this driver program is updating when 'Service entry is revoked'.  Plz help me out... this is very urgent.
    Thanks
    Sai.

    Hi,
    'Service entry is revoked' means blocked or released..
    Sorry..I am not an expert on Service entry..But I am trying to search for the fields which you are looking for..
    Thanks,
    Naren

  • Pass subroutine to Sapscript

    sir,
      Like to know How we pass subroutine in sapscript and how standard texts are added and what is its command and transaction.
    Edited by: Alvaro Tejada Galindo on Apr 28, 2008 4:45 PM

    Subroutines in scripts:
    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.

Maybe you are looking for

  • Recovering from a disk crash

    i experienced a hard disk failure on my MacBook Pro today. at first Safari started complaining it's unable to save bookmarks, then Mail gave errors about not being able to write data. i tried logging out and logging in again with the same account but

  • Real Estate Lock Box Key

    I have owned three Palms and now on my 4th.  The very first one,second one and third was able to be integrated with the software/programming to be installed into my phone for the ability to open realtor lock boxes.  ALL Palms have infrared  so once i

  • Integration via Services

    I will make an integration between an ERP system and a WMS. This integration will be made via services, or when I need to send information from ERP to WMS, the ERP will draw on my ALDSP a service that will map the parameters of the Webservice (XSD) t

  • Uncheck Invoice receipt indicator in Purchase Order Local

    We want to uncheck invoice receipt indicator in Purchase Order Local ( field BBP_PDSET-IR_IND) when a Shopping Cart is complete and PO Local is created automatically by system. We are using BADI BBP_DOC_CHANGE_BADI with Method BBP_PO_CHANGE but no ch

  • Error in hitting url

    i wanna hit a url and retrieve the data.i`m using teh simple code given below.i just realized that my net connection uses a proxy server to connect.does that create any issues????i tried the url on the browser and it works.plz help.its urgent.the run