cancel
Showing results for 
Search instead for 
Did you mean: 

hi smart forms

Former Member
0 Kudos

hi i have saved the form done in pdf format now i need it send this form to

receipnts mail plz guide me the steps i need to do after saving it to the pdf format

below is my program for which i have saved the program into pdf format

&----


*& Report ZSF

*&

&----


*&

*&

&----


REPORT ZSF.

&----


*& Report ZINV1

*&

&----


*&

*&

&----


TABLES : KNA1, " General Data In Customer Master

KNB1, " Customer Master(Company Code)

BSID, " Accounting: Secondary Index for Customers

ZSMARTFORM, " Custom table for Storing Bank Details

zsf_exp_inv, " Structure that stores required fields from all tables used

KNVK. " Customer Master Contact Partner

data : Begin of it_struct occurs 0.

include structure zsf_exp_inv01.

data : End of it_struct.

types : begin of ty_bsid,

kunnr like bsid-kunnr,

WAERS like bsid-WAERS,

XBLNR LIKE BSID-XBLNR,

BUDAT LIKE BSID-BUDAT,

WRBTR LIKE BSID-WRBTR,

BUKRS LIKE BSID-BUKRS,

end of ty_bsid.

types : begin of ty_kna1,

kunnr like kna1-kunnr,

NAME1 LIKE KNA1-NAME1,

STRAS LIKE KNA1-STRAS,

MCOD3 LIKE KNA1-MCOD3,

LAND1 LIKE KNA1-LAND1,

SORTL LIKE KNA1-SORTL,

end of ty_kna1.

types : begin of ty_knb1,

kunnr like knb1-kunnr,

ZTERM LIKE KNB1-ZTERM,

end of ty_knb1.

types : begin of ty_knVK,

kunnr like kNVK-kunnr,

NAME1 LIKE KNVK-NAME1,

end of ty_knVK.

types : begin of ty_ZSMARTFORM,

SNO LIKE ZSMARTFORM-SNO,

CURRENCY LIKE zsmartform-currency,

BANKNAME LIKE zsmartform-bankname,

ADDRESS1 LIKE ZSMARTFORM-ADDRESS1,

ADDRESS2 LIKE ZSMARTFORM-ADDRESS2,

ADDRESS3 LIKE ZSMARTFORM-ADDRESS3,

ADDRESS4 LIKE ZSMARTFORM-ADDRESS4,

ADDRESS5 LIKE ZSMARTFORM-ADDRESS5,

ADDRESS6 LIKE ZSMARTFORM-ADDRESS6,

VALIDFROM LIKE ZSMARTFORM-VALIDFROM,

VALIDTO LIKE ZSMARTFORM-VALIDTO,

end of ty_ZSMARTFORM.

data : it_bsid type table of ty_bsid,

it_kna1 type table of ty_kna1,

it_knb1 type table of ty_knb1,

it_zsmartform type table of ty_zsmartform,

it_knVK type table of ty_kNVK.

data : wa_bsid like line of it_bsid,

wa_kna1 like line of it_kna1,

wa_knb1 like line of it_knb1,

wa_zsmartform like line of it_zsmartform,

wa_knVK like line of it_knVK.

*****************Selection Screen**********************************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

SELECT-OPTIONS : S_KUNNR FOR KNA1-KUNNR,

S_belnr FOR BSID-belnr,

S_BUKRS FOR BSID-BUKRS,

S_CURR FOR ZSMARTFORM-CURRENCY.

SELECTION-SCREEN END OF BLOCK B1.

DATA : BEGIN OF IT_PARAM OCCURS 0.

INCLUDE STRUCTURE ZPARAMETERS.

DATA : END OF IT_PARAM.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

SKIP 1.

Parameters : OPTION1 AS CHECKBOX,

P_POINF(300) type c,

OPTION2 AS CHECKBOX,

P_DESC(300) TYPE C,

OPTION3 AS CHECKBOX,

P_MONTH(200) TYPE C,

OPTION4 AS CHECKBOX,

P_RATE(100) TYPE C.

SELECTION-SCREEN END OF BLOCK B2.

*********************************************************************

**********************PARAMETERS***********************************

data : l type i,

Y(300) type c,

j type i,

k type i value 1,

s type i,

m(300) type c,

p type i,

z type i.

data : l1 type i,

