cancel
Showing results for 
Search instead for 
Did you mean: 

regarding smartforms very urgent

Former Member
0 Kudos

Hi All,

I have created a smartfrom.In that I have converted smartform output to html.Now I am sending this HTML output as an attachment to an email address but here I am unable to add graphic to the HTML ouput.How can I do this.

Regards,

shravan

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi sharavan,

just try this code, u can get the solution.

&----


*& Report ZINV_FORM

*&

&----


*&

*&

&----


report zinv_form.

tables: vbrk,vbrp.

*TYPES: BEGIN OF t_itab,

  • vbeln TYPE vbeln_vf,

  • fkdat TYPE fkdat,

  • name1 TYPE name1_gp,

  • addr TYPE c.

*TYPES: END OF t_itab.

types : begin of ty_binary,

binary_field(1000) type c,

end of ty_binary.

data: g_name_itab type standard table of zinv_name.

data: g_name_wa type line of zinv_namet.

data: g_head_itab type standard table of zinv_str_head.

data: g_head_wa type line of zinv_ttype_head.

data: g_item_itab type standard table of zinv_str_item.

data: g_item_wa type line of zinv_ttype_item.

data: g_tot_tab type standard table of zinv_str.

data: g_tot_wa type line of zinv_ttype.

data: g_pay_tab type standard table of zinv_pay_str.

data: g_pay_wa type line of zinv_pay_tab.

data: l_index type i.

data: sf_name type rs38l_fnam.

data: ssfcrescl type ssfcrescl,

final_ssfcrescl type ssfcrescl,

xstring type xstring,

l_data_tab type standard table of ty_binary,

tline type table of tline with header line,

ls_out_opt type ssfcompop,

filesize type i,

l_pac_list type standard table of sopcklsti1,

  • l_pac_list LIKE sodocchgi1,

  • l_docu_data LIKE sodocchgi1-doc_size,

l_doc_chng type sodocchgi1,

l_receivers type standard table of somlreci1.

select-options: s_inv for vbrk-vbeln.

*PARAMETERS: p_inv LIKE vbrk-vbeln default '90005298'.

*PARAMETERS: p_email1 LIKE somlreci1-receiver.

start-of-selection.

perform get_header.

perform get_item.

perform get_name.

perform call_form.

  • PERFORM send_email.

&----


*& Form get_header

&----


  • text

----


form get_header.

select vbeln fkdat kunag zterm from vbrk into corresponding fields of table

g_head_itab where vbeln in s_inv.

loop at g_head_itab into g_head_wa.

select zterm text1 spras from t052u into table g_pay_tab where zterm = g_head_wa-zterm

and spras = sy-langu.

l_index = sy-tabix.

read table g_pay_tab into g_pay_wa index l_index.

move: g_pay_wa-text1 to g_tot_wa-text1.

move-corresponding g_head_wa to g_tot_wa.

append g_tot_wa to g_tot_tab.

endloop.

endform. "get_header

&----


*& Form get_item

&----


  • text

----


form get_item.

select vbeln posnr arktx fkimg netwr mwsbp from vbrp into corresponding fields of table g_item_itab

for all entries in g_head_itab where vbeln eq g_head_itab-vbeln.

loop at g_head_itab into g_head_wa.

  • l_index = sy-tabix.

  • g_item_wa-tot = g_item_wa-fkimg * g_item_wa-netwr.

  • MODIFY g_item_itab FROM g_item_wa INDEX l_index.

data: l_tab_item type standard table of zex_struct.

data: l_wa_item like line of l_tab_item.

clear l_tab_item[].

call function 'ZAPR_GET_COND_DETAILS'

exporting

i_vbeln = g_head_wa-vbeln

  • I_POSNR =

  • I_KSCHL =

tables

export_tab = l_tab_item.

  • EXCEPTIONS

  • INCORRECT_INV_NUMBER = 1

  • COND_REC_NOT_FOUND = 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.

delete l_tab_item where kschl ne 'PR00'.

loop at l_tab_item into l_wa_item.

l_index = sy-tabix.

move l_wa_item-kbetr to g_item_wa-kbetr.

modify g_item_itab from g_item_wa transporting kbetr where posnr = l_wa_item-posnr

and vbeln = g_head_wa-vbeln.

endloop.

endloop.

endform. "get_item

&----


*& Form get_name

&----


  • text

----


form get_name.

select name1 kunnr from kna1 into corresponding fields of table g_name_itab

for all entries in g_head_itab where kunnr = g_head_itab-kunag.

if sy-subrc = 0.

loop at g_name_itab into g_name_wa .

l_index = sy-tabix.

call function 'Z_DR_GET_CUSTOMER_ADDRESS'

exporting

customerno = g_name_wa-kunnr

importing

customer_city = g_name_wa-ort01

customer_street = g_name_wa-stras

customer_country = g_name_wa-landx

customer_zipcode = g_name_wa-pstlz.

modify g_name_itab from g_name_wa index l_index.

endloop.

loop at g_name_itab into g_name_wa .

move-corresponding g_name_wa to g_tot_wa.

modify g_tot_tab from g_tot_wa

transporting ort01 stras landx name1 pstlz where kunag = g_name_wa-kunnr.

endloop.

endif.

endform. "get_name

end-of-selection.

&----


*& Form call_form

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form call_form .

data: wa_output type zinv_str,

gt_header type table of zinv_str_head,

gt_temp type table of zinv_str_item,

wa_header type zinv_str_head,

l_lines type i,

l_tabix type sy-tabix,

l_ssfctrlop type ssfctrlop.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZINV_FORM1'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

importing

