You are on page 1of 11

Home » Tutorials Library » SAP ABAP » Sapscripts

SAP ABAP Tutorial SAP ABAP - Sapscripts


 ABAP Smart Forms ABAP Customer Exits 
SAP ABAP - Introduction

SAP ABAP - Basic Screen Navigation

SAP ABAP - Statements

SAP ABAP - First program


Search Semiconductor Here
SAP ABAP - Data Types Transistor Diode Capacitor MOSFET IGBT Amplifier

SAP ABAP - Variables ALLDATASHEET.COM Open

SAP ABAP - Constants


Estas a tan solo una búsqueda
SAP ABAP - Literals
Alcanza a sus clientes en los momentos que
importan, con Google Ads. ¡Comienza ahora!
SAP ABAP - Basic Statements
Google Ads Regístrese
SAP ABAP - Message Handling

SAP ABAP - Strings


SAPScript is a tool used to create and maintain forms used for sending across
SAP ABAP - Date & Time and mass printing. The tool can develop the forms which supports printing,

SAP ABAP - Formatting Data faxing, e-mailing or XML generated outputs.

SAP ABAP - Operators Scripts are older version of SAP print forms. SAP Scripts are client dependent Search Semiconductor Here
and not visible to other clients. Transistor Diode Capacitor MOSFET IGBT Amplifier
SAP ABAP - Decision Control
Statements Advanced version of script is client independent and they will be visible in all ALLDATASHEET.COM Open

SAP ABAP - Types of loops clients.

SAP ABAP - Loop Control statements SE71 is the transaction code for SAP scripts. The SAP system has a standard
SAPscript forms that are used as a template for form creation.
SAP ABAP - Exception Handling

SAP ABAP - Data Dictionary The SAPscript form structure contains of 2 key components −

SAP ABAP - Domains Content − This can be either text or graphics.

Layout − The form content appears.

Function Modules used in SAP Scripts:

Some function modules used to develop SAP scripts listed below.

Function Description
module

OPEN_FORM used to open a form for execution by loading it into


memory.

WRITE_FORM used to write Some information on the SAP Script form


using Text Element.

CLOSE_FORM used to close the form which is opened by open form.

 About Us ▼
Seleccionar idioma ​
START_FORM used to call another SAP Script into current SAP Script
(Nested Scripts).

END_FORM used to end the form which started by START_FORM.

Components of SAP Scripts:

SAP script components are:


Component Description

Header Contains header information of the script.


Administrative and basic settings of the script

Pages Page is group of windows.


Only 99 pages can be created.

Windows Is a container which contains the information to display.


Four types of windows are: main window, constant window,
variable window, graphical window.

Page Windows assigned to a page called page windows


windows

Paragraph Used to specify the format for all the characters in


format paragraph.
The format can be font size/family/Bold/italic/underlined.
TABS also can be specified.

Character The format used by a group of characters.


format

Layout Specifies the place to design the page with windows.

Example:

Simple example to implement SAP scripts in writing a Report from the table.

There is two steps in using the SAP script.

1. Creating Script

2. Including in SAP Program

Below are the step by step process for creating the script.

Step-1: Go to SE71 transaction. It opens the ‘Form painter: Request’ screen. Enter
the Form name with starting letter is Z or Y and select ‘page layout’ as
subobjects. In this case, the form name is ‘ZPRODUCT1 and click on Create
button.

Step-2: It will open information dialog to create ZPRODUCT1 and click on green
tick mark.

Step-3: Enter the meaning and click on save.


Step-4: It opens the ‘Form: Change Header: ZPRODUCT1’. Click on Setting ->
Form Painter. In SAPscript tab, uncheck both options and click on green tick
mark.

Step-5: Click on Pages button to create a new page like below.

Step-6: Click on Character Formats to create custom character format like below.
Step-7: Click on Paragraph Formats to create a new paragraph like below.

Step-8: Click on Windows button to create the new window like below.
Step-9: Click on Page windows button to configure the windows under the page.
Click on Edit > Create Element to add the window.

Step-10: Add main page as first one, HEADER page as second one and their
alignments like below.

Step-11: go to edit and click on text element to enter some content like below.
Step-12: Click on back to exit from Window header. Go to settings > Form
painter.
Step-13: In SAPScript tab, check both options and click on right tick mark.

Step-14: It opens the page layout like below. Review the layout.

Step-15: To close this layout go to setting > form painter and uncheck the
graphical form painter.
Step-16: Enter the default paragraph and First page name in the below screen
on ‘basic settings’.

Step-17: Activate the form.

Step-18: Now Write the program to include the script.

REPORT Z_SCRIPT_PROG.

* Specifying table name


TABLES ZTC_TPRODUCT.
* Declaring cursor and work area
DATA: head(60) TYPE C VALUE ' PRODUCT INFORMATION ',
heading(60) TYPE C VALUE 'PRODUCTID | PRODUCT |
PAMOUNT |',
WA LIKE ZTC_TPRODUCT,
it TYPE TABLE OF ZTC_TPRODUCT.

START-OF-SELECTION.
PERFORM display_script.

FORM display_script.

CALL FUNCTION 'OPEN_FORM'


EXPORTING
form = 'ZPRODUCT1'
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 'Form is not opened successfully' TYPE 'I'.
ENDIF.

"Starting the Form


CALL FUNCTION 'START_FORM'
EXPORTING
form = 'ZPRODUCT1'
program = 'Z_SCRIPT_PROG'
EXCEPTIONS
form =1
format =2
unended =3
unopened =4
unused =5
spool_error = 6
codepage =7
OTHERS = 8.

IF sy-subrc <> 0.
MESSAGE 'Form is not started successfully' TYPE 'I'.
ENDIF.

"Writing the Heading of PO Item


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.
WRITE: 'Head not written', sy-subrc.
ENDIF.

"Writing the Heading of PO Item


CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'heading'
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 'Heading not written' TYPE 'I'.
ENDIF.

* Retrieving data from the table with product ID


SELECT *
INTO WA
FROM ZTC_TPRODUCT ORDER BY PRODUCTID.
"Writing the line Items one by one
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'wa'
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.
WRITE: / WA-PRODUCTID, '|', WA-PRODUCT, '|',WA-PAMOUNT, '|'.
ENDSELECT.

"Ending the Form


CALL FUNCTION 'END_FORM'

.
IF sy-subrc <> 0.
MESSAGE 'Form is not ended' TYPE 'I'.
ENDIF.

"Closing the Form


CALL FUNCTION 'CLOSE_FORM'

.
IF sy-subrc <> 0.
MESSAGE 'Form is not closed' TYPE 'I'.
ENDIF.
WRITE: 'Report completed..'.
ENDFORM.

 ABAP Smart Forms ABAP Customer Exits 


More..
About Us Careers Privacy policy Terms and conditions Helping Contact Us    

 Copyright 2018. All Rights Reserved.  Sitemap

You might also like