‎2007 Sep 27 10:53 AM
‎2007 Sep 27 10:59 AM
Hi Ritu,
Check these linkes,
Link for SAP Scripts (step by step procedure)
SAPScripts
http://esnips.com/doc/1ff9f8e8-0a4c-42a7-8819-6e3ff9e7ab44/sapscripts.pdf
http://esnips.com/doc/1e487f0c-8009-4ae1-9f9c-c07bd953dbfa/script-command.pdf
http://esnips.com/doc/64d4eccb-e09b-48e1-9be9-e2818d73f074/faqss.pdf
http://esnips.com/doc/cb7e39b4-3161-437f-bfc6-21e6a50e1b39/sscript.pdf
http://esnips.com/doc/fced4d36-ba52-4df9-ab35-b3d194830bbf/symbols-in-scripts.pdf
SAP SCRIPT FIELDS
http://help.sap.com/saphelp_erp2005vp/helpdata/en/d1/8033ea454211d189710000e8322d00/content.htm
scripts easy material
http://www.allsaplinks.com/sap_script_made_easy.html
http://www.sappoint.com/abap/ssintro.pdf
http://www.sappoint.com/abap/sscript.pdf
http://www.sappoint.com/abap/sscript.pdf
http://www.sappoint.com/abap/lsetssap.pdf
http://www.sappoint.com/abap/sscrtpex1.pdf
http://www.sap-img.com/sapscripts.htm
http://www.thespot4sap.com/Articles/SAPscript_Introduction.asp
http://www.sapbrain.com/TUTORIALS/TECHNICAL/SAPSCRIPTS_tutorial.html
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVSCRPROG/BCSRVSCRPROG.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVSCRRDI/BCSRVSCRRDI.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVSCREDIT/BCSRVSCREDIT.pdf
http://www.sappoint.com/abap/sscrtpex1.pdf
http://www.sap-img.com/sapscripts.htm
http://www.esnips.com/doc/1ff9f8e8-0a4c-42a7-8819-6e3ff9e7ab44/sapscripts.pdf
Other Links
http://www.virtuosollc.com/PDF/Get_Reporter.pdf
http://help.sap.com/saphelp_47x200/helpdata/en/da/6ada3889432f48e10000000a114084/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/66/bc7d2543c211d182b30000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/5b/d22cee43c611d182b30000e829fbfe/frameset.htm
http://www.virtuosollc.com/PDF/Get_Reporter.pdf
http://help.sap.com/saphelp_47x200/helpdata/en/da/6ada3889432f48e10000000a114084/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/66/bc7d2543c211d182b30000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/5b/d22cee43c611d182b30000e829fbfe/frameset.htm
http://www.thespot4sap.com/Articles/Code_CostCentreReport.asp
http://www.allsaplinks.com/dialog_programming.html
http://help.sap.com/saphelp_webas630/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/frameset.htm
http://www.allsaplinks.com/files/using_table_in_screen.pdf
http://www.geocities.com/ZSAPcHAT
Regards,
Pritha.
Reward points if helpful.
‎2007 Sep 27 11:01 AM
Hi
Transaction Codes Used
SE71 : Form Painter
SE72 : Style Maintenance
SE73 : Font Maintenance
SE78 : Sapscript Graphics Management
RSTXLDMC : Import graphics as text .
SYMBOLS
Symbols are place holder for values in the forms and are filled during
print formatting e.g. &DATE& ,&KNA1-NAME& . They are case insensitive
and are surrounded by &.
There are 3 types of symbols
1) System Symbols
System symbols are system maintained and their value is provided
by the system. These are as follow:
DATE
TIME
HOURS
MINUTES
SECONDS
PAGE
NEXTPAGE
DAY
MONTH
YEAR
NAME_OF_DAY
SPACE
DEVICE
2)Standard Symbols
Standard sumbols are user maintained by using transaction SM30 .These symbols are stored in table TTDG e.g &MFG& which
stands for ' Your's Faithfully ' .
3)Program Symbols
Program symbols are placeholder for database fields and global program symbols in the print program e.g &KNA1-NAME1& here the table
KNA1 has alreadty been declared in the print program using TABLES statement.
CONTROL COMMANDS
Control Commands are used to change text output , these are used with
the format key /: in the format column
e.g. INCLUDE MYTEXT OBJECT TEXT ID ST
These are:
INCLUDE
DEFINE
ADDRESS ... ENDADDRESS
PROTECT ... ENDPROTECT
NEW-PAGE
IF ... ENDIF
CASE .... ENDCASE
PERFORM ... USING
INCLUDE name OBJECT name ID name PARAGRAPH name LANGUAGE name
Include command is used to include standard text in a form.the text
should be already defined by using transaction SO10.
Here name is the name of text
ID is used to classify text e.g. SDVD (SD related text) , ST (Standard text)
OBJECT is used to specify type of object it an be TEXT , DOKU
LANGUAGE is used to specify language like EN ,if ommited than logon
language is used
PARAGRAPH is used to specify the paragraph like C
e.g. /:INCLUDE mytext OBJECT TEXT ID ST LANGUAGE EN
Here the standard text created in SO10 with name mytext is
included in the form in language EN (English)
DEFINE
Define is used to define a symbol in the form i.e defining a variable and
giving it a value . e.g. /:DEFINE &NAME& = 'Niraj Visnoi'
/:DEFINE &SPECIAL& = ' 14 TH APRIL'
ADDRESS ... ENDADDRESS
ADDRESS and ENDADDRESS is used to specify the address which will
be formatted according to the target country i.e the recipient country.
e.g. /:ADDRESS sales PARAGRAPH C
/:NAME &KNA1-NAME1&
/:STREET &KNA1-STRAS&
/:POSTCODE &KNA1-PSTLZ&
/:CITY &KNA1-ORT01&
/:COUNTRY &KNA1-LAND1&
/:FROMCOUNTRY 'DE'
/:ENDADDRESS
PROTECT .... ENDPROTECT
The text which we want to be printed without any break i.e printed completely in a page is
inserted between PROTECT and ENDPROTECT . If sapscript finds that the text cannot be printed on that page completely a implicit page break occurs and the text is printed on the next page
NEW-PAGE
NEW-PAGE is used to insert a page break ,it can be conditional if used between IF..ENDIF
e.g. /:IF &KNA1-NAME1& = 'NIRAJ'
/:NEW-PAGE
/:ENDIF
IF ... ENDIF
IF ... ENDIF is used in the same way as in ABAP , a condition is tested and if it is true
all the statements between IF and ELSE are executed otherwise statements between ELSE
and ENDIF are executed, ELSE is optioonal.
/:IF condition
..
..
/:ENDIF
or
/:IF condition
..
ELSE
..
/:ENDIF
CASE ... ENDCASE
It si similar to multiple IF.. ENDIF's but is much cleaner.
/:CASE condition
/:WHEN value1
...
/:WHEN value2
...
...
/:ENDCASE
TIME/DATE/COUNTRY Formats
These commands are used for specifying the format of date and
time and setting the default country.
/:SET DATE MASK = 'MM.DD.YYYY'
/:SET TIME MASK = 'HH:MM'
/:SET COUNTRY 'DN'
PERFORM ... IN PROGRAM .... USING.. CHANGING ..
ENDPERFORM
To call ABAP subroutines from within a form we use the
PERFORM... IN PROGRAM ... statement , the advantage of
using it is that the print program is not required to cahnge and we
can get the new data from the subroutine which is placed in a Z
report . To pass and get the values from th subroutine the
parameters are passed which are of type structure ITCSY.
e.g. /:PERFORM get_date IN PROGRAM zreport
/:USING &SALESORDER&
/:CHANGING &S_DATE&
/:ENDPERFORM
The date &S_DATE& ....
The ABAP Code would be
REPORT zreport.
TABLES ztab.
FORM get_date TABLES in_tab STRUCTURE ITCSY out_tab
STRUCTURE ITCSY .
READ TABLE in_tab INDEX 1.
SELECT some_date FROM ztab WHERE salesorder = in_tab-value.
IF sy-subrc EQ 0.
READ TABLE out-tab INDEX 1.
MOVE ztab-somedate TO out_tab-value
MODIFY out_tab INDEX 1.
ENDIF.
ENDFORM.
In the above code USING is used to pass the value to the
subroutine while changing is used to recieve the value from th
subroutine ,for further paramters we can use either USING or
CHANGING .
In the subroutine the type of paramter is always an internal table of
type ITCSY irrespective of the value passed.The VALUE field
of the internal table is used to fill and recieve the values .
The print program is used to print the actual form ,the functions the print program has to do include retrieving of data from database tables , selecting a FORM and printing of TEXT ELEMENTS in a desired sequence.
The function modules used in aprint prgram are :
OPEN_FORM
START_FORM
WRITE_FORM
CONTROL_FORM
END_FORM
CLOSE_FROM
To start printing a form we must use OPEN_FORM and in the end we should use CLOSE_FORM to complete the spool request.
Function modules in detail.
OPEN_FORM function module
This function module should be called first before any printing can take place , here we specify the name of the form and the print language.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DIALOG = 'X'
DEVICE = 'PRINTER'
FORM = form name
LANGUAGE = SY-LANGU
OPTIONS =
EXCEPTIONS
CANCELLED = 1
DEVICE = 2
FORM = 3
OTHERS = 11
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
In the above function module the parameter
FORM = Name of form
DEVICE = PRINTER (print using spool),TELEFAX (fax output)
SCREEN (output to screen)
OPTIONS = It is a structure of type ITCPO and it controls the various
attributes like number of copies , print preview etc.
START_FROM function module
This function module is called if we want to use different forms with similar characterstics in a single spool request,it must be closed by END_FORM function module.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM =
LANGUAGE =
STARTPAGE =
EXCEPTIONS
FORM = 1
OTHERS = 7
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
WRITE_FORM Function module
This function module is used to write text in a window in the form using
text elements (/:E element). We can specify whether the text is to be appended , replaced or added and in which portion of the window it will be printed i.e TOP, BOTTOM ,BODY. In this function module actual printing takes place.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT =
FUNCTION =
TYPE =
WINDOW =
EXCEPTIONS
ELEMENT = 1
OTHERS = 9
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
Here in this function module the ELEMENT specifies which textelement is
printed . WINDOW specifies which window of the form to be print in.
TYPE specifies the output area of the window TOP,BOTTOM,BODY.
FUNCTION specifies whether the text is to be appended , replaced or added.
CLOSE_FORM function module
This function module should be called in the end and it has no exporting
parameter.
CALL FUNCTION 'CLOSE_FROM'
IMPORTING
RESULT =
EXCEPTIONS
UNOPENED = 1
OTHERS = 5
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
Here the result parameteer returns the status information and print/fax parameters after the form has been printed.
CONTROL_FORM function module
This function module is used to insert SAPScript control commands like NEW-PAGE etc from whithin the ABAP program.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
COMMAND =
EXCEPTIONS
UNOPENED = 1
OTHERS = 3
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
NOTE: The print program and the form are stored in the table TNAPR
To use graphics in the SAPScript FORMS they must be imported to R/3 system for this we use transaction SE78 or report RSTXLDMC and give the graphics a name . The image type is generally .TIF(tagged image format) or .BMP (windows bitmap file) .
The RSTXLDMC report is used to import images which are in Tagged Image Format (.TIF) into R/3 and saved as standard text (OBJECT TEXT and ID ST) in the system. Since these images (.TIF) are stored as standard text they can be included in the sapscript using the standard INCLUDE statement. The image to be used if is not in .TIF format than it should be converted to this format e.g. by using IMAGING program in WINDOWS.
Once converted to .TIF they can be used in RSTXLDMC report. The image is stored by the name of ZHEX-MARCO-name . The other parameters in this report e.g. are used to indicate the type of IMAGE
BCOL for color or BMON for mono color images.
e.g. /:INCLUDE ZHEX-MARCO-name OBJECT TEXT ID ST
After the graphics has been imported we can use the INCLUDE statement to include the graphics or use the menu Edit->Graphics->Create.
e.g. /:BITMAP logo OBJECT GRAPHICS ID BMAP .
The above include statement is inserted automatically if we use the menu command.
BOXES and LINES
To use boxes in the form or to create a table in the form we use BOX statement. a table can be constructed by using a combination of BOXes.
/:BOX XPOS val unit YPOS val unit WIDTH val HEIGHT val INTENSITY val FRAME val unit .
The Unit used in the sapscript cane be:
TW twip
MM milimeter
CM centimeter
LN line
CH character
IN inch
PT point
The parameters like WIDTH , XPOS etc should be followed by a proper unit.
The INTENSITY is in the percentage of the grey scale.
The FRAME parameter is the thickness of the frame the default value is 0.
e.g.
/:BOX XPOS '5' CM YPOS '2' CM WIDTH '14' CM HEIGHT '20' CM FRAME 20 TW INTENSITY 10.
e.g.
/:BOX INTENSITY 10
will fill the current window background with a shading of grey scale 10%..
To draw a horizontal line we set the HEIGHT parameter to the value of 0.
e.g.
/:BOX XPOS '5' CM HEIGHT 0 TW FRAME 10 TW.
This will draw a horizontal line across the top edge of the window.
To draw a horizontal line we should set the value of WIDTH parameter to 0.
e.g.
/:BOX XPOS '5' CM YPOS WIDTH '0' TW FRAME 10 TW.
This will draw a vertical line across the complete height of the left edge of the current window.
POSITION and SIZE
We can use POSITION and SIZE to set default position and size of the window and also for relative positioning. With POSITION we can use the paramters XORIGIN , YORIGIN ,WINDOW. With SIZE we can use WIDTH and HEIGHT and WINDOW and PAGE.
e.g.
/:POSITION XORIGIN '5' CM YORIGIN '5'CM
/:SIZE HEIGHT '5' CM WIDTH '14' CM
/:BOX FRAME 10 TW INTENSITY 10
POSITION WINDOW
We can use POSITION WINDOW to set the position relative to current window i.e to the left,top of the current window ,then we can use POSITION with XORIGIN and YORIGIN to specify the current position relative to the start of the window, we can use '+' and '-' with the values.
e.g.
/:POSITION WINDOW
/:POSITION XORIGIN '5' CM YORIGIN '5' CM
In the above example the position now becomes 5 CM left from the origin of the window and 5 CM from the top of the window.
WINDOW sets the value of the WIDTH and HEIGHT to current window and
PAGE sets the value of the WIDTH and HEIGHT to current page.
e.g.
/:SIZE WINDOW
e.g.
/:SIZE PAGE.
In subroutine pool type report give this coding
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.Hope it solves your issue
Regards
Pavan
‎2007 Sep 27 12:20 PM
Hi,
Here are some useful programs for SAPSCRIPT development/search ...
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
Check the following link:
http://sap-img.com/sapscripts.htm
Regards,
Bhaskar