Table of Contents

What is SAP Script?

SAP Script is a special tool that helps businesses make different types of documents, like purchase orders, sales orders, invoices, and shipping labels. To make these documents, we use something called layout sets. These layout sets are made using forms, which can be either SAP Script or Smart Form.

 

In simple words, SAP Script is a tool for creating business documents. Usually, SAP gives us standard layouts for most applications. Sometimes, it’s the job of an ABAPER to change these layouts or add extra logic to make them work better.

 

Driver Program is used to fetch the data from the Database and Transfer it to the layout.

Component of SAP Script

  1. Layout
  2. Driver program

Component of Layout:

  1. Header 
  2. Pages
  3. Windows
  4. Page Windows
  5. Paragraph format
  6. Character format
  7. Documentation

Header:  It is used to maintain the administrative information i.e. form name, Language, Page format, and basic settings. Page format is created by basis people based on page width and height.

 

Page: The page is the Physical Area where we can place the windows we can’t print the data directly on the page.

 

Windows: We can place the same window on any number of pages. We can’t print the data directly on the windows.

There are 2 types of windows:

  1. Main window
  2. Variable Window

Note: The Main Window is the default window in SAP Script. Without a main window, we can’t design SAP Script.

We can’t create a Main window we create a variable window.

 

     

 

Page Window: A page window is nothing but planning the window with coordinates (Upper Margin, width, Left margin, Height) We can print the data only on the Page window.

 

Paragraph Format: This is used to print the entire paragraph with the required font and style.

 

Character Format: This is used to print the particular text in the required font and style.

 

Documentation: This is used to maintain the document related to form.

 

Note: SE71 is the Transaction code for the form builder.

 

Object: Design the layout as shown below.

         

Steps to Design the Layout:

  • Execute SE71 Transaction code – Provide the form name – Click on Create – 
  • Provide the Short Description – Click on pages in the application toolbar – In the Menubar click on Edit – create Element – Provide the page.
  •  
  • Name and Short Description – Enter
  • Repeat the same steps for all the pages
  • Click on windows in the application toolbar – Click on Edit – Create Element.
  • Provide the window name and Short Description – Enter
  •  
  • Repeat the same steps for all the windows.

    Click on the page windows in the application toolbar – in the menu bar click on Edit – Create the element – double click on our required window – provide the coordinates.

  •  
  • Repeat the same steps for all the page windows.

    • Click on Paragraph format in the application toolbar – in the menu bar click on Edit – Create the element  – Provide the paragraph format name and press enter – Provide Short description – 

    • click on the header in the application toolbar – click on Basic settings – provide the first page – Pages – Provide default paragraph P1 
    •  
    • Click on save

How to Align the Layout?

  • In the menubar click on settings – form Painter – Select the graphical form Painter and press enter – click on the layout in the application toolbar – align the layout by using drag and drop.
  • In the menu bar click on settings form painter – remove the graphical form painter checkbox and enter.
  • Save the layout – check the layout (form – check – definition)
  • Activate the layout (Form – Activate)

Note: We can place the variable window only once per page whereas the main window we can place up to 99 times per page (Main00, Main01….Main99).



  • Printing the data on the page window is always through symbols
  • Each symbol starts with ‘&’ and Ends with ‘&’.

There are 4 Types of Symbols.

  1. Program Sysmbols &WA_T001-WERKS&’
  2. System Symbols: System Symbol are system variables
    1. SAPSCRIPT: SUBRC, JOBPAGES, DRIVER, Counter, etc.
    2. SYST: ABAP System fields – CPROG, CPAGE, GROUP, Index, etc.
    3. TTXSY: SAPSCRIPT System Symbol – DATE, DAY, TIME, MONTH, etc.
  3. Standard Symbols: Stndared symbols are coming from TTDTG standard Database Table. Annotation, Authorization, AREA, Result, &Mr.&, &Dear& etc.
  4. Text Symbol: Text Symbols are the variables, which are declared in the page. &ABC&

How to Develop the Driver program:

  • Create an Executable program using SE38 Transaction code and implement the retrieving logic.
  • Access the layout from the driver program by using the ‘OPEN_FORM’ function module. The input for the above Function module is the window name.
  •  Repeat the same steps for each page window that contains program symbols.
  • Close the form by using the ‘CLOSE_FORM’ Function module.

Object 1: based on the given company code to display the company address (BUKRS, BUTXT, ORT01) in the address window by using SAP SCRIPT.


Step1 : Execute the Program

REPORT  ZCOMP_ADD_DISPLAY.


*TABLES: T001.

TYPES: BEGIN OF TY_T001,

      BUKRS TYPE T001BUKRS,

      BUTXT TYPE T001BUTXT,

      ORT01 TYPE T001ORT01,

      END OF TY_T001.


DATA: wa_company_address TYPE ty_T001,

      it_company_address TYPE TABLE OF ty_t001.


PARAMETERS: p_bukrs TYPE T001BUKRS.


START-OF-SELECTION.


  SELECT SINGLE BUKRS BUTXT ORT01 FROM T001 INTO wa_company_address

    WHERE BUKRS = p_bukrs.


* Access the Layout


  CALL FUNCTION ‘OPEN_FORM’

   EXPORTING

     FORM                              = ‘ZTEST_SCRIPT ‘

            .

*Transfer the data to address window

    CALL FUNCTION ‘WRITE_FORM’

     EXPORTING

       WINDOW                         = ‘ADDRESS’.


* Close the form


    CALL FUNCTION ‘CLOSE_FORM’.


Process Flow


P_BUKRS = 2200


BUKRS(Company Code)

BUTXT(Description)

ORT01 (PLACE)

2200

TEST1123