Y1(300) type c,

j1 type i,

k1 type i value 1,

s1 type i,

m1(300) type c,

p1 type i,

z1 type i.

data : l2 type i,

Y2(300) type c,

j2 type i,

k2 type i value 1,

s2 type i,

m2(300) type c,

p2 type i,

z2 type i.

data : l3 type i,

Y3(300) type c,

j3 type i,

k3 type i value 1,

s3 type i,

m3(300) type c,

p3 type i,

z3 type i.

IF OPTION1 = 'X'.

concatenate P_POINF ',' into P_POINF.

l = strlen( P_POINF ).

do l times.

Y = P_POINF+j(k).

case Y.

when ','.

m = P_POINF+s(z).

s = j + 1.

z = -1.

p = p + 1.

if p = 1.

IT_PARAM-LINE1 = m.

endif.

if p = 2.

IT_PARAM-LINE2 = m.

endif.

if p = 3.

IT_PARAM-LINE3 = m.

endif.

  • when '.'.

if p = 4.

IT_PARAM-LINE4 = m.

endif.

endcase.

j = j + 1.

z = z + 1.

enddo.

ENDIF.

IF OPTION2 = 'X'.

concatenate P_DESC ',' into P_DESC.

l1 = strlen( P_DESC ).

do l1 times.

Y1 = P_DESC+j1(k1).

case Y1.

when ','.

m1 = P_DESC+s1(z1).

s1 = j1 + 1.

z1 = -1.

p1 = p1 + 1.

if p1 = 1.

IT_PARAM-LINE5 = m1.

endif.

if p1 = 2.

IT_PARAM-LINE6 = m1.

endif.

if p1 = 3.

IT_PARAM-LINE7 = m1.

endif.

  • when '.'.

if p1 = 4.

IT_PARAM-LINE8 = m1.

endif.

endcase.

j1 = j1 + 1.

z1 = z1 + 1.

enddo.

ENDIF.

IF OPTION3 = 'X'.

concatenate P_MONTH ',' into P_MONTH.

l2 = strlen( P_MONTH ).

do l2 times.

Y2 = P_MONTH+j2(k2).

case Y2.

when ','.

m2 = P_MONTH+s2(z2).

s2 = j2 + 1.

z2 = -1.

p2 = p2 + 1.

if p2 = 1.

IT_PARAM-LINE9 = m2.

endif.

if p2 = 2.

IT_PARAM-LINE10 = m2.

endif.

if p2 = 3.

IT_PARAM-LINE11 = m2.

endif.

  • when '.'.

if p2 = 4.

IT_PARAM-LINe12 = m2.

endif.

endcase.

j2 = j2 + 1.

z2 = z2 + 1.

enddo.

ENDIF.

IF OPTION4 = 'X'.

concatenate P_RATE ',' into P_RATE.

l3 = strlen( P_RATE ).

do l3 times.

Y3 = P_RATE+j3(k3).

case Y3.

when ','.

m3 = P_RATE+s3(z3).

s3 = j3 + 1.

z3 = -1.

p3 = p3 + 1.

if p3 = 1.

IT_PARAM-LINE13 = m3.

endif.

if p3 = 2.

IT_PARAM-LINE14 = m3.

endif.

if p3 = 3.

IT_PARAM-LINE15 = m3.

endif.

if p3 = 4.

IT_PARAM-LINe16 = m3.

endif.

endcase.

j3 = j3 + 1.

z3 = z3 + 1.

enddo.

ENDIF.

APPEND IT_PARAM.

*********************************************************

select * from kna1 into corresponding fields of table it_kna1 where kunnr in s_kunnr.

select * from knb1 into corresponding fields of table it_knb1 for all entries in it_kna1 where kunnr = it_kna1-kunnr.

select * from bsid into corresponding fields of table it_bsid for all entries in it_kna1 where kunnr = it_kna1-kunnr and belnr in s_belnr and bukrs in s_bukrs..

SELECT * FROM KNVK INTO CORRESPONDING FIELDS OF TABLE IT_KNVK FOR ALL ENTRIES IN IT_KNA1 WHERE KUNNR = IT_KNA1-KUNNR.

select * from zsmartform into corresponding fields of table it_zsmartform .

DATA : AMT LIKE SPELL.

loop at it_bsid into wa_bsid.

