cancel
Showing results for 
Search instead for 
Did you mean: 

SAP SCRIPT

Former Member
0 Kudos

Can u give any example for adding one field in SAP- Script form??? please give some specific example don't give link

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Often there are instances where an output from a SAP program is required on a physical paper in a pre-designed format. Using normal ABAP code this is not possible. Instead SAP provides an object called SAPSCRIPT to generate such kind of documents which can contain logos, tables and other objects and which can look like pre-printed documents.

This article focuses on the design and use of Layout sets in ABAP programs to generate beautified output in SAP.

A layout set is a template designed in SAP to place the stream of data coming from a SAP program on different parts of a physical page. The designer needs to lay out the various elements that need to be printed on the page and store it as an object in the SAP system. An ABAP program will subsequently call this object to generate an instance of the template – thus generating an output document from the program.

Character Strings

Used to define the fonts and the formatting and printing styles for each and every character that needs to be printed on the output document. The start of the character string is indicated by <string name>, while the end of the character string is indicated by </>

Pages

The designer needs to organise the template as a series of pages. When an actual output document is printed, it will refer to each page for putting the data coming from the ABAP program. The order of pages is also taken from the template i.e the layout set defined.

Windows

Various parts of the output document can be conveniently organised on the pages using windows. Thus the data stream coming from the ABAP program can be logically grouped into various parts and can be placed on different locations on a page

There are 2 main types of windows that can be used in a layout set:

MAIN - A layout set can have only one MAIN window which is created by default. This window can flow over multiple pages.

CONSTANT - A layout set can have any number of constant windows. A constant window can be used once per page

Text Elements

Any text that needs to be written on the output document should be placed within a text element. This includes constant text as well as variable data like internal table data coming from the ABAP program.

It is advisable to group logically related data within one text element.

The fields of various tables defined in the ABAP program will be included under these text elements. These fields are carriers of data. Every field should be included in a pair of & characters. (e.g. &aufk-aufnr&)

Page Windows

All the windows that form a page of the layout set.

Choose the window and click the Text Elements button to go to the Layout Set Editor. This consists of 2 parts

The small space on the left is for specifying the type of command, while the window adjacent to it is for writing the command or the text that needs to go under a text element.

he various types of commands that can be used within a layout set are tabulated below

Command Purpose

  • Default paragraph

Blank Continuous text

= Extended Line

