Paylisp in PDF Through Email
HI All,
I have a requirement to send payslip in PDF format through Email ( PE51- HR FORM EDITOR)
Converted the Payslip into PDF by using F.M BAPI_GET_PAYSLIP_PDF .
PDF got generated nd for the same am sending through Email by using the FM SO_DOCUMENT_SEND_API1.
Recieved an email but the format is not proper ..
Got hanged with this problem..
Please provide any suggestion to move furthur ...
Regards ,
Dheeraj.
@ Sriram and all ..
Here is the link of the o/p :
http://i56.tinypic.com/2w3w96d.jpg
.. Have used the FM 'QCE1_CONVERT' ( i.e to make the PDF content in a compatible format) before making use of 'SO_NEW_DOCUMENT_ATT_SEND_API1' FM.
Still am facing the same probs nd am also herewith posting the code ..
First have retrieved the latest payroll result and made the below....
VARIABLES FOR SENDING EMAIL
DATA document_data TYPE STANDARD TABLE OF sodocchgi1
WITH HEADER LINE .
DATA packing_list TYPE STANDARD TABLE OF sopcklsti1
WITH HEADER LINE .
DATA object_header TYPE STANDARD TABLE OF solisti1
WITH HEADER LINE .
DATA contents_bin TYPE STANDARD TABLE OF solisti1
WITH HEADER LINE .
DATA contents_txt TYPE STANDARD TABLE OF solisti1
WITH HEADER LINE .
DATA receivers TYPE STANDARD TABLE OF somlreci1
WITH HEADER LINE .
DATA i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE .
DATA tab_lines_txt TYPE i .
DATA tab_lines TYPE i .
DATA : successfully_sent TYPE c .
CALL FUNCTION 'BAPI_GET_PAYSLIP_PDF'
EXPORTING
employeenumber = p0001-pernr
sequencenumber = number
payslipvariant = c_payslip_variant
IMPORTING
return = return
payslip = pdf_content
pdf_fsize = pdf_fsize.
IF pdf_content IS INITIAL.
it_log-count = count.
it_log-pernr = p0001-pernr.
it_log-message_type = 'E'.
it_log-message = return-message.
APPEND it_log.
ELSE.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = pdf_content
TABLES
binary_tab = binary.
ENDIF.
ENDIF.
BREAK-POINT.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = binary
t_target_tab = i_objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
CONCATENATE 'PAYSLIP' '_' p0001-pernr '_' INTO
gc_testing.
=================================================
NAME OF THE OBJECT TO BE SENT
=================================================
BREAK-POINT.
CLEAR document_data .
document_data-obj_name = gc_tst.
document_data-obj_descr = gc_testing.
=================================================
CALCULATING THE SIZE OF THE TEXT IN THE MESSAGE
BODY AND UPDATING THE PACKING LIST
=================================================
BREAK-POINT.
DESCRIBE TABLE binary LINES gv_tab_lines .
READ TABLE binary INDEX gv_tab_lines. .
document_data-doc_size =
( gv_tab_lines - 1 ) * 255 + STRLEN( binary ).
CLEAR packing_list.
packing_list-head_start = 1.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = gv_tab_lines.
packing_list-doc_type = 'RAW'.
APPEND packing_list.
* =================================================
CALCULATING THE SIZE OF THE PDF ATTACHEMENT
AND UPDATING THE PACKING LIST
=================================================
BREAK-POINT.
DESCRIBE TABLE i_objbin LINES tab_lines.
CLEAR packing_list .
packing_list-transf_bin = 'X'.
packing_list-head_start = 1.
packing_list-head_num = 1.
packing_list-body_start = 1 .
packing_list-body_num = tab_lines .
packing_list-doc_type = 'PDF'.
packing_list-obj_name = 'INFORMATION.PDF' .
packing_list-obj_descr = 'INFORMATION.PDF' .
packing_list-doc_size = tab_lines * 255.
APPEND packing_list.
=================================================
CREATING THE ATTACHMENT OF THE MESSAGE
=================================================
FREE contents_bin .
LOOP AT i_objbin .
CLEAR contents_bin .
contents_bin = i_objbin .
APPEND contents_bin .
ENDLOOP .
* =================================================
LIST OF RECEPIENTS
=================================================
FREE receivers.
CLEAR receivers.
receivers-receiver = 'email id' .
receivers-rec_type = 'U'.
APPEND receivers.
=================================================
=================================================
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = document_data
put_in_outbox = ' '
commit_work = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = packing_list
object_header = object_header
contents_bin = contents_bin
contents_txt = contents_txt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = 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 EQ 0 .
successfully_sent = 'X' .
ENDIF .
Please suggest and let me know for furthur changes that need to be done for the above coding to resolve my problem..
Regards ,
Dheeraj
Similar Messages
-
Dear All
i have written the program for send payslip through email and its working fine
But problem is that i am not getting the correct format in PDF
Regards
ArunHi All
Plz find my code here which i am using to send Payslip through email, its working fine
But when i received the email with attachment, PDF is not coming in correct format
You can see the output of PDF given below after my code
REPORT zsendmail.
TABLES:pa0001.
DATA : BEGIN OF rgdir OCCURS 0.
INCLUDE STRUCTURE pc261.
DATA END OF rgdir.
DATA : country LIKE t001p-molga VALUE 'IN',
v_pabrj LIKE t549q-pabrj,
v_pabrp LIKE t549q-pabrp,
v_vabrj LIKE t549q-vabrj,
v_vabrp LIKE t549q-vabrp,
v_fpper1 LIKE rgdir-fpper,
v_fpper2 LIKE rgdir-fpper,
return LIKE bapireturn1,
*payslip LIKE bapi7004_payslip OCCURS 0 WITH HEADER LINE,
payslip TYPE xstring,
*slip LIKE pc408,
bin_file TYPE xstring,
pdf_fsize TYPE i,
x TYPE i,
x1 TYPE i,
v_srno LIKE pa0000-pernr.
DATA BEGIN OF slip OCCURS 0.
INCLUDE STRUCTURE pc408.
DATA END OF slip.
DATA BEGIN OF slip1 OCCURS 0.
INCLUDE STRUCTURE pc407.
DATA END OF slip1.
DATA: BEGIN OF i_pernr OCCURS 0,
pernr LIKE pa0000-pernr,
seqnr LIKE hrpy_rgdir-seqnr,
abkrs LIKE hrpy_rgdir-abkrs,
fpper LIKE hrpy_rgdir-fpper,
inper LIKE hrpy_rgdir-inper,
ipend LIKE hrpy_rgdir-ipend,
usrid_long LIKE pa0105-usrid_long,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
anred LIKE pa0002-anred,
ename LIKE pa0001-ename,
END OF i_pernr.
DATA result TYPE pay99_result.
DATA lv_buffer TYPE xstring. " added later
DATA ihrpy LIKE hrpy_rgdir OCCURS 0.
DATA whpr TYPE hrpy_rgdir.
DATA : bt_header TYPE LINE OF hrpay99_bt,
rt_header TYPE LINE OF hrpay99_rt.
DATA : objhex LIKE solix OCCURS 0 WITH HEADER LINE,
objhex1 TYPE solix.
*************************Added Later
DATA : objbin LIKE solix OCCURS 0 WITH HEADER LINE,
objbin1 TYPE solix.
DATA: y TYPE i ,
z TYPE i,
mname TYPE string.
DATA: mail_attachment_lines TYPE i,
lv_tablines LIKE sy-tabix.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: i_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
wa_reclist TYPE somlreci1 .
DATA: doc_chng LIKE sodocchgi1,
l_date(10) TYPE c,
l_time(8) TYPE c.
DATA: objhead TYPE soli_tab.
DATA : w_repid LIKE sy-repid,
w_dynpro LIKE sy-dynnr.
SELECTION-SCREEN BEGIN OF BLOCK b1 .
PARAMETERS : p_bukrs LIKE pa0001-bukrs OBLIGATORY,
p_permo LIKE t549q-permo.
SELECT-OPTIONS:s_date FOR pa0001-begda NO-EXTENSION OBLIGATORY,
s_abkrs FOR pa0001-abkrs OBLIGATORY,
s_persg FOR pa0001-persg,
s_pernr FOR pa0001-pernr.
SELECTION-SCREEN END OF BLOCK b1.
LOAD-OF-PROGRAM.
MOVE sy-repid TO w_repid. MOVE sy-dynnr TO w_dynpro.
WRITE: sy-datum TO l_date, sy-uzeit TO l_time.
START-OF-SELECTION.
PERFORM select_data.
*& Form SELECT_DATA
FORM select_data .
SELECT SINGLE pabrj pabrp vabrj vabrp FROM t549q INTO (v_pabrj,v_pabrp,v_vabrj,v_vabrp) WHERE permo = p_permo AND begda >= s_date-low AND endda <= s_date-high.
CONCATENATE v_pabrj v_pabrp INTO v_fpper1.
CONCATENATE v_vabrj v_vabrp INTO v_fpper2.
CASE v_pabrp.
WHEN '01'. CONCATENATE 'APRIL' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '02'. CONCATENATE 'MAY' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '03'. CONCATENATE 'JUNE' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '04'. CONCATENATE 'JULY' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '05'. CONCATENATE 'AUGUST' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '06'. CONCATENATE 'SEPTEMBER' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '07'. CONCATENATE 'OCTOBER' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '08'. CONCATENATE 'NOVEMEBR' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '09'. CONCATENATE 'DECEMBER' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '10'. CONCATENATE 'JANUARY' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '11'. CONCATENATE 'FEBRUARY' s_date-high+0(4) INTO mname SEPARATED BY space.
WHEN '12'. CONCATENATE 'MARCH' s_date-high+0(4) INTO mname SEPARATED BY space.
ENDCASE.
hrpy_rgdir table is getting filled once the payroll is run.
SELECT hrpy_rgdirpernr hrpy_rgdirseqnr hrpy_rgdirabkrs hrpy_rgdirfpper hrpy_rgdirinper hrpy_rgdiripend pa0105usrid_long pa0002nachn pa0002vorna pa0002anred pa0001~ename
FROM hrpy_rgdir
JOIN pa0105 ON hrpy_rgdirpernr = pa0105pernr AND subty = '0010'
JOIN pa0002 ON hrpy_rgdirpernr = pa0002pernr
JOIN pa0001 ON hrpy_rgdirpernr = pa0001pernr
INTO CORRESPONDING FIELDS OF TABLE i_pernr
WHERE inper > v_fpper2
AND inper <= v_fpper1
AND fpper > v_fpper2
AND fpper <= v_fpper1
AND hrpy_rgdir~pernr IN s_pernr
AND srtza = 'A'
AND pa0105~endda >= s_date-high
AND pa0002~endda >= s_date-high
AND pa0001~endda >= s_date-high
AND pa0001~bukrs = p_bukrs
AND pa0001~abkrs IN s_abkrs
AND pa0001~persg IN s_persg.
LOOP AT i_pernr.
REFRESH : objhex , objpack , objtxt ,i_reclist.
CLEAR : objhex1, y,z,x1,x, mail_attachment_lines, wa_reclist, doc_chng , objhead.
CALL FUNCTION 'BAPI_GET_PAYSLIP_PDF'
EXPORTING
employeenumber = i_pernr-pernr
sequencenumber = i_pernr-seqnr
payslipvariant = 'ZOFF'
IMPORTING
RETURN =
payslip = payslip
pdf_fsize = pdf_fsize.
x = pdf_fsize / 255.
z = pdf_fsize - 255.
DO x TIMES.
IF x1 > z .
EXIT.
ENDIF.
objhex1-line = payslip+x1(255).
APPEND objhex1 TO objhex.
objbin1-line = payslip+x1(255).
APPEND objbin1 TO objbin.
x1 = x1 + 255.
ENDDO.
y = pdf_fsize - x1 .
objhex1-line = payslip+x1(y) .
APPEND objhex1 TO objhex.
DESCRIBE TABLE objhex LINES mail_attachment_lines.
doc_chng-obj_name = 'PAYSLIP'.
CONCATENATE 'PAYSLIP FOR' mname INTO doc_chng-obj_descr SEPARATED BY space .
CASE i_pernr-anred.
WHEN 1.
CONCATENATE 'Dear' 'Mr.' i_pernr-vorna i_pernr-nachn INTO objtxt-line SEPARATED BY ' '.
WHEN 2. CONCATENATE 'Dear' 'Ms.' i_pernr-vorna i_pernr-nachn INTO objtxt-line SEPARATED BY ' '.
WHEN 3. CONCATENATE 'Dear' 'Dr.' i_pernr-vorna i_pernr-nachn INTO objtxt-line SEPARATED BY ' '.
WHEN OTHERS. CONCATENATE 'Dear' i_pernr-vorna i_pernr-nachn INTO objtxt-line SEPARATED BY ' '.
ENDCASE.
CLEAR objtxt.
APPEND objtxt.
CONCATENATE 'Please find attached payslip for' mname INTO objtxt-line SEPARATED BY space.
APPEND objtxt.
CLEAR objtxt.
WRITE: sy-datum TO l_date,
sy-uzeit TO l_time.
CONCATENATE 'SAP System generated statement (on' l_date 'At' l_time 'IST) enclosed which does not REQUIRE SIGNATURE.' INTO objtxt-line SEPARATED BY space.
APPEND objtxt.
CLEAR objtxt.
*--FOR EMPTY LINE APPEND objtxt.
objtxt-line = 'Regards,'.
APPEND objtxt.
CLEAR objtxt.
objtxt-line = 'TEAM HR.'.
APPEND objtxt.
CLEAR objtxt.
CASE i_pernr-abkrs.
WHEN 'ZO'.
objtxt-line = 'ENGLISH LTD'.
WHEN 'Z2'. objtxt-line = 'ENGLISH LTD'.
WHEN 'Z8'. objtxt-line = 'ENGLISH LTD'.
WHEN 'Z5'. objtxt-line = 'ENGLISH LTD'.
WHEN OTHERS. objtxt-line = ''.
ENDCASE.
APPEND objtxt.
CLEAR objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES lv_tablines.
READ TABLE objtxt INDEX lv_tablines TRANSPORTING ALL FIELDS.
doc_chng-doc_size = ( lv_tablines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = lv_tablines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Pack to PDF.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = mail_attachment_lines.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'Noti'.
objpack-doc_size = pdf_fsize.
objpack-doc_size = mail_attachment_lines * 255.
objpack-obj_descr = 'payslip.pdf'.
APPEND objpack.
CLEAR: wa_reclist.
REFRESH i_reclist[].
CLEAR wa_reclist.
wa_reclist-receiver = i_pernr-usrid_long.
wa_reclist-rec_type = 'U'.
APPEND wa_reclist TO i_reclist.
CLEAR wa_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
object_header =
contents_bin = objbin
contents_txt = objtxt
contents_hex = objhex
contents_hex = slip
receivers = i_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.
* message i000 with 'Error When Sending the File'.
ELSE.
WAIT UP TO 5 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
WRITE : / 'Sucess','Emp No',
i_pernr-pernr.
ELSE.
WRITE : 'Not Sucess','Emp No',
i_pernr-pernr.
ENDIF.
ENDFORM. " SELECT_DATA
PDF Output
Bank Name Account No. Amount = Earnings - Deductions +
Adjustment
UTI002 12112112 24,287.00 = 27,950.00 - 3,663.00
+ 0.00
|----
|Earnings |Deductions
Perks/Other income/Exemptptions/Rebates
-||--
|
Basic Salary
18,000.00
Income Tax
3,663.00 ||Agg of Chapter VI | 122,000.00 |
Children Education Allow
1,200.00
Special Allowance
5,000.00
Conveyance Allowance
3,500.00
Medical Allowance - T
250.00
Total
27,950.00
Total
3,663.00 || | |
Net Pay
24,287.00 Recovery 0.00
Form 16 summary |
Gross Salary 335,400.00 |
Balance 335,400.00 |
Incm under Hd Salary 335,400.00 |
Gross Tot Income 335,400.00 |
Agg of Chapter VI 122,000.00 |
Total Income 213,400.00 |
Tax on total Income 42,680.00 |
Tax payable and surcharg 43,960.00 |
Tax deducted so far 3,663.00 |
Income Tax 3,663.00 |
|
|
|
|
|
This is a computer generated statement and signature is not required. -
Sending SAPSCRIPT in PDF through email
Hi everybody,
I'm trying to send via email a sapscript. I red more posts regarding this issue but nothing seems to run correctly.
Some posts refers to a sample program ZRICH_0003.
I've just copied the code and replaced the form's name with one of mine and run it.
The function SO_NEW_DOCUMENT_ATT_SEND_API1 return with error code 2 (document not sent). I really don't know why. I've just run it in two different SAP (4.7 and 5.0)
Both didn't work. Both systems are UNIX. Must I do something in customizing or some RFC definition?
Is there anybody that have a simple program that uses this function?
Thanks in advance
Fabrizioi have tried the same thing. first generating spool & then convering sppol to PDF.
REPORT ZPO_PDF NO STANDARD PAGE HEADING
LINE-SIZE 254.
converts list to PDF - send via mail as attachment
TABLES: adrp, "Persons (central address administration)
bhdgd, "Common data area batch heading routine
bsik, "Accounting: Secondary Index for Vendors
usr21. "Assign user name address key
General data definition
TYPE-POOLS: icon.
TYPE-POOLS: slis.
DATA: d_linsz LIKE sy-linsz.
Constants
CONSTANTS: c_yes(1) TYPE c VALUE 'X'.
Structures
DATA: e_variant TYPE disvariant.
Selection-screen
DATA: le_parameters LIKE pri_params.
DATA: l_valid(1) TYPE c.
DATA: lt_pdf TYPE TABLE OF tline WITH HEADER LINE.
DATA: l_spool_c LIKE tsp01_sp0r-rqid_char.
DATA: l_spool_i LIKE tsp01-rqident,
_RECEIVER LIKE bsik-xref3.
Get the SPOOL number
PARAMETERS:
spoolno LIKE TSP01-RQIDENT.
l_spool_i = spoolno.
DATA: NUMBYTES TYPE I,
ARC_IDX LIKE TOA_DARA,
pdfspoolid like tsp01-rqident,
jobname like tbtcjob-jobname,
jobcount like tbtcjob-jobcount,
is_otf.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = l_spool_i
NO_DIALOG = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = numbytes
PDF_SPOOLID = pdfspoolid
OTF_PAGECOUNT =
BTC_JOBNAME = jobname
BTC_JOBCOUNT = jobcount
TABLES
PDF = lt_pdf
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Build the mail
PERFORM build_mail
TABLES lt_pdf
USING _receiver.
FORM prepare_print_format USING parameters LIKE priparams.
DATA: BEGIN OF lt_report_source OCCURS 0,
line(72) TYPE c,
END OF lt_report_source.
DATA: l_string_linsz TYPE string.
DATA: l_tabix LIKE sy-tabix.
DATA: BEGIN OF lt_sentencia OCCURS 0,
line(72) TYPE c,
END OF lt_sentencia.
DATA: lt_tsp1d TYPE TABLE OF tsp1d WITH HEADER LINE.
READ REPORT sy-repid INTO lt_report_source.
CHECK sy-subrc = 0.
CLEAR: l_tabix.
WHILE NOT l_string_linsz CS '.'.
ADD 1 TO l_tabix.
READ TABLE lt_report_source
INDEX l_tabix.
TRANSLATE lt_report_source-line TO UPPER CASE.
IF l_string_linsz CS 'REPORT'
OR lt_report_source-line CS 'REPORT'.
CONCATENATE l_string_linsz
lt_report_source-line
INTO l_string_linsz
SEPARATED BY space.
CONDENSE l_string_linsz.
ENDIF.
ENDWHILE.
TRANSLATE l_string_linsz USING '. '.
CLEAR: lt_report_source.
REFRESH: lt_report_source.
FREE: lt_report_source.
SPLIT l_string_linsz AT space INTO TABLE lt_sentencia.
LOOP AT lt_sentencia
WHERE line CS 'LINE-SIZE'.
l_tabix = sy-tabix.
EXIT.
ENDLOOP.
ADD 1 TO l_tabix.
READ TABLE lt_sentencia
INDEX l_tabix.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_tsp1d
FROM tsp1d
WHERE type = 'L'
AND outcolumns >= lt_sentencia-line.
SORT lt_tsp1d
BY outcolumns.
READ TABLE lt_tsp1d
INDEX 1.
parameters-linct = lttsp1d-outrows.
parameters-linsz = ltsentencia-line.
parameters-paart = lttsp1d-papart.
ENDFORM. " prepare_print_format
FORM build_mail TABLES tpdf STRUCTURE tline
USING _receiver TYPE c.
DATA: l_length_t_pdf TYPE i.
DATA: l_string TYPE xstring.
DATA: l_string_bck TYPE string.
DATA: l_length_string TYPE i.
DATA: l_length_objbin TYPE i.
DATA: l_max_tabix TYPE i.
DATA: l_dif TYPE i.
DATA: l_hex_null TYPE x VALUE '00'.
DATA: lt_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: l_tab_lines LIKE sy-tabix.
DATA: le_doc_chng LIKE sodocchgi1.
DATA: lt_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: lt_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: lt_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: lt_contents_bin LIKE solisti1 OCCURS 0 WITH HEADER LINE.
Mail text
(...here you should fill table lt_objtxt-line)
lt_objtxt-line = 'First line of text'.
append lt_objtxt.
lt_objtxt-line = 'Second line'.
append lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
le_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255
+ STRLEN( lt_objtxt ).
le_doc_chng-obj_descr = 'PO in PDF By mail'.
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
Attached file, in PDF-format
DESCRIBE FIELD tpdf LENGTH l_length_t_pdf.
CLEAR: l_string_bck,
l_string.
LOOP AT tpdf.
CONCATENATE l_string_bck tpdf INTO l_string_bck.
l_dif = l_length_t_pdf - STRLEN( tpdf ).
DO l_dif TIMES.
CONCATENATE l_string_bck l_hex_null INTO l_string_bck.
ENDDO.
CONCATENATE l_string tpdf INTO l_string.
ENDLOOP.
sy-subrc = 0.
WHILE sy-subrc = 0.
REPLACE l_hex_null WITH space INTO l_string_bck.
ENDWHILE.
l_length_string = strlen( l_string_bck ).
DESCRIBE FIELD lt_contents_bin LENGTH l_length_objbin.
l_max_tabix = ceil( l_length_string / l_length_objbin * '1.0' ).
DO l_max_tabix TIMES.
lt_contents_bin = l_string_bck.
APPEND lt_contents_bin.
IF sy-tabix <> l_max_tabix.
l_string_bck = l_string_bck+l_length_objbin.
ENDIF.
ENDDO.
DESCRIBE TABLE lt_contents_bin LINES l_tab_lines.
APPEND lt_objhead.
lt_objpack-transf_bin = c_yes.
lt_objpack-head_start = 1.
lt_objpack-head_num = 1.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'PDF'.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255.
LOOP AT lt_contents_bin.
ENDLOOP.
lt_objpack-doc_size = lt_objpack-doc_size + STRLEN( lt_contents_bin ).
APPEND lt_objpack.
lt_reclist-receiver = 'testmailgmail.com'.
lt_reclist-rec_type = 'U'.
APPEND lt_reclist.
Finally! we send the mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = le_doc_chng
put_in_outbox = c_yes
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_contents_bin
contents_hex =
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.
ENDFORM. " build_mail -
hi,
i am sending an adobeform as pdf in an email body to an external address.ie. i need an output in my outlook account as : an email with PDF document as the body of the Email.
Problem --> I am getting the PDF as an attachment always.
here is my code
TRY.
send_request = cl_bcs=>create_persistent( ).
lp_pdf_size = XSTRLEN( ls_formoutput-pdf ).
pdf_content = cl_document_bcs=>xstring_to_solix(
ip_xstring = ls_formoutput-pdf ).
document = cl_document_bcs=>create_document(
i_type = 'PDF'
i_hex = pdf_content
i_length = lp_pdf_size
i_subject = 'test created by BCS_EXAMPLE_6' ). "#EC NOTEXT
send_request->set_document( document ).
recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = p_email ).
send_request->add_recipient( i_recipient = recipient ).
sent_to_all = send_request->send(
i_with_error_screen = 'X' ).
can someone help here
ThanksHi,
check the link , i think u will get a solution
link :
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/convertSmartformtoPDFformat
Reards ,
Sachhi -
HI,
I need to send the pdf through email. for that i have used 'CONVERT_OTF_2_PDF' which converts into PDF.
Now how to send this through mail.Hi
[Check this|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSpoolrequesttoPDFandsendase-mail]
Regards
Pavan -
I have a form that is submitting a pdf through email. Usage rights are enabled. When I hit submit I get an error. The operation failed. Any ideas?
You do not have MAPI active on your system. Acrobat uses MAPI to access your e-mail client. Since this is client dependent, it is a risky way to distribute a form.
-
Need to Generate PDF file and send it to customer through email-ALV report
HI All,
I am having data in Internal table.
can we create PDF file with out having spool-request number.
My requirement is whenever user clicks on execute button the output is generated in PDF format automatically and then send it to customer through email.
I found few programs in SDN for generation PDF. But problem is everyone passing the spool request to the function module.
spool request will be generated whenever we click on print button.
Am I correct?.
Is there any other way to create spool request automatically. If so we can pass the this spool number to the function module.
Regards,
vinod.hi
For sending a mail, this code will help you.
Pls reward if help.
FORM send_mail_2 USING msgid msgno msgv1.
mailuser oder Gruppe like sy-uname default 'Ruckerk'.
DATA: express_hold_time LIKE sovaltime.
DATA: text LIKE sotxtinfo.
DATA: receiver LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
MESSAGE ZF100 (FTP an UDB fehlgeschlagen)
text-msgid = msgid.
text-msgno = msgno.
text-msgv1 = msgv1.
text-msgv2 = ' '.
text-msgv3 = ' '.
text-msgv4 = ' '.
express_hold_time
express_hold_time-days = 01.
express_hold_time-h_min_sec = 240000.
receiver
receiver-receiver = mreceivr.
Gruppe von Empfängern
receiver-rec_type = 'C'.
und Expressmeldung ausgeben
receiver-express = 'X'.
APPEND receiver.
CALL FUNCTION 'MESSAGE_SEND_AS_MAIL'
EXPORTING
msgid = text-msgid
msgno = text-msgno
msgv1 = text-msgv1
msgv2 = text-msgv2
msgv3 = text-msgv3
TABLES
receivers = receiver.
IF sy-subrc <> 0.
WRITE:/ 'hat nicht geklappt', 'SY-SUBRC =', sy-subrc.
ENDIF.
PERFORM print_error_report.
Fehlermeldung zum Abbrechen des Report's ausgeben.
MESSAGE e398 WITH 'Jobabbruch' msgv1.
ENDFORM. " SEND_MAIL_2
Another Program:
*& Report ZSENDEMAIL *
*& Example of sending external email via SAPCONNECT *
REPORT zsendemail .
PARAMETERS: psubject(40) type c default 'Hello',
p_email(40) type c default '[email protected]' .
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*& Form POPULATE_MESSAGE_TABLE
Adds text to email text table
form populate_message_table.
Append 'Email line 1' to it_message.
Append 'Email line 2' to it_message.
Append 'Email line 3' to it_message.
Append 'Email line 4' to it_message.
endform. " POPULATE_MESSAGE_TABLE
*& Form SEND_EMAIL_MESSAGE
Send email message
form send_email_message.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
Describe the body of the message
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_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
append it_receivers.
Call the FM to post the message to SAPMAIL
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM -
How to send pdf files from local dir through emails attachments
I have some pdf documents in some directory, I want to send those pdf's as an attachment throu emails to the concerned person.
Please let me know how to attach the files and send through email.
Thanks.You are using Forms 4.5, which is a client/server configuration. When you create a pdf file, the file has to be written to a directory that is accessible from your PC. D:\ is acessible, /tmp/ not (that is a directory on some Unix server). If you want to write files to a Unix server, you have to set up Samba and map a drive from your PC to he Unix directory.
Since you are creating multiple pdf files, you will have to wait until all reports are finished and mail them afterwards. You can create a batch script to mail the files. -
Sending smartform as PDF attachment through email
Hi,
I have used the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the smartform as PDF attachment through email.In SOST transaction I can see that the mail has been sent to the reciepient,but the mail is not going to the mail box.What would be the reason for this?
Regards,
HemaThat should be the basis issue. They needs to do some settings. Please ask them to do so.
Pranav -
Sending PDF attachment through EMAIL Triggering
Hi,
Could you plaese let me know How to send Pdf Attachments
through Email in SAP.
Using Function Module SO_NEW_DOCUMENT_ATT_SEND_API1.
Regards
BhuvanaHi,
GP does not involve any sort of coding.
Just like workflow, GP has a flow desgined in a process.
Each step has a callable object associated with it.
Check [this|http://help.sap.com/saphelp_nw04s/helpdata/en/0f/619fd378a641b29386063019c24fc4/frameset.htm] link for details
-Ashutosh -
Encypting Pdf document sent through email from BO WEBI
Hi,
Encypting Pdf document sent through email from BO WEBI . Is there any sdk scripts/3rd part tools to do this.
Thanks
RanjithHello Ranjith,
There is no native functionality for encrypting a PDF document from within BusinessObjects Enterprise. Additionally, none of the BOE SDKs are able to encrypt a PDF document either. Generally speaking, if it is not possible in the product (BOE) it's not possible with the various SDKs.
I am not aware of any third party tools that can do this from inside BOE either. If you haven't done so already you may want to post a question to the [Business Objects Board|http://www.forumtopics.com/busobj/index.php?sid=1037068e7b26619422be6a7b18a8c2ee] (BOB) to see if anyone there has a suggestion.
Sincerely,
Dan Kelleher -
Submitting PDF form through email
I created an order form PDF a year ago (with Acrobat Pro 8) for a client's website with a button to submit the form through email. The customers can fill out the order form in Acrobat Reader 8 and email the PDF to my client's email. Now that doesn't seem to work anymore - an illegal operation message comes up. I've changed the action for the button to submit the order form as a FDF file but the form data is not found once the email is sent. I've found the FDF Toolkit but have no idea what to do with it. Is there a simpler way for customers to fill out the form and email it to my client?
zorro248 wrote:
Is there a simpler way for customers to fill out the form and email it to my client?
Sure. Just enable the form so Reader users can save it when it's finished then instruct them to do so and attach it to an email. -
Sending smartform through email as PDF attachment
Hi,
I want to send a smartform through email as pdf attachment.In the code I have hardcoded the receiver mail id.But I don't want this to be sent only to a particular receiver.I want this to be sent as many people as I can without hardcoding their mail id's in the program.How can I do that?
Regards,
Hema**Data Declarations
**Internal Table
DATA : BEGIN OF it_spfli OCCURS 0,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
END OF it_spfli.
DATA: it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
storing receivers
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
**storing file attachment data
it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE, gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
l_gntxt LIKE t357g_t-gntxt,
lv_message(100) TYPE c.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE. "storing mail body
DATA : psubject(30) TYPE c VALUE 'Sample Mail'. "subject of the mail
DATA : ld_format TYPE so_obj_tp , "file format
ld_attfilename TYPE so_obj_des, "file name
w_cnt TYPE i.
**Selecting the data
SELECT carrid connid INTO TABLE it_spfli FROM spfli WHERE carrid EQ 'AA'.
**Perform for populating mail body
PERFORM populate_message.
**Perform for populating file attachment
PERFORM populate_attachment.
**Perform for populating mail characteristic info
PERFORM populate_pack.
**Perform for populating receivers
PERFORM populate_receivers.
**Perform to send mail
PERFORM send_mail.
*& Form populate_message
text
--> p1 text
<-- p2 text
FORM populate_message .
**Populating the body
lv_message = 'Sample mail for testing purpose.'.
APPEND lv_message TO it_message.
ENDFORM. " populate_message
*& Form populate_attachment
text
--> p1 text
<-- p2 text
FORM populate_attachment .
**Populating the attachment file with the data from final intenal table
CONCATENATE 'CARRIER ID'
'CONNECTION ID'
INTO it_attachment SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO
it_attachment.
APPEND it_attachment.
LOOP AT it_spfli.
CONCATENATE it_spfli-carrid it_spfli-connid INTO it_attachment SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO
it_attachment.
APPEND it_attachment.
ENDLOOP.
ENDFORM. " populate_attachment
*& Form populate_receivers
text
--> p1 text
<-- p2 text
FORM populate_receivers .
**Populating Mail Recepients
**If there are more than one mail recepient then loop and append them to it_receivers
it_receivers-receiver = '[email protected]'.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
it_receivers-express = 'X'.
APPEND it_receivers.
ENDFORM. " populate_receivers
*& Form populate_pack
text
--> p1 text
<-- p2 text
FORM populate_pack .
**File Type
ld_format = 'XLS'.
**File Name
ld_attfilename = 'File1'.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject .
gd_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR gd_doc_data.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
READ TABLE it_attachment INDEX w_cnt.
gd_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_attachment ).
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
Describe the body of the message
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_message LINES it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
APPEND it_packing_list.
**Describe the attachment info
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_attachment LINES it_packing_list-body_num.
it_packing_list-doc_type = ld_format.
it_packing_list-obj_name = ld_attfilename.
it_packing_list-obj_descr = ld_attfilename.
it_packing_list-doc_size = it_packing_list-body_num * 255.
APPEND it_packing_list.
ENDFORM. " populate_pack
*& Form send_mail
text
--> p1 text
<-- p2 text
FORM send_mail .
**Function Module to send mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_packing_list
contents_bin = it_attachment
contents_txt = it_message
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.
ENDFORM. " send_mail -
Error while trying to open an attachment sent through email in smartform
Hi,
My requirement is to send the smartform through email as PDF attachment.I am able to send the mail.But when I try to open the attachment I am getting error as 'Adobe reader could not open the attachment 'advance shipment notification.PDF' because it is either not the supported file type or the file has been corrupted(for example, it was sent as an email attachment and was't correctly decoded)'.What does it mean?
Can anyone give me a proper solution for this?
It's very urgent.Useful answers will be rewarded.
Thanks,
HemaHi,
Are you using any webdispatcher or some proxy? Is there any URL filter configured in between?
If yes then I think you have to allow these pages.
Regards,
Vamshi. -
Sending Invoice as PDF in email
Hello,
I have a requirement where I have to send Proforma Invoice as PDF in email.
Now, the Proforma Invoice is already using output type to Print and when I see the routines in Tcode NACE
It uses RVADAUS1 Program where it calls RV_EXPORT_DOCUMENT_PRINT function module to generate the Print document.
This works fine.
So, I created a new output type, copied the RVADAUS1 to ZRVADAUS1 and modified the code where I am capturing the Spool generated through the original code and pass it to CONVERT_ABAPSPOOLJOB_2_PDF to convert it to PDF and then send it as an email.
Now, the problem I am facing is that, I am not able to generate a Spool when I am using the medium ( '5' External Send ). So the further code of capturing Spool and convert to PDF and send as email fails.
Any guidance is appreciated.
Regards,
DNPHi Sudhanshu,
Just before calling the function module RV_EXPORT_DOCUMENT_PRINT.
I forced TNAPR-NACHA = '1'. and NAST-NACHA = '1'.
which means I forced Transmission medium as 1(Print) instead of 5(External Send)
This created a SPOOL.
Regards,
DNP
Edited by: DNP on Aug 14, 2009 11:45 AM
Maybe you are looking for
-
AS2 Adapter Error: Error while parsing AS2 message: AUTHENTICATION_ERROR #
Hi, Following Scenario: Inbound. i have been receiving messages via Seeburger AS2 Adapter with the following Error message Error while parsing AS2 message: AUTHENTICATION_ERROR # I have done the following in the AS2 adapter as per findings in the fo
-
Hi All difference between abap and hr-abap urgent pls
Hi All difference between abap and hr-abap urgent pls
-
Problems saving to pdf files with adobe acrobat on imac
I have just installed and activated Adobe Acrobat 9.0 on my new iMac OS X 10.8.2, but it keeps coming up with an error message when trying to save a powerpoint presentation to a pdf file. I have downloaded all updates, painfully, one by one, from 9.1
-
Combine PDF feature missing from right click option Acrobat Pro 9/Windows 7
I combine PDF's all day long and need this feature. I had it on my old computer and since moving over to the new computer I do not have the option to combine PDF's when right clicking on PDF documents. I have searched the forum and found other fixes,
-
How to write the query for year revenue and avg
Hello Team I have the table create table sale (sale_id varchar2(32) not null, sale_epoch_microsec numeric(18,0) not null, sale_amount_cents numeric(18,0) not null, customer_id varchar2(32) not null, industry_id varchar2(32) not null, prod