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: 

duplication when printing sapscript form

0 Kudos

i have created a sapscript that is supposed to be printing a statement but when printing it prints the first record twice what could be the problem , the text elements are being generated from an internal table.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

before write_form call start_form and after that close that page.

it is behaving like that because, the text element called twice initially, u can notice it if u debug the form.

Even i have faced the same problem, to overcome that i have called start and end form...

hope this should help u.. try it out..

Rgds.,

subash

5 REPLIES 5

Former Member
0 Kudos

hi

please refer to this document

http://help.sap.com/saphelp_nw04/helpdata/en/d6/0db303494511d182b70000e829fbfe/frameset.htm

hope it helps

regards

Aakash Banga

Former Member
0 Kudos

hi,

before write_form call start_form and after that close that page.

it is behaving like that because, the text element called twice initially, u can notice it if u debug the form.

Even i have faced the same problem, to overcome that i have called start and end form...

hope this should help u.. try it out..

Rgds.,

subash

0 Kudos

using the start and close form is not helping it still is printing the first record twice let me put the code and maybe you can see wat im doing wrongly

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

DEVICE = 'PRINTER'

  • DIALOG = 'X'

FORM = 'ZSECURITIES_REP'

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'

EXPORTING

  • ARCHIVE_INDEX =

FORM = 'ZSECURITIES_REP '

  • LANGUAGE = 'EN '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • 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.

clear itab_print.

refresh itab_print.

LOOP AT itab INTO itab_print.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = 'PRINT_ITEMS'

  • 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

  • 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.

ENDLOOP.

CALL FUNCTION 'END_FORM'

  • IMPORTING

  • RESULT =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SPOOL_ERROR = 3

  • CODEPAGE = 4

  • OTHERS = 5

.

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 '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.

ENDIF.

0 Kudos

ok everything seems to be fine..but i noticed text element missing in write form..

in place of

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'PRINT_ITEMS' // i think it is commented, but give some value say B and in the editor of script where u r printing values in the command prompt use /B.

and in write_form use element = B.

Rgds.,

subash

0 Kudos

hi,

sorry in command prompt use /E and give PRINT_ITEMS adjacent to it..

and in write_form pass this element = 'PRINT_ITEMS'.