read table it_kna1 into wa_kna1 with key kunnr = wa_bsid-kunnr.

read table it_knb1 into wa_knb1 with key kunnr = wa_bsid-kunnr.

read table it_zsmartform into wa_zsmartform with key CURRENCY = wa_bsid-WAERS.

READ TABLE IT_KNVK INTO WA_KNVK WITH KEY KUNNR = WA_BSID-KUNNR.

it_struct-name1 = wa_kna1-name1.

it_struct-stras = wa_kna1-stras.

it_struct-mcod3 = wa_kna1-mcod3.

it_struct-land1 = wa_kna1-land1.

it_struct-sortl = wa_kna1-sortl.

it_struct-zterm = wa_knb1-zterm.

it_struct-xblnr = wa_bsid-xblnr.

  • it_struct-currency = wa_zsmartform-currency.

it_struct-currency = wa_bsid-waers.

it_struct-budat = wa_bsid-budat.

it_struct-BANKNAME = wa_zsmartform-BANKNAME.

it_struct-ADDRESS1 = wa_zsmartform-ADDRESS1.

it_struct-ADDRESS2 = wa_zsmartform-ADDRESS2.

it_struct-ADDRESS3 = wa_zsmartform-ADDRESS3.

it_struct-ADDRESS4 = wa_zsmartform-ADDRESS4.

it_struct-ADDRESS5 = wa_zsmartform-ADDRESS5.

it_struct-ADDRESS6 = wa_zsmartform-ADDRESS6.

it_struct-CURR = WA_BSID-WRBTR.

IT_STRUCT-NAME = WA_KNVK-NAME1.

  • IT_STRUCT-AMOUNT = IT_SPELL-AMT.

append it_struct.

endloop.

data : x type i,

x1 type i,

a type string.

loop at it_struct.

x = strlen( it_struct-curr ).

x1 = x - 3.

a = it_struct-curr+0(x1).

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = a

    • CURRENCY = ' '

    • FILLER = ' '

    • LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = AMT.

    • EXCEPTIONS

    • NOT_FOUND = 1

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

endloop.

DATA: ws_ucomm LIKE sy-ucomm.

DATA: form_name TYPE rs38l_fnam.

DATA: wa_ctrlop TYPE ssfctrlop,

wa_outopt TYPE ssfcompop.

DATA: t_otfdata TYPE ssfcrescl,

t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.

DATA: t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.

DATA: w_filesize TYPE string.

DATA: w_bin_filesize TYPE i.

wa_ctrlop-getotf = 'X'.

CALL FUNCTION '/1BCDWB/SF00000001'

EXPORTING

control_parameters = wa_ctrlop

output_options = wa_outopt

user_settings = 'X'

IN_WORDS = amt

importing

job_output_info = t_otfdata

TABLES

I_ZSF_EXP_INV = it_struct

I_ZPARAMETERS = it_param.

IF SY-SUBRC <> 0.

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

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

ENDIF.

t_otf[] = t_otfdata-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = w_bin_filesize

TABLES

otf = t_otf

lines = t_pdf_tab

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4

.

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

EXPORTING

bin_filesize = w_bin_filesize

  • CODEPAGE = ' '

filename = 'c:\test.PDF'

filetype = 'BIN'

IMPORTING

filelength = w_filesize

TABLES

data_tab = t_pdf_tab

EXCEPTIONS

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10

.

IF sy-subrc <> 0.

*You should include message-id in the report heading

WRITE : sy-subrc.

ELSE.

WRITE : 'File Test.pdf downloaded succesfully'.

ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

r u using 4.6 version of SAP.

you can use FM 'SO_NEW_DOCUMENT_SEND_API1' to email and 'SO_NEW_DOCUMENT_ATT_SEND_API1' FM to email with attachment.

do u want code to implement the above FM's.

Message was edited by:

Durgaprasad Kare

Former Member
0 Kudos

hi durga prasad

i m using ecc 5.0 version .does the version effect the scenario

Former Member
0 Kudos

Hi,

The logics given by anversha and kishan will solve the problem but i wondered as to y r u using ws_download which is an obsolete FM .better use GUI_DOWNLOAD.Generally obsolete FMs are not supposed to be used unless untill u have no other option.

Former Member
0 Kudos

hi durgaprasad thanku

