Converting string into inputstream and outputstream Jsch (ssh connection)
hi,
I'm not really sure if this is the place where i should ask this, but if it is so then tell me!
So my problem is that everything works just fine with input output streams like in this code, but i need to change this input stream into string messadge(Which would work!!)
The main problem is not that i can't change string to inputstream, but that when i use inputstream every commands works, and when i try to do the same with sting>inputstream this doesn't work...
unfortunatelly newgrp server; or newgrp doesn't rerally work just frezzes :/
anyway i solved the initial problem, because Jsch have two (probably more methods of sending info to unix server, but because there is no documentation htere no way to know :D)
methods of sending info to server : exec and shell , the exec sends one command and only works with commands like date;ls... now the shell can easily send any type of command including newgrp server1, and everything works :)
so we connect to the server(passw,user,host) then excecute commands, this code works perfectle but the commented code// doesn't work :
JSch jsch=new JSch();
String host=null;
String user="me1234";
host="super.server.co.uk";
String passw="12345";
Session session=jsch.getSession(user, host, 22);
session.setPassword(passw);
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
Channel channel=session.openChannel("shell"); //the power of shell, if i use exec doesn't excecute newgrp...
//String command = "newgrp xxxx;"; //this doesn't work ...
//InputStream is = new ByteArrayInputStream(command.getBytes("UTF-8"));
//channel.setInputStream(is);
//then somehow printout the response from server...
channel.setInputStream(System.in); // well instead of this I'd prefer channel.send(command);
channel.setOutputStream(System.out);
channel.connect();
Edited by: 842778 on 14-Mar-2011 01:42
You seem to be leaving out the newlines.
Similar Messages
-
Convert string into XML inside BPEL
Hello ,
How to convert string into xml format ? And make element and define attribute inside it ??There are several problems with your input:
1. Your xml is not well-formed because the attribute values should be enclosed withing double " quotes and not single ' quotes;
2. You use a prefix (sml) for the folowing part but you dont define the namespace:
<ids>
<VID ID="new"/>
<data>
<*sml:*attr name="std">
<sml:value></sml:value>
</sml:attr>
<sml:attr name="xde">
<sml:value></sml:value>
</sml:attr>
</data>
</ids>
Complete message should be:
<ids xmlns:sml="somenamespace">
<VID ID="new"/>
<data>
<sml:attr name="std">
<sml:value></sml:value>
</sml:attr>
<sml:attr name="xde">
<sml:value></sml:value>
</sml:attr>
</data>
</ids>
3. Do you assign this expression to a variable that is based on the schema of your message you want to parse
Regards,
Melvin
* TIP Answer the question as helpful or correct if it helps you , so that someone else will be knowing that this solution helped you or worked for you and also it gives points to the person who answers the question. * -
Are inputstream and outputstream independent of eachother ?
<b><u>Code snippet 1) </u></b><br>
ByteArrayInputStream inputPDFStream = (ByteArrayInputStream) <SOME INPUT STREAM OBJECT>;<br>
byte [] bArray = new byte [inputPDFStream.available()];<br>
//Reading into byte array.<br>
inputPDFStream.read( bArray );<br>
//Dumping byte array contents onto file system.<br>
File file = new File("//exchange//EPP//template//test_PDF_OnPortal.pdf");<br>
FileOutputStream os = new FileOutputStream(file);<br>
os.write(bArray);<br>
os.flush();<br>
os.close();<br>
//Closing input stream, after all operations have been performed.<br>
<b>inputPDFStream.close();</b><br>
<br>
<b><u>Code snippet 2)</u></b><br>
ByteArrayInputStream inputPDFStream = (ByteArrayInputStream)pdfObject.createPDF();<br>
byte [] bArray = new byte [inputPDFStream.available()];<br>
int iBytesRead = inputPDFStream.read( bArray );<br>
/*************** change starts here ************/<br>
//Closing input stream immediately after it has been read from.<br>
<b>inputPDFStream.close();</b><br>
/*************** change ends here ************/<br>
File file = new File("//exchange//EPP//template//test_PDF_OnPortal.pdf");<br>
FileOutputStream os = new FileOutputStream(file);<br>
os.write(bArray);<br>
os.flush();<br>
os.close();<br>
/*************** change starts here ************/<br>
// commented this line of code and shifted it above.<br>
<b>//inputPDFStream.close(); </b><br>
/*************** change ends here ************/<br>
<br><br>
<b><u>Questions -</u></b> <br>
<br>
1) Are inputstream and outputstream objects totally independent of eachother ?<br>
2) Will the change in the position of the "inputstream.close()" method as shown above, affect the writing of the file to the file system ?
In other words, will the outcome of an "FileOutputStream.write(), flush() or close()" depend on when the inputstream object is closed as seen in code snippet (2) ?<br>
3) Assuming that the output buffer is flushed, will any data that you try to write using the OutputStream.write() method, be written to the outputstream target (whether a file, or response object), irrespective of whether the inputstream is active at that point of time ??<br>
<br>
Thanks,<br>
Navneet.<br>
Changes made by -Hey kaj...Do you have any idea about the "not normal"
situations in which case the input and output streams
might influence eachother ? ;)Those cases are when both streams comes from a resource which closes both streams when one of them is closed. It's very rare to see, but I've seen some socket implementations which does that.
Kaj -
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 -
Converting String into SecretKey
Hi there,,
I'm having probs with decrypting my encrytped data.In fact I have encrypted the data on the client side and have sent the encrypted data and the key to the server database.On the server side I wanna retrieve the key and decrypt the encrypted data with the help of it but I'm finding no way to retrieve it as a key,,moreover while trying to cast the retreived string (having converted it to an Object),,I get the ClassCastException,,
SecretKey key=(SecretKey) myRetrievedKeyObject;
Hope somebody can help me out with this,,,sample code highly welcomed....
thanks...Here's the class I'm using for encryption and decryption..
import java.security.*;
import java.io.*;
import java.util.StringTokenizer;
import javax.crypto.*;
import sun.misc.*;
import java.sql.*;
public class DesEncrypter {
Cipher ecipher;
Cipher dcipher;
DesEncrypter(SecretKey key) {
try {
ecipher = Cipher.getInstance("DES");
dcipher = Cipher.getInstance("DES");
ecipher.init(Cipher.ENCRYPT_MODE, key);
dcipher.init(Cipher.DECRYPT_MODE, key);
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
public String encrypt(String str) {
try {
// Encode the string into bytes using utf-8
byte[] utf8 = str.getBytes("UTF8");
// Encrypt
byte[] enc = ecipher.doFinal(utf8);
// Encode bytes to base64 to get a string
return new sun.misc.BASE64Encoder().encode(enc);
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
} catch (java.io.IOException e) {
return null;
public String decrypt(String str) {
try {
// Decode base64 to get bytes
byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
// Decrypt
byte[] utf8 = dcipher.doFinal(dec);
// Decode using utf-8
return new String(utf8, "UTF8");
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
} catch (java.io.IOException e) {
return null;
hope you can guide me... -
Convert String to Date and Format the Date Expression in SSRS
Hi,
I have a parameter used to select a month and year string that looks like: jun-2013
I can convert it to a date, but what I want to do is, when a user selects a particular month-year (let's say "jun-2013")
I populate one text box with the date the user selected , and (the challenge Im having is) I want to populate a text box next to the first text box with the month-year 2 months ahead. So if the user selects
jun-2013 textbox A will show jun-2013
and textbox B will show aug-2013..
I have tried:
=Format(Format(CDate(Parameters!month.Value ),
"MM-YYYY" )+ 2 ) -- But this gives an error
This returns the month in number format like "8" for august...
=Format(Format(CDate(Parameters!month.Value ),
"MM" )+ 2 )
What is the proper syntax to give me the result in this format = "aug-2013" ???
Thanks in advance.
MC
M CollierYou can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
In your case, the code would be something like:
var sDate = "2013-01-10";
// Convert string to date
var oDate = util.scand("yyyy-mm-dd", sDate);
// Convert date to new string
var sDate2 = util.printd("mm/dd/yyyy", oDate);
// Set a field value
getField("date2").value = sDate2;
The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started. -
I Need help in converting a pdf into word. I've purchased it a few months ago and now for the first time I tried to use word and I can't it only gives me the option to convert it into a pdf when it is already a pdf! Urgent help please
Not sure what you mean by "tried to use Word". ExportPDF doesn't change what Word can do. Can you explain what you try and what happens in more detail?
-
How to convert XML into idocs and post in ECC using PI
Hello All,
I want to configure the scenario like this MDM->PI->ECC. Using FTP I am getting able to fetch the xml file from MDM Server Ready folder. Now, I need to convert this XML file into Idocs and post it in ECC. Can anyone provide me step by step configuration in PI to achieve this. I have configured communication channel with adapter type Idoc in Itegration Builder. But, I am not sure where it will do the conversion of XML into Idoc and how do post it to ECC. I am working first time on PI 7.1. I have worked on XI 3.0 in 2006-2007. Any help to configure this step by step shall be appreciated.
Thanks & Regards,
HemalIn you have the XML from MDM you have to use the mapping provided by the funtionals in the Funtional specification documents. once you did it you must configure the Receiver IDoc Adapter. and later dont fonget to configure properly the ReceiverAgreement.
as you receive the docuement from MDM via FTP, thats not a SAP System that means that you have to define PI as the sender of the IDoc,otherwise you will have the Error "Unable to convert the sender service to an ALE logical system"
to do that in the receiver Agreement>Header Mapping>Sender System-->Select PI server.
Take in mind to send IDocs to any SAP System, the system that send it must be a SAP system too. thats why you configure it
http://help.sap.com/saphelp_nw04/helpdata/en/5d/112d20f6ce6c46ba66afb98d278fbd/frameset.htm
Another thing is you have configure the ALE distribution Model.
se this:
http://wiki.sdn.sap.com/wiki/display/XI/FileToIDOC
/people/michal.krawczyk2/blog/2005/03/29/xi-error--unable-to-convert-the-sender-service-to-an-ale-logical-system
/people/venugopalarao.immadisetty/blog/2007/01/24/troubleshooting-file-to-idoc-scenario-in-xi
Let us know
Rodrigo P-. -
How to convert string into date
Hi all,
I m new to JDeveloper
I m taking the date as a string then passing it as a string in the method.
I want to convert tht string into the date of format (DD-MON-YYYY) or any other format
require yur assistance in this job.
THANKXX in advance
ankitIs this what you are looking for:
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MMMMM-YYYY");
java.util.Date date1 = null;
try
date1 = formatter.parse("Thu Jun 3 09:09:30 2004");
catch(Exception e)
e.printStackTrace();
System.out.println("Date1 in millis : " + date1.getTime());
System.out.println("Date1 in string : " + date1);
java.util.Date date2 = new java.util.Date(date1.getTime());
System.out.println("Date2 in string : " + date2);or look at http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html for more options -
"converting strings into integers in a array"
I'm really left scrating my head trying to figure this out.
What I have right now is this
public class NameManager
private names[] collection; // collection of names
private int count;
public NameManager() // Creating an array which for now is empty
collection = new names[1000];
count = 0;
String [] collection = {"boston", "Springfield", "New Haven",
"New York", "Albany"};
Its a namemanager for my road trip project which will be sort of like mapquest. What it does, or it's supposed to do is I have a array of names of cities, that represented as strings, in a array called, collection. What my proffeser wants me to do is turn the strings into integers, so in this elements in the array can be referenced .
It's probably so easy that I'll want to kick myself when I find out how to do it , but for whatever reason , all the information have found on the internet seems to go right over
If any body can give some idea of how to turn the string you see above into a set of intege s I would be so grateful.turn the string into the index in the array
i.e.
boston => 0
springfield => 1
New Haven => 2
New York => 3
Albany => 4I should've mention this before but I need the names to go along with the numbers.
This is the directions from my proffesser, I know it's not the easiest to understand
but hopefully It will give you a better idea of what I'm talking about.
A name manager. This object turns strings into numbers. Every time a name is added to the name manager, it is checked to see if it has already been seen. If so, return the number previously assigned to the name. If not, increment the "number of known names" and return this number as well as remember the string for future reference. You can assume that there will be no more than 1000 names in the manager. Each name is a string.
A city. A city is a simple object: the city has a name and a number (at present).
I got most of this part done it just strings integers part that's getting me. -
How to Convert frames into minutes and seconds
Hi,
does anyone know how to convert frames into time (minutes and
seconds). I need the users to view the swf with current time being
played and over time. I have 2152 frames in total and I want that
to be converted to time. Can anyone help me on this. I would really
appreciate it. It is very urgent!!!!
ThanksTime Indicator,
> does anyone know how to convert frames into time
(minutes
> and seconds).
That depends entirely on the framerate of the movie. At the
default
12fps, 12 frames would be one second; 24 frames would be two.
At 24fps, 24
frames would be one second.
> I need the users to view the swf with current time being
played
> and over time. I have 2152 frames in total and I want
that to be
> converted to time. Can anyone help me on this. I would
really
> appreciate it. It is very urgent!!!!
Judging by your four exclamation points, I'd say it's
definitely urgent!
Well, again, if you're at 12fps, 2152 frames would take 179
seconds, or 2
minutes and 59 seconds. I arrived at that number by dividing
2152 by 12.
Keep in mind, though, framerate is actually more of a
guideline than an
exact figure. Framerate determines the rate at which Flash
will *try* to
display content. On an especially slow computer, the Flash
Player may not
be able to keep up, and the same number of frames might
actually take more
time.
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design." -
UCCX: unable to convert string into a number
Hi all,
I used the Get Digit String to pull a 4 digital numbers (stored as variable sYear) from a caller, this number is obviously stored as a string. Then i used 'set iYear=sYear' to conver this string to an integer.
I debuged the script, when I entered number of year without following #, it worked fine. If I entered number of year and followed by #, i got the message 'unable to conver string into a number'. Can someone help me with that?
Thanks a lot.Hi Reena,
The UCCX version is 10.5.1.
I found the problem. It works after i changed input length to 5. 'The terminating key overrides the Maximum Input Length to terminate input'.
Thanks. -
[RS232] how to use InputStream and OutputStream
hi
i am using javax.comm
i get input and outputstream
try {
out = serialPort.getOutputStream();
in =serialPort.getInputStream();
} catch (IOException e) {
}but i can use only write(bytes[]) and read(bytes[])
i would use println and readln .. how can i do that?
thanks in advance, nik@OP: Maybe this thread is of use to you:
http://forum.java.sun.com/thread.jspa?forumID=31&threadID=698876 -
CONVERTING SMARTFORM INTO PDF AND PRINTING DIRECTLY
Hai guys,
I got a problem.
First the Smartform I created doesnt show all TABLE LINES(the rows coloumns)...
so I have converted the SMART FORM to ADOBE FORM PROGRAMITICALY ...
now in order to PRINT ..
one has to first SAVE the FORM(adobe form) onto desktop(or whereever) and give it to PRINT...
unfortunately my CLIENT doeasnt like the EXTRA STEP..
so i best i can SAVE the file to a hardcoded location and
OPEN it ..
But then CAN I
a)PRINT DIRECTLY without SAVING??
b)ISSUE PRINT PROGRAMITICALY
c)I learnt that a SMARTFORM can be GENERATED INTO PDF only at RUNNTIME(from SMARTFORMS>UTILITIES etc)..i briefly tried that..can I use that to GET THE PDF to PRINT when one gives PRINT from SPOOL REQUEST(sp01)
hoping to give some quick pointsHi,
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
or
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
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: w_recsize TYPE i.
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.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
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
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
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 p_error
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_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
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 = ld_email.
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_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_code.
ENDLOOP.
ENDFORM.
Regards,
Kumar -
Convert string into java.sql.Date
Hi,
I want to convert a date in string form into java.sql.Date to persist into the database column with Date as its datatype in Oracle. I'm trying as follows:
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class DateTest
public static void main(String[] args)
String strDate = "2002-07-16 14:45:01";
System.out.println("strDate = "+strDate);
Date aDate = null;
try
if(strDate != null && !strDate.trim().equals(""))
SimpleDateFormat aSDF = new SimpleDateFormat();
aSDF.applyPattern("yyyy-MM-dd hh:mm:ss");
java.util.Date utilDate = aSDF.parse(strDate);
System.out.println("utildate = "+utilDate);
aDate = new Date(utilDate.getTime());
aDate.setTime(utilDate.getTime());
System.out.println("aDate = "+aDate);
catch (ParseException e)
System.out.println("Unable to parse the date - "+strDate);
catch (Exception ex)
ex.printStackTrace();
System.out.println("Caught Exception :"+ex.getMessage());
It gives the output as :
strDate = 2002-07-16 14:45:01
utildate = Tue Jul 16 14:45:01 IST 2002
aDate = 2002-07-16
If I put this value into the database table, I can see only the date. Time part is missing. Is this the problem with java.sql.Date or Oracle datatype Date? Please help me asap.
Thanks in advance.
Regards,
Rajapriya.R.If I put this value into the database table, I can
see only the date. Time part is missing. Is this the
problem with java.sql.Date or Oracle datatype Date?This is not a problem, this is the defined behaviour of the Date type. RTFAPI and have a look at Timestamp, while you're at it.
Maybe you are looking for
-
Error uninstalling, and weird disk utility message?
So I installed a keylogging app call type agent and it came with an uninstall terminal command, which I just tried to run. Unfortunately, terminal won't let me run the command, giving me this prompt: /Library/StartupItems/Type\ Agent/uninst ; exit; M
-
Problems Reading gas meter flow rate ni 9402 counter
2015/07/13 Can any one help with this? I have been trying to overcome the problem of the delay were a value is retained at the output of the counter for a period after the gas meter has stopped. This is causing me a problem as I am feeding this value
-
Work protect - admin settings in Portal?
Hi, Is there any config for switching on work protect mode? I have a 2 portals with ESS ERP2004 that behave differently. eg under Personal Data > Address Data if I make a change and hit exit Portal 1 I get a pop up box asking if I want to continue a
-
TS1363 why the i tunes can not show in my ipod?
please kindly help me because i can not connect the itunes to my ipod?
-
Hello, is it possible to configure the RETRY modus of XI for a single Adapter, or connection, e.g the HTTP adapter? I know there are some configuration parameters for the XI system. Is it possible to configure the how XI restarts the messages in RETR