cancel
Showing results for 
Search instead for 
Did you mean: 

Calling subroutines from SAPScript

Former Member
0 Kudos

Hi all,

I have added a piece of code in my MAIN window which calls a subroutine in another program. This works just fine. However, when I moved the code from one <b>window element</b> of MAIN to another, the code is no longer triggered.

What causes this to happen? Is it related to the calling of function module WRITE_FORM in the application program? Any ideas?

All helpful answers will be rewarded!

Regards,

M.V.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In some case we need to do some mathematical operations in scripts !! Those things we cant do in Script Editor !! thats y the subroutines are there in scripts !!

You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.

PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.

**************************************************************************************************

Syntax in a form window:

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.

OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.

The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:

FORM <form> TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

...

ENDFORM.

Regards

Rama.Pammi

Former Member
0 Kudos

Hi,

As explained the script calls a subroutine in an external program, and this subroutine returns a value. All of this works fine...!

The problem is that the code is not triggered when i move the PERFORM... code piece from one <u><b>window element</b></u> to antoher - so what I am asking is if there are any restrictions related to the WRITE_FORM function module call in the driver program that might cause this?

Regards,

M.V

Former Member
0 Kudos

Hi,

The elements in the MAIN window are triggered individually by the print program. Each call could be conditional based on some ABAP logic, not every element is guarenteed to be call in every run. It may be that for your current test data the element where your PERFORM now sits is not being called.

Regards,

Nick

Answers (0)