i will change that fm could u plz tell me why we use the function module ssf_function_module fm .

i have not used this stil i m able to save it in pdf do we have to do this for sending it as a mail

Former Member
0 Kudos

Hi,

ssf_function module name is the FM through which u can identify the smartform.

ie., when u execute ur form it will give u a function module value.

so u can execute it directly. but incase if u dont know the fm value u cannot. so, using the SSf fm u pass the fom name and retrieve the FM value.

aftyer that u hold the fm value and call function with this fm value.

Former Member
0 Kudos

hi durga i have the program as below it is saved n pgdf but i couldnt see it my mail box plz look thru it

*&----


*

*& Report ZSF

*&

*&----


*

*&

*&

*&----


*

REPORT ZSF.

*&----


*

*& Report ZINV1

*&

*&----


*

*&

*&

*&----


*

TABLES : KNA1, " General Data In Customer Master

KNB1, " Customer Master(Company Code)

BSID, " Accounting: Secondary Index for Customers

ZSMARTFORM, " Custom table for Storing Bank Details

zsf_exp_inv, " Structure that stores required fields from all tables used

KNVK. " Customer Master Contact Partner

data : Begin of it_struct occurs 0.

include structure zsf_exp_inv01.

data : End of it_struct.

types : begin of ty_bsid,

kunnr like bsid-kunnr,

WAERS like bsid-WAERS,

XBLNR LIKE BSID-XBLNR,

BUDAT LIKE BSID-BUDAT,

WRBTR LIKE BSID-WRBTR,

BUKRS LIKE BSID-BUKRS,

end of ty_bsid.

types : begin of ty_kna1,

kunnr like kna1-kunnr,

NAME1 LIKE KNA1-NAME1,

STRAS LIKE KNA1-STRAS,

MCOD3 LIKE KNA1-MCOD3,

LAND1 LIKE KNA1-LAND1,

SORTL LIKE KNA1-SORTL,

end of ty_kna1.

types : begin of ty_knb1,

kunnr like knb1-kunnr,

ZTERM LIKE KNB1-ZTERM,

end of ty_knb1.

types : begin of ty_knVK,

kunnr like kNVK-kunnr,

NAME1 LIKE KNVK-NAME1,

end of ty_knVK.

types : begin of ty_ZSMARTFORM,

SNO LIKE ZSMARTFORM-SNO,

CURRENCY LIKE zsmartform-currency,

BANKNAME LIKE zsmartform-bankname,

ADDRESS1 LIKE ZSMARTFORM-ADDRESS1,

ADDRESS2 LIKE ZSMARTFORM-ADDRESS2,

ADDRESS3 LIKE ZSMARTFORM-ADDRESS3,

ADDRESS4 LIKE ZSMARTFORM-ADDRESS4,

ADDRESS5 LIKE ZSMARTFORM-ADDRESS5,

ADDRESS6 LIKE ZSMARTFORM-ADDRESS6,

VALIDFROM LIKE ZSMARTFORM-VALIDFROM,

VALIDTO LIKE ZSMARTFORM-VALIDTO,

end of ty_ZSMARTFORM.

data : it_bsid type table of ty_bsid,

it_kna1 type table of ty_kna1,

it_knb1 type table of ty_knb1,

it_zsmartform type table of ty_zsmartform,

it_knVK type table of ty_kNVK.

data : wa_bsid like line of it_bsid,

wa_kna1 like line of it_kna1,

wa_knb1 like line of it_knb1,

wa_zsmartform like line of it_zsmartform,

wa_knVK like line of it_knVK.

*****************Selection Screen**********************************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

SELECT-OPTIONS : S_KUNNR FOR KNA1-KUNNR,

S_belnr FOR BSID-belnr,

S_BUKRS FOR BSID-BUKRS,

S_CURR FOR ZSMARTFORM-CURRENCY.

SELECTION-SCREEN END OF BLOCK B1.

DATA : BEGIN OF IT_PARAM OCCURS 0.

INCLUDE STRUCTURE ZPARAMETERS.

DATA : END OF IT_PARAM.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

SKIP 1.

Parameters : OPTION1 AS CHECKBOX,

P_POINF(300) type c,

OPTION2 AS CHECKBOX,

P_DESC(300) TYPE C,

OPTION3 AS CHECKBOX,

P_MONTH(200) TYPE C,

