on 05-09-2007 4:28 PM
Hi Guys,
I have a function module that runs in the background which in turn calls a print program for a sapscript. Here is the code I have in the print program:
IF sy-batch = space.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
dialog = 'X'
form = 'ZTRAVELER'
language = 'E'
IMPORTING
RESULT = i_itcpp.
MOVE-CORRESPONDING i_itcpp TO itcpo.
ELSE.
MESSAGE i000 WITH 'Printing Traveller'.
itcpo-tdimmed = 'X'.
itcpo-tdnewid = 'X'.
itcpo-tddelete = ' '.
itcpo-tdcopies = '1'.
itcpo-tdlifetime = '1'.
itcpo-tdprogram = sy-repid.
itcpo-tddest = 'LOCL'.
itcpo-tdpreview = ' '.
itcpo-tdsenddate = sy-datum.
itcpo-tdsendtime = ' '.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
device = 'PRINTER'
dialog = ' '
form = 'ZTRAVELER'
language = sy-langu
OPTIONS = itcpo.
ENDIF.
My form appears in the spool but it doesn't print immediately unless I manually go to SP01 and choose Print. Does anyone here know how I can make my form print immediately? Thanks, points will be rewarded for useful suggestions!
Hi
U can't use the device LOCL: it's assigned to the default printer of your pc, so it can't used in background, because it's a front-end process.
Use another SAP printer:
itcpo-tdimmed = 'X'.
itcpo-tdnewid = 'X'.
itcpo-tddelete = ' '.
itcpo-tdcopies = '1'.
itcpo-tdlifetime = '1'.
itcpo-tdprogram = sy-repid.
*itcpo-tddest = 'LOCL'.
<b>itcpo-tddest = <SAP PRINTER>.</b>
itcpo-tdpreview = ' '.
itcpo-tdsenddate = sy-datum.
itcpo-tdsendtime = ' '.
Max
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try to set * for device: it should mean "to use the default printer user":
itcpo-tdimmed = 'X'.
itcpo-tdnewid = 'X'.
itcpo-tddelete = ' '.
itcpo-tdcopies = '1'.
itcpo-tdlifetime = '1'.
itcpo-tdprogram = sy-repid.
<b>itcpo-tddest = '*'.</b>
itcpo-tdpreview = ' '.
itcpo-tdsenddate = sy-datum.
itcpo-tdsendtime = ' '.
So u make sure every user has setted a default printer (go to Systems->User profile->Own data: Defaults or trx SU3).
In this way the system'll print on the default printer, the problem will be if the user sets LOCL as default printer: in this case the system'll be able to print in background and u can't do nothing.
Another solution can be to insert a parameter in selection-screen to choose the printer for background mode:
<b>PARAMETERS: P_DEST LIKE ITCPP-TDDEST.</b>
TABLES: ITCPO.
ITCPO-TDIMMED = 'X'.
ITCPO-TDNEWID = 'X'.
ITCPO-TDDELETE = ' '.
ITCPO-TDCOPIES = '1'.
ITCPO-TDLIFETIME = '1'.
ITCPO-TDPROGRAM = SY-REPID.
*itcpo-tddest = 'LOCL'.
<b>ITCPO-TDDEST = P_DEST.</b>
ITCPO-TDPREVIEW = ' '.
ITCPO-TDSENDDATE = SY-DATUM.
ITCPO-TDSENDTIME = ' '.
Max
Hi Max,
Thanks, I think the best I can do is to set the parameter to '*' as you suggested. That way if the default printer is anything other than 'LOCL' it'll print immediately, if not the user will just have to go to SP01 and manually print it. Thanks for the help. I'm awarding all points to you!
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.