06-06-2006 5:58 AM
hi friends,
when i run this program in the background by creating the job name and givung the program name,,the error i am getting is "specify the printer settings in the master record "where i should give the printer name while exexuting the program in background.knidly help me please..here is my code
&----
*& Report ZMAIL_SEND
*&
&----
*&
*&
&----
REPORT ZMAIL_SEND.
DATA : x_itcpo TYPE itcpo, "SAPscript output interface
x_itcpp1 TYPE itcpp, "SAPscript output parameters
x_itcpp2 TYPE itcpp,
c_std_text(8) TYPE c VALUE 'STD_TEXT', "variable that is used in SAP SCRIPT
it_packing_list TYPE TABLE OF sopcklsti1 INITIAL SIZE 0 WITH HEADER LINE,
it_objtxt TYPE TABLE OF solisti1 INITIAL SIZE 0 WITH HEADER LINE,
s_spool TYPE tsp01-rqident,
it_spool_file TYPE TABLE OF soli INITIAL SIZE 0 WITH HEADER LINE,
v_sender TYpe soextreci1-receiver VALUE 'B00732@FREESCALE.COM',
c_addr_type TYPE soextreci1-adr_typ VALUE 'INT',
it_reclist TYPE TABLE OF somlreci1 INITIAL SIZE 0 WITH HEADER LINE,
v_receiver TYPE somlreci1-receiver VALUE 'RAJKUMAR.S@LNTINFOTECH.COM',
x_docdata TYPE sodocchgi1,
tab_lines TYPE sy-tabix,
lin1 TYPE i.
------ Printer settings structure -
x_itcpo-tddest = ''.
x_itcpo-tdrdidev = ''.
x_itcpo-tdnewid = 'x'.
x_itcpo-tdsenddate = sy-datum.
x_itcpo-tdsendtime = sy-uzeit.
x_itcpo-tdschedule = 'IMM'.
x_itcpo-tdimmed = ' '.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
device = 'PRINTER'
dialog = 'X'
form = 'ZTEST_FORM '
language = sy-langu
options = x_itcpo
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT = X_ITCPP1
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.
*Assigning the standard text name
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
name = c_std_text
value = 'ZTEST_STD1'
value_length = 0
replace_symbols = 'x'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'E05_HEADER '
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.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ELEMENT1'
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.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'E05_FOOTER '
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.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = x_itcpp2
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
***********************EXECUTES SUCCESSFULLY UNTIL THIS*********************************
------- spool no. of the spool generated -
s_spool = x_itcpp2-tdspoolid.
------- Fetching of the spool contents -
IF NOT s_spool IS INITIAL.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = s_spool
first_line = 1
last_line = 1000
desired_type = 'RAW'
IMPORTING
REAL_TYPE =
SP_LANG =
TABLES
buffer = it_spool_file "mail content
BUFFER_PDF =
EXCEPTIONS
NO_SUCH_JOB = 1
JOB_CONTAINS_NO_DATA = 2
SELECTION_EMPTY = 3
NO_PERMISSION = 4
CAN_NOT_ACCESS = 5
READ_ERROR = 6
TYPE_NO_MATCH = 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.
ENDIF.
CALCULATING THE NO OF RECORDS IN IT_SPOOL_FILE************
DESCRIBE TABLE it_spool_file LINES lin1.
*------ Filling the spool contents into internal table obtxt,-----
*------ whose contents will be displayed as the body of email -
*
CLEAR it_objtxt.
IF lin1 GT 0.
LOOP AT it_spool_file.
it_objtxt-line = it_spool_file-line.
APPEND it_objtxt.
CLEAR it_objtxt.
CLEAR it_spool_file-line.
ENDLOOP.
ENDIF.
DESCRIBE TABLE it_objtxt LINES tab_lines.
READ TABLE it_objtxt INDEX tab_lines.
*------ Calculating doc. size which is email -
*
x_docdata-obj_name = 'ZTEST_STD1'.
x_docdata-obj_descr = 'HAI TEST'.
x_docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_objtxt ).
*THIS SET OF CODE IS TO UPDATE THE RECEIVER EMAIL ADDRESS
CLEAR it_reclist.
REFRESH it_reclist.
it_reclist-receiver = v_receiver.
it_reclist-rec_type = 'U'.
it_reclist-copy = 'x'.
it_reclist-blind_copy = ' '.
APPEND it_reclist.
*contains the document description
CLEAR it_packing_list.
REFRESH it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_objtxt LINES it_packing_list-body_num.
*
it_packing_list-doc_type = 'RAW'.
APPEND it_packing_list.
*this is the function module which sends the mail
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = x_docdata
put_in_outbox = 'X'
sender_address = v_sender "senders mail address
sender_address_type = 'INT'
commit_work = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
SENDER_ID =
TABLES
packing_list = it_packing_list
OBJECT_HEADER =
CONTENTS_BIN =
contents_txt = it_objtxt "this is the table which contains the content of the mail
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = it_reclist "contains the receivers mail id
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 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.
06-06-2006 6:09 AM
Hi rajkumar,
1. specify the printer settings in the master record
This probably must be the
Default Printer Setting
for the User (background user)
2. This can be done by basis team.
regards,
amit m.
06-06-2006 6:08 AM
The system is asking you to maintain a default printer for the user, which you can do in SU01 transaction.
Regards
Ravi
06-06-2006 6:09 AM
Hi rajkumar,
1. specify the printer settings in the master record
This probably must be the
Default Printer Setting
for the User (background user)
2. This can be done by basis team.
regards,
amit m.
06-06-2006 7:02 AM
hi amit ,
i just wanna run my program in background instead of foreground for that what i should do???no spool request has been made for the particular ruhn of the program..
06-06-2006 7:05 AM
As I said, Just maintain a default printer for the user in SU01 transaction.
If you want to get the user defaults, you can use GET_PRINT_PARAMETERS or BAPI_USER_GET_DETAILS to get the default printer.
Regards
Ravi
06-06-2006 7:13 AM
Hi again,
1. Whenever we run a program in background,
and if output is there,
2. then automatically it will go in spool.
regards,
amit m.
06-06-2006 7:15 AM
Hai
go through the following F.M
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING MODE = 'BATCH'
REPORT = 'MYREPORT'
IMPORTING OUT_PARAMETERS = PARAMS
VALID = VALID.
look into this link
http://help.sap.com/saphelp_nw04/helpdata/en/d5/6243ea8a4111d4b605006094192fe3/content.htm
You need to set the USER_SETTINGS perameter in your SmartForm to SPACE
Thanks & regards
Sreenivasulu P