OPTION4 AS CHECKBOX,

P_RATE(100) TYPE C.

SELECTION-SCREEN END OF BLOCK B2.

*********************************************************************

**********************PARAMETERS***********************************

data : l type i,

Y(300) type c,

j type i,

k type i value 1,

s type i,

m(300) type c,

p type i,

z type i.

data : l1 type i,

Y1(300) type c,

j1 type i,

k1 type i value 1,

s1 type i,

m1(300) type c,

p1 type i,

z1 type i.

data : l2 type i,

Y2(300) type c,

j2 type i,

k2 type i value 1,

s2 type i,

m2(300) type c,

p2 type i,

z2 type i.

data : l3 type i,

Y3(300) type c,

j3 type i,

k3 type i value 1,

s3 type i,

m3(300) type c,

p3 type i,

z3 type i.

IF OPTION1 = 'X'.

concatenate P_POINF ',' into P_POINF.

l = strlen( P_POINF ).

do l times.

Y = P_POINF+j(k).

case Y.

when ','.

m = P_POINF+s(z).

s = j + 1.

z = -1.

p = p + 1.

if p = 1.

IT_PARAM-LINE1 = m.

endif.

if p = 2.

IT_PARAM-LINE2 = m.

endif.

if p = 3.

IT_PARAM-LINE3 = m.

endif.

  • when '.'.

if p = 4.

IT_PARAM-LINE4 = m.

endif.

endcase.

j = j + 1.

z = z + 1.

enddo.

ENDIF.

IF OPTION2 = 'X'.

concatenate P_DESC ',' into P_DESC.

l1 = strlen( P_DESC ).

do l1 times.

Y1 = P_DESC+j1(k1).

case Y1.

when ','.

m1 = P_DESC+s1(z1).

s1 = j1 + 1.

z1 = -1.

p1 = p1 + 1.

if p1 = 1.

IT_PARAM-LINE5 = m1.

endif.

if p1 = 2.

IT_PARAM-LINE6 = m1.

endif.

if p1 = 3.

IT_PARAM-LINE7 = m1.

endif.

  • when '.'.

if p1 = 4.

IT_PARAM-LINE8 = m1.

endif.

endcase.

j1 = j1 + 1.

z1 = z1 + 1.

enddo.

ENDIF.

IF OPTION3 = 'X'.

concatenate P_MONTH ',' into P_MONTH.

l2 = strlen( P_MONTH ).

do l2 times.

Y2 = P_MONTH+j2(k2).

case Y2.

when ','.

m2 = P_MONTH+s2(z2).

s2 = j2 + 1.

z2 = -1.

p2 = p2 + 1.

if p2 = 1.

IT_PARAM-LINE9 = m2.

endif.

if p2 = 2.

IT_PARAM-LINE10 = m2.

endif.

if p2 = 3.

IT_PARAM-LINE11 = m2.

endif.

  • when '.'.

if p2 = 4.

IT_PARAM-LINe12 = m2.

endif.

endcase.

j2 = j2 + 1.

z2 = z2 + 1.

enddo.

ENDIF.

IF OPTION4 = 'X'.

concatenate P_RATE ',' into P_RATE.

l3 = strlen( P_RATE ).

do l3 times.

Y3 = P_RATE+j3(k3).

case Y3.

when ','.

m3 = P_RATE+s3(z3).

s3 = j3 + 1.

z3 = -1.

p3 = p3 + 1.

if p3 = 1.

IT_PARAM-LINE13 = m3.

endif.

if p3 = 2.

IT_PARAM-LINE14 = m3.

endif.

if p3 = 3.

IT_PARAM-LINE15 = m3.

endif.

if p3 = 4.

IT_PARAM-LINe16 = m3.

endif.

endcase.

j3 = j3 + 1.

z3 = z3 + 1.

enddo.

ENDIF.

APPEND IT_PARAM.

*********************************************************

select * from kna1 into corresponding fields of table it_kna1 where kunnr in s_kunnr.

select * from knb1 into corresponding fields of table it_knb1 for all entries in it_kna1 where kunnr = it_kna1-kunnr.

select * from bsid into corresponding fields of table it_bsid for all entries in it_kna1 where kunnr = it_kna1-kunnr and belnr in s_belnr and bukrs in s_bukrs..

