Skip to Content
avatar image
Former Member

How to get Internal table data into a script form

How to get internal table data into a script form, by calling a subroutine

in a program.

A list of line items in an internal table have to be fetched into a script form which is used by a standard print program. The number of line items will vary based on document number passed by the form.

Print program cannot be modified. A Z program is created with a subroutine.

How to create the subroutine in the Z program so that it will pass the internal table data to the script form.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Dec 11, 2006 at 05:37 AM

    Hi

    list of line items are possible to print in MAIN form only. So after fetching the records, pass the values and call the element and MAIN window. It will be print either single or n number of records ...

    Add comment
    10|10000 characters needed characters exceeded

    • As SAPScript allows only data transfer via ITCSY, we cannot pass internal tables to SAPScripts.

      Only single varibale data can be passed. Either you should know how many lines will be there in the table beforehand.

      Or 😊

      Use "SmartForms".

      Regards,

      Vivek.

  • avatar image
    Former Member
    Dec 11, 2006 at 08:00 AM

    Hi,

    Call a Subroutine with following statement in the script (which ever window the data has to be printed) PERFORM '<Subroutine program name (starting with Z or Y)' with using field names (i.e. fields which need to be passed to the subroutine ) and changing field or variables names(fields data which need to retrieved from subroutine).

    Now create a subroutine program with the same name as defined in the script window.

    In this subroutine define subroutinr declaration as follows :

    FORM SUBroutine<program name) TABLES IN_PAR STRUCTURE ITCSY

    OUT_PAR STRUCTURE ITCSY.

    (where imnpar will be of the using fields data and outpar will be of sending fields data).

    Now using the inpar fields data you can write the code accodingely and get the required data and send it into the oupar structure so that the exteranl data can be populated in the script.

    Do let me know if you need any info in this regard.

    Raghotham Reddy.

    • Allocate reward point accordingely if this solved your requirment.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Please give a code passing internal table to out parameter in the external program

      and code for calling perform statement in the form calling the subroutine in the external program

  • avatar image
    Former Member
    Dec 12, 2006 at 07:08 PM

    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.

    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.

    <b>Syntax in a form window:</b>

    /: 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.

    This example fetches the sales document type using sales order number.

    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.

    Syntax in a form window:

    /: PERFORM GET_SALES_TYPE IN PROGRAM <prog>

    /: USING &VBELN&

    /: CHANGING &AUART&

    /: ENDPERFORM

    VBELN - Sales Document

    AUART - Sales Order type

    FORM GET_SALES_TYPE TABLES IN_TAB STRUCTURE ITCSY

    OUT_TAB STRUCTURE ITCSY.

    data : v_vbeln type vbeln,

    V_AUART TYPE AUART.

    READ TABLE IN_TAB WITH KEY ‘VBELN’.

    CHECK SY-SUBRC = 0.

    V_VBELN = IN_TAB-VALUE.

    SELECT SINGLE AUART FROM VBAK

    INTO V_AUART WHERE VBELN = V_VBELN.

    IF SY-SUBRC = 0.

    READ TABLE OUT_TAB WITH KEY ‘AUART’.

    CHECK SY-SUBRC = 0.

    OUT_TAB-VALUE = V_AUART.

    MODIFY OUT_TAB INDEX SY-TABIX.

    ENDIF.

    ENDFORM.

    Add comment
    10|10000 characters needed characters exceeded