( Raw Line

/ Line Feed

/= Line feed and extended line

/( Line Feed and Raw Line

/: Command Line

/* Comment Line

/E Text Element

<PN> This is either the name of the paragraph that should be applicable from that line of the layout set

The steps for including graphical elements in the layout set are as follows

  • The graphical element (like company logo) should be in valid graphic file format like .bmp or .jpg

  • Use appropriate software to convert the above file into a .TIFF file

  • Use report RSTXLDMC to upload this file as a text module in SAP

  • Execute the above program from the ABAP /4 editor

  • Enter the location of the .TIFF file on the PC

  • Specify BMON or BCOL as the raster image type

  • The SAP system suggests a name for the file ( like ZHEX-MARCO-* ). The * indicates the type of file. For e.g. if the file contains a logo then the name can be ZHEX-MACRO-LOGO

  • The ID should be ‘ST’ and give the logon language

  • Running the program will convert this .TIFF file into a text element

  • Incorporate this converted logo in the appropriate window under the appropriate text element by giving

INCLUDE ZHEX-MACRO-LOGO OBJECT TEXT ID ST in the first line

Next Page

Previous Page

The commands that are commonly used in a sap script are as follows -:

Command Use

New-page <page name> Prints the text following this command on a new page (when a page name is specified then that page is taken as the next page)

Protect ….. Endprotect This acts like a conditional page break. Putting the text within this command prevents the breaking of the text across multiple pages. If there is not enough space for the entire paragraph to be printed in the space remaining on the page, then the entire paragraph is printed on the next page

Box <xpos> <ypos> <width> <height> <frame> <intensity>

Position <xorigin> <yorigin> <window> <page>

Size <width> <height> <window> <page>

The BOX command draws a box as per the specifications. The x y co-ordinates are for the upper left corner relative to the values in the position command.

POSITION command is used to set the x y co-ordinates with respect to the start position of the window.

SIZE command is used to specify the size of the box that we need to draw.

Varying these parameters also helps to draw a line instead of a box.

IF ….. END IF This allows the conditional printing of the text on the output document. The various conditional operators that can be used are as follows

= EQ Equal to

< LT Less than

> GT Greater than

<= LE Less than or equal to

>= GE greater than or equal to

<> NE not equal to

The logical operators that can be used are as follows

NOT, AND, OR

The best way to explain the various steps in designing a SAP script is to visualize the creation of a document. The entire process is explained as a series of steps.

Let us assume that we need to design the document Invoice.doc for the ABC Company Limited.

1. Understand the structure of the document that needs to be generated page by page.

2. Find out the different pages that form the document.

3. Decide the FIRST page of the document and the pages that are going to follow.

4. Find out the various fonts and styles (bold, italics, etc) that are used in the document.

5. Also try to group the data printed on the document into logical parts.

6. Create all the character strings that have been used in the document

7. Create all the paragraphs that have been used in the document

8. Create all CONSTANT the windows that have been uniquely identified in the document

9. Identify the MAIN window of the every page of the document

10. Define the pages that form the parts of the document

11. Assign the windows to each page

12. Define the text elements within each window

13. Use function module OPEN_FORM to open the layout set.

14. Use function module WRITE_FORM to write the text elements in various windows

15. Use function module CLOSE_FORM to close the layout set

Always remember to check and activate the layout set when any change is done to it, otherwise the change will not appear on the output document that is printed!!!

SAPScript Important Programs

Here are some useful programs for SAPSCRIPT development

RSTXFCAT - Program to find out SAP Scirpt names (Search Program)

RSTXCDM1 - SAPscript: Sample Program for Form Printing

RSTXCNVR - Converting SAPscript standard text to RAW format (ASCII)

RSTXCPDF - Routines for Converting OTF Format to PDF Format

RSTXDBUG - Activate/Deactivate Form Debugger

RSTXFCAT - Find Forms

RSTXFCPY - Copy Forms Between Clients

RSTXFCOM - Comparison of Two Forms

RSTXFCON - SAPscript: Conversion of Page Format for Forms

RSTXFINF - Comprehensive Information about a Specific Form

RSTXHTML - Conversion of SAPscript Texts (ITF) to HTML

RSTXICON - List of SAP icons and their names and SAP numbers <xxxxx>

RSTXSYMB - List of SAP symbols and their names as well as <xxxxx> SAP number

RSTXR3TR - Transport Program For SAPscript Transport Objects

RSTXSCAT - Find Styles

RSTXSF01 - TrueType font installation for SAPscript/SmartForms

RSTXTCAT - Find Standard Texts

REPORT ZPSAPSCRIPT.

TABLES : EKKO,

EKPO,

KNA1,

USR01,

MARA,

MAKT.

DATA : BEGIN OF ZOPTION.

INCLUDE STRUCTURE ITCPO.

DATA : END OF ZOPTION.

PARAMETERS: P_EBELN LIKE EKKO-EBELN,

P_EBELP LIKE EKPO-EBELP.

CLEAR EKPO.

SELECT SINGLE * FROM EKPO

WHERE EBELN = P_EBELN AND

EBELP = P_EBELP.

CLEAR KNA1.

SELECT SINGLE NAME1 FROM KNA1

INTO KNA1-NAME1

WHERE KUNNR = EKPO-KUNNR.

CLEAR MAKT.

SELECT SINGLE MAKTX FROM MAKT

INTO MAKT-MAKTX

WHERE MATNR = EKPO-MATNR AND

SPRAS = SY-LANGU.

CLEAR USR01.

SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.

ZOPTION-TDDEST = USR01-SPLD. "Output device (printer)

ZOPTION-TDIMMED = 'X'. "Print immediately

ZOPTION-TDDELETE = 'X'. "Delete after printing

ZOPTION-TDPROGRAM = 'ZPQRPRNT'. "Program Name

CALL FUNCTION 'OPEN_FORM'

EXPORTING

APPLICATION = 'TX'

  • ARCHIVE_INDEX = ' '

  • ARCHIVE_PARAMS = ' '

DEVICE = 'PRINTER'

DIALOG = ' '

FORM = 'Z_TESTSCRIPT'

LANGUAGE = SY-LANGU

OPTIONS = ZOPTION

IMPORTING

LANGUAGE = SY-LANGU

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'HEADER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'HEADER'

EXCEPTIONS

ELEMENT = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MAIN'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

ELEMENT = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'FOOTER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'FOOTER'

EXCEPTIONS

ELEMENT = 1.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

Thanks&Regards,

Phani,

Points if helpful.

Former Member
0 Kudos

hi

I want to ask about SAP-Script..I dont know much about SAP-Script ??

details: I'm doing one program(report).. in which the final output goes into SAP-Script..

means final ouput displayed in SAP-Script?? and there I want to add one another additional field???

I want to know about that how to add field in that script???

please reply

Former Member
0 Kudos

Hi,

If the field is coming from print program/driver Program you can directly write like this

&WA_TEST-Fieldname&

(Here work area wa_test and Fieldname should be present in The program.)

if the field are not present in the Program

To fetch the field you have to write



/: 	DEFINE &V_MTART&
/: 	DEFINE &V_MBRSH&
/: 	DEFINE &V_MAKTL&
/:   PERFORM FETCH_DATA_MARA IN PROGRAM 'Z_SUBPOOL_SANDI' 
/: 	USING        &CAUFVD-MATNR&
/:	CHANGING &V_MTART&
/: 	CHANGING &V_MBRSH&
/: 	CHANGING &V_MAKTL&
/: 	END PERFORM

Then You Can Write


Material Typ:&V_MTART&

Here 'Z_SUBPOOL_SANDI' is a subroutine pool from where your data will come.

Reward if it helps u.

Regards

Sandipan

Former Member
0 Kudos

using SE71, I read my certificate form and there i created one window in my SAP - Script form by using

Edit >Windows>create-->variable window.

to add the field....

but i cant get that field box after executing report related to this..is it right method???

if right how to add text for that box(field) in output????

Thanks in Advance...

Former Member
0 Kudos

Hi,

After that in window.

Give your variable name &var&

Or u can give within text element as

/E elmnt_name

P &var&

whr p is paragraph format.

Add this window to the page.

Activate and then see the output.

reward if useful.

Former Member
0 Kudos

Hi,

Can u tell in detail Please.

and Please post your Question Once.

Regards

Sandipan