PARIS


Now, In our form “ZTEST_SCRIPT” for address window text element pass the variable


&WA_T001-BUKRS&

&WA_T001-BUTXT&

&WA_T001-ORT01&

Here, Write form function module will pass the data in the form.

Working with LOGO

  • We can print either .BMP image or .Tiff image.
  • Whenever we are working with .BMP image then we must convert .BMP to Graphics image by using SE18 Transaction code.
  • Whenever we are working with .Tiff image then we must convert .Tiff to text image by using “RSTXLDMC” Standard program.

 

Steps to convert .BMP to Graphics Image:

  • Execute SE78 – Expand the Graphics – Double click on bitmap images
  • Provide the Graphics name
  • Select the Radio button color bitmap
  • Click on Import
  • Browse the Bitmap image
  • Press enter

 

Steps to Insert Graphics Image into LOGO window:

  • Execute SE71 – Open the form in Change mode – click on page window
  • Double click on our required window
  • Click on Insert – Graphics – click on stored on Document Server – Provide the Graphics name
  • Select the Radio button Color and enter
  • Click on Back – Save, check and Activate

 

Steps to convert tiff to Text Images:

  • Execute SE38 – Provide the program name “RSTXLDMC” – Execute
  • Provide the tiff file name C:/file.tiff – Provide type BCOL
  • Provide text name “SANDEEP” Execute

What are the control commands in SAP Script?

In SAP Script, control commands are special instructions that allow you to control the flow and behavior of your document. These commands provide a way to add logic and conditions to your script, enabling you to create more dynamic and flexible documents. Here are some commonly used control commands in SAP Script: control commands start with /: 

Control Commands are:

Include

Include Command is used to include the standard text which is defined in SO10 Transaction. If we want to maintain the same text in more than one form instead of maintaining the same text in each form it’s better to create one standard text with common information and later we include the standard text in each form.

 

 

How to Create Standard Text:

  • Execute SO10 – provide the standard text name – “ZST_SAMPLE”
  • Click on create – provide text 

* HELLOTECH

* Berliner Str

* Berlin, Germany

  • Click on Save

How to include standard text in the page window of layout:

  • Execute SE71 Transaction code
  • OPEN the form in change mode
  • Click on page window in the application tool bar – double-click on our required window
  • Click on text elements-> place the cursor where we want to include the standard text.
  • In the menubar click on insert – Text Standard – provide standard text name and enter
  • Click on back- save-check – activate.

Define:

The define command is used to declare the variables in the page window

Eg. /: Define &V1& = 10.

Address - EndAddress:

This Command is used to print the address in the format of the target country.

/: Address

* &WA_KNA1-NAME1&

* &WA_KNA1-STRAS&

* &WA_KNA1-ORT01&

* &WA_KNA1-PSTLZ&

* &WA_KNA1-LAND1&

/: ENDADDRESS

Protect - End Protect:

This command is used to print the continuous text without any page breaks. Here, the system checks each page which page has enough of the page if no page has enough page space then it breaks the page and maintains in a different page. 

/: Protect

* Hello World Tech

* Berlin Str. 123

* Berlin, Germany

/: End Protect

TOP - EndTop:

This command is used to print the header information in the main window.

/: Top

* Purchase Doc,, Item,, Qty,, UOH,, Price

/: End-Top

Bottom - End Bottom:

This command is used to display the footer information in the main window.

/: Bottom

* Total & V_Total&

/: End-Bottom

Note: Top and Bottom commands only work in the main window these do not work in variable windows.

IF - ENDIF:

This command acts like ordinary if and Endif command functionality. 

/: If &WA_EKKO-BSART& = ‘DOM’

* Domestic Purchase Order

/: ELSEIf &WA_EKKO-BSART& = ‘IMP’

* Import Purchase order

/: ELSE

* Stock Transfer

/: Endif.

CASE...ENDCASE:

This command is used to break the page.

New Page:

This command is used to break the page.

New-Window:

This command is used to call the next window.

Set Date:

This command displays the Date and Time per client’s requirement.

/: SET Date Mask =  ‘DD:MM:YYYY’

* Date &Date& (23:03:2024)

/: SET Date Mask =  ‘DD/MM/YYYY’

* Date &Date& (23/03/2024)

/: SET TIME Mask =  ‘HH:MM:SS’

* TIME &Time& (11:10:15)

BOX:

Box command is used to draw the boxes’ vertical lines and Horizontal Lines.

Syntax of Box Command:

/: Box XPOS  ‘<Values>’ <Units> YPOS ‘<Values>’ <Units> WIDTH ‘<Values>’ <Units> HEIGHT ‘<Values>’ <Units> INTENSIFY ‘<Values>’ <Units> Frame ‘<Values>’ <Units>.

Units

Description

CM

Centimeter

MM

Millimeter

IN

Inches

CH

Character

PT

Point

TW

Twip (1 tw = 1/20 PT) 20TW = 1PT

Eg. of 3 CM height and 4 CM width box

/: Box XPOS ‘0’ CM YPOS ‘0’ CM WIDTH ‘4’CM Height ‘3’ CM frame ‘20’ TW.

Note:  if we want to draw the Horizontal Line then the height is 0. If we want to draw the vertical line then width is 0.

Eg. /: Box XPOS ‘0’ CM YPOS ‘0’ CM WIDTH ‘7’CM Height ‘0’ CM frame ‘20’ TW.

 

 OR

Eg. /: Box XPOS ‘0’ CM YPOS ‘0’ CM WIDTH ‘0’CM Height ‘4’ CM frame ‘20’ TW.

Perform - End Perform:

This command is used to add some additional logic to the standard driver program.

Scroll to Top