ABAP/4

ABAP/4 Example Code: How to call SAPscript form from ABAP report

Now we already have SAPscript form name ’ZFORM001’ and in this form we have element ’LINE1’ on window ’MAIN’. We want to call this form from ABAP report.

Example:


START-OF-SELECTION.
  PERFORM OPEN_FORM.
  PERFORM START_FORM.
  PERFORM WRITE_FORM USING ’LINE1’.
  PERFORM END_FORM.
  PERFORM CLOSE_FORM.

*&---------------------------------------------------------------------*
*&      Form  OPEN_FORM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM OPEN_FORM .
  CALL FUNCTION ’OPEN_FORM’
*   EXPORTING
*     APPLICATION                       = ’TX’
*     ARCHIVE_INDEX                     =
*     ARCHIVE_PARAMS                    =
*     DEVICE                            = ’PRINTER’
*     DIALOG                            = ’X’
*     FORM                              = ’ ’
*     LANGUAGE                          = SY-LANGU
*     OPTIONS                           =
*     MAIL_SENDER                       =
*     MAIL_RECIPIENT                    =
*     MAIL_APPL_OBJECT                  =
*     RAW_DATA_INTERFACE                = ’*’
*     SPONUMIV                          =
*   IMPORTING
*     LANGUAGE                          =
*     NEW_ARCHIVE_PARAMS                =
*     RESULT                            =
   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.

ABAP/4 Example Code: SAVE_TEXT

You can create and save long text by apply function module ’SAVE_TEXT’.

Example: We will create program for create standard text. The created text will be contained text ’Test Create Text’. you can input name of long text on selection screen. After you run this program, you can check the output of program in transaction SO10 (Standard Text).


DATA: GW_THEAD LIKE THEAD,
      IT_LINE TYPE TABLE OF TLINE WITH HEADER LINE.
PARAMETERS: P_TXTNAM LIKE THEAD-TDNAME.
START-OF-SELECTION.

ABAP/4 Example Code: GET & GET ... LATE


*** Using Logical Database: F1S ***
TABLES: SPFLI,
SFLIGHT,
SBOOK,
        SCARR.
START-OF-SELECTION.
  GET SPFLI.
    WRITE:/ ’SPFLI: ’, SPFLI-CARRID, SPFLI-CONNID, SPFLI-AIRPFROM, SPFLI-AIRPTO.
    GET SFLIGHT.
WRITE:/  ’  SFLIGHT: ’, SFLIGHT-CARRID, SFLIGHT-CONNID,
SFLIGHT-FLDATE.
      GET SBOOK.
        WRITE:/ ’    SBOOK: ’, SBOOK-CARRID, SBOOK-CONNID,

How to define variable in SAPscript

You can define variable in SAPscript by apply statement ’DEFINE’.

Example: We will define variable name = ’TXT1’ and initial value = ’Text1’. After we already define it, we will write a value of field.


/: DEFINE &TXT1& = ’Text1’
*  Test Define Text = &TXT1&
img10

The Output is

 img11

How to debugging SAPscript form

Go to transaction SE71 and input form name that you want to debug.

img7

Select menu Utilities -> Activate Debugger.

img5

System will generate message that debugger success or fail.

img6

After you run program that call this form, system will skip to form debugger.

How to import & export SAPscript form

You can import and export SAPscript form by using report ’RSTXSCRP’.

img2

You can specify form name in field ’Object name’.

img4

About mode options:

img3