‎2006 Sep 26 12:29 PM
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 i am using.
********************************
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.
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.
‎2006 Sep 26 7:13 PM
Hi,
Try specifying the printer right before to call the FM 'PRINT_TEXT'.
....
options-tddest = 'TEC'.
CALL FUNCTION 'PRINT_TEXT'
....
If you prefer to specify any printer on runtime set the parameter X_DIALOG = 'X' on FM 'EFG_GET_ITCPO'.
I hope this helps,
Aubin
‎2006 Sep 27 5:19 AM
Hi Aubin...I am already doing it thru FM-'EFG_GET_ITCPO'.
I hv already tried the suggestions u hv made. but, it is not working.
Thanks,
Ram.
‎2006 Sep 27 10:01 AM
Hi Ram,
By calling the EFG_GET_ITCPO you may be overwriting the field TDDEST that you previously set to X. That is why I suggest to set TDDEST to an X after calling the FM GET_ITCPO.
What happens if you call the FM PRINT_TEXT with the parameter X_DIALOG = 'X'?
Are you getting the print dialog and able to print in the printer that are mentioning?
Aubin
‎2006 Sep 30 1:22 PM
Hi...I am using the 'EFG_GET_ITCPO' only to populate the "options" parameter in PRINT_TEXT' with few more added details that gets populated automatically by the system.
If you look at my coding...the printer I want to use is 'TEC'. I am passing the information related to the printer when calling 'EFG_GET_ITCPO'. Since for PRINT_TEXT...I donno how to make the "dialog" parameter work I tried getting these details from EFG_GET_ITCPO by entering these details in dialog mode also when calling this. Thats the only reason for me using EFG_GET_ITCPO.
The print dialog box does not show up even when I make dialog = 'X' in PRINT_TEXT. I use EFG_GET_ITCPO only to get the ITCPO info that I can use to pass to PRINT_TEXT.
If there is any other FM which I can use..plz lemme know. What I found was...the printing happens only in the frontend default printer. Is PRINT_TEXT only for printing to a frontend printer?
any suggestion for an alternate FM for printing from any printer???
Thanks,
Ram.
‎2006 Oct 02 9:43 AM
HAVE A LOOK AT THIS SIMPLE PRINT PROGRAM, i WAS ABLE TO DIRECT TEXT OUTPUT TO THE PRINTER OF MY CHOICE VIA DIALOG:
REPORT ZNRW_TEXT_PRINT .
parameters:
p_sttxt LIKE rssce-tdname OBLIGATORY DEFAULT 'Z_FERTTERMS_SIGNUP_EMAIL',
P_DIALOG AS CHECKBOX DEFAULT 'X',
p_ldest LIKE nast-ldest.
DATA: t_stlines LIKE tline OCCURS 0 WITH HEADER LINE.
data l_HEADER LIKE THEAD.
data: L_options like itcpo.
INITIALIZATION.
*default the printer to the user's own default
SELECT SINGLE SPLD FROM usr01
INTO p_ldest
WHERE bname = sy-uname.
.
START-OF-SELECTION.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'ST'
language = sy-langu
name = p_sttxt
object = 'TEXT'
importing header = l_header
TABLES
lines = t_stlines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
L_OPTIONS-TDDEST = p_ldest.
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
DIALOG = 'X'
header = l_HEADER
OPTIONS = L_OPTIONS
tables
lines = t_stlines
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
.
‎2006 Oct 02 11:48 AM
Hi Neil...Thanx for ur suggestion.
I have already tried that. Are U able send the print request to the printer of ur choice? May be ur frontend default printer and the printer of ur choice r the same. In my case the frontend printer, user master printer and my choice of printer for printing this are different from each other. They r 3 different printers. In this case, it goes to the frontend default printer only.
Any further help?
Thanx,
Ram.
‎2006 Oct 03 10:57 AM
Hi Ram,
I actually tested it using 'locl'and it worked. I'll try out another one to see what happems but it's different to my default one anyway.
Did you copy my program and try it out?
‎2006 Oct 03 12:05 PM
Yes Neil. I did try ur code. It goes to the windows default printer only. In fact I have a different printer in my user master. But, that is ignored.