Function to convert timestamps into milliseconds
Hi,
Does SAP have a function module which can read in a date/timestamp and output that time in milliseconds (a long integer starting from 1st January 1970)?
Many thanks in advance,
Peter
try:
PARAMETERS:d2 TYPE sy-datum DEFAULT sy-datum,
d1 TYPE sy-datum default '19700101'.
data sec_day TYPE i . "ms per day
DATA : d TYPE i.
DATA result TYPE f.
DATA rp(16) type p decimals 0.
AT SELECTION-SCREEN ON d2.
IF d2 LE d1.
MESSAGE e001(00) WITH 'date must be greater than 1970/01/01'.
ENDIF.
START-OF-SELECTION.
sec_day = 24 * 60 * 60 * 1000.
d = d2 - d1.
rp = result = d * sec_day.
WRITE: / d2, d1, d, / result, rp.
hope that helps
Andreas
Edited by: Andreas Mann on Apr 10, 2008 3:37 PM
Similar Messages
-
Converting Date Into Milliseconds?
I want to convert the following date and time into milliseconds: 4/21/2003 21.50. I know how to convert milliseconds into a date, but not the other way around. Could someone, please, help?
String etd = "4/21/2003 10:45";
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
df.setLenient(true);
try {
df.parse(etd);
catch(Exception e) {
e.printStackTrace();
I'm trying to use DateFormat to convert a date into ms. However, I'm getting a parsing error. Any suggestions? -
How to convert Timestamp into exact Date and Time(FM)
Hi Gurus,
could anyone tel me ,
e.g:20.11.2008:11:23:54am
How to convert Time stamp into exact Date and TimeHi,
Following is one way of doing it
Timestamp timeStamp = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println(timeStamp);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
System.out.println(dateFormat.format(timeStamp));
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
System.out.println(timeFormat.format(timeStamp));
Output
2008-11-20 11:59:35.693 -> Timestamp
11/20/2008
11:59:35
Regards
Ayyapparaj -
Converted WSDL into .java-files - and now?
I should implement a client for an existing web service. All I have is a .wsdl-file of the web service to call.
Therefore I used the eclipse's functionality to convert .wsdl into .java files, which generated some files for me, for example:
- interface XXX extending java.rmi.Remote
- interface XXXService extends javax.xml.rpc.Service
- class XXXProxy implements XXX
- class XXXServiceLocator extends org.apache.axis.client.Service
- class XXXSoapBindingStub extends org.apache.axis.client.Stub implements XXX
- class XXXRfcException extends org.apache.axis.AxisFault implements java.io.Serializable
- class XXXRfcExceptions implements java.io.Serializable
My question... what to do now? How can I get the service and call its functionality?
Your help is really, REALLY appreciated...Hi,
Write client application like below.
public class Client{
public static void main(String [] args) throws Exception {
// Make a service
XXXService service = new XXXServiceLocator();
// Now use the service to get a stub which implements the SDI.
AddressBook port = service.getAddressBook();
// Make the actual call
Address address = new Address(...);
port.addEntry("Russell Butek", address);
Thanks&Regards,
M.Kumaraswamy. -
Convert timestamp from text file (hh:mm:ss) into seconds
How can I import a column of time stamps from a text file of the form hh:mm:ss and convert it into seconds using LabView? For example, 13:30:30 into 48630.
Also, using the "Read from Spreadsheet File VI" I can't seem to get the entire time stamp imported correctly. Only the value before the colon is read. For example, if the timestamp reads 13:30:30, only 13 is inputed into the array in LabView.
FYI I'm using LabView 7. Thanks!Here's a LV 7 example. Just a Scan From String, a couple of Multiply functions and add the results. As far as your Read From Spreadsheet issue, by default, the function creates an array of SGLs. 13:30:30 is text and the functions needs to be modified to return an array of strings. There are instructions on the diagram on how to do this. When you've made the changes, save it as a new name and in a new location.
Attachments:
time_to_seconds.vi 17 KB -
Function to convert PO quantity and cancelled quantity into Primary UOM
Hello,
I am looking for a function to convert PO quantity and cancelled quantity into its Primary UOM from the unit of measure the line order was placed.
Thank youhi
In case if you are already working in production remember that decimal places should not change. It will affect all previous data.
For your problem best solution is make order unit as 1000. So that your problem will solve
e.g. instead of 2.009 inr for 1 Unit use 2009 inr for 1000 unit. -
How to convert rows into columns with decode function
Hi,
How to convert rows into columns with the help of decode function in oracle.
thanks and regards
P Prakashsay
col1 col2
1 10
2 20
3 30
then use
select col1,
sum(decode(col2,10,10)) "new1"
sum(decode(col2,20,20))"new2"
sum(decode(col2,30,30))"new3"
from table_name
group by col1;
we used sum u can use ny function if wont u have to give the column name i.e col2 name also
so i think u got it nw
regards -
Converting sql timestamp into a usable java format??
hi there.
does anyone know how to convert an sql timestamp into a usable java format? i have retrieved a timestamp from a mysql table in a jsp script and would like to convert it into the following format:
12:42pm | 08.07.02
as i understand it, i'll need to convert the timestamp into seconds since 1970 and then manipulate it as a calendar object? my first line is working, but i don't know what to do after...
java.sql.Timestamp sqlTimestamp = resultSet.getTimestamp("date_and_time");
next...?
any help would be much appreciated!!
thanks.please excuse my java sytnax ignorance, but i've tried a bunch of different syntax arrangements and can't figure out how to use the getTime() method. what comes after my first line there?
java.sql.Timestamp sqlTimestamp = resultSet.getTimestamp("date_and_time");
then something like:
long msec=date.getTime(sqlTimestamp);
but that doesn't seem to work...
thanks for any help! -
Whether i would write user-defined function convert euro into rupee or USD
hi expects,
whether it need to right user defined functions for convert the currency into euro or any other currency into rupee or USD.as my client is having business in different region.please help me.
Edited by: santosh kumar sethis on Apr 24, 2008 10:39 AMI suggest to use a UDF and call an RFC function\BAPI in the ERP system.
Currency conversion values are maintained in the ERP system by the Financial people so you'll have the most updated rates.(maybe even according to the date of purchase)
So 3 scenarios come to mind:
1. if the message is send from a 3rd party system or from ERP ,the currency must be converted already in the message,
2.the RFC of the ERP will do the conversion or you.
3.Find a currency conversion web service that has parameters of date and currency so you'll do the conversion as accurate as possible.
bare in mind:
there might be inconsistency of the money values due to the change in currency from the time the order was placed in the system till the time of entering the SAP .ask for the advise of a financial person so you wont do any mistakes in conversion.
ANY WAY - don't use hard coded constants in XI mapping for currency conversion.
Good luck.
Nimrod -
Want to create a function module which will convert smartform into PDF .
Hi All ,
Requirement : I want to create a function module/report which will convert smartform into PDF .
Thanks in advanceHi All ,
zsuresh_test : for converting smartform into pdf.
when I am excuting this report(zsuresh_test) and by passing the smartform name FOPCR_STANDARD_F1
I am getting error :
Incorrect parameter with CALL FUNCTION
Can you please help me out..
REPORT zsuresh_test.
Variable declarations
DATA:
w_form_name TYPE tdsfname VALUE 'FOPCR_STANDARD_F1',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
Internal tables declaration
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
This function module call is used to retrieve the name of the Function
module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
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.
Calling the SMARTFORM using the function module retrieved above
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
Printer name to be used is provided in the export parameter
OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = w_cparam
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = w_outoptions
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
JOB_OUTPUT_OPTIONS =
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.
t_otf[] = t_otf_from_fm-otfdata[].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = W_bin_filesize
BIN_FILE =
TABLES
otf = T_OTF
lines = T_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.
To display File SAVE dialog window
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 = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_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.
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_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'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = T_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Convert data into Date Format imported from MS SQL Server.
I have imported Data from MS SQL Server. The "Date Column" received in number format like 41017.6361109954. How can i convert it into Date in Oracle SQL.
If i import same Data in Excel and change the Column Type to Date. It changes successfully. But in Oracle, I tried To_Date function with different parameters but it didn't work.
Edited by: XAVER on Apr 22, 2012 2:31 AMXAVER wrote:
The actual date for 41017.6361109954 is 22-Apr-2012 but its showing 20-APR-2082It looks like offset is January 1, 2000:
select timestamp '2000-01-01 00:00:00' + numtodsinterval(41017.6361109954,'day') from dual;
20-APR-12 03.15.59.990002560 PM
SQL> SY. -
Need to convert values into coma separated
Need to convert values into coma separated
I have a string value that stores data like 'NYK,IND,SGP,GER'
FOR EXAMPLE
V_CITY_CODE = 'NYK,IND,SGP,GER'
When I query
select * from city where city_code = V_CITY_CODE;I get no rows, this is because V_CITY_CODE has all city code as single code.
I need a function to search , and replace with ','.
I tried using instr and replace but was unable to convert it.
could some one pls assist me.
thanks in advance
SazLooking for this?
SQL> select * from emp
2 /
EMPNO DEPTNO ENAME SAL DOJ JOB
1 1 Karthick 80 03-DEC-11
2 1 Karthick_1 90 23-NOV-11
3 2 Ram 80 03-DEC-11
4 2 Ram_1 90 23-NOV-11
SQL> var v_ename varchar2(1000)
SQL> exec :v_ename := 'Karthick,Karthick_1'
PL/SQL procedure successfully completed.
SQL> select *
2 from emp
3 where ename in (
4 select regexp_substr(val, '[^,]+', 1, level)
5 from (select :v_ename val from dual)
6 connect by level <= length(val) - length(replace(val, ','))+1
7 )
8 /
EMPNO DEPTNO ENAME SAL DOJ JOB
1 1 Karthick 80 03-DEC-11
2 1 Karthick_1 90 23-NOV-11 -
Inserting Timestamp into a SQL database
I am having a problem inserting a timestamp into a Sql Database. I keep getting this error or a different on when i format the timestamp differently. In the following code the timestamp is not formated at all.
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '13'
this is the sql statement that is executed
insert into timesheet(IDNUM,TimeIn,TimeOut,HoursWorked) values (123 , 2005-07-15 13:20:06.062 , 2005-07-15 13:20:06.062 ,0)
the code is as follows:
<%
try
SimpleDateFormat test = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Timestamp stamp = new Timestamp(System.currentTimeMillis());
java.util.Date date = new java.util.Date();
String sql = "insert into timesheet(IDNUM,TimeIn,TimeOut,HoursWorked) values (" + session.getAttribute("IDNum") + " , " + stamp + " , " + stamp + " ,0)";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cnxn = DriverManager.getConnection("jdbc:odbc:EmployeeSystem");
Statement stmt = cnxn.createStatement();
stmt.execute(sql);
response.sendRedirect("employee.jsp");
catch(Exception dberr)
SimpleDateFormat test = new SimpleDateFormat("yyyyMMddhhmm");
Timestamp stamp = new Timestamp(System.currentTimeMillis());
out.println(dberr);
out.println("insert into timesheet(IDNUM,TimeIn,TimeOut,HoursWorked) values (" + session.getAttribute("IDNum") + " , " + stamp + " , " + stamp + " ,0)");
%>please help.
The reason that i need the timestamps in there is that i am creating a time clock program for my school that they can put on a intranet so thier hourly employees can use instead of the current manual system they use.even better would be to use prepared statements and set the fields via Timestamp objects.
String sql = "insert into timesheet(IDNUM ,TimeIn ,TimeOut ,HoursWorked ) values (?,?,?,?)";
Statement stmt = cnxn.prepareStatement(sql);
int idNum = (Integer)session.getAttribute("IDNum").intValue();
Timestamp stamp = new Timestamp(System.currentTimeMillis());
stmt.setInt(1, idNum);
stmt.setTimeStamp(2, stamp);
stmt.setTimeStamp(3, stamp);
stmt.setInt(4, 0);
stmt.execute();It makes your code much more portable, as you don't have to worry about the database having a TO_DATE function with that syntax.
Cheers,
evnafets -
Making spool, convert it into PDF and send that PDf throgh EMAIl
Hi,
In my making ALV report. In that i want to make the spool and then convert it into the pdf and send mail to the recepient.
AtulHi,
please try the following code. It works for me.
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.
DATA:receiver TYPE somlreci1-receiver ,
p_file LIKE rlgrap-filename.
declarations for PDF convertion
DATA: path1 TYPE string ,
fullpath TYPE string.
DATA :textlines LIKE tline OCCURS 100 WITH HEADER LINE.
DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.
DATA it_lines LIKE tline OCCURS 100 WITH HEADER LINE.
DATA options LIKE itcpo.
DATA header LIKE thead.
DATA result LIKE itcpp.
DATA: bin_filesize TYPE i.
fullpath type string.
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.
DATA: filesize TYPE i,
convcount TYPE i,
cancel(1).
textlines-tdformat = '*'.
textlines-tdline = 'Hello Hao'.
APPEND textlines.
options-tdgetotf = 'X'.
options-tdnoprev = 'X'.
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX = ' '
ARCHIVE_PARAMS = ' '
DEVICE = 'PRINTER'
dialog = ' '
header = header
OPTIONS = options
IMPORTING
NEW_ARCHIVE_PARAMS =
RESULT = RESULT
tables
lines = textlines
otfdata = otf
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
UNKNOWN = 6
FORMAT = 7
TEXTFORMAT = 8
COMMUNICATION = 9
BAD_PAGEFORMAT_FOR_PRINT = 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.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = filesize
TABLES
otf = otf
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_bad_otf = 2.
fullpath = 'C:/foldername/test.pdf'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = fullpath
filetype = 'BIN'
APPEND = ' '
CODEPAGE = ' '
NO_BYTEORDER_MARK = ' '
IMPORTING
FILELENGTH = c
TABLES
data_tab = it_lines
FORMAT_TAB =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6.
*filename = fullpath.
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 = 'Tst'.
docdata-obj_descr = 'Testing'.
reclist-receiver = give the mail id.
reclist-rec_type = 'U'.
APPEND reclist.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = fullpath
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 = fullpath.
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
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT itab.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
objbin+len = itab(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND objbin.
CLEAR: objbin, len.
IF pos < 134.
objbin = itab+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND objbin.
ENDIF.
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
name = extension.
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 = name.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = name.
APPEND objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
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.
Keerthi -
Convert SmartForm into PDF(PDF should be password protected)
Hi Friends,
This is my requirement.
Need to convert SmartForm into PDF and this PDF should be send as an email with attachment and PDF should be password protected.
Can anyone plz help me???Dear Jena,
This is my code.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZBIN_SMARTFORM'
IMPORTING
fm_name = v_fm.
*& ASSIGNING VALUES TO FORM CONTROL STRUCTURE AND FORM COMPOSER
gs_ctrlop-getotf = 'X'.
gs_ctrlop-device = 'PRINTER'.
gs_ctrlop-preview = ' '.
gs_ctrlop-no_dialog = 'X'.
gs_outopt-tddest = 'LOCL'.
* GETTING THE OTF DATA
CALL FUNCTION v_fm
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = gs_ctrlop
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = gs_outopt
user_settings = ' '
wa_lfa1 = wa_lfa1
wa_t001 = wa_t001
wa_ekko = wa_ekko
wa_adrc = wa_adrc
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = gs_otfdata
* JOB_OUTPUT_OPTIONS =
TABLES
it_ekpo = it_ekpo
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.
* ASSIGNING THE OTFDATA TO OTF STRUCTURE TABLE
CLEAR gt_otf.
gt_otf[] = gs_otfdata-otfdata[].
* CONVERTING THE OTFDATA
CLEAR gt_lines.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
* PDF_PREVIEW = ' '
* USE_CASCADING = ' '
IMPORTING
bin_filesize = bin_file
* bin_file = bin_file
TABLES
otf = gt_otf
lines = gt_lines
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.
DATA l_file TYPE string .
CONCATENATE 'D:\usr\sap\CID\DVEBMGS00\work' '.PDF' INTO l_file.
OPEN DATASET l_file FOR OUTPUT IN BINARY MODE .
IF sy-subrc = 0 .
LOOP AT gt_lines INTO gs_lines .
TRANSFER gs_lines TO l_file .
ENDLOOP.
CLOSE DATASET l_file .
ELSE.
WRITE : / 'operating system could not open file' .
ENDIF.
* ASSIGNING THE DESCRIPTION OF THE OBJECT SENT IN MAIL
CLEAR gs_docdata.
gs_docdata-obj_name = gc_tst.
gs_docdata-obj_descr = gc_testing.
gs_docdata-obj_langu = sy-langu.
* ASSIGNING THE EMAIL-ID TO STRUCTURE OF API RECIPIENT LIST TABLE
CLEAR : gt_reclist,gs_reclist.
***IF INTERNAL MAIL-ID
* gs_reclist-receiver = sy-uname.
* gs_reclist-rec_type = 'B'.
***IF EXTERNAL MAIL-ID
gs_reclist-receiver = '[email protected]'.
gs_reclist-rec_type = 'U'.
APPEND gs_reclist TO gt_reclist.
* PASSING THE SAP SCRIPT LINES TO SAP OFFICE
CLEAR : gs_objbin,gs_lines.
LOOP AT gt_lines INTO gs_lines.
gv_pos = 255 - gv_len.
IF gv_pos > 134.
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_lines(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255.
APPEND gs_objbin TO gt_objbin.
CLEAR : gs_objbin,gv_len.
IF gv_pos < 134.
gs_objbin = gs_lines+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin.
ENDIF.
* FILLING THE DETAILS IN SAP OFFICE
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + strlen( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = 'ATTACHMENT'.
gs_objpack-obj_descr = 'TEST'.
APPEND gs_objpack TO gt_objpack.
ENDIF.
DATA: BEGIN OF command_list OCCURS 0.
INCLUDE STRUCTURE sxpgcolist.
DATA: END OF command_list .
DATA: BEGIN OF exec_protocol OCCURS 0.
INCLUDE STRUCTURE btcxpm.
DATA: END OF exec_protocol.
DATA: status LIKE btcxp3-exitstat,
commandname LIKE sxpgcolist-name VALUE 'ZB_TEST',
sel_no LIKE sy-tabix.
* GET LIST OF EXTERNAL COMMANDS
CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
EXPORTING
commandname = commandname
operatingsystem = sy-opsys
TABLES
command_list = command_list
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'SXPG_COMMAND_CHECK'
EXPORTING
commandname = command_list-name
operatingsystem = sy-opsys
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
x_error = 6
too_many_parameters = 7
parameter_expected = 8
illegal_command = 9
communication_failure = 10
system_failure = 11
OTHERS = 12.
CLEAR command_list.
REFRESH command_list.
DATA: v_dir_input TYPE sxpgcolist-parameters.
DATA: v_dir_input1 TYPE sxpgcolist-parameters.
command_list-name = 'ZB_TEST'.
command_list-opsystem = 'Windows NT'.
DATA : doc TYPE string.
DATA : pass TYPE string ,
name(40).
doc = 'invoice'.
pass = '123456'.
CONCATENATE 'cnd/c d:\pdf\encryptpdf.exe' doc'.PDF' INTO name.
CONCATENATE 'cmd /c d:\pdf\encryptpdf.exe' '-i' name '-o ' name '-u' pass INTO v_dir_input SEPARATED BY space .
READ TABLE command_list INDEX sel_no.
CONCATENATE command_list-opcommand v_dir_input INTO command_list-opcommand SEPARATED BY space.
* CHECK AUTHORIZATION
command_list-addpar = 'X'.
APPEND command_list.
CONSTANTS: c_extcom TYPE sxpgcolist-name VALUE 'ZB_TEST',
c_oper TYPE syopsys VALUE 'Windows NT'.
DATA: t_result TYPE STANDARD TABLE OF btcxpm.
v_dir_input = command_list-opcommand.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = c_extcom
additional_parameters = v_dir_input
operatingsystem = c_oper
TABLES
exec_protocol = t_result
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
OPEN DATASET l_file FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
READ DATASET l_file INTO itab_attach.
CLOSE DATASET l_file.
ENDIF.
CALL METHOD cl_bcs_convert=>xstring_to_solix
EXPORTING
iv_xstring = itab_attach
RECEIVING
et_solix = t_attachment.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gs_docdata
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = gt_objpack
* OBJECT_HEADER =
CONTENTS_BIN = gt_objbin
* CONTENTS_TXT =
CONTENTS_HEX = t_attachment
* OBJECT_PARA =
* OBJECT_PARB =
receivers = gt_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 sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE 'SENT SUCCESSFULLY'.
ENDIF.
SUBMIT rsconn01 WITH mode EQ 'INT' AND RETURN.
The mail is sent to inbox successfully,but when am opening the attachment am getting the below error as,
---> There was an error while opening this file.The file is damaged and couldnt be repaired.
Maybe you are looking for
-
Basic feather does not carry to PDF in CS4
Using InDesign CS4 6.0.5 on Mac OS X 10.4.11 A client supplied a file that has a single piece of art going across a 2-page spread. The art frame has "basic feather" applied to soften the edges. When we create a PDF of this spread, the feather shows u
-
Headphone jack broken, using dock connector instead?
So after dropping my iPod the other day the headphone jack is acting a little funky, I have to twist and fiddle with the headphones a little bit to get the sound to play in both ears nicely (It's not the headphones as I've tried with several pairs).
-
DBMS_LDAP SSL Authentication
Hello everyone. I am using the DBMS_LDAP package to connect to a Windows 2000 Server running Active Directory as the LDAP directory. I have set up the Oracle Wallet manager, and I can successfully connect to the LDAP directory...however, the code whi
-
Spread table on tab canvases doesn't work
Hi, I've got a form with a master/details block. The detail blocks are on tab canvases and are multi-records. I'd like to have spread tables, but it doesn't work. Is it a normal behaviour ? I'm working with Designer 6.0.3.5.0 Thanks for your help Dom
-
I have an invoice report that has billing categories and under each billing category there are one or more bliing category lines. I want to calculate the total for each billing category e.g. BILLING CATEGORY 1 Billing Category 1 0.00 Billing Category