SELECT * FROM KNVK INTO CORRESPONDING FIELDS OF TABLE IT_KNVK FOR ALL ENTRIES IN IT_KNA1 WHERE KUNNR = IT_KNA1-KUNNR.

select * from zsmartform into corresponding fields of table it_zsmartform .

DATA : AMT LIKE SPELL.

loop at it_bsid into wa_bsid.

read table it_kna1 into wa_kna1 with key kunnr = wa_bsid-kunnr.

read table it_knb1 into wa_knb1 with key kunnr = wa_bsid-kunnr.

read table it_zsmartform into wa_zsmartform with key CURRENCY = wa_bsid-WAERS.

READ TABLE IT_KNVK INTO WA_KNVK WITH KEY KUNNR = WA_BSID-KUNNR.

it_struct-name1 = wa_kna1-name1.

it_struct-stras = wa_kna1-stras.

it_struct-mcod3 = wa_kna1-mcod3.

it_struct-land1 = wa_kna1-land1.

it_struct-sortl = wa_kna1-sortl.

it_struct-zterm = wa_knb1-zterm.

it_struct-xblnr = wa_bsid-xblnr.

  • it_struct-currency = wa_zsmartform-currency.

it_struct-currency = wa_bsid-waers.

it_struct-budat = wa_bsid-budat.

it_struct-BANKNAME = wa_zsmartform-BANKNAME.

it_struct-ADDRESS1 = wa_zsmartform-ADDRESS1.

it_struct-ADDRESS2 = wa_zsmartform-ADDRESS2.

it_struct-ADDRESS3 = wa_zsmartform-ADDRESS3.

it_struct-ADDRESS4 = wa_zsmartform-ADDRESS4.

it_struct-ADDRESS5 = wa_zsmartform-ADDRESS5.

it_struct-ADDRESS6 = wa_zsmartform-ADDRESS6.

it_struct-CURR = WA_BSID-WRBTR.

IT_STRUCT-NAME = WA_KNVK-NAME1.

  • IT_STRUCT-AMOUNT = IT_SPELL-AMT.

append it_struct.

endloop.

data : x type i,

x1 type i,

a type string.

loop at it_struct.

x = strlen( it_struct-curr ).

x1 = x - 3.

a = it_struct-curr+0(x1).

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = a

    • CURRENCY = ' '

    • FILLER = ' '

    • LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = AMT.

    • EXCEPTIONS

    • NOT_FOUND = 1

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

endloop.

DATA: ws_ucomm LIKE sy-ucomm.

DATA: form_name TYPE rs38l_fnam.

DATA: wa_ctrlop TYPE ssfctrlop,

wa_outopt TYPE ssfcompop.

data : i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,

i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: t_otfdata TYPE ssfcrescl,

t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,

i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.

data : wa_objhead TYPE soli_tab,

wa_doc_chng typE sodocchgi1,

w_data TYPE sodocchgi1,

wa_buffer TYPE string,

v_len_in LIKE sood-objlen,

v_len_out LIKE sood-objlen,

v_len_outn TYPE i,

v_lines_txt TYPE i,

v_lines_bin TYPE i.

DATA: t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.

DATA: w_filesize TYPE string.

DATA: w_bin_filesize TYPE i.

wa_ctrlop-getotf = 'X'.

CALL FUNCTION '/1BCDWB/SF00000001'

EXPORTING

control_parameters = wa_ctrlop

output_options = wa_outopt

user_settings = 'X'

IN_WORDS = amt

importing

job_output_info = t_otfdata

TABLES

I_ZSF_EXP_INV = it_struct

I_ZPARAMETERS = it_param.

IF SY-SUBRC <> 0.

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

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

ENDIF.

t_otf[] = t_otfdata-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = w_bin_filesize

TABLES

otf = t_otf

lines = t_pdf_tab

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4

.

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

EXPORTING

bin_filesize = w_bin_filesize

  • CODEPAGE = ' '

filename = 'c: est43.PDF'

filetype = 'BIN'

IMPORTING

filelength = w_filesize

TABLES

data_tab = t_pdf_tab

EXCEPTIONS

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10

.

IF sy-subrc <> 0.

*You should include message-id in the report heading

WRITE : sy-subrc.

ELSE.

WRITE : 'File Test.pdf downloaded succesfully'.

ENDIF.

