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

Problems with SAPScript PRINT_TEXT

Former Member
0 Likes
673

Hello,

I try to print on a SAPScript-Form with the following code:

-


REPORT ZVERSUCH.

DATA: table TYPE STANDARD TABLE OF ITCPO.

DATA BEGIN OF HEADER.

INCLUDE STRUCTURE THEAD.

DATA END OF HEADER.

DATA LINES TYPE STANDARD TABLE OF TLINE.

DATA line TYPE TLINE.

DATA prod TYPE STRING.

PARAMETERS prod1.

HEADER-tdobject = 'DOKU'.

HEADER-tdid = 'ST'.

HEADER-tdspras = 'D'.

HEADER-tdform = 'S_DOCU_SHOW'.

DO 10 TIMES.

line-TDLINE = '1111111111111111111111111111111111111111'.

line-TDFORMAT = '*'.

APPEND line TO LINES.

ENDDO.

CALL FUNCTION 'OPEN_FORM'

EXPORTING FORM = 'ZTESTDRUCK'

device = 'PRINTER'.

PERFORM SAPSCRIPT_COMMAND USING 'POSITION YORIGIN +1.0 CM'.

PERFORM SAPSCRIPT_COMMAND USING 'POSITION XORIGIN +1.0 CM'.

Call FUNCTION 'PRINT_TEXT'

EXPORTING HEADER = HEADER

TABLES LINES = LINES

EXCEPTIONS

OTHERS = 01.

CALL FUNCTION 'WRITE_FORM'.

prod = 's'.

*IF sy-sysid = 'D01'.

IF prod1 = 'P'.

PERFORM PrintWasserzeichen.

ENDIF.

CALL FUNCTION 'CLOSE_FORM'.

FORM PrintWasserzeichen.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'VERSUCH'

WINDOW = 'WINDOW1'.

ENDFORM.

-


But the Part printed with "PRINT-TEXT" doesn't appear on the printer. Can anybody help me, please?

Sincerely, Lars.

4 REPLIES 4
Read only

Lakshmant1
Active Contributor
0 Likes
600

Hi Lars,

In the PRINT_TEXT function module, use OPTIONS parameter for populating the printer settings. Also have alook at

RSTXSYMB on how to use the function module.

Thanks

Lakshman

Read only

Former Member
0 Likes
600

Hello Lakshman,

thank you, for your quick response. Your hint helps me alot. Thank you. Sincerely, Lars.

Read only

Former Member
0 Likes
600

Hi Lars,

Modify your code with the following details:

DATA:
  OPTIONS LIKE ITCPO.
...
CALL FUNCTION 'INIT_TEXT'
     EXPORTING
          ID       = 'ST'
          LANGUAGE = SY-LANGU
          NAME     = 'DOCU_SHOW'
          OBJECT   = 'TEXT'
     IMPORTING
          HEADER   = HEADER
     TABLES
          LINES    = LINES.
...
OPTIONS-TDDEST = '*'.
OPTIONS-TDIMMED = '*'.
OPTIONS-TDDELETE = '*'.
...
CALL FUNCTION 'PRINT_TEXT'
     EXPORTING
          DEVICE  = 'PRINTER'
          HEADER  = HEADER
          OPTIONS = OPTIONS
     TABLES
          LINES   = LINES
     EXCEPTIONS
          OTHERS  = 0.

This should work for you.

Regards,

Rob.

Read only

Former Member
0 Likes
600

Hello Rob,

thank you for your help. Your code helped me very much. Regards, Lars.