Application Development and Automation 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: 
Read only

Issue with open_form

Former Member
0 Likes
1,682

Hi all,

I have this piece of code .

when i click cancel win the pop window which shows me print,print preview and cancel with all other printer and print parametrs.

If i click cancel i get a message saying

output was cancelled by the user

call function 'OPEN_FORM'

exporting

device = 'PRINTER'

dialog = 'X'

form = space

language = sy-langu

options = itCTT

.

call function 'START_FORM'

exporting

  • ARCHIVE_INDEX =

form = 'ZFORM '

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

  • EXCEPTIONS

  • FORM = 1

  • FORMAT = 2

  • UNENDED = 3

  • UNOPENED = 4

For this piece of code the iam getting a mess

START_FORM is invalid, OPEN_FORM is missing

call function 'OPEN_FORM'

exporting

device = 'PRINTER'

dialog = 'X'

form = space

language = sy-langu

options = itcTT

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • 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

others = 11

.

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'

exporting

  • ARCHIVE_INDEX =

form = 'ZFORM '

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

  • EXCEPTIONS

  • FORM = 1

  • FORMAT = 2

  • UNENDED = 3

  • UNOPENED = 4

For the second case the sy-subrc is 1

Thanks

David

1 ACCEPTED SOLUTION
Read only

alejandro_bindi
Active Contributor
0 Likes
1,150

That's right, call OPEN_FORM specifying exceptions as in the second piece of code. Then check sy-subrc value and DON'T call START_FORM if it is 1 (or better, if it's not zero).

Something like this:


if sy-subrc <> 0.

	MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
	WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Else.
	call function 'START_FORM'
	exporting
	* ARCHIVE_INDEX =
	form = 'ZFORM '
	* LANGUAGE = ' '
	* STARTPAGE = ' '
	* PROGRAM = ' '
	* MAIL_APPL_OBJECT =
	* IMPORTING
	* LANGUAGE =
	* EXCEPTIONS
	* FORM = 1
	* FORMAT = 2
	* UNENDED = 3
	* UNOPENED = 4
	.
endif.

Regards.

<b>Please reward points if helpful.</b>

4 REPLIES 4
Read only

former_member192429
Active Participant
0 Likes
1,150

Did you try giving the form name in OPEN_FORM as ZFORM and uncomment the exceptions in the function module?

-Kriss

Read only

alejandro_bindi
Active Contributor
0 Likes
1,151

That's right, call OPEN_FORM specifying exceptions as in the second piece of code. Then check sy-subrc value and DON'T call START_FORM if it is 1 (or better, if it's not zero).

Something like this:


if sy-subrc <> 0.

	MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
	WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Else.
	call function 'START_FORM'
	exporting
	* ARCHIVE_INDEX =
	form = 'ZFORM '
	* LANGUAGE = ' '
	* STARTPAGE = ' '
	* PROGRAM = ' '
	* MAIL_APPL_OBJECT =
	* IMPORTING
	* LANGUAGE =
	* EXCEPTIONS
	* FORM = 1
	* FORMAT = 2
	* UNENDED = 3
	* UNOPENED = 4
	.
endif.

Regards.

<b>Please reward points if helpful.</b>

Read only

0 Likes
1,150

Hi,

i did that, why we comment the exceptions in the open_form , doesnot go for forward and open a start_form and where is the error coming from in the first case when we comment or delete the exception in open_form

Thanks

Read only

0 Likes
1,150

You must uncomment the exceptions in the OPEN_FORM call. That way you can capture errors and identify them according to SY-SUBRC value. In thes case, whatever error occurs, you must not call START_FORM, so you just evaluate SY-SUBRC <> 0.

If you comment the exceptions, a dump will occur if an error does.

Regards.

<b>Please reward points if helpful. </b>