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: 

SAPScript: Function module as a print program

Former Member
0 Kudos

Hi community!

I need to configure a function module as a print program. So when in a form I add the function as a print program the form can't "see" the values of parameters.

When I create the include in function group I got a dump: the program type is I instead of 1 or M.

Is there any way to solve the problem?

Thanks forhead.

8 REPLIES 8

Former Member
0 Kudos

Hi

Which include are you adding?

Max

0 Kudos

Hi Max!

I am adding include type I in which I call the Open form/Close form functions.

0 Kudos

Hi

So have you created a form where you call your sapscript?

If it's so, if I'm understand you should have something like this:

FUNCTION Z_MY_FUNCTION.

PERFORM CALL_FORM.

ENDFUNCTION.

You want to create the form CALL_FORM in an include, is it right?

Check where you have inserted that include, you should create it into main program of function group here you find the top include and the include where the function modules are defined, so put your new include after these include.

Y should rispect the name convention for your include too.

Max

0 Kudos

I did all this. The problem is in sapscript in se71 when add the print program(my include) I got dump: the program type is I instead of 1 or M.

0 Kudos

Hi

I'm sorry: ok now I've understood.

Yes it's ok, all the routines you need to call in a sapscript have to be defined in a program so (type 1) and not in a include.

Infact the statament is:

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

Where <prog> has to pe a program.

If you have defined the routine an include of a function group, try to use the name of the main program instead of the name of the include, so:

/: PERFORM <form> IN PROGRAM <SAPLZ....>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

If you haven't inserted the include into any function group, you have to change the type from I to 1.

Max

0 Kudos

OK, I did not explain my self good enough.

I need to call the sapscript layout from a function module.

So, the print program can be:

1. the function module himself.

2. some include in function group.

Now, when try the (1) I call the Open form and Close form just from the function group. It works, but the layout can't "see" the values of parameters, in the layout they are empty.

(2) When I put the Open form \ Close form functions in some include in function group I get dump. I cant change the include type to '1' because it will be a report program.

0 Kudos

Hi

1) It depends on where the parameters to be printed are defined, they should be dafined in the top include of the function group, so they have to be global data.

So your code should be:

a) directly in fm

FUNCTION Z_CALL_FORM.

*"----


""Interfaccia locale:

*"----


CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = <SAPSCRIPT>.

.............................

CALL FUNCTION 'CLOSE_FORM'.

ENDFUNCTION.

2) In an include:

FUNCTION Z_CALL_FORM.

*"----


""Interfaccia locale:

*"----


INCLUDE ZCALL_FORM.

ENDFUNCTION.

3) In a routine:

FUNCTION Z_CALL_FORM.

*"----


""Interfaccia locale:

*"----


PERFORM ZCALL_FORM.

ENDFUNCTION.

The routine is defined in an include of function group

----


***INCLUDE LZFORMF01 .

----


FORM ZCALL_FORM.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'Z_MY_FORM'.

..............................

CALL FUNCTION 'CLOSE_FORM'.

ENDFORM. " ZCALL_FORM

Anyway I don't know how to call your sapscript, but you can do it only by methods above.

In all methods the data you have to print have to be defined in <b>TOP INCLUDE as GLOBAL DATA</b>.

You can indicate a different program where the data to be printed are defined in the field OPTIONS-TDPROGRAM.

Generally this field is empty and so the system insert the program defined in SY-CPROG, so the program has called the form.

2) I can't understand in which includes you have inserted them.

Max

0 Kudos

Well, I solve it by importing parameters from function to the printing program, but anyway your answers were helpfull. Thanks.