Professional Documents
Culture Documents
Sap Scripts and Components of Sap Scripts: Sapscripts
Sap Scripts and Components of Sap Scripts: Sapscripts
SAP SCRIPT
SAP Script is a tool which is used to printable business documents in SAP like invoice form,
Sales Order form, Delivery form, other form related to HR etc.
Scripts are older version of SAP print forms, advanced version to scripts are smartforms( we will
learn in next chapters ).
SAP Scripts are client dependent, that is if we develop a script in client 200, it will not be visible in
other clients like 300, 100.
Advanced version of scripts, smartforms are client independent, they will be visible in all clients.
Texts are nothing but a data, as per SAP all data is client dependent, so SAP Scripts are client
dependent.
3. Windows.
4. Page windows.
5. Paragraph format.
6. Character Format.
7. Layout.
Header
It contains header information of SAP Script i:e administrative data and basic settings of SAP
script.
Administrative Data: It contains administrative data like package, client, user and language.
Basic Settings: It contains settings like page format, first page, default paragraph etc.
Pages
SAP Script is a group of pages, each page contains layout.
Windows
A window is a container which contains some information to display, the entire page is designed
using windows.
Main window:
A Window which automatically expands depending upon the data is called main window.
As there are 99 pages only in scripts, we can have maximum 99 main windows only The main
Window data is divided into blocks called as text elements.
Text Element:
The entire main Window data is divided into blocks called as text elements.
Now,Display a particular text element, so that only that specific info related to text element is
displayed.
Constant Window:
A Window which is constant for all the pages is called constant Window.
Variable Window:
A Window which does not expand i.e., width and height is fixed .
Graphical Window:
Page windows:
The windows assigned to particular page are called page windows.
Paragraph format :
It is used to specify a particular format (font size/family/Bold/italic/underlined) for all the
characters in a paragraph .
Tabs : Tabs are used to specify a position in sap script so that the text will be displayed at that
particular position.
Character format :
A format which is used by a group of characters inside a paragraph is called a character format .
Layout:
It is a place where we design the page with windows.
Function Modules used in SAP Scripts
We use some function modules to develop SAP Scripts, explained
below.
OPEN_FORM
This is used to open a form for execution by loading it into memory.
WRITE_FORM
It is used to write Some information on the SAP Script form using Text Element.
CLOSE_FORM
It is used to close the form which is opened by open form.
START_FORM
It is used to call another SAP Script into current SAP Script(Nested Scripts).
END_FORM
It is used to end the form which started by START_FORM.
Driver Program
A program which contains business logic statements i.e., all select statements ,loops,appends
etc, is called Driver prg.
All the variables ,work areas ,internal tables which are declared in the driver program will be
automatically transferred to SAP Scripts.
If we want to display the variables or workarea values we need to follow below syntax.
Syntax : &variable&
&workarea-fname&
Purchase Order SAP Script
Developing Purchase order SAPScript with totals, subtotals, terms in SAP
ABAP programming
Requirement: Develop a purchase order with Logo, Address and page no.
A Real Time Scenario on Purchase Order SAP Script Form
Step 7 : Write the code for Printing Headings, Line item information, Grand total in
Mainwindow
Step 8 : Write the code for Printing Vendor address in Address window
Step 9 : Write the code for Printing Footer information in Footer window
Step19 : Change the Driver Program for using STARTFORM AND END FORM
Detailed Steps:
1. Se71->Give formname ->ZV_PO ->create.
7. Click on Page windows-> EDIT->CRATE ELEMENT->Double click on each window so that the
window would be added to the page. Give the appropriate height, width, left/right margin as
below for each window
Give font family as COURIER AND size as 12 for all paragraph formats, except for TITLE
paragraph. Give 16 for this TITLE paragraph.
Step 7 : Write the code for Headings, Line item information, Grand total in Mainwindow
Here…
/:TOP…ENDTOP is used to print header information in the main window so that the it flows
on to every page .
/EBODY----this is used to print body. All the line item values .
/E-Total----used to print total at the end of main window ..
This element is called after the loop..endloop..so that Grand total is printed immediately
Step 8 : Write the code for Printing Vendor address in Address window
Step 9 : Write the code for Printing Footer information in Footer window
FT--&ULINE(60)&
ID : BMAP
automatically
Similarly, for all windows write the below code in the text editor
DF-- PO No : &wa_ekko-ebeln&
DF--Page.No : &PAGE&/&SAPSCRIPT-FORMPAGES(C)&
Goto->Pagewindows->Double click on TITLE window and click on texteditor->write the below
code
TL----Purchase Order
We can write the text directly in the window. But in the real time we use a concept called
standard Text.
Write the below text->click on save->go back and click on print preview.
Go back to script
Or
Finally, Lets Re-arrange all the window positions again by going to Graphical Form Painer.
REPORT ZV_PO_DRIVER.
TABLES : ADRC,LFA1,EKKO.
*DATA DECLARATIONS
INTO WA_EKKO
DO 100 TIMES .
ENDDO.
FORM = 'ZV_PO'
LANGUAGE = SY-LANGU.
WA_EKPO-MATNR = 'APACHE-160' .
EXPORTING
ELEMENT = 'BODY'
WINDOW = 'MAIN'.
AT LAST .
EXPORTING
ELEMENT = 'TOTAL'
WINDOW = 'MAIN'.
ENDAT.
ENDLOOP .
Now Create a second Page PAGE2 and copy the Main Window, Page No Window, Footer
Window.
Now Lets Re-arrange the MAIN window position i.e. Just Increase the height of MAIN window
as below by going to Graphical Form Painer.
Page : Page1
Page Windows : Copy MAIN window and TERMS windows onto page1 .
Create a title paragraph format and write the below text with font size 22 points
Step19 : Change the Driver Program for using STARTFORM AND END FORM
Write the below code in the above driver program i.e. just add the below code to the above code
CALL FUNCTION 'CLOSE_FORM'.
*The start form is used to call a different form for printing TREMS&CONDITIONS.
*This for is reusable as it is only for printing
* TREMS&CONDITIONS
EXPORTING
* ARCHIVE_INDEX = ARCHIVE_INDEX
form = 'ZV_PO_TERMS'
language = sy-langu
EXPORTING
element = 'TERMS'
window = 'MAIN'.
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZV_PO_DRIVER.
TABLES : ADRC,LFA1,EKKO.
*DATA DECLARATIONS
INTO WA_EKKO
DO 100 TIMES .
ENDDO.
EXPORTING
FORM = 'ZV_PO'
LANGUAGE = SY-LANGU.
WA_EKPO-MATNR = 'APACHE-160' .
EXPORTING
ELEMENT = 'BODY'
WINDOW = 'MAIN'.
EXPORTING
ELEMENT = 'TOTAL'
WINDOW = 'MAIN'.
ENDAT.
ENDLOOP .
*The start form is used to call another SAP SCRIPT form for printing TERMS&CONDITIONS.
EXPORTING
* ARCHIVE_INDEX = ARCHIVE_INDEX
FORM = 'ZV_PO_TERMS'
LANGUAGE = SY-LANGU
EXPORTING
ELEMENT = 'TERMS'
WINDOW = 'MAIN'.