fm_name = sf_name.

  • EXCEPTIONS

  • NO_FORM = 1

  • NO_FUNCTION_MODULE = 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.

  • CLEAR g_tot_tab[].

  • g_tot_tab[] = gt_output[].

  • gt_temp[] = gt_output[].

  • DELETE ADJACENT DUPLICATES FROM gt_header COMPARING order_number.

describe table g_head_itab lines l_lines.

gt_temp[] = g_item_itab[].

*

  • l_ssfctrlop-no_dialog = 'X'.

  • l_ssfctrlop-preview = 'X'.

  • l_ssfctrlop-getotf = 'X'.

  • ls_out_opt-tdnoprev = 'X'.

  • ls_out_opt-tddest = 'locl'.

*

*

loop at g_tot_tab into g_tot_wa.

g_item_itab[] = gt_temp[].

delete g_item_itab where vbeln ne g_tot_wa-vbeln.

loop at g_item_itab into g_item_wa.

move: sy-tabix to g_item_wa-sino.

modify g_item_itab from g_item_wa.

endloop.

add 1 to l_tabix.

if l_tabix gt 1 and l_tabix le l_lines.

l_ssfctrlop-no_open = 'X'.

endif.

if l_tabix eq l_lines.

l_ssfctrlop-no_close = space.

else.

l_ssfctrlop-no_close = 'X'.

endif.

call function sf_name

exporting

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = l_ssfctrlop

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = ls_out_opt

  • USER_SETTINGS = 'X'

is_inv_header = g_tot_wa

importing

  • DOCUMENT_OUTPUT_INFO =

job_output_info = ssfcrescl

  • JOB_OUTPUT_OPTIONS =

tables

l_itab = g_item_itab

  • EXCEPTIONS

  • FORMATTING_ERROR = 1

  • INTERNAL_ERROR = 2

  • SEND_ERROR = 3

  • USER_CANCELED = 4

  • OTHERS = 5

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

  • APPEND LINES OF ssfcrescl-otfdata TO final_ssfcrescl-otfdata.

endloop.

call function 'CONVERT_OTF'

exporting

format = 'PDF'

  • MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

  • COPYNUMBER = 0

  • ASCII_BIDI_VIS2LOG = ' '

importing

bin_filesize = filesize

bin_file = xstring

tables

otf = final_ssfcrescl-otfdata

lines = tline

  • EXCEPTIONS

  • ERR_MAX_LINEWIDTH = 1

  • ERR_FORMAT = 2

  • ERR_CONV_NOT_POSSIBLE = 3

  • ERR_BAD_OTF = 4

  • OTHERS = 5

.

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 'SCMS_XSTRING_TO_BINARY'

exporting

buffer = xstring

  • APPEND_TO_TABLE = ' '

  • IMPORTING

  • OUTPUT_LENGTH =

tables

binary_tab = l_data_tab.

call function 'GUI_DOWNLOAD'

exporting

  • BIN_FILESIZE =

filename = 'C:\invoice.pdf'

filetype = 'BIN'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • IMPORTING

  • FILELENGTH =

tables

data_tab = l_data_tab

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_WRITE_ERROR = 1

  • NO_BATCH = 2

  • GUI_REFUSE_FILETRANSFER = 3

  • INVALID_TYPE = 4

  • NO_AUTHORITY = 5

  • UNKNOWN_ERROR = 6

  • HEADER_NOT_ALLOWED = 7

  • SEPARATOR_NOT_ALLOWED = 8

  • FILESIZE_NOT_ALLOWED = 9

  • HEADER_TOO_LONG = 10

  • DP_ERROR_CREATE = 11

  • DP_ERROR_SEND = 12

  • DP_ERROR_WRITE = 13

  • UNKNOWN_DP_ERROR = 14

  • ACCESS_DENIED = 15

  • DP_OUT_OF_MEMORY = 16

  • DISK_FULL = 17

  • DP_TIMEOUT = 18

  • FILE_NOT_FOUND = 19

  • DATAPROVIDER_EXCEPTION = 20

  • CONTROL_FLUSH_ERROR = 21

  • OTHERS = 22

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. "call_form

*

*&----


**& Form send_email

*&----


    • text

*----


*FORM send_email.

*

      • Document information.

**wa_doc_chng-obj_name = 'Smartform'.

**wa_doc_chng-expiry_dat = sy-datum + 10.

**wa_doc_chng-obj_descr = 'Smart form output'.

**wa_doc_chng-sensitivty = 'F'. "Functional object

**wa_doc_chng-doc_size = v_lines_txt * 255.

**data:i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

**

**

**

**

  • CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

  • EXPORTING

  • document_data = l_doc_chng

  • put_in_outbox = 'X'

    • sender_address = sder_add

  • sender_address_type = 'U'

  • commit_work = 'X'

    • IMPORTING

    • SENT_TO_ALL =

    • NEW_OBJECT_ID =

    • SENDER_ID =

  • TABLES

  • packing_list = l_pac_list

    • OBJECT_HEADER =

    • CONTENTS_BIN =

    • CONTENTS_TXT =

    • CONTENTS_HEX =

    • OBJECT_PARA =

    • OBJECT_PARB =

  • receivers = l_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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

*ENDFORM. "send_email

regards,

seshu.

Former Member
0 Kudos

Hi srinivas,

Then how can I add graphic to the attachment? Please help me.

Regards,

shravan G.

Former Member
0 Kudos

Use PDF format as attachment..

u can refer to the links below:

Thanks

Former Member
0 Kudos

When u download the smartform into an html format and if u want to send as a attachment it not possible but u can send as a separately.

reward points if useful,

regards,

srinivas.