Skip to Content
author's profile photo Former Member
Former Member

SAP SCRIPT

can u give me one example for SAP-SCRIPT that, what are subroutines gets called when we are using it in our program??? (some standard subroutines)...such as WRITE_FORM OPEN_FORM...etc..

Please give example with explaination...

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 03, 2008 at 06:57 AM

    Hi,

    use of Function modules:

    OPEN_FORM: This form opens the script. The module OPEN_FORM opens layout set printing.

    WRITE_FORM: This form is used to write the content mentioned in the windows of the SAP Script.

    START_FORM: This form is dynamically call a page in the script. The layout set can be changed in the current print procedure with START_FORM. This may also be used to trigger a new-spool id.

    END_FORM: This form is used to close the current layout set.

    CLOSE_FORM: This form close the current SAP script form.

    You can have any number for WRITE_FORM, START_FORM and END_FORM, but for a script you can have only one OPEN_FORM and CLOSE_FORM

    open link:

    http://help.sap.com/saphelp_nw04s/helpdata/en/d2/cb3d8e455611d189710000e8322d00/content.htm

    Thanks and Regards,

    Reward If Helpful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 03, 2008 at 07:07 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 03, 2008 at 07:09 AM

    Hi,

    Go through The Standard Program RSTXEXP1.

    Call function modules :

    OPEN_FORM (to initialize the print output of the form),

    WRITE_FORM (to output the general text and data in the main window)

    CLOSE_FORM (ends the printing of the form)

    Note: For each printout of a form, you must use the pair of function modules OPEN_FORM and CLOSE_FORM. You can also use a print program to print several forms, which you can either maintain in separate spool requests or combine into one. In the latter case, you

    must use the function modules START_FORM and END_FORM.

    Reward Helpful Answers

    Regards

    Sandipan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 03, 2008 at 08:56 AM

    Hi,

    i am sending sample code for scripts.you go through this.

    &--


    structure declaration--

    TYPES:BEGIN OF ST_LFA1,

    LIFNR TYPE LFA1-LIFNR,

    NAME1 TYPE LFA1-NAME1,

    LAND1 TYPE LFA1-LAND1,

    ORT01 TYPE ORT01,

    REGIO TYPE REGIO,

    END OF ST_LFA1.

    TYPES:BEGIN OF ST_EKKO,

    EBELN TYPE EKKO-EBELN,

    BUKRS TYPE EKKO-BUKRS,

    AEDAT TYPE EKKO-AEDAT,

    ERNAM TYPE EKKO-ERNAM,

    BSTYP TYPE EKKO-BSTYP,

    LIFNR TYPE EKKO-LIFNR,

    END OF ST_EKKO.

    TYPES:BEGIN OF ST_EKPO,

    EBELN TYPE EKPO-EBELN,

    EBELP TYPE EKPO-EBELP,

    LOEKZ TYPE EKPO-LOEKZ,

    AEDAT TYPE EKPO-AEDAT,

    MATNR TYPE EKPO-MATNR,

    NETWR TYPE EKPO-NETWR,

    END OF ST_EKPO.

    &--


    internal table,work area declaration--

    DATA:WA_LFA1 TYPE ST_LFA1,

    IT_LFA1 TYPE STANDARD TABLE OF ST_LFA1,

    WA_EKKO TYPE ST_EKKO,

    IT_EKKO TYPE STANDARD TABLE OF ST_EKKO,

    WA_EKPO TYPE ST_EKPO,

    IT_EKPO TYPE STANDARD TABLE OF ST_EKPO.

    &--


    data declaration--

    DATA:TOTAL TYPE EKPO-NETWR,

    V_EBELN TYPE EKKO-EBELN.

    DATA: V_ITEM(20) TYPE C.

    &--


    parameter for purchase document number--

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    PARAMETERS P_PURDOC LIKE V_EBELN.

    SELECTION-SCREEN END OF BLOCK B1.

    START-OF-SELECTION.

    PERFORM GET_DATA_FROM_EKKO.

    PERFORM GET_DATA_FROM_LFA1.

    PERFORM GET_DATA_FROM_EKPO.

    &--


    grand total--

    LOOP AT IT_EKPO INTO WA_EKPO.

    TOTAL = TOTAL + WA_EKPO-NETWR.

    CLEAR WA_EKPO.

    ENDLOOP.

    &--


    open form--

    CALL FUNCTION 'OPEN_FORM'

    EXPORTING

    DEVICE = 'PRINTER'

    FORM = 'Z_50886_VENDOR'

    LANGUAGE = SY-LANGU

    EXCEPTIONS

    CANCELED = 1

    DEVICE = 2

    FORM = 3

    OPTIONS = 4

    UNCLOSED = 5

    MAIL_OPTIONS = 6

    ARCHIVE_ERROR = 7

    INVALID_FAX_NUMBER = 8

    MORE_PARAMS_NEEDED_IN_BATCH = 9

    SPOOL_ERROR = 10

    CODEPAGE = 11

    OTHERS = 12

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    &--


    write form for header details--

    READ TABLE IT_EKKO INTO WA_EKKO INDEX 1.

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    ELEMENT = 'HEAD'

    WINDOW = 'HEADER'

    EXCEPTIONS

    ELEMENT = 1

    FUNCTION = 2

    TYPE = 3

    UNOPENED = 4

    UNSTARTED = 5

    WINDOW = 6

    BAD_PAGEFORMAT_FOR_PRINT = 7

    SPOOL_ERROR = 8

    CODEPAGE = 9

    OTHERS = 10

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    &--


    write form for item details--

    LOOP AT IT_EKPO INTO WA_EKPO.

    CONCATENATE WA_EKKO-EBELN WA_EKPO-EBELP INTO V_ITEM.

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    ELEMENT = 'ITEM'

    WINDOW = 'MAIN'

    EXCEPTIONS

    ELEMENT = 1

    FUNCTION = 2

    TYPE = 3

    UNOPENED = 4

    UNSTARTED = 5

    WINDOW = 6

    BAD_PAGEFORMAT_FOR_PRINT = 7

    SPOOL_ERROR = 8

    CODEPAGE = 9

    OTHERS = 10

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDLOOP.

    &--


    write form for vendor details--

    READ TABLE IT_LFA1 INTO WA_LFA1 INDEX 1.

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    ELEMENT = 'VENDOR'

    WINDOW = 'ADDRESS'

    EXCEPTIONS

    ELEMENT = 1

    FUNCTION = 2

    TYPE = 3

    UNOPENED = 4

    UNSTARTED = 5

    WINDOW = 6

    BAD_PAGEFORMAT_FOR_PRINT = 7

    SPOOL_ERROR = 8

    CODEPAGE = 9

    OTHERS = 10.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    &--


    write form for grand total--

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    WINDOW = 'TOTAL'

    EXCEPTIONS

    ELEMENT = 1

    FUNCTION = 2

    TYPE = 3

    UNOPENED = 4

    UNSTARTED = 5

    WINDOW = 6

    BAD_PAGEFORMAT_FOR_PRINT = 7

    SPOOL_ERROR = 8

    CODEPAGE = 9

    OTHERS = 10

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    &--


    close form--

    CALL FUNCTION 'CLOSE_FORM'

    EXCEPTIONS

    UNOPENED = 1

    BAD_PAGEFORMAT_FOR_PRINT = 2

    SEND_ERROR = 3

    SPOOL_ERROR = 4

    CODEPAGE = 5

    OTHERS = 6

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    &----


    *& Form get_data_from_ekko

    &----


    FORM GET_DATA_FROM_EKKO .

    SELECT EBELN

    BUKRS

    AEDAT

    ERNAM

    BSTYP

    LIFNR

    FROM EKKO INTO TABLE IT_EKKO WHERE EBELN = P_PURDOC.

    ENDFORM. " get_data_from_ekko

    &----


    *& Form get_data_from_lfa1

    &----


    FORM GET_DATA_FROM_LFA1 .

    IF NOT IT_EKKO[] IS INITIAL.

    SELECT LIFNR

    NAME1

    LAND1

    ORT01

    REGIO

    FROM LFA1 INTO TABLE IT_LFA1 FOR ALL ENTRIES IN IT_EKKO WHERE

    LIFNR = IT_EKKO-LIFNR.

    ENDIF.

    ENDFORM. " get_data_from_lfa1

    &----


    *& Form get_data_from_ekpo

    &----


    FORM GET_DATA_FROM_EKPO .

    IF NOT IT_EKKO[] IS INITIAL.

    SELECT EBELN

    EBELP

    LOEKZ

    AEDAT

    MATNR

    NETWR

    FROM EKPO INTO TABLE IT_EKPO

    WHERE EBELN = P_PURDOC.

    ENDIF.

    ENDFORM. " get_data_from_ekpo

    the different forms in scripts are

    open_form:to open the form

    write_form:to call different windows

    start_form:to call another form

    end_form:ending the form

    close_form:it closes the form

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.