cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Script - Open / write from from subroutine - via perform stmt

former_member615325
Participant
0 Kudos

Please let me know if I can reference "open_form" and "write_form" function modules from subroutine. I have following code in the sapscript form.

/: perform hdr_text in the program zhdr_pgm

in the zhdr_pgm, I am calling the open_form and write_form to reference new text element that I created in the form.

zhdr_pgm.

form hdr_text.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'ZPO_FORM'

EXCEPTIONS

canceled = 01

device = 02

OTHERS = 03.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'TERMS'

function = 'SET'

type = 'BODY'

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.

CLEAR sy-subrc.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

i have this same scenario. and in the thread was the answer "possible" or not "possible"?

to explain further here is my requirement

scenario:

dunning letter.

requriement:

when dunning rejected payment, we want to output all invoices related to it.

problem:

in f150 (dunning print program)

fetches all items for dunning

for each line item it calls the form to print each line (window main, text element 531)

now, for DD (rejected payments) from the script we can call a function pool to get all the invoices. but, how do we print these actually? can we from this function call write_form so that we can loop through each invoice items and print it?

Regards,

R

Former Member
0 Kudos

Hi,

Instead of using the OPEN_FORM use the START_FORM & END_FORM function modules. Why because it is not possible to use OPEN_FORM FM again with out the CLOSE_FORM.

Regards,

Jagadeesh T

Former Member
0 Kudos

Hi,

it is not possible to call another SAp script form from one script form.

you cannot open one form inside another form, it will never work because I have checked that.

Former Member
0 Kudos

So you are the "last instance" of SAP-SCRIPT knowledge? sorry just kidding, but it read a bit like this :).

You could however, store the information you wish to print on "second level" in an itab and then when you first form is ready process these stored "forms".

Former Member
0 Kudos

what is your exact requirement?

what do you mean by "to reference new text element that I created in the form"??

Former Member
0 Kudos

Yes - it's bound to be easier to simply create a text and include it.

Rob

Former Member
0 Kudos

Well, since you already have a form open (your SAPScript form), I don't think trying to call OPEN_FORM again is going to work.

Rob

former_member615325
Participant
0 Kudos

Rob..Thank you!, do you think, just write_form is going to work, if I remove call to open_form, please let me know.

Former Member
0 Kudos

It seems awkward, but I guess all you can do is try it.

I guess it won't work. you are trying to write one form while you have another open.

Rob

Edited by: Rob Burbank on Sep 21, 2010 4:56 PM

Former Member
0 Kudos

I dont really see a benefit with this solution, just problems.

Would you mind to tell us what brings you to the diea? what is your exact requirement, maybe we can propose something else which will fulfill your task as well.

E.G. like rob already proposed, building a text saving it useing SAVE_TEXT and inculding it.

former_member615325
Participant
0 Kudos

Thank you Rob, Patrik and Florian, thank you for your input. required design is to loop through the elements on the form and print text, we are still working on it and will keep you posted.

Former Member
0 Kudos

I would still ask you to explain to us in brief your total requiremnt