loop at t_pdf_tab.

translate t_pdf_tab using '~'.

concatenate wa_buffer t_pdf_tab into wa_buffer.

endloop.

translate wa_buffer using '~'.

do.

i_record = wa_buffer.

append i_record.

shift wa_buffer left by 255 places.

if wa_buffer is initial.

exit.

endif.

enddo.

  • Attachment

refresh:

i_reclist,

i_objtxt,

i_objbin,

i_objpack.

clear wa_objhead.

i_objbin[] = i_record[].

              • Create Message Body

        • Title and Description

i_objtxt = 'test with pdf-Attachment!'.

append i_objtxt.

describe table i_objtxt lines v_lines_txt.

read table i_objtxt index v_lines_txt.

wa_doc_chng-obj_name = 'smartform'.

wa_doc_chng-expiry_dat = sy-datum + 10.

wa_doc_chng-obj_descr = 'smartform'.

wa_doc_chng-sensitivty = 'F'.

wa_doc_chng-doc_size = v_lines_txt * 255.

        • Main Text

  • wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )

*.

clear i_objpack-transf_bin.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_txt.

i_objpack-doc_type = 'RAW'.

append i_objpack.

        • Attachment

  • (pdf-Attachment)

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

  • Länge des Attachment ermitteln

describe table i_objbin lines v_lines_bin.

read table i_objbin index v_lines_bin.

i_objpack-doc_size = v_lines_bin * 255 .

i_objpack-body_num = v_lines_bin.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = 'smart'.

i_objpack-obj_descr = 'test'.

append i_objpack.

clear i_reclist.

i_reclist-receiver = 'jayakrishna.boyapalli@cambridge-asia.com'.

i_reclist-rec_type = 'U'.

append i_reclist.

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

TABLES

packing_list = i_objpack

object_header = wa_objhead

CONTENTS_BIN = i_objbin

contents_txt = i_objtxt

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.

Former Member
0 Kudos

HI,

u have used following stmt.

CALL FUNCTION '/1BCDWB/SF00000001'

but replace it by following code.

DATA: gv_fm_name TYPE rs38l_fnam, "DV1K909057 PRASADDX

gv_formname TYPE tdsfname. "DV1K909057 PRASADDX

  • Calling the layout set

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = gv_formname

IMPORTING

fm_name = gv_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

PERFORM protocol_update.

ENDIF.

IF gv_fm_name IS NOT INITIAL.

  • Below function module is used to show the Smart form

CALL FUNCTION gv_fm_name

here the gv_fm_name will hold the value '/1BCDWB/SF00000001'.

now coming to ur mail problem.

u r saying that u can download the PDF. and mail is having problem.

i think the code is fine.jst check the scot settings. i will execute it and get back to u.

Former Member
0 Kudos

i think wat u told is right thers some problem with the scot settings

Answers (2)

Answers (2)

anversha_s
Active Contributor
0 Kudos

hi,

chk this sample.

  • Internal Table declarations

DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
      i_tline TYPE TABLE OF tline WITH HEADER LINE,
      i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
      i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
* Objects to send mail.
      i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
      i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
 
* Work Area declarations
      wa_objhead TYPE soli_tab,
      w_ctrlop TYPE ssfctrlop,
      w_compop TYPE ssfcompop,
      w_return TYPE ssfcrescl,
      wa_doc_chng typE sodocchgi1,
      w_data TYPE sodocchgi1,
      wa_buffer TYPE string,"To convert from 132 to 255
 
* Variables declarations
      v_form_name TYPE rs38l_fnam,
      v_len_in LIKE sood-objlen,
      v_len_out LIKE sood-objlen,
      v_len_outn TYPE i,
      v_lines_txt TYPE i,
      v_lines_bin TYPE i.
 
call function 'SSF_FUNCTION_MODULE_NAME'
     exporting
          formname           = 'ZZZ_TEST1'
     importing
          fm_name            = v_form_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.
 
 
w_ctrlop-getotf = 'X'.
w_ctrlop-no_dialog = 'X'.
w_compop-tdnoprev = 'X'.
 
CALL FUNCTION v_form_name
     EXPORTING
          control_parameters = w_ctrlop
          output_options     = w_compop
          user_settings      = 'X'
     IMPORTING
          job_output_info    = w_return
     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.
 
