02-23-2012 6:07 AM
Hello Experts,
Please help me out.
I'm sending PAYSLIP in pdf format to MAIL.
In Dev and Qlty Server the Payslip which i'm sending opened properly after downloading from mail.In this attached file size is 50k.
But when i'm sending payslip from Production server , after downloading the file it could not be open.In this attached file size is 25k.
I'm using same Z* report in DEV-QLTY-PROD.
Really i'm helpless please give some solution experts....
Thanks in advance.
02-24-2012 4:39 AM
hi,
i assume that you are using the F.M SO_NEW_DOCUMENT_ATT_SEND_API1 to send mail with pdf.
if so, then check the document_data-doc_size value.
02-28-2012 1:30 PM
Hi,
How are you sending the mail? and from where you are getting the pdf data?
Is it through a smartform or through adobe forms?
Regards,
Aravind
02-29-2012 2:25 PM
03-01-2012 11:34 AM
Hi,
The file size has nothing to do with this. The file size will obviously change with the contents in your PDF.
The actual problem might be that the file is not getting properly attached before sending the email in the Production server.
Compare your program in both Development & Production server. If they appear to be same, consult your basis consultant immediately. Also, just check if the attachment opens in SOST.
Regards,
Danish.
03-02-2012 6:39 AM
I compared the program , in all server it is identical....
Very much helpless..
03-02-2012 6:48 AM
Hi,
Can you please post part of your code for attaching the PDF file and sending mail ?
Regards,
Danish.
03-02-2012 7:36 AM
*&----
**& Report ZHR_PY_PAYSLIP_MAIL
**&
*&----
**&
**&
*&----
*
REPORT ZHR_PY_PAYSLIP_MAIL.
*
tables : pernr, tsp01. "table that contains spool request num
infotypes : 0000,0001,0105.
data : user_mail_id(100) type c,
password(10) type c.
types : ty_line type string.
*data for get_print_parameter
data : out_parms like pri_params, "Structure to get the print paramtrs
valid(1),
pernrname like pri_params-prrec.
*data for job_open
data : number type tbtcjob-jobcount,
job_name type tbtcjob-jobname value 'JOB_TEST'.
*submit declaration - for blocking popop and nostat screen
data : p_popup type xfeld value ' ',
p_nostat type hrf_nostat value 'X'.
*data for CONVERT_OTFSPOOLJOB_2_PDF
data : rqident like tsp01-rqident, "Spool request number
bytecount type i,
filename type rlgrap-filename,
lt_tsp01 like tsp01 occurs 0 with header line,
out_tab like tline occurs 0 with header line.
*for downloading file
data : numbytes type i.
*pdffile and encryptpdf file
data : pdffile like rlgrap-filename,
encryptpdf type string.
*batch file
data : batch_file type string,
command(15) type c,
return type i.
*data for batch file
data : begin of filetable occurs 0,
text(100),
end of filetable.
*after converting
data : i_record like solisti1 occurs 0 with header line.
DATA: obj_bin type table of solisti1,
gs_objbin type solisti1.
data : it_attachment type soli occurs 0 with header line,
it_attachment_long type ty_line occurs 0 with header line,
lv_document_data type sodocchgi1,
l_att_lines type i,
subject(65) type c,
tab_lines like sy-tabix.
DATA: payslip type xstring.
data : itab_binnew like solisti1 occurs 10 with header line.
*mail declaration
data : lt_objpack like sopcklsti1 occurs 2 with header line,
lt_objhead like solisti1 occurs 1 with header line,
lt_objbin like solisti1 occurs 10 with header line,
lt_objtxt like solisti1 occurs 10 with header line,
lt_reclist like somlreci1 occurs 5 with header line.
data : cancel.
data : monthtext(15) type c.
data:recever type SO_RECNAME.
initialization.
message 'Please ensure Payroll is run for the entered period' type 'S'.
start-of-selection.
clear: lt_reclist, lt_reclist[],
lt_objhead, lt_objhead[],
lt_objtxt, lt_objtxt[],
lt_objbin, lt_objbin[],
lt_objpack, lt_objpack[].
get pernr.
clear: user_mail_id,recever.
provide * from p0001 between pn-begda and pn-endda.
endprovide.
clear : out_parms.
clear : out_tab, out_tab[].
refresh : out_tab[].
clear : i_record, i_record[].
refresh : i_record[].
clear : number, rqident.
clear : user_mail_id, password.
*--
provide * from p0105 between pn-begda and pn-endda.
case p0105-subty.
when '0010'.
move : p0105-usrid_long to user_mail_id.
when '4001'.
move : p0105-usrid to password.
when 'MAIL'.
move : p0105-usrid to user_mail_id.
endcase.
endprovide.
if user_mail_id is initial.
reject.
endif.
*----
if user_mail_id is initial.
write : 'Error : Email id not found for pernr :', pernr-pernr.
reject.
endif.
*
if password is initial.
write : 'Error : Password not found for pernr :', pernr-pernr.
reject.
endif.
move pernr-pernr to pernrname.
***To get the Printer parameters.
call function 'GET_PRINT_PARAMETERS'
exporting
destination = 'LP01'
copies = '1'
expiration = '1'
new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
receiver = pernrname
importing
out_parameters = out_parms
valid = valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
if valid <> space.
**Run the report and pass the output to the spool request**
call function 'JOB_OPEN'
exporting
jobname = job_name
importing
jobcount = number
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if sy-subrc = 0.
clear :pnpxabkr, pnpabkrs-low, pnppernr-low.
move : pernr-pernr to pnppernr-low,
pernr-abkrs to pnpxabkr,
pernr-abkrs to pnpabkrs-low.
submit HINCEDT0 to sap-spool
spool parameters out_parms
without spool dynpro
with pnpxabkr eq pernr-abkrs
with pnptimra eq 'X'
with pcce_period eq '2'
WITH pnpdisbd EQ pnpdisbd
WITH pnpdised EQ pnpdised
with pnppabrp eq pnppabrp
with pnppabrj eq pnppabrj
with pnppernr-low eq pernr-pernr
with pnpabkrs-low eq pernr-abkrs
with FORMULAR eq 'ZSIL'
with ANDRUCK eq 'A'
with RUECKD eq 'X'
with RUECKR eq 'J'
with SORT_RR eq '1'
with SPRACHE eq 'B'
with p_popup eq ' '
with p_nostat eq 'X'
via job job_name number number
and return.
endif.
if sy-subrc = 0.
call function 'JOB_CLOSE'
exporting
jobcount = number
jobname = job_name
strtimmed = 'X'
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
others = 8.
if sy-subrc ne 0.
write : 'Job not executed'.
endif.
else.
write : 'Payslip not generated'.
endif.
else.
write : 'Job not executed'.
endif.
endif.
if sy-subrc = 0.
select single ltx into monthtext from t247
where mnr eq pn-begda+4(2)
and spras eq 'EN'.
condense monthtext.
concatenate monthtext pn-begda+0(4)
into monthtext separated by space.
*added so as to create time delay for fetching the spool.
wait up to 10 seconds.
**get the spool number stored in the table tsp01.***
select * from tsp01 into table lt_tsp01 where RQIDENT = number OR rqreceiver = pernrname.
if sy-subrc = 0.
sort lt_tsp01 descending by rqident.
read table lt_tsp01 index 1.
if lt_tsp01-rqdoctype eq 'LIST'."'SMART'.
if sy-subrc = 0.
rqident = lt_tsp01-rqident.
else.
write : 'Spool request not found'.
endif.
else.
write : 'Error : Payroll not generated for the pernr', pernr-pernr, ' during the period', monthtext.
reject.
endif.
endif.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = rqident
no_dialog = ' '
DST_DEVICE = out_parms-pdest
PDF_DESTINATION =
get_size_from_format = out_parms-pdest
IMPORTING
pdf_bytecount = bytecount
pdf_spoolid = pdfspoolid
LIST_PAGECOUNT =
" btc_jobname = job_name
" btc_jobcount = NUMBER
TABLES
pdf = out_tab
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11.
IF sy-subrc NE 0.
ENDIF.
*----
*----
check not ( out_tab[] is initial ).
refresh i_record.
clear : i_record.
*
call function 'QCE1_CONVERT'
tables
t_source_tab = out_tab
t_target_tab = i_record
exceptions
convert_not_possible = 1
others = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*
do.
i_record = it_attachment_long.
append i_record.
shift it_attachment_long left by 255 places.
if it_attachment_long is initial.
exit.
endif.
enddo.
select single ltx into subject from t247
where mnr eq pn-begda+4(2)
and spras eq 'EN'.
condense subject.
concatenate 'Payslip for the month of' subject pn-begda+0(4)
into subject separated by space.
describe table lt_objbin lines tab_lines.
read table lt_objbin index l_att_lines.
lv_document_data-doc_size = tab_lines * 255 .
lv_document_data-obj_name = 'Payslip'.
lv_document_data-obj_descr = subject.
e-mail body
clear lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = tab_lines.
lt_objpack-doc_type = 'RAW'.
" LT_OBJPACK-doc_size = STRLEN( LT_OBJTXT ).
append lt_objpack.
For e-mail attachment
lt_objhead = 'payslip.pdf'.
append lt_objhead.
lt_objbin[] = i_record[]."out_tab[]."
describe table lt_objbin lines l_att_lines.
CLEAR LT_OBJPACK.
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_att_lines.
lt_objpack-doc_type = 'PDF'.
lt_objpack-obj_name = 'attachment'.
lt_objpack-obj_descr = 'payslip'.
lt_objpack-doc_size = ( l_att_lines - 1 ) * 255 + strlen( lt_objbin ).
append lt_objpack.
make recipient list
" check user_mail_id is not initial.
move user_mail_id to recever.
lt_reclist-receiver = recever."user_mail_id.
lt_reclist-rec_type = 'U'.
append lt_reclist.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = lv_document_data
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
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.
write:/ 'Mail sent to', p0001-ename.
write : sy-uline.
else.
write:/ 'Error encountered'.
endif.
clear : lt_objpack, lt_objhead, lt_objbin, lt_reclist.
refresh : lt_objpack, lt_objhead, lt_objbin, lt_reclist.
clear : filepath+3(17), pdffile, encryptpdf, batch_file.
clear : out_tab, i_record, filetable.
clear : user_mail_id, password.
else.
write : 'payslip not generated'.
endif.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
end-of-selection.
&----
03-07-2012 3:29 AM
Hi ,
Could you please check if the spool to pdf conversion is happening as expected in production , may be some data lose here can result in such an error .
Regards,
Ratheesh BS
03-07-2012 6:27 AM
Hello Experts,
Just i debug the report in DEV and PROD simultaneously
Came to know that "SBCOMS_SR_FROM_DOCUMENT_CREATE" this function module in both server are not Identical.
What should i do now....
Regards ,
Prajyot
03-07-2012 6:53 AM
Hi,
Compare this function module in Development and Production using some File Comparison software.
Since this is a standard function module, the differences could be present only due the application of OSS Notes.
Regards,
Danish.
03-07-2012 7:27 AM
yupieeeee....
Note has been IMPLEMENTED and Issue Resolved...
NOTE number : 1430123
03-02-2012 8:46 AM
Hi ,
Use CS_BCS metind for sednig emails
lcl_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = i_body_msg
i_subject = pu_text ).
*** add the PDF as attachment to document object
lcl_document->add_attachment(
i_attachment_type = 'PDF'
i_attachment_subject = pu_text
i_att_content_hex = i_binary_content_pdf ).
03-06-2012 7:17 AM
DATA: it_lines TYPE STANDARD TABLE OF tline,
v_filename TYPE string.
CONCATENATE 'C:\PO\'sy-UNAME '\' GS_FINAL-EBELN '_' sy-datum '.pdf'INTO v_filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = v_filename
FILETYPE = 'BIN'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = it_lines
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
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 'SX_TABLE_LINE_WIDTH_CHANGE'
TABLES
CONTENT_IN = IT_LINES
CONTENT_OUT = IT_LINES255
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4.
GV_CONTRACT = GS_FINAL-EBELN.
CONCATENATE 'Kindly Find an attached copy of Purchase Order :' GV_CONTRACT '.' into BODY_CONTRACT SEPARATED BY SPACE.
CONCATENATE 'Purchase Order Confirmation :' GV_CONTRACT into GV_CONTRACT SEPARATED BY SPACE.
WA_DOCUMENT_DATA-OBJ_NAME = 'SMARTFORM'.
WA_DOCUMENT_DATA-EXPIRY_DAT = SY-DATUM + 10.
WA_DOCUMENT_DATA-OBJ_DESCR = GV_CONTRACT.
WA_DOCUMENT_DATA-SENSITIVTY = 'P'.
WA_DOCUMENT_DATA-OBJ_PRIO = '1'.
"TEXT CONTENTS OF EMAIL BODY...
CLEAR: IT_CONTENTS_TXT[],
WA_CONTENTS_TXT.
Mail Contents
IT_CONTENTS_TXT = 'Dear Sir/Madam,'.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = ' '.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = BODY_CONTRACT.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = ' This is System generated Mail, So do not reply.'.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = ' '.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = 'Thanking you'.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = ' '.
APPEND IT_CONTENTS_TXT.
IT_CONTENTS_TXT = 'Emami Paper Mills Ltd.'.
APPEND IT_CONTENTS_TXT.
DESCRIBE TABLE IT_CONTENTS_TXT LINES TAB_LINES.
READ TABLE IT_CONTENTS_TXT INDEX TAB_LINES.
WA_DOCUMENT_DATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( IT_CONTENTS_TXT ).
"SET MAIN CONTENT AS RAW (SEND THE TEXT CONTENT AS THE EMAIL BODY)
CLEAR: IT_PACKING_LIST[],
WA_PACKING_LIST.
WA_PACKING_LIST-TRANSF_BIN = ' '.
WA_PACKING_LIST-HEAD_START = 1.
WA_PACKING_LIST-HEAD_NUM = 0.
WA_PACKING_LIST-BODY_START = 1.
WA_PACKING_LIST-BODY_NUM = TAB_LINES.
WA_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND WA_PACKING_LIST TO IT_PACKING_LIST.
CLEAR: IT_RECEIVERS[],
WA_RECEIVERS.
WA_RECEIVERS-RECEIVER = GS_FINAL-SMTP_ADDR.
WA_RECEIVERS-EXPRESS = 'X'.
WA_RECEIVERS-REC_TYPE = 'U'.
APPEND WA_RECEIVERS TO IT_RECEIVERS.
CLEAR: IT_OBJECT_HEADER[].
"HOW MANY 255 WIDTH LINES DID WE GET?
DESCRIBE TABLE IT_LINES255 LINES I_LINECOUNT.
CLEAR: WA_PACKING_LIST.
"THIS IS A BINARY ATTACHMENT...
WA_PACKING_LIST-TRANSF_BIN = 'X'.
"AND THE ATTACHMENT NAME WILL BE <FORMNAME>.PDF
ATTACH_CONTRACT = GS_FINAL-EBELN.
SHIFT ATTACH_CONTRACT LEFT DELETING LEADING '0'.
SHIFT VBDKA-VBELN LEFT DELETING LEADING '0'.
CONCATENATE
WA_FORMS-NAME
'InvoiceNO-' ATTACH_CONTRACT
'.PDF'
INTO
WA_PACKING_LIST-OBJ_DESCR.
CONCATENATE ATTACH_CONTRACT '_' sy-datum '.PDF'INTO WA_PACKING_LIST-OBJ_DESCR.
"WE DON'T CARE ABOUT HEADER INTERNAL TABLE...
WA_PACKING_LIST-HEAD_START = 1.
WA_PACKING_LIST-HEAD_NUM = 0.
"FIRST TIME THROUGH, I_BODYSTART = 1
"THEN, AFTER WE APPEND THE FIRST FORM, WE SET I_BODYSTART = I_BODYSTART + I_LINECOUNT
"THIS WAY, WE ALWAYS KNOW WHERE THE BODY OF THE NEXT ATTACHMENT BEGINS...
WA_PACKING_LIST-BODY_START = I_BODYSTART.
WA_PACKING_LIST-BODY_NUM = I_LINECOUNT.
APPEND WA_PACKING_LIST TO IT_PACKING_LIST.
"APPENDING THE 255 LINES TO IT_CONTENTS_BIN FOR THE EMAIL.
LOOP AT IT_LINES255 INTO WA_LINES255.
APPEND WA_LINES255 TO IT_CONTENTS_BIN.
ENDLOOP.
"INCREASING I_BODYSTART FOR OTHER ATTACHMENTS
I_BODYSTART = I_BODYSTART + I_LINECOUNT.
WA_DOCUMENT_DATA-OBJ_DESCR = GV_CONTRACT.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
STARTING NEW TASK VBDKA-VBELN
EXPORTING
DOCUMENT_DATA = WA_DOCUMENT_DATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = IT_PACKING_LIST
OBJECT_HEADER = IT_OBJECT_HEADER
CONTENTS_BIN = IT_CONTENTS_BIN
CONTENTS_TXT = IT_CONTENTS_TXT
RECEIVERS = IT_RECEIVERS
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 'Mail Sent Succesfully' TYPE 'S'.
ENDIF.
Try this code..... Hope this will work........
03-07-2012 8:54 AM
03-07-2012 1:34 PM
Hi Prajyot,
Please mark the thread as resolve so that it will be easier for others to get the resolution from your experience and solution.
Jyoti