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

PRINT_TEXT

Former Member
0 Likes
489

Hi....I am trying to use the FM - PRINT_TEXT for printing a word document which is attached to the application - Appropriation Request.

(For details..goto transaction 'IMA11' and click on the long text button. If the config is set for word document, this will appear on the screen).

My problem is printing this document directly from the prom the program using PRINT_TEXT. I am capturing the required long text information using READ_TEXT. The problem is not with the printing but the printer. Evenif I specify the printer details in the "options" parameter of the FM, it prints the document in the windows default printer only. Can anyone help me on what needs to be done to make the document print in the required printer.

Please find below the code.

********************************

DATA: LINES LIKE TLINE OCCURS 0 with header line.

data: head like thead.

data: options like itcpo.

DATA: L_ITCPP LIKE ITCPP.

data: l_input like itcpo.

options-tddest = 'TEC'.

options-tdIMMED = 'X'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'XLTD'

LANGUAGE = sy-langu

NAME = '001000000041'

OBJECT = 'IMAK'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

IMPORTING

HEADER = head

TABLES

LINES = lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 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.

else.

  • Get the print parameters

l_INPUT-TDDEST = 'TEC'.

l_INPUT-TDIMMED = 'X'.

l_INPUT-TDCOPIES = 1.

l_input-tdnewid = 'X'.

l_input-tdsenddate = syst-datum.

l_input-tdsendtime = syst-uzeit.

l_input-tdprogram = sy-repid.

L_INPUT-TDTITLE = '001000000041'.

*

CALL FUNCTION 'EFG_GET_ITCPO'

EXPORTING

X_ITCPO = l_input

X_DEVICE = 'PRINTER'

X_NO_PRINT_BUTTONS = ' '

  • X_RDI = '*'

  • X_ARCHIVE_PARAMS =

  • X_ARCHIVE_INDEX =

X_DIALOG = ' '

IMPORTING

Y_ITCPO = options

  • Y_ITCPP =

EXCEPTIONS

CANCELLED = 1

FAILED = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Print

CALL FUNCTION 'PRINT_TEXT'

EXPORTING

APPLICATION = 'TX'

  • ARCHIVE_INDEX = ' '

  • ARCHIVE_PARAMS = ' '

DEVICE = 'PRINTER'

DIALOG = ' '

HEADER = head

OPTIONS = options

IMPORTING

  • NEW_ARCHIVE_PARAMS =

RESULT = L_ITCPP

TABLES

LINES = lines

  • OTFDATA =

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

UNKNOWN = 6

FORMAT = 7

TEXTFORMAT = 8

COMMUNICATION = 9

BAD_PAGEFORMAT_FOR_PRINT = 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.

else.

*For test purpose

loop at lines.

write: / lines-tdline.

endloop.

ENDIF.

ENDIF.

Hi....I am trying to use the FM - PRINT_TEXT for printing a word document which is attached to the application - Appropriation Request.

(For details..goto transaction 'IMA11' and click on the long text button. If the config is set for word document, this will appear on the screen).

My problem is printing this document directly from the prom the program using PRINT_TEXT. I am capturing the required long text information using READ_TEXT. The problem is not with the printing but the printer. Evenif I specify the printer details in the "options" parameter of the FM, it prints the document in the windows default printer only. Can anyone help me on what needs to be done to make the document print in the required printer.

Please find below the code.

********************************

DATA: LINES LIKE TLINE OCCURS 0 with header line.

data: head like thead.

data: options like itcpo.

DATA: L_ITCPP LIKE ITCPP.

data: l_input like itcpo.

options-tddest = 'TEC'.

options-tdIMMED = 'X'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'XLTD'

LANGUAGE = sy-langu

NAME = '001000000041'

OBJECT = 'IMAK'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

IMPORTING

HEADER = head

TABLES

LINES = lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 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.

else.

  • Get the print parameters

l_INPUT-TDDEST = 'TEC'.

l_INPUT-TDIMMED = 'X'.

l_INPUT-TDCOPIES = 1.

l_input-tdnewid = 'X'.

l_input-tdsenddate = syst-datum.

l_input-tdsendtime = syst-uzeit.

l_input-tdprogram = sy-repid.

L_INPUT-TDTITLE = '001000000041'.

*

CALL FUNCTION 'EFG_GET_ITCPO'

EXPORTING

X_ITCPO = l_input

X_DEVICE = 'PRINTER'

X_NO_PRINT_BUTTONS = ' '

  • X_RDI = '*'

  • X_ARCHIVE_PARAMS =

  • X_ARCHIVE_INDEX =

X_DIALOG = ' '

IMPORTING

Y_ITCPO = options

  • Y_ITCPP =

EXCEPTIONS

CANCELLED = 1

FAILED = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Print

CALL FUNCTION 'PRINT_TEXT'

EXPORTING

APPLICATION = 'TX'

  • ARCHIVE_INDEX = ' '

  • ARCHIVE_PARAMS = ' '

DEVICE = 'PRINTER'

DIALOG = ' '

HEADER = head

OPTIONS = options

IMPORTING

  • NEW_ARCHIVE_PARAMS =

RESULT = L_ITCPP

TABLES

LINES = lines

  • OTFDATA =

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

UNKNOWN = 6

FORMAT = 7

TEXTFORMAT = 8

COMMUNICATION = 9

BAD_PAGEFORMAT_FOR_PRINT = 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.

else.

*For test purpose

loop at lines.

write: / lines-tdline.

endloop.

ENDIF.

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
444

Hi,

Defining your printer in SPAD transaction helps i guess.

Here give details fo printer on which you want to print.

Rgds,

HR

Read only

0 Likes
444

Hi...thanx for the reply but I hv all those things set up. The printer is already defined and I am using it for printing from SAP already.

The problem here is what are the values that needs to be passed and in what parameters of PRINT_TEXT. As you can see, I am passing the required values for printing to the parameter "options" so as to print in the required printer. But, it is still getting printed in the windows default printer only. Is there anything else that is influencing this printing to the default printer??

Thanks,

Ram.