Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to call scriprt in report and report in script

Former Member
0 Kudos
180

hi friends,

is it possible to call script in report and reports in script

10 REPLIES 10

vinod_vemuru2
Active Contributor
0 Kudos
107

Hi Devi,

Welcome to SDN:-)

What do u mean by calling script in report? We have to create print program to display the layout defined for that script.

We have to call FMs like OPEN_FORM, WRITE_FORM, START_FORM, END_FORM, CLOSE_FORM, CONTROL_FORM in ur print program. There will be no logic in script unlike in smart form. What ever be the logic, calculations etc will be done in print program and we will just use these variables to print the content in script.

We can't call report in script as i told there will be no logic put in script.

Hope it is clear.

Thanks,

Vinu.

Former Member
0 Kudos
107

hi,

form report u r calling script...

Function module... go through this FM

open_form

start_form

write_form

end_form

close_form

regards,

pritam.

Former Member
0 Kudos
107

HI,

It is possible to call Script in report(Print Program) using

OPEN_FORM

WRITE_FORM

START_FORM

END_FORM

CLOSE_FORM

in Print Program.

It is not possible to call Report in Script.

We want to design Script, Which contains all field name(Headings) and Records, Then we can use this script in Print Program.

Once Print Program Executes, It retrieves data from DB and feeds it into Script.

bpawanchand
Active Contributor
0 Kudos
107

Hi

Buddy, well let me explain you the concept in detail

we are not going to call the script or the report is not called from the script.Suppose if in a company we have 5000 employees and you want to send a some sort of greetings or notice then you need to design the layout of your greeting ,I mean the look and feel of the greeting card than after that you need to print 5000 copies of the created greeting card layout .So in this case SAP provides us a way to go for mass printing where you are going to design the layout of any thing (like BILLS INVOICES etc..) and then you are going to

defina a PRINT PROGRAM or DRIVER PROGRAM both are one and the same so you are going to pass your layout to different function modules that you have defined in the print program

we have various function modules like

OPEN_FORM

CLOSE_FORM

START_FORM

END_FORM

WRITE_FORM E.T.C

so here is the example how the print program prints your layout

CALL FUNCTION 'OPEN_FORM' // Initializes your Composer

  • EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

  • FORM = 'ZSCRIPT1'

  • LANGUAGE = SY-LANGU

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

ARCHIVE_ERROR = 7

INVALID_FAX_NUMBER = 8

MORE_PARAMS_NEEDED_IN_BATCH = 9

SPOOL_ERROR = 10

CODEPAGE = 11

OTHERS = 12

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'START_FORM' // Passing your layout name

EXPORTING

  • ARCHIVE_INDEX =

FORM = 'ZFORM1'

  • LANGUAGE = ' '

  • STARTPAGE = 'X'

PROGRAM = 'ZSCRIPT1'

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

  • EXCEPTIONS

  • FORM = 1

  • FORMAT = 2

  • UNENDED = 3

  • UNOPENED = 4

  • UNUSED = 5

  • SPOOL_ERROR = 6

  • CODEPAGE = 7

  • OTHERS = 8

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM' // Displaying the script n Data

EXPORTING

  • ELEMENT = ' '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'HEADER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

OTHERS = 9

.

IF SY-SUBRC <> 0.

write:/ 'ERROR IN HEADER'.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = ' '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

OTHERS = 9

.

IF SY-SUBRC <> 0.

write:/ 'ERROR IN HEADER'.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = ' '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'FOOTER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

OTHERS = 9

.

IF SY-SUBRC <> 0.

write:/ 'ERROR IN HEADER'.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'END_FORM' // Closing the form

  • IMPORTING

  • RESULT =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SPOOL_ERROR = 3

  • CODEPAGE = 4

  • OTHERS = 5

.

CALL FUNCTION 'CLOSE_FORM' // Closing the composer

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SEND_ERROR = 3

  • SPOOL_ERROR = 4

  • CODEPAGE = 5

  • OTHERS = 6

.

reward points if useful

Regards

Pavan

Former Member
0 Kudos
107

Hi Devi,

Welcome to SDN.

We call the script by mentioning the name in OPEN_FORM function module..

And from script we call the report program in which we have a subroutine with the help of control command.

/: PERFORM

/: ENDPERFORM

Go through library regarding the control commands in SCRIPTS which will help you a lot doing things easily.

Hope you got a brief idea.

Regards

Narin Nandivada.

Former Member
0 Kudos
107

hi Devi,

Welcome to SDN.

You cannot call a report program in your SCRIPT program but only the Sub Routine declared in the Program.

For calling a Sub Routine you can Use:

😕 PERFORM <subName> IN PROGRAM <Rep prog Name>

😕 ENDPERFORM.

This way you can communicate with a report program through the SCRIPT Program.

You can Call Script Program Using

OPEN_FORM FM.

Hope this will help.

Reward if useful.

Sumit Agarwal

Edited by: Sumit Agarwal on Jun 30, 2008 8:15 AM

Former Member
0 Kudos
107

Hi Reddy,

Calling a script in a report :

To call a script in your report use the function Module Open_Form.

Calling a report in a Script :

To call a report from your script use the report name in the PERFORM statement of the script.

Regards,

Swapna.

Former Member
0 Kudos
107

Hello Devi,

To call a script in report : use

OPEN_FORM function module here pass the form name .

To call the Report program from the script use

PERFORM .

Regards,

Rajitha.

Former Member
0 Kudos
107

Hi devi,

We can call a script from a report using the FM

Open_form,

Write_form,

Close_form.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'Form1' " Name of the script

language = sy-langu

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

ARCHIVE_ERROR = 7

INVALID_FAX_NUMBER = 8

MORE_PARAMS_NEEDED_IN_BATCH = 9

SPOOL_ERROR = 10

CODEPAGE = 11

OTHERS = 12

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'ELEMENT1' "Element name,here i placed a logo in the element element1

window = 'LOGO' "Window name

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'ELEMENT2'

window = 'MAIN'

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*(Similarly we can call any number of elements using write form)

call function 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

exceptions

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

others = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

we can use start_form and end_form also but they are optional.

To call a report,place the required code in a PERFORM and call the same in the script

Former Member
0 Kudos
107

Hi,

In Report we can call a script by using Function Module

'OPEN_FORM' and specify your Script Form Name in it.

I n Script we call a Subroutine program using

Control Command like

/: PERFORM

/: ENDPERFORM