Smartform convert to PDF dump - divide by zero
SAP Version 4.7 Enterprise
hello all,
i am trying to do somethign rather basic that is discussed in these forums many times: convert Samrtforms output to PDF. i used the suggested forms but came across a unique (i think) error. my problem is that when i run the CONVERT_OTF_2_PDF function i get a core dump with the error "divide by zero". reading the core dump i see that there appears to be a font issue in the form:
Code: Select all
055610 * non-proportional font
055620 * if charwidth is not equal the default PostScript charwidth,
055630 * print string with individual character positioning
055640 * WARNING: The unit used with PDFs (..) xx TJ command for individual
055650 * char positioning is 1 EM = 1/1000 fontsize!!!
055660 * ofs_em = 1000 * (charwidth / fontsize_twip)
055670 * WARNING: ...TJ moves current point to the LEFT of character
055680
055690 * set word spacing = 0
055700 PERFORM PDF_APPEND_STREAM USING '0 Tw'. "#EC NOTEXT
055710 IF CHARWIDTH < FONTINFO-DEF_SPACEWIDTH.
055780 * a positive value moves charpos to the LEFT!
055790 ELSE.
055800 * OTF character spacing is wider than PostScript default
> OFFSET_EM = 1000 * ( CHARWIDTH - FONTINFO-DEF_SPACEWIDTH )
055820 / FONTINFO-FONTSIZE_TW.
055830 PERFORM PDF_REM_LEAD_ZEROES_I USING 5 OFFSET_EM COORD.
055840 * a negative value moves charpos to the RIGHT!
needless to say this works perfectly when printing to paper. i am not using any non-stnadard fonts. the fonts are Arial with sizes of 6, 8, 10 and 12. any ideas? FYI, the code to call the functions is below. cheers,
james
Code: Select all
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = sy-langu
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = dev_typ
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
OTHERS = 5.
ctrl_params-no_dialog = 'X'.
ctrl_params-getotf = 'X'.
out_opt-tdnewid = 'X'.
out_opt-xsfcmode = 'X'.
out_opt-xsf = ' '.
out_opt-xdfcmode = 'X'.
out_opt-xdf = ' '.
out_opt-tdprinter = dev_typ.
CALL FUNCTION fm_name
EXPORTING
control_parameters = ctrl_params
IMPORTING
job_output_info = job_info
TABLES
i_outtab = i_output
i_header = i_header
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.
p_otf[] = job_info-otfdata.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = l_bin_filesize
TABLES
otf = p_otf[]
doctab_archive = p_doctab[]
lines = p_lines[]
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
SAP Version 4.7 Enterprise
hello all,
i am trying to do somethign rather basic that is discussed in these forums many times: convert Samrtforms output to PDF. i used the suggested forms but came across a unique (i think) error. my problem is that when i run the CONVERT_OTF_2_PDF function i get a core dump with the error "divide by zero". reading the core dump i see that there appears to be a font issue in the form:
Code: Select all
055610 * non-proportional font
055620 * if charwidth is not equal the default PostScript charwidth,
055630 * print string with individual character positioning
055640 * WARNING: The unit used with PDFs (..) xx TJ command for individual
055650 * char positioning is 1 EM = 1/1000 fontsize!!!
055660 * ofs_em = 1000 * (charwidth / fontsize_twip)
055670 * WARNING: ...TJ moves current point to the LEFT of character
055680
055690 * set word spacing = 0
055700 PERFORM PDF_APPEND_STREAM USING '0 Tw'. "#EC NOTEXT
055710 IF CHARWIDTH < FONTINFO-DEF_SPACEWIDTH.
055780 * a positive value moves charpos to the LEFT!
055790 ELSE.
055800 * OTF character spacing is wider than PostScript default
> OFFSET_EM = 1000 * ( CHARWIDTH - FONTINFO-DEF_SPACEWIDTH )
055820 / FONTINFO-FONTSIZE_TW.
055830 PERFORM PDF_REM_LEAD_ZEROES_I USING 5 OFFSET_EM COORD.
055840 * a negative value moves charpos to the RIGHT!
needless to say this works perfectly when printing to paper. i am not using any non-stnadard fonts. the fonts are Arial with sizes of 6, 8, 10 and 12. any ideas? FYI, the code to call the functions is below. cheers,
james
Code: Select all
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = sy-langu
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = dev_typ
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
OTHERS = 5.
ctrl_params-no_dialog = 'X'.
ctrl_params-getotf = 'X'.
out_opt-tdnewid = 'X'.
out_opt-xsfcmode = 'X'.
out_opt-xsf = ' '.
out_opt-xdfcmode = 'X'.
out_opt-xdf = ' '.
out_opt-tdprinter = dev_typ.
CALL FUNCTION fm_name
EXPORTING
control_parameters = ctrl_params
IMPORTING
job_output_info = job_info
TABLES
i_outtab = i_output
i_header = i_header
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.
p_otf[] = job_info-otfdata.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = l_bin_filesize
TABLES
otf = p_otf[]
doctab_archive = p_doctab[]
lines = p_lines[]
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
Similar Messages
-
Separate program to send a smartform converted into pdf, thru mail
Hi Folks,
I had created a smartform and converted it into a PDF format.
Now I want a separate program where in if i submit this program it should sent it throuogh mail.
Note:-<b>I want a separate program not the one where in you design a smartform,convert into pdf and then send thru mail all in one program</b>
Points will be given.
K.Kiran.hi kiran
the program is as follows
The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = 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 ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
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.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
regards,
navjot
reward if helpfull -
Problem in Smartform convert to PDF with special character
Hi ABAP Guru,
While convert smartforms to pdf.Some special character like ( - ) convert to ( # ).In development server there is no problem but the problem arise in quality.Please helpHi Palash,
Please use PDF! in print preview command field.. it will convert pdf file.
regards,
Thangam.P -
Uploading smartforms converted file (pdf) to BDS
Hi Experts,
I have the following requirements:
1. Convert the smartforms to pdf data.
2. Upload the file to (pdf data) to BDS.
I have no problem in step 1 but my concern is uploading the file to BDS directly after converting the otf data of the form to pdf. How can I upload the pdf data to BDS directly?
Points will be awarded. Thanks!
LeoHI
<u><i><b>1. Convert the smartforms to pdf data.</b></i></u>
Please check this code and replace the variables as per ur reqt.
This is the code which is working perfectly .
event handler for checking and processing user input and
for defining navigation
DATA: cached_response TYPE REF TO if_http_response.
DATA: response TYPE REF TO if_http_response.
DATA: guid TYPE guid_32.
generated result: PDF format
DATA: l_pdf_xstring TYPE xstring,
lt_lines TYPE TABLE OF tline,
ls_line TYPE tline,
l_pdf_len TYPE i.
DATA: lf_fm_name TYPE rs38l_fnam ,
e_ssfcrescl TYPE ssfcrescl,
lv_spool TYPE tsfspoolid,
e_ssfctrlop TYPE ssfctrlop,
e_ssfcompop TYPE ssfcompop.
DATA w_printer TYPE rspopname."user01-spld.
DATA:l_doc_output_info TYPE ssfcrespd, "#EC NEEDED
l_job_output_info TYPE ssfcrescl, "#EC NEEDED
l_job_output_options TYPE ssfcresop. "#EC NEEDED
DATA :l_devtype TYPE rspoptype.
Get the function module name of Smartform
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = '/BSHP/FW_SF_LIST_DEL'
variant = ' '
direct_call = ' '
IMPORTING
fm_name = lf_fm_name "/1BCDWB/SF00000084
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.
Set print parameters
e_ssfctrlop-no_dialog = 'X' .
Setting of output options
language
language = sy-langu.
TRANSLATE language TO UPPER CASE.
e_ssfctrlop-langu = language.
set control parameters to get the output format (OTF) from Smart Forms
e_ssfctrlop-no_dialog = 'X'.
e_ssfctrlop-getotf = 'X'.
get device type from language
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = l_devtype
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
set device type in output options
e_ssfcompop-tdprinter = l_devtype.
Call the func module of the Smartform
CALL FUNCTION lf_fm_name " '/1BCDWB/SF00000084'
EXPORTING
control_parameters = e_ssfctrlop
output_options = e_ssfcompop
user_settings = space
sf_werks = p_werks
sf_lifnr = p_lifnr
sf_matnr_low = s_matnr_low
sf_matnr_high = s_matnr_high
sf_vbeln_low = s_vbeln_low
sf_vbeln_high = s_vbeln_high
sf_lfdat_low = s_lfdat_low
sf_lfdat_high = s_lfdat_high
sf_vgbel_low = s_vgbel_low
sf_vgbel_high = s_vgbel_high
IMPORTING
document_output_info = l_doc_output_info
job_output_info = l_job_output_info
job_output_options = l_job_output_options
TABLES
gt_final_fi = gt_final
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.
Conversion of output format OTF into PDF format
now convert the final document (OTF format) into PDF format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
IMPORTING
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring " binary file
TABLES
otf = l_job_output_info-otfdata
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5 .
IF sy-subrc EQ 0.
CREATE OBJECT cached_response TYPE cl_http_response EXPORTING add_c_msg = 1.
l_pdf_len = XSTRLEN( l_pdf_xstring ).
cached_response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.
CONCATENATE runtime->application_url '/' guid '.pdf' INTO display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
ENDIF.
REGARDS
NAVJOT
REWARD IF HELPFULL -
Can you help me? a question of smartform convert to PDF file
when I do a smartform in Polish ,preview and print is ok.but when covert to pdf use report RSTXPDFT4,some words is wrong code(#).
Can you help me?hi,
if the data which is printing in # might be a included text or Text module if the text contains any " in the text delete that and again insert that with " i.e if we copy the text from word and paste them in the text editor in the print preview it shows correctly but in print it gets converted into #. I also faced this problem so that i came to know this. If it is not the case leave it.
Thanks,
Nethaji. -
Smartforms - Convert to PDF always displying bold, ignoring styles and font
Hi out there,
I'm not new to smartforms. But after creating a new form within a new style I'm not able to design it.
But mayby it's designed correctly and only pdf conversion failed?
The courios thing is, that sometimes (hleve font is replayced with standard courier) and all the fonts are displayed in BOLD.
I also tried with standard sap styles, like hrforms etc...but the text is always displayed in BOLD.
I just wanna use helve 10,12 px bold and non bold. I'm sure, that the fonts are setr up with se73, cause i have used them in an other form and they never did any problems.
Regards,
Ti did a stupid misstake in getting the device.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = v_language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = v_e_devtype.
tdprinter was not set properly! -
The file is damaged and could not be repaired when smartforms convert to pdf
i m using your code but error is occur
please help me
when i goto sost and open my pdf file at that time give error message
my whole program is below
report ypayment_advice2.
tables : bsak,skat.
types : begin of t_bsak,
belnr type bsak-belnr,
gjahr type bsak-gjahr,
augbl type bsak-augbl,
augdt type bsak-augdt,
xblnr type bsak-xblnr,
bldat type bsak-bldat,
* DMBTR TYPE BSAK-DMBTR,
* WAERS TYPE BSAK-WAERS,
lifnr type bsak-lifnr,
saknr type bsak-saknr,
budat type bsak-budat,
* EBELN TYPE BSAK-EBELN,
* EBELP TYPE BSAK-EBELP,
bukrs type bsak-bukrs,
buzei type bsak-buzei,
ebeln type bseg-ebeln,
ebelp type bseg-ebelp,
hkont type bseg-hkont,
shkzg type bseg-shkzg,
werks type bseg-werks,
dmbtr type bseg-dmbtr,
bldat1 type bsak-bldat,
xblnr1 type bsak-xblnr,
end of t_bsak.
types : begin of t_bseg,
belnr type bseg-belnr,
gjahr type bseg-gjahr,
ebeln type bseg-ebeln,
ebelp type bseg-ebelp,
hkont type bseg-hkont,
shkzg type bseg-shkzg,
werks type bseg-werks,
dmbtr type bseg-dmbtr,
end of t_bseg.
types : begin of t_bseg2,
belnr type bseg-belnr,
gjahr type bseg-gjahr,
ebeln type bseg-ebeln,
ebelp type bseg-ebelp,
werks type bseg-werks,
end of t_bseg2.
types : begin of t_bseg1,
augbl type bseg-augbl,
gjahr type bseg-gjahr,
hkont type bseg-hkont,
end of t_bseg1.
types : begin of t_bkpf,
bukrs type bkpf-bukrs,
cpudt type bkpf-cpudt,
blart type bkpf-blart,
usnam type bkpf-usnam,
budat type bkpf-budat,
end of t_bkpf.
types : begin of t_bsak1,
lifnr type bsak-lifnr,
end of t_bsak1.
*DATA : IT_FINAL TYPE STANDARD TABLE OF T_FINAL WITH HEADER LINE.
*DATA : WA_FINAL TYPE T_FINAL.
data : wrk_answer type c.
data : it_bsak type standard table of t_bsak.
data : wa_bsak type t_bsak.
data : it_bsak_temp type standard table of t_bsak1 with header line,
wa_bsak_temp type t_bsak1.
data : it_bsak_temp1 type standard table of t_bsak1 with header line,
wa_bsak_temp1 type t_bsak1.
data : it_bsak1 type standard table of t_bsak.
data : wa_bsak1 type t_bsak.
data : it_bseg type standard table of t_bseg.
data : wa_bseg type t_bseg.
data : it_bseg1 type standard table of t_bseg1.
data : wa_bseg1 type t_bseg1.
data : it_bseg2 type standard table of t_bseg2.
data : wa_bseg2 type t_bseg2.
data : it_bkpf type standard table of t_bkpf.
data : wa_bkpf type t_bkpf.
data : l_cntr type i value 1.
data : op type ssfcompop.
data : control type ssfctrlop.
data: formname1 type tdsfname," value 'YPAYMENT_ADVICE',
fm_name type rs38l_fnam.
data : i_smtp_addr type adr6-smtp_addr,
i_adrnr type lfa1-adrnr.
data: gd_recsize type i.
data : it_tsp01 type standard table of tsp01 with header line .
data : it_pdf like tline occurs 0 with header line .
data : gd_buffer type string.
data: gd_spool_nr like tsp01-rqident,
gd_destination like rlgrap-filename,
gd_bytecount like tst01-dsize.
data: gd_subject like sodocchgi1-obj_descr,
it_mess_bod like solisti1 occurs 0 with header line,
it_mess_att like solisti1 occurs 0 with header line,
gd_sender_type like soextreci1-adr_typ,
gd_attachment_desc type so_obj_nam,
gd_attachment_name type so_obj_des.
data : w_emailid type adr6-smtp_addr.
* JOB RUNTIME PARAMETERS
data: gd_eventid like tbtcm-eventid,
gd_eventparm like tbtcm-eventparm,
gd_external_program_active like tbtcm-xpgactive,
gd_jobcount like tbtcm-jobcount,
gd_jobname like tbtcm-jobname,
gd_stepcount like tbtcm-stepcount,
gd_error type sy-subrc,
gd_reciever type sy-subrc.
data: t_otfdata type soli_tab,
t_otfdata_item type soli_tab,
t_objhex type solix_tab,
t_objhead type soli_tab,
w_transfer type sx_boolean,
w_length type sood-objlen,
w_length_item type sood-objlen,
w_lines_txt type i,
w_lines_bin type i,
wa_soli type soli,
wa_solix type solix,
w_doc_chng type sodocchgi1,
t_objcont type standard table of soli with header line,
t_objcont_item type standard table of soli with header line,
t_objpack like sopcklsti1 occurs 0 with header line,
t_reclist like somlreci1 occurs 0 with header line,
t_objtxt like solisti1 occurs 0 with header line.
data : ls_control type ssfctrlop,
ls_output type ssfcrescl,
ls_output_opt type ssfcompop,
lt_lines type table of tline,
lt_linesx type table of tdline.
data : lv_pdf type xstring,
lv_filelen type i,
lv_file type string.
selection-screen begin of block b1 with frame title text-001.
select-options : p_lifnr for bsak-lifnr.
select-options : p_augbl for bsak-augbl obligatory,
p_year for bsak-gjahr obligatory.
* P_BUDAT FOR BSAK-BUDAT.
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform process_data .
perform call_smartforms.
*& Form GET_DATA
* text
* --> p1 text
* <-- p2 text
form get_data .
select augbl gjahr budat xblnr
from bsak
into corresponding fields of table it_bsak1
where augbl in p_augbl
and gjahr in p_year
and blart = 'KZ'
and lifnr in p_lifnr.
if sy-subrc <> 0.
message 'No Record Found ' type 'E'.
endif.
select augbl augdt belnr gjahr xblnr
dmbtr lifnr saknr budat bukrs buzei
from bsak
into corresponding fields of table it_bsak
for all entries in it_bsak1
where augbl = it_bsak1-augbl
and augdt = it_bsak1-budat
and blart = 'RE'.
* FOR ALL ENTRIES IN IT_BSAK
* WHERE AUGBL = '1500000011' "IT_BSAK-AUGBL
* AND GJAHR = '2013' "IT_BSAK-GJAHR
* AND BLART = 'RE'.
select belnr gjahr shkzg dmbtr koart
from bseg
into corresponding fields of table it_bseg
for all entries in it_bsak
where belnr = it_bsak-belnr
and gjahr = it_bsak-gjahr
and koart = 'K'.
* AND BUKRS = IT_BSAK-BUKRS.
* AND BUZEI = IT_BSAK-BUZEI.
select belnr gjahr hkont
from bseg
into corresponding fields of table it_bseg1
for all entries in it_bsak1
where belnr = it_bsak1-augbl
and gjahr = it_bsak1-gjahr
and koart = 'S'.
select belnr gjahr ebeln ebelp werks
from bseg
into corresponding fields of table it_bseg2
for all entries in it_bseg
where belnr = it_bseg-belnr
and gjahr = it_bseg-gjahr
and buzid = 'W'.
* BREAK ABAP.
select bukrs cpudt blart usnam budat
from bkpf
into corresponding fields of table it_bkpf
for all entries in it_bsak
where belnr = it_bsak-belnr
and gjahr = it_bsak-gjahr.
* AND BUKRS = IT_BSAK-BUKRS
loop at it_bsak into wa_bsak.
read table it_bseg into wa_bseg with key belnr = wa_bsak-belnr
gjahr = wa_bsak-gjahr.
if sy-subrc = 0.
move wa_bseg-shkzg to wa_bsak-shkzg.
move wa_bseg-dmbtr to wa_bsak-dmbtr.
modify it_bsak from wa_bsak transporting shkzg dmbtr.
endif.
read table it_bseg2 into wa_bseg2 with key belnr = wa_bsak-belnr
gjahr = wa_bsak-gjahr.
if sy-subrc = 0.
move wa_bseg2-ebeln to wa_bsak-ebeln.
move wa_bseg2-ebelp to wa_bsak-ebelp.
move wa_bseg2-werks to wa_bsak-werks.
modify it_bsak from wa_bsak transporting ebeln ebelp werks .
endif.
read table it_bseg1 into wa_bseg1 with key gjahr = wa_bsak-gjahr.
if sy-subrc = 0.
move wa_bseg1-hkont to wa_bsak-hkont.
modify it_bsak from wa_bsak transporting hkont where gjahr = wa_bsak-gjahr.
endif.
read table it_bsak1 into wa_bsak1 with key augbl = wa_bsak-augbl
gjahr = wa_bsak-gjahr.
if sy-subrc = 0.
move wa_bsak1-bldat to wa_bsak-bldat1.
move wa_bsak1-xblnr to wa_bsak-xblnr1.
modify it_bsak from wa_bsak transporting bldat1 xblnr1 where augbl = wa_bsak-augbl
and gjahr = wa_bsak-gjahr.
endif.
endloop.
loop at it_bsak into wa_bsak.
move wa_bsak-lifnr to wa_bsak_temp-lifnr.
append wa_bsak_temp to it_bsak_temp .
endloop.
loop at it_bsak_temp into wa_bsak_temp.
collect wa_bsak_temp into it_bsak_temp1.
endloop.
endform. " GET_DATA
*& Form PROCESS_DATA
* text
* --> p1 text
* <-- p2 text
form process_data .
export it_bsak to memory id 'IT_BSAK'.
export it_bseg to memory id 'IT_BSEG'.
export it_bkpf to memory id 'IT_BKPF'.
* BREAK ABAP.
endform. " PROCESS_DATA
*& Form CALL_SMARTFORMS
* text
* --> p1 text
* <-- p2 text
form call_smartforms .
* LOOP AT IT_BSAK_TEMP.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'YPAYMENT_ADVICE1'
importing
fm_name = fm_name.
* CALL FUNCTION FM_NAME"'/1BCDWB/SF00000442'
* EXPORTING
* P_LIFNR = IT_BSAK_TEMP-LIFNR.
call function fm_name"'/1BCDWB/SF00000442'
exporting
it_bsak = it_bsak
it_bseg = it_bseg
it_bkpf = it_bkpf.
clear wrk_answer.
* BREAK ABAP.
call function 'POPUP_TO_CONFIRM'
exporting
titlebar = 'LOGOFF'
* DIAGNOSE_OBJECT = ' '
text_question = 'Do You Want Send Mail?'
text_button_1 = 'YES'
* ICON_BUTTON_1 = ' '
text_button_2 = 'NO'
display_cancel_button = space
start_column = 25
start_row = 6
importing
answer = wrk_answer
* TABLES
* PARAMETER =
exceptions
text_not_found = 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.
*Mail send coding
check wrk_answer = '1'.
loop at it_bsak_temp1 into wa_bsak_temp1.
break abap.
select single adrnr from lfa1
into i_adrnr where lifnr = wa_bsak_temp1-lifnr.
select single smtp_addr from adr6
into w_emailid
where addrnumber = i_adrnr.
if w_emailid is not initial.
perform mail.
else.
message 'E-Mail Address is not maintained for Vendor' type 'S'.
endif.
endloop.
endform. " CALL_SMARTFORMS
*& Form SEND_EMAIL
* text
* -->P_P_EMAIL1 text
form send_email using p_email.
check not ( p_email is initial ).
refresh it_mess_bod.
*BREAK-POINT.
* DEFAULT SUBJECT MATTER
gd_subject = 'SUBJECT'.
gd_attachment_desc = 'Invoice '.
* CONCATENATE 'ATTACH_NAME' ' ' INTO GD_ATTACHMENT_NAME.
it_mess_bod = 'Hi,'.
append it_mess_bod.
it_mess_bod = 'Kindly Find an attached copy of Sale Invoice : '.
concatenate it_mess_bod p_lifnr into it_mess_bod separated by space.
append it_mess_bod.
it_mess_bod = 'This is system generated Mail,So do not reply.'
append it_mess_bod.
it_mess_bod = 'Thank you,'.
append it_mess_bod.
it_mess_bod = 'Gokul Refoils & Solvent Ltd.'.
append it_mess_bod.
data : p_sender type somlreci1-receiver.
p_sender = '[email protected]'
* IF NO SENDER SPECIFIED - DEFAULT BLANK
if p_sender eq space.
gd_sender_type = space.
else.
gd_sender_type = 'INT'.
endif.
* SEND FILE BY EMAIL AS .XLS SPEADSHEET
perform send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Narendra CHECK Invoice-Gokul Refoils & Solvent Ltd.'
*'Sale Invoice .pdf document attached'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
endform. " SEND_EMAIL
* & FORM SEND_FILE_AS_EMAIL_ATTACHMENT
* TEXT
* -->P_IT_MESS_BOD TEXT
* -->P_IT_MESS_ATT TEXT
* -->P_P_EMAIL TEXT
* -->P_1395 TEXT
* -->P_1396 TEXT
* -->P_GD_ATTACHMENT_NAME TEXT
* -->P_GD_ATTACHMENT_DESC TEXT
* -->P_P_SENDER TEXT
* -->P_GD_SENDER_TYPE TEXT
* <--P_GD_ERROR TEXT
* <--P_GD_RECIEVER TEXT
form send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing perror
p_reciever.
data:ld_error type sy-subrc,
ld_reciever type sy-subrc,
ld_mtitle like sodocchgi1-obj_descr,
ld_email like somlreci1-receiver,
ld_format type so_obj_tp ,
ld_attdescription type so_obj_nam ,
ld_attfilename type so_obj_des ,
ld_sender_address like soextreci1-receiver,
ld_sender_address_type like soextreci1-adr_typ,
ld_receiver like sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_receivers1 like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* FILL THE DOCUMENT DATA.
w_doc_data-doc_size = 1.
* POPULATE THE SUBJECT/GENERIC MESSAGE ATTRIBUTES
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* FILL THE DOCUMENT DATA AND GET SIZE OF ATTACHMENT
*BREAK-POINT.
clear w_doc_data.
read table it_attach index w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + strlen( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
clear t_attachment.
refresh t_attachment.
t_attachment[] = it_attach[].
* DESCRIBE THE BODY OF THE MESSAGE
clear t_packing_list.
refresh t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
describe table it_message lines t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.
* CREATE ATTACHMENT NOTIFICATION
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
describe table t_attachment lines t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
append t_packing_list.
* ADD THE RECIPIENTS EMAIL ADDRESS
clear t_receivers.
refresh t_receivers.
t_receivers-receiver = w_emailid.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
append t_receivers.
** CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
** EXPORTING
** DOCUMENT_DATA = W_DOC_DATA
** PUT_IN_OUTBOX = 'X'
** COMMIT_WORK = 'X'
** TABLES
** PACKING_LIST = T_PACKING_LIST
** CONTENTS_BIN = T_ATTACHMENT
** CONTENTS_TXT = IT_MESSAGE
** RECEIVERS = T_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.
** COMMIT WORK.
** LOOP AT T_RECEIVERS.
** LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
** ENDLOOP.
**ENDFORM. "SEND_FILE_AS_EMAIL_ATTACHMENT
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_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.
* POPULATE ZERROR RETURN CODE
ld_error = sy-subrc.
* POPULATE ZRECEIVER RETURN CODE
loop at t_receivers.
ld_receiver = t_receivers-retrn_codeNot sure if the flollowing will be of use, but worth a try?…
Try changing the .ai to .eps or .pdf to see if anything happens to see if it makes a difference to importing or exporting as a pdf?
If you have Indesign, try importing the file into Indesign then saving that file as a pdf or/and export as a Indesign eps file.
Sorry I cannot be of any more assistance.
Good luck! -
Smartform convert to WORD - e-mail/fax
Hi All,
Quickly can we convert Smartform output to Word output. Currently I am doing Smartform converted to PDF and sending that as e-mail/fax. New requirement is to send in word format. Can we convert Samrtform to WORD and send as e-mal/fax?
Thanks in advance.
Regards,
TimCheck this code below ....
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSD_SFM_ATTACH'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
CALL FUNCTION FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = wa_control
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = wa_prnctrl
USER_SETTINGS = 'X'
CUST_LINE = gl_cust_line
IMPORTING
DOCUMENT_OUTPUT_INFO = wa_doc_info
JOB_OUTPUT_INFO = wa_outinfo
JOB_OUTPUT_OPTIONS = wa_job_opt
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
t_otf[] = wa_outinfo-otfdata[].
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
USE_OTF_MC_CMD = 'X'
ARCHIVE_INDEX =
IMPORTING
BIN_FILESIZE = g_filesize
TABLES
OTF = t_otf
DOCTAB_ARCHIVE = t_docs
LINES = i_tline
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 2
OTHERS = 3
convert PDF 132 to 255
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
No translation
loop at i_tline.
i_objbin-line = i_tline-tdline.
append i_objbin.
endloop.
Convert PDF from 132 to 255.
LOOP AT i_tline.
Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Refresh: i_reclist, i_objtxt, i_objbin, i_objpack.
clear w_objhead.
Object with PDF.
i_objbin[] = i_record[].
loop at i_record.
i_objbin-line = i_record-line.
append i_objbin.
endloop.
DESCRIBE TABLE i_objbin LINES v_lines_bin.
glt_objpack-head_start = 1.
Number of lines of an object header in object packet
glt_objpack-head_num = 0.
Start line of object contents in an object packet
glt_objpack-body_start = 1.
Number of lines of the object contents in an object packet
glt_objpack-body_num = v_lines_txt.
Code for document class
glt_objpack-doc_type = 'RAW'.
APPEND i_objpack.
Packing as PDF.
glt_objpack-transf_bin = 'X'.
glt_objpack-head_start = 1.
glt_objpack-head_num = 1.
glt_objpack-body_start = 1.
glt_objpack-body_num = v_lines_bin.
glt_objpack-doc_type = 'PDF'.
glt_objpack-obj_name = 'ReturnForm'.
CONCATENATE 'ReturnForm_output' '.pdf'
INTO glt_objpack-obj_descr.
glt_objpack-doc_size = v_lines_bin * 255.
APPEND glt_objpack.
glt_objhead = 'Return_form.PDF'. append glt_objhead.
Document information.
CLEAR i_reclist.
Fill the receiver list
clear gs_reclist.
condense gl_fax_num.
gs_reclist-receiver = P_Z_MFR_MAIL.
gs_reclist-rec_type = co_u.
append gs_reclist to i_reclist.
Sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gl_doc_chng
put_in_outbox = 'X'
COMMIT_WORK = 'X'
TABLES
packing_list = glt_objpack
object_header = glt_objhead
CONTENTS_BIN = i_objbin
contents_hex = i_objbin
contents_txt = gt_objcont
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. -
Convert Smartform Output to PDF
Hi all,
I am trying to save Output of Smartform in PDF file format. for that purpose i am calling "CONVERT_OTF" FM from my driver program.
But it is giving me Information "OTF end command // missing in OTF data"
while executing FM "CONVERT_OTF". i debug it it is giving Sy-subrc = 2.
Please Help me in this context. I am also givin code of my driver program:
TABLES: vbrp.
DATA: fm_name TYPE rs38l_fnam,
it_invoice TYPE STANDARD TABLE OF vbrp,
it_invoice_wa TYPE vbrp,
it_inv TYPE STANDARD TABLE OF vbrp,
it_inv_wa TYPE vbrp,
invoice_no(25) TYPE c,
invoice_l(10) TYPE c,
invoice_h(10) TYPE c.
Converting Output to PDF Declaration **********
DATA: tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
bin_filesize LIKE sood-objlen,
outop TYPE ssfcompop, " Output Parameters
cparam TYPE ssfctrlop, " Control Parameters
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
my_tabix TYPE sy-tabix,
file_size TYPE i.
SELECT-OPTIONS doc_no FOR vbrp-vbeln.
SELECT vbeln posnr fkimg vrkme meins netwr matnr
FROM vbrp INTO CORRESPONDING FIELDS
OF TABLE it_invoice
WHERE vbeln IN doc_no.
Inserting Unique Invoice Numbers for Displaying Individual Details in
Smart Form
LOOP AT it_invoice INTO it_invoice_wa.
AT NEW vbeln.
MOVE it_invoice_wa-vbeln TO it_inv_wa-vbeln.
APPEND it_inv_wa TO it_inv.
ENDAT.
ENDLOOP.
invoice_no = doc_no.
invoice_l = doc_no-low.
invoice_h = doc_no-high.
suppressing the Print dialog box *********************
*outop-tddest = 'locl'.
*cparam-no_dialog = 'X'.
*cparam-preview = space.
*cparam-getotf = 'X'.
START-OF-SELECTION.
Calling Smart Form *********************************
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSB_SMARTFORM_INVOICE'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
CALL FUNCTION fm_name
EXPORTING
invoice_no_h = invoice_h
invoice_no_l = invoice_l
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = cparam
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = outop
user_settings = ''
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = tab_otf_data
JOB_OUTPUT_OPTIONS =
TABLES
it_invoice = it_invoice
it_inv = it_inv
***removing the initial and final markers from the OTF data*********
DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
searching for the end-of-page in OTF table************
READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
my_tabix = sy-tabix + 1.
appending the modified OTF table to the final OTF table****
*INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.
tab_otf_final[] = tab_otf_data-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
IMPORTING
bin_filesize = bin_filesize
BIN_FILE =
TABLES
otf = tab_otf_final
lines = pdf_tab
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.
write :/ bin_filesize.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = bin_filesize
filename = 'E:/Test.pdf'
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = file_size
tables
data_tab = pdf_tab
FIELDNAMES =
Help will be rewarded.
Regards,
Sachinhi
good
go through this ,hope this ll help you to solve this problem
Check out the following documentation and example program and help links
s_control_parameters-no_dialog = 'X'.
s_control_parameters-getotf = 'X'.
CALL FUNCTION v_func_name "call your smartform
EXPORTING
output_options = s_output_options
control_parameters = s_control_parameters
IMPORTING
job_output_info = s_job_output_info
call function 'CONVERT_OTF_2_PDF'
tables
otf = s_job_output_info-otfdata
lines = t_pdf
here is the example for SAMRTFORM TO PDF.
http://www.sap4.com/wiki/index.php/Genera_PDF_a_partir_de_Smartforms
Example Program
data:
fm_name TYPE RS38L_FNAM, "Smart Forms: FM Name
sf_name TYPE TDSFNAME
value 'YOUR_FORM_NAME', "Smart Forms: Form Name
P_OUTPUT_OPTIONS TYPE SSFCOMPOP,
P_JOB_OUTPUT_INFO TYPE SSFCRESCL,
P_CONTROL_PARAMETERS TYPE SSFCTRLOP,
P_LANGUAGE TYPE SFLANGU value 'E',
P_E_DEVTYPE TYPE RSPOPTYPE.
data:
P_BIN_FILESIZE TYPE I,
P_BIN_FILE TYPE XSTRING,
P_OTF type table of ITCOO,
P_DOCS type table of DOCS,
P_LINES type table of TLINE,
name type string,
path type string,
fullpath type string,
filter type string,
guiobj type ref to cl_gui_frontend_services,
uact type i,
filename(128).
GET SMARTFORM FUNCTION MODULE NAME ---
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = sf_name
IMPORTING
FM_NAME = fm_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.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
I_LANGUAGE = P_LANGUAGE
I_APPLICATION = 'SAPDEFAULT'
IMPORTING
E_DEVTYPE = P_E_DEVTYPE.
P_OUTPUT_OPTIONS-XSFCMODE = 'X'.
P_OUTPUT_OPTIONS-XSF = SPACE.
P_OUTPUT_OPTIONS-XDFCMODE = 'X'.
P_OUTPUT_OPTIONS-XDF = SPACE.
P_OUTPUT_OPTIONS-TDPRINTER = P_E_DEVTYPE.
P_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
P_CONTROL_PARAMETERS-GETOTF = 'X'.
****...................................PRINTING.........................
CALL FUNCTION fm_name
EXPORTING
CONTROL_PARAMETERS = P_CONTROL_PARAMETERS
OUTPUT_OPTIONS = P_OUTPUT_OPTIONS
(....) <--- your form import parameters
IMPORTING
JOB_OUTPUT_INFO = P_JOB_OUTPUT_INFO.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.
****...................................CONVERT TO PDF...............
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
BIN_FILESIZE = P_BIN_FILESIZE
TABLES
OTF = P_OTF
DOCTAB_ARCHIVE = P_DOCS
LINES = P_LINES
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 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.
concatenate 'xxxx' '.pdf' into name.
****..................................REQUEST FILE NAME.................
create object guiobj.
call method guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = name
file_filter = filter
CHANGING
filename = name
path = path
fullpath = fullpath
user_action = uact.
if uact = guiobj->action_cancel.
exit.
endif.
move fullpath to filename.
****..................................DOWNLOAD AS FILE................
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = P_BIN_FILESIZE
FILENAME = filename
FILETYPE = 'BIN'
TABLES
DATA_TAB = P_LINES
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
NO_AUTHORITY = 10
OTHERS = 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.
reward poing if helpful..
thanks
mrutyun^ -
Converting smartforms output into PDF
Hi ALL,
How to convert the smartforms output into PDF based form. After executing the form, it should directly open in PDF. How to do this?
Points will be awarded.
Thanks and regards,
vinoth.Hi Vinoth Kumar,
Please go throuh the below procedure and sample Code, this might help you.
Procedure
When we activate the Smartform the system generates a Function Module. The function module name we can get from Smartfrom screen from menubar
Environment => Function Module_Name . In a report we can get this Function module name by calling a Function Module standard SSF_FUNCTION_MODULE_NAME. This function module at runtime calls the FM generated by smartform, which in turn is then used to pass data from the report to Smartform. In the report given below the FM generated is /1BCDWB/SF00000152 . In this FM we can see CONTROL_PARAMETERS in import tab. This is of type SSFCTRLOP. We need to set the GETOTF of this to be X. Setting this field will activate the OTF field in smartform.
In export tab of the FM generated by smartform we can see a parameter JOB_OUTPUT_INFO which is of type SSFCRESCL. The SSFCRESCL is a structure of having one of fields as OTFDATA. OTFDATA in turn is a table of type ITCOO. ITCOO has two fields TDPRINTCOM and TDPRINTPAR. TDPRINTCOM represents command line of OTF format data and TDPRINTPAR contains command parameters of OTF format data.
In every Smartform output in OTF format, TDPRINTCOM begins and ends with //. EP represents the end-of-page value for TDPRINTCOM field.
In addition we need to set few fields at the place where we call this FM(generated by smartform) in our program. While calling this FM we should set control_parameters, output_options, user_settings and job_putput_info fields as shown in program.
Once these settings are done we can call Function Module CONVERT_OTF to convert the OTF data of smartfrom output to PDF data format. Once these are done we can call method cl_gui_fronted_services=>file_save_dialog to specify the directory path where we want to save the output PDF file. After this we can call Function Module GUI_DOWNLOAD to download the PDF file on our local system.
Here is a sample code of program to perform the function.
SAMPLE CODE
*& Report ZAMIT_SMART_FORM_PDF *
REPORT ZAMIT_SMART_FORM_PDF .
data: carr_id type sbook-carrid,
cparam type ssfctrlop,
outop type ssfcompop,
fm_name type rs38l_fnam.
DATA: tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
file_size TYPE i,
bin_filesize TYPE i,
FILE_NAME type string,
File_path type string,
FULL_PATH type string.
parameter: p_custid type scustom-id default 1.
select-options: s_carrid for carr_id default 'LH' to 'LH'.
parameter: p_form type tdsfname default 'ZAMIT_SMART_FORM'.
data: customer type scustom,
bookings type ty_bookings,
connections type ty_connections.
start-of-selection.
suppressing the dialog box for print preview****************************
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = SPACE.
cparam-getotf = 'X'.
select single * from scustom into customer where id = p_custid.
check sy-subrc = 0.
select * from sbook into table bookings
where customid = p_custid
and carrid in s_carrid
order by primary key.
select * from spfli into table connections
for all entries in bookings
where carrid = bookings-carrid
and connid = bookings-connid
order by primary key.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting formname = p_form
variant = ' '
direct_call = ' '
importing fm_name = fm_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.
exit.
endif.
Hope this resolves your query.
Reward all the helpful answers.
Regards
calling the generated function module
call function fm_name
exporting
archive_index =
archive_parameters =
control_parameters = cparam
mail_appl_obj =
mail_recipient =
mail_sender =
output_options = outop
user_settings = SPACE
bookings = bookings
customer = customer
connections = connections
importing
document_output_info =
job_output_info = tab_otf_data
job_output_options =
exceptions formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
if sy-subrc <> 0.
error handling
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
tab_otf_final[] = tab_otf_data-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
IMPORTING
bin_filesize = bin_filesize
BIN_FILE =
TABLES
otf = tab_otf_final
lines = pdf_tab
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 METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
FILE_FILTER =
INITIAL_DIRECTORY =
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = FILE_NAME
path = FILE_PATH
fullpath = FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 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.
************downloading the converted PDF data to your local PC*******
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = FULL_PATH
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 = file_size
TABLES
data_tab = pdf_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.
ENDIF. -
I have a problem in converting smartform output to pdf format.
Hi,
While converting the smartform output to pdf format.
It is showing this error.
otf end command // missing in otf data.
I have used this function.
Assigning the OTFDATA to OTF Structure table
CLEAR gt_otf.
gt_otf[] = gs_otfdata-otfdata[].
Convert the OTF DATA to SAP Script Text lines
CLEAR gt_pdf_tab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = gv_bin_filesize
TABLES
otf = gt_otf
lines = gt_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.
Please help me in this regard. Thanks in advance.Hi ,
I am getting this exception "err_conv_not_possible"
CALL FUNCTION f_name " '/1BCDWB/SF00000092'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = st_control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = st_output_options
USER_SETTINGS = 'X'
ZST_TEXTSYMBOLS = ZST_TEXTSYMBOLS
wa_kna1 = wa_kna1
wa_claim_header = wa_claim_header
IMPORTING
DOCUMENT_OUTPUT_INFO = st_document_output_info
JOB_OUTPUT_INFO = st_job_output_info
JOB_OUTPUT_OPTIONS = st_job_output_options
TABLES
IT_CLAIM_VERSION = IT_CLAIM_VERSION
IT_CLAIM_ITEM = IT_CLAIM_ITEM
IT_CLAIM_PARTNER = IT_CLAIM_PARTNER
IT_FINAL = IT_FINAL
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.
ELSE.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
USE_OTF_MC_CMD = 'X'
ARCHIVE_INDEX =
IMPORTING
BIN_FILESIZE = v_bin_filesize
TABLES
OTF = st_job_output_info-OTFDATA[]
DOCTAB_ARCHIVE = it_docs
LINES = it_lines
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 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.
ENDIF.
HERE when i tried to debug it i got SY-SUBRC = 1.
Please help me in this regard. Thanks in advance. -
Problem while converting smartform out to PDF.
Hi,
I have an issue while converting smartform output to PDF. After converting samrtform out to PDF, apostrophe(') is appearing as # in the pdf file. For example the word Indian's is getting printed as Indian#s. I'm using Helvetica font for printing this text.
How ever print preview is coming fine.
Could anybody provide me some inputs to solve this.
Thanks,
Rick.I'm using FM: CONVERT_OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_filesize
TABLES
otf = ls_job_info-otfdata
lines = lt_pdf_table
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. -
Alignment problem in converting smartform printpreview into PDF
Hi all,
I am getting some alignment problem in converting smartform printpreview into PDF format, i.e the format of PDF is different from printpreviw of smartform.
kindly suggest something so that alignment is not changed while converting to PDF.
Regards,
Sumalathause below f.m to convert it into 255 characters....
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = i_tline
t_target_tab = so_ali[]
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2. -
Converting Smartform spool to PDF results in loss of formatting
A smart form contains texts which is printed in bold.
This is clearly visible in both the preveiw and the prionout.
When we convert the output of a smartform into a PDF form the bold text is converted into a normal text for that font.
We are using a custom ZARIAL font in the smartstyle, and cannot tell if it is this Z font which the PDF conversion cannot support or if there is some setting which needs to be tweaked.
Kindly advice.Hi
ZARIAL font which you have created in the smartstyle and used in the smartform is no supporting while converting from OTF TO PDF.
[Output in PDF Format|http://help.sap.com/saphelp_nw70/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm]
Regards,
Sravanthi -
To convert smartform spool to pdf
Hi all,
I need to convert smartfom spool to pdf..
When i executed the smartform it is generating a spool number and
tsp01-rqdoctype = 'SMART'.
To convert Spool to PDF Iam using the following function module
'CONVERT_ABAPSPOOLJOB_2_PDF'
It is converting to pdf only if the document type is 'LIST'.
can any one suggest me how to convert smartform spool to pdf?
Regards
cnuHi
Refer to this link :
Re: smartform output to mail
Reward if useful
Thanks
Krushna
Maybe you are looking for
-
Can't Get Hyperlink To Work From One iWeb Site To Another
I created a "family" website, including a blog page. In a recent blog, I briefly announced that my two nieces just completed a two-week adventure in the African bush. I have created a second website using iWeb which is a simple photo page. I had hope
-
Hello. I have a problem with activation my iPhone 5. I have bought the iPhone one month ago and update iOS 8.1.3 yesterday. After update iPhone has an activation screen and asks previous owner's Apple ID and Password. I don't know Apple ID and Passwo
-
Item Text of PO needs to be populated before it is saved
Hi All, I have to write Item text of PO to Application server along with other PO details. So using ME21n I am trying to do this using a BTE, but when BTE is triggered by that time item text is not saved to PO so I am unable to capture it. Please su
-
Installing Oracle Applications E-Business Suite R12 error
hi everyone i have error while installing Oracle Applications E-Business Suite R12 on Windows server 2003 R12 plz help me this is log file: Processing DriverFile = E:\Oracle R12\Oracle12_Source\Oracle12\stage12i\startCD\Disk1\rapidwiz\template\adriap
-
Installation issue: Sun one web server 6.1 SP5 with JDK1.6 on Windows XP
Hi, I am trying to install sun one webserver 6.1 SP5 on my system which has windows XP operating system for the development work. the JDK version i am using is JDK1.6. While installing sun one webserver at step where i can use custom java development