i_otf[] = w_return-otfdata[].
 
call function 'CONVERT_OTF'
       EXPORTING
            format                = 'PDF'
            max_linewidth         = 132
       IMPORTING
            bin_filesize          = v_len_in
       TABLES
            otf                   = i_otf
            lines                 = i_tline
       EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            others                = 4.
*   Fehlerhandling
  if sy-subrc <> 0.
 
  endif.
 
  loop at i_tline.
    translate i_tline using '~'.
    concatenate wa_buffer i_tline into wa_buffer.
  endloop.
 
  translate wa_buffer using '~'.
 
  do.
    i_record = wa_buffer.
    append i_record.
    shift wa_buffer left by 255 places.
    if wa_buffer is initial.
      exit.
    endif.
  enddo.
 
* Attachment
  refresh:
    i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
 
  clear wa_objhead.
 
  i_objbin[] = i_record[].
 
 
******* Create Message Body
**** Title and Description
  i_objtxt = 'test with pdf-Attachment!'.
  append i_objtxt.
  describe table i_objtxt lines v_lines_txt.
  read table i_objtxt index v_lines_txt.
  wa_doc_chng-obj_name = 'smartform'.
  wa_doc_chng-expiry_dat = sy-datum + 10.
  wa_doc_chng-obj_descr = 'smartform'.
  wa_doc_chng-sensitivty = 'F'.
  wa_doc_chng-doc_size = v_lines_txt * 255.
 
**** Main Text
*  wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
*.
  clear i_objpack-transf_bin.
  i_objpack-head_start = 1.
  i_objpack-head_num = 0.
  i_objpack-body_start = 1.
  i_objpack-body_num = v_lines_txt.
  i_objpack-doc_type = 'RAW'.
  append i_objpack.
 
**** Attachment
* (pdf-Attachment)
  i_objpack-transf_bin = 'X'.
  i_objpack-head_start = 1.
  i_objpack-head_num = 0.
  i_objpack-body_start = 1.
* Länge des Attachment ermitteln
  describe table i_objbin lines v_lines_bin.
  read table i_objbin index v_lines_bin.
  i_objpack-doc_size =  v_lines_bin * 255 .
 
  i_objpack-body_num = v_lines_bin.
  i_objpack-doc_type = 'PDF'.
  i_objpack-obj_name = 'smart'.
  i_objpack-obj_descr = 'test'.
  append i_objpack.
 
  clear i_reclist.
  i_reclist-receiver = 'zyz@wipro.com'.
  i_reclist-rec_type = 'U'.
  append i_reclist.
 
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
              document_data              = wa_doc_chng
              put_in_outbox              = 'X'
         TABLES
              packing_list               = i_objpack
              object_header              = wa_objhead
              CONTENTS_BIN               = i_objbin
              contents_txt               = i_objtxt
              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.

Regards

Anver

Former Member
0 Kudos
REPORT  ZNEGI_SMARTFORMS                        .

DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
* Objects to send mail.
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

* Work Area declarations
wa_objhead TYPE soli_tab,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl,
wa_doc_chng typE sodocchgi1,
w_data TYPE sodocchgi1,
wa_buffer TYPE string,"To convert from 132 to 255

* Variables declarations
v_form_name TYPE rs38l_fnam,
v_len_in LIKE sood-objlen,
v_len_out LIKE sood-objlen,
v_len_outn TYPE i,
v_lines_txt TYPE i,
v_lines_bin TYPE i.

call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZCOMPLETE_REFRENCE'
importing
fm_name = v_form_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.


w_ctrlop-getotf = 'X'.
w_ctrlop-no_dialog = 'X'.
w_compop-tdnoprev = 'X'.

CALL FUNCTION v_form_name
EXPORTING
control_parameters = w_ctrlop
output_options = w_compop
user_settings = 'X'
IMPORTING
job_output_info = w_return
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.

i_otf[] = w_return-otfdata[].

call function 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
others = 4.
* Fehlerhandling
if sy-subrc <> 0.
daTA : p_file LIKE rlgrap-filename VALUE 'C:test.pdf'.
data : file type string.
file = p_file.

data : wf_len_in1 type i.

wf_len_in1 = v_len_in.


CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = wf_len_in1
FILENAME = file
FILETYPE = 'BIN'
TABLES
DATA_TAB = i_tline.