cancel
Showing results for 
Search instead for 
Did you mean: 

scripts

Former Member
0 Kudos

how to include reports in Sap scripts???

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Definition in the SAPscript form:

/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO

/: USING &PAGE&

/: USING &NEXTPAGE&

/: CHANGING &BARCODE&

/: ENDPERFORM

/

/ &BARCODE&

Coding of the calling ABAP program:

REPORT QCJPERFO.

FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

DATA: PAGNUM LIKE SY-TABIX, "page number

NEXTPAGE LIKE SY-TABIX. "number of next page

READ TABLE IN_PAR WITH KEY ‘PAGE’.

CHECK SY-SUBRC = 0.

PAGNUM = IN_PAR-VALUE.

READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.

CHECK SY-SUBRC = 0.

NEXTPAGE = IN_PAR-VALUE.

READ TABLE OUT_PAR WITH KEY ‘BARCODE’.

CHECK SY-SUBRC = 0.

IF PAGNUM = 1.

OUT_PAR-VALUE = ‘|’. "First page

ELSE.

OUT_PAR-VALUE = ‘||’. "Next page

ENDIF.

IF NEXTPAGE = 0.

OUT_PAR-VALUE+2 = ‘L’. "Flag: last page

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

hope dis code will help u

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello,

I ur script the following is the syntax.

Syntax in a form window:

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

In the report where the subroutine is written the following is the syntax.

FORM <form> TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

...

ENDFORM.

Let me know if you face any problem.

Regards,

Former Member
0 Kudos

SAPSCRIPTS:

-


This is a tool used to redirect SAP data to output devices. SE71 is the Tcode

to create SAPScript.

Components of a SAPScript tool are:

1. BASIC SETTINGS.

Paragraph format, character format.

2. ADMINISTRATIVE SETTINGS.

Name of the form, short description.

Layout is used to create a form in SAPScript. Layout is a collection of pages.

Page is a collection of Windows.

Types of Windows:

-


1. Main Window - This is a common window for all pages. This is a default window.

2. Constant Window - This window is used to create footer space, header space for a particular page.

3. Variable Window - This is a subwindow.

4. Graphical Window - This is an optional window, which is used to create logos or some other graphics for the page.

NAVIGATIONS FOR CREATING A SAPSCRIPT:

-


SE71 -> Specify Form name starting with Z or Y (ZSHABFORM) -> Click on Create -> Opens an interface -> Enter short description -> Click on 'Paragraph Format' from Appn. toolbar -> Specify Paragraph Name (P1)-> Press Enter -> Enter short description -> Click on 'Definitions' pushbutton from application toolbar -> Specify Default Paragraph (P1) created -> Click on Layout pushbutton from appn. toolbar -> Opens a layout with a default window 'MAIN' -> Right click on Main Window -> Select 'Edit Text' -> Opens a Line Editor -> Specify a statement -> Come back -> Save -> Activate the form -> A SAPscript is created.

To invoke the form created, we have to create a print program. Create an Executable Program

and specify the following:

CALL FUNCTION 'OPEN_FORM'

EXPORTING

FORM = 'ZSHABFORM'

LANGUAGE = SY-LANGU.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ELEMENT'

WINDOW = 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'.

-> Save -> Activate -> Execute -> Opens an interface -> Specify output device as LP01 -> Click on Print Preview (F8) pushbutton -> Executes the form.

The FM 'OPEN_FORM' is used to call the sapscript form. Here, we have to specify the name of the form as an argument.

'WRITE_FORM' is used to specify the name of the text elements and window types.

'CLOSE_FORM' is used to save and close the form attributes.

The function modules OPEN_FORM and CLOSE_FORM are mandatory ones.

PASSING ARGUMENTS TO THE FORM:

-


In Line editor, specify an argument enclosed by an ampersand symbol (&).

eg. &KARTHIK&.

Save -> Activate the form.

To pass a value from the print program to the form, declare the variable as follows in Print PRogram:

DATA KARTHIK(10) VALUE 'CHENNAI'.

....OPEN_FORM

...

....CLOSE_FORM

Save -> Activate -> Execute.

PASSING TABLE VALUES AS AN ARGUMENT TO SAPSCRIPT:

-


In the line editor, specify the table field arguments enclosed by '&' symbol as follows:

/E ELEMENT

&KNA1-KUNNR& ,, &KNA1-NAME1& ,, &KNA1-LAND1&

Save -> Activate.

In the Print Program, specify following code:

TABLES KNA1.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

FORM = 'ZSHABFORM1'

LANGUAGE = SY-LANGU.

SELECT * FROM KNA1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ELEMENT'

WINDOW = 'MAIN'.

ENDSELECT.

CALL FUNCTION 'CLOSE_FORM'.

Save -> Activate -> Execute.

PASSING INTERNAL TABLE AS AN ARGUMENT TO THE FORM:

-


In line editor, specify following arguments:

/E ELEMENT

&ITAB-KUNNR& &ITAB-NAME1& &ITAB-LAND1&

Save -> Activate.

In Print Program, specify following code:

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

SELECT * FROM KNA1 INTO TABLE ITAB.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

FORM = 'ZSHABFORM1'

LANGUAGE = SY-LANGU.

LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ELEMENT'

WINDOW = 'MAIN'.

ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'.

-> Save -> Activate -> Execute.

ADDING IMAGES TO THE FORM:

-


Create a .bmp file and save it in a directory

-> Goto SE78 Tcode -> Double click BMAP Bitmap images

-> Click on Import icon from appn. toolbar -> Opens an interface

-> Specify the path of .bmp file from the OS

-> Specify the name for the image -> Select Color bitmap image radiobutton

-> Click on Continue -> Image is imported.

To add the imported image into the form, right click on the form layout

-> Select Create Graphic -> Opens an interface

-> Select image from the form directory

-> Select Color bitmap image radiobutton

-> Specify resolution as 100 -> Continue

-> An image is added to the script.

Simply call the form from the print program.

To upload .TIFF files into the SAPscript directory, make use of a predefined executable program called as RSTXLDMC.

In SE38 Tcode, specify the above name, click on execute pushbutton from application toolbar -> Opens an interface -> Specify the file path -> Execute.

Text Elements in the line editor are used to avoid data duplication.

Do reward if useful..

Regards

Karthik.T

Former Member
0 Kudos

Hi,

You need to call subroutines in scripts.

Below is an example for how to call subroutines:

Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine

/: DEFINE &TOT_PRICE&

/: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name>

/:USING &KOMVD-KBERT&

/:CHANGING &TOT_PRICE&

/:ENDPERFORM

Then write the variable where ever you want it to be printed (mostly it will be in footer window)

Then create subroutine pool program and you have to write the code.

FORM F_GET_PRICE tables int_cond structure itcsy

outt_cond structure itcsy.

data : value type kbert,

value1 type kbert.

Read int_cond table WITH KEY 'KOMVD-KBERT'.

IF SY-SUBRC EQ 0.

value = int_cond-value.

ENDIF.

value1 = value1 + value.

Read outt_cond table with key 'TOT_PRICE'.

IF SY-SUBRC EQ 0.

outt_cond-value = value1.

Modify outt_cond index SY-TABIX.

ENDIF.

ENDFORM.

Regards,

Narendra.