Reading attachment: diposition NULL
Hi,
I am trying to read attachment using javamail but when I use getDisposition function, I always get NULL disposition value,even for attachment.Please help me.This is the code I am using.
import java.io.*;
import javax.swing.*;
import java.util.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.sql.*;
public class try_attachment{
public static void main(String args[])throws Exception
String host = "host";
String username = "username";
String password = "password";
Properties Prop = new Properties();
Session session = Session.getInstance(Prop,null);
Store store = session.getStore("imap");
store.connect(host,username,password);
// open Inbox
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
// get Directory
Message msg[] = folder.getMessages();
for (int i=0;i<msg.length;i++)
Object content = msg.getContent();
if(content instanceof Multipart)
handleMultipart(( Multipart)content);
else
handlePart(msg[i]);
folder.close(false);
store.close();
public static void handleMultipart( Multipart multipart)
throws MessagingException, IOException
for(int i=0;i<multipart.getCount();i++)
handlePart(multipart.getBodyPart(i));
public static void handlePart(Part part)throws MessagingException,IOException
String disposition = part.getDisposition();
String contentType = part.getContentType();
// trying to read disposition value
System.out.println("Hello "+ disposition);
try{ if (disposition == null)
System.out.println("Null: " +contentType);
//checkif plain
// if ((contentType.length()>=10)&& (contentType.toLowerCase().substring(0,10).equals("text/plain")))
// part.writeTo(System.out);
else if(disposition.equalsIgnoreCase(Part.ATTACHMENT))
System.out.println("Attachment:" + part.getFileName() + ":" + contentType);
saveFile(part.getFileName(),part.getInputStream());
else if(disposition.equalsIgnoreCase(Part.INLINE))
System.out.println("Inline :"+ part.getFileName()+":" + contentType);
saveFile(part.getFileName(),part.getInputStream());
else
System.out.println("Other");
catch(Exception e)
{ System.out.println(e);}
public static void saveFile(String filename, InputStream input) throws IOException
if (filename == null)
filename = File.createTempFile("testmail",".out").getName();
//do not overwrite
File file = new File(filename);
for(int i=0;file.exists();i++)
file = new File(filename+i);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
BufferedInputStream bis = new BufferedInputStream(input);
int aByte;
while ((aByte = bis.read())!= -1)
bos.write(aByte);
bos.flush();
bos.close();
bis.close();
Hello Mark,
1. My Soap Sender Adapter, I checked the Keep Attachment option
2. I am getting the WSDL file from the SOAP Sender Agreement.. it is like http(s)://host:port/XISOAPAdapter/MessageServlet?channel=p:s:c? as you said.
I used the user-defined function, it works when <inc:Include href="cid:test.jpg" xmlns:inc="http://www.w3.org/2004/08/xop/include" /> is deleted in the message.
If the coming message includes <inc:Include href="cid:test.jpg" xmlns:inc="http://www.w3.org/2004/08/xop/include" />,
the <null> error occurs.
Thanx for your reply..
Similar Messages
-
Reading attachment in SOAP message with ABAP mapping
I am searching an ABAP code to read attachment in sender SOAP message..
I am using PI 7.3, I can read by java mapping but I get another error after reading the attachment.. So I try to abap mapping..
That's it..
Thanx ..Hello Mark,
1. My Soap Sender Adapter, I checked the Keep Attachment option
2. I am getting the WSDL file from the SOAP Sender Agreement.. it is like http(s)://host:port/XISOAPAdapter/MessageServlet?channel=p:s:c? as you said.
I used the user-defined function, it works when <inc:Include href="cid:test.jpg" xmlns:inc="http://www.w3.org/2004/08/xop/include" /> is deleted in the message.
If the coming message includes <inc:Include href="cid:test.jpg" xmlns:inc="http://www.w3.org/2004/08/xop/include" />,
the <null> error occurs.
Thanx for your reply.. -
"We had difficulty reading this feed. null" Atom feeds no longer work?
Hi - our Audioboo feeds used to work fine when submitting as a podcast (eg http://audioboo.fm/users/4705/boos.atom). It seems like they stopped working recently - maybe in the past couple of days - and just report "We had difficulty reading this feed. null" when you try to submit them.
I'm beginning to suspect that the use of atom rather than rss is the cause. Can anyone confirm?
-JonathanThis feed can be subscribed to manually in iTunes (from the 'Advanced' menu) - actually I'm rather surprised it works because it isn't a valid podcast feed (though it is a valid Atom feed).
It has the iTunes 'declaration' and some itunes tags, although the former is contained in a 'feed' tag whereas it should be a 'rss' tag: there is no 'channel' tag enclosing the podcast data, no 'item' tags enclosing each episode, and no 'enclosure' tags within each episode containing the media URL. I'm not surprised you can't submit it as a podcast, and as I say it's a but surprising that the iTunes application recognizes it.
In order to get it accepted in the iTunes Store you need to create a feed in the correct format: this page contains a sample basic feed so you can see how it should look:
http://www.wilmut.org.uk/pc
If the feed contains the valid iTunes format it can also contain atom tags, which iTunes will ignore. -
How to Read Attached Document In oracle apps.
Hi All,
how to read attached document in Oracle apps.
Select * from fnd_attached_documents.
Regards,
Mohan ReddyHi Husseein,
how to read pdf file in blob data type column
i have tried below query but in this part utl_file.fopen asking directory name i don't have directory name.
could you give any another solution.
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32767);
l_amount BINARY_INTEGER := 32767;
l_pos NUMBER := 1;
l_blob BLOB;
l_blob_len NUMBER;
BEGIN
SELECT FILE_DATA
INTO l_blob
FROM fnd_lobs
where file_name = 'est-1.pdf' and FILE_ID = 332810;
l_blob_len := DBMS_LOB.getlength(l_blob);
-- Open the destination file.
l_file := UTL_FILE.fopen('IRB','STD_FlipBook_Religion2013.doc','wb',18306); --(Here I don't have Directory name)
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer, TRUE);
l_pos := l_pos + l_amount;
-- Close the file.
UTL_FILE.fclose(l_file);
END;
Regards,
Mohan Reddy -
Read attachment content in Mapping
Hi,
In PI 7.1 there is one option to read attachment content inside mapping using the api: "com.sap.aii.mapping.api".
To do that in operation mapping we have to check the option "ReadAttachments", to get the attachments in addition to the payload. If I check the Readattachments check box, message goes into the queue and the queue status is running.
Please help me to read the attachment content in mapping.
Thanks & Regards,
YugaHi,
That issue has been solved,the problem is with the syntax.
Now I was able to get the attachment details,but i was not able to read the content of the attachment.
Here is my code:
String Content = "";
String AttachmentID ="";
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
if(inputAttachments.areAttachmentsAvailable())
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
int attachmentCount = arrayObj.length;
for(int i =0;i<attachmentCount;i++)
AttachmentID =(String) arrayObj<i>;
Attachment attachments =inputAttachments.getAttachment(AttachmentID);
Content = Content + attachments.getContent().toString();
return Content;
My requirement is to read all the attachment's.Attachment has XML content, so after reading I need to parse the xml content inside graphical mapping itself is there is any option to do like this.
Thanks & Regards,
Yuga -
Hii All..
I have one Zprog with attachment option.
to display attachment in report i m using class CL_GOS_MANAGER and method START_SERVICE_DIRECT.
my requirment is if attachment file exists change icon .
so how to read attachment file exists or not?
Thanks in Advance
Regards
VshalYou have to use the same method CL_GOS_MANAGER=>START_SERVICE_DIRECT, informing parameter IP_CHECK_AVAILABLE:
call method lr_manager->start_service_direct
EXPORTING
IP_SERVICE = 'VIEW_ATTA'
IP_CHECK_AVAILABLE = 'X'
IMPORTING
EP_AVAILABLE = lv_available.
This way the service will not be launched and you will know whether there are attachemnts or not. -
IMAC won't boot with USB card reader attached
My quite new 24" iMAC won't boot if I have a USB card reader attached:
I get to the white screen with the apple logo, but it gets stuck there and the little spinning gear below the apple logo never appears (I've waited several minutes). (In all my test cases, there is no card in the card reader.)
I've tried two different card readers with the same results ("iDOTconnect" brand and a brand new Apacer unit, both are USB2.0 multi-format card readers).
The 1st one I tried via a USB hub, the second one I tried via a new hub and also directly connected to the mac (both of those hubs work fine).
Anyone have any ideas?
Regards,
Strathglass
Message was edited by: strathglassHello strathglass
The same thing can also happen with other connected devices such as external HD's and iPods, the Startup Manager is lost and searching for a boot volume.
1. You may be able to fix it by going to: *System Preference / Startup Disk* and select the *Mac OS X 10.5.5 on Macintosh HD* then *Click the lock to prevent further changes.*
2. Leave those devices that cause boot issues disconnected until the iMac is up and running!
3. Only sleep the iMac, and be sure to disconnect those devices be for shutting down or updates that require a restart!
As a habit, I have always ejected and disconnected all mounted USB devices (flash driver, iPods, cameras, card reader, etc.) from my hub be for sleeping, restarting or shutting down...
Dennis -
Can't read attached files to older emails in Outlook 2010
Hello,
I have Outlook 2010 connected with MS Exchange.
I can’t read attached files to older emails than 3 months. In attached elements there are only small files and I’m not able to open them (size in Bytes!) - double click doesn't work. I've tried different solutions:
1. https://social.technet.microsoft.com/Forums/en-US/dd2869cb-5e53-4852-b0bb-15de6653db0c/dont-see-attachments-in-old-emails-on-outlook-2013?forum=outlook
2. https://social.technet.microsoft.com/Forums/office/en-US/cbd420f1-ec7f-44ae-8f78-c7613e2eabb6/unable-to-retrieve-attach-document-for-older-emails-in-outlook-2010?forum=outlook
3. Clear cache in Advanced Settings of Forms and clear C:\Users\%username%\AppData\Local\Microsoft\FORMS
None of them works
Thanks in advanceHi,
Can you read the attachments if we logon in OWA? If attachments can be read in OWA, we may try to delete the original OST file and restart Outlook to sync a new one to see the result. If still no luck, we can create a new mail profile in Control Panel to
check the result. See:
http://support.microsoft.com/kb/829918
If same issue continues in OWA, you may need to recover the data from the backup you create before.
Regards,
Steve Fan
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
Problem reading attached PDF files
<!--[if gte mso 9]><xml>
</xml><![endif]--><!--[if gte mso 9]><xml>
Normal
0
false
false
false
MicrosoftInternetExplorer4
</xml><![endif]--><!--[if gte mso 9]><xml>
</xml><![endif]--><!--[if !mso]>
<object
classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui>
</object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
Hello.
At my work, we use JavaMail (version 1.4.1) in server
programs, processing mails with attached files from customers. Mostly it is
TIFF images, but it can also be PDF
files, and the attached files are extracted and saved for further processing.
Sometimes, we have a problem, reading attached PDF
files. The files get saved, but is of size 0 bytes. If I forward it, however,
using an Outlook client, the forwarded item can be read by our JavaMail program, and files saved OK.
I have tried to forward it using JavaMail, but I cannot
compose the mail parts, that fails, however - of the same reasons: I cannot
read the them in:-)
It looks like it's when the mail is send from a Mac.
Anyway, the part to read is of content type "APPLICATION/APPLEFILE" whereas when it's forwarded, it's content
type is "APPLICATION/OCTET-STREAM"
The way, I read the part, is to check if the part is an
instance of an InputStream, and then saving into a byte array, like this:
h5. Object
obj = part.getContent();
if (obj instanceof
InputStream) {
InputStream
inStream = part.getInputStream();
byte[]
buffer = new byte[BUFFER_SIZE];
int
bytesRead;
BufferedOutputStream
outBufStream = new BufferedOutputStream(new FileOutputStream(attFileName));
while
((bytesRead = inStream.read(buffer)) != -1)
outBufStream.write(buffer,
0, bytesRead);
inStream.close();
h5. outBufStream.close();
Problem
is that .read() method always returns -1 when content type Is APPLICATION/APPLEFILE,
so a file of 0 bytes are created.
Interesting is perhaps, that debugging shows me that the
part instance of the InputStream actually is a
com.sun.mail.util.BASE64DecoderStream when it fails, and a
com.sun.mail.util.QPDecoderStream
when it works OK.
So I have this idea, that I's a certain type of decoder
stream we're missing? We use Java 1.6.0 update 10 and JavaMail 1.4.1. and since
we use java 1.6 we use the JAF framework from that one, I guess?
Hope you guys can help?
Thanks in advance, Per Jensen
[email protected]We have two (MS Exchange) servers (from trace log):
Microsoft Exchange IMAP4rev1-server version 5.5.2650.23
Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7226.0
- the first one is the one, we're using here, but I have tried on the other, newer version too, and it didn't help either.
But I've found out a couple of interesting things:
1: Debugging shows me, that the part instance of the InputStream actually is a com.sun.mail.util.BASE64DecoderStream when it fails, and if I forward the mail via Outlook as described earlier, and it can be read OK, the part is a com.sun.mail.util.QPDecoderStream instance.
2: I can save the WHOLE message to a file, using message.getInputStream(), and when I opens the file I can find the individual attachments - as well as the bodytext, if any - as they are separated with the disposition, mimetype and filename fields, showed as plain text. And the attachments are showed as blocks of characters; I guess it's the ascii character representation of the bytes. Here's a snippet, note the first two sentences. They seemes to be added, somehow, when I dump the message to file(?):
<START OF DUMPED FILE>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C9A8A2.19479FE4
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
(The body text here)
------_=_NextPart_000_01C9A8A2.19479FE4
Content-Type: application/applefile;
name="first_attachment.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="first_attachment.pdf"
AAUWAAACAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAASgAAABAAAAAJAAAAWgAAACAAAAADAAAA
egAAABAAAAABAAAAigAAI6IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA1NzE2NSBCTkhhdWcucGRmJVBERi0xLjMKJbe+raoKMSAwIG9iago8PAovVHlwZSAv
Q2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9L
aWRzIFsgNCAwIFIgXQovQ291bnQgMQo+PgplbmRvYmoKMyAwIG9iago8PAovUHJvZHVjZXIgKEhh
...(and so on)
DMgMDAwMDAgbg0KMDAwMDAwNTM1NSAwMDAwMCBuDQowMDAwMDA2NTA5IDAwMDAwIG4NCjAwMDAw
MDc2NjUgMDAwMDAgbg0KdHJhaWxlcgo8PAovUm9vdCAxIDAgUgovSW5mbyAzIDAgUgovU2l6ZSAx
MQo+PgpzdGFydHhyZWYKODgyNAolJUVPRgo=
------_=_NextPart_000_01C9A8A2.19479FE4
Content-Type: application/applefile;
name="second_attachment.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="second_attachment.pdf"
AAUWAAACAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAASgAAABAAAAAJAAAAWgAAACAAAAADAAAA
egAAABAAAAABAAAAigAAI9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA1NzE4MSBCTkhhdWcucGRmJVBERi0xLjMKJbe+raoKMSAwIG9iago8PAovVHlwZSAv
Q2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9L
...(and so on)
<END OF DUMPED FILE>I understand that it's base64 encoded and must be decoded, and I have tried to copy/paste the blocks separately, run them through the com.sun.mail.util.BASE64DecoderStream, and saving them as PDF files, which works fine(!).
As the solution seems to be painfull: Parse the mail to find where the attachments starts and stops and saving them as files, I hope you guys can send me on the right track?
PS: The trace log when dumping the file shows everything OK, I think. Here's a bit of the log at the end of dumping the message:
(...)MTUgMDAwMDAgbg0KMDAwMDAwNTg2NyAwMDAwMCBuDQowMDAwMDA3MDIxIDAwMDAwIG4NCjAwMDAw
MDgxNzcgMDAwMDAgbg0KdHJhaWxlcgo8PAovUm9vdCAxIDAgUgovSW5mbyAzIDAgUgovU2l6ZSAx
MQo+PgpzdGFydHhyZWYKOTMzNgolJUVPRgo=
------_=_NextPart_000_01C9A8A2.19479FE4--
A10 OK FETCH fuldført.
A11 FETCH 1 (BODY[TEXT]<40336.16384>)
* 1 FETCH (BODY[TEXT]<40336> {0}
20/03-09 15:18:21,445 3 Done, writing bytes to ByteArrayOutputStream. Size: 40336 bytes (..common.mail.MailUtil.dumpMessageToFile.dumpMessageToFile)
20/03-09 15:18:21,445 3 Done, writing ByteArrayOutputStream to file. (..common.mail.MailUtil.dumpMessageToFile.dumpMessageToFile)
A11 OK FETCH fuldført. -
Hello Java Forum,
I read in a char szText[256] is there a way to stop reading at the null char?
I don't want to read the whole array if I don't have to.
ThanksHow else is it going to be done? If there (hypothetically) was a method that read in a null-terminated string, that's what it would have to do if you looked inside it.
-
Unable to read attachment from javamail using IMAP
I am unable to read and save attachement in java mail using IMAP, but able to do using POP3
Sample code below:
Multipart multipart = (Multipart) message.getContent();
for (int i = 0, n = multipart.getCount(); i < n; i++)
Part part = multipart.getBodyPart(i);
String disposition = part.getDisposition();
// here i am getting dispostion null if use IMAP, if i use POP3 then i can able to recevive attachment
if ((disposition != null) && ((disposition.equals(Part.ATTACHMENT) || (disposition.equals(Part.INLINE)))))
System.out.println("file name is " + part.getFileName());
message.setFlag(Flags.Flag.ANSWERED, true);
saveFile(part.getFileName(), part.getInputStream());
public static void saveFile(String fn, InputStream in) {
try {
FileOutputStream fos = new FileOutputStream(new File("c://test//" + fn));
byte[] buf = new byte[1024];
int i = 0;
while ((i = in.read(buf)) != -1) {
fos.write(buf, 0, i);
in.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
Any help is appreciated
Thanks
SamiIf you're getting disposition == null it's because your IMAP server
isn't returning this information to you. Possibly your IMAP server
is buggy. You can look at the protocol trace to see what the IMAP
server is returning, and if it's missing information that should be there,
report a bug to your IMAP server vendor.
Your program might need to work around this problem by deciding
that any body part with a filename is an attachment, or any part
after the first is an attachment. -
How Read attachment form eml file ?
i try to get details form .eml(e-mail) file, which contain attachment.it works if that attachment types are pdf/word..
but if that attachment type .eml(means email file have email attachment) then it is not work returning null.Can you help to extract that attachment.
This is the code...
package tools;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;
import javax.activation.DataHandler;
import javax.mail.*;
import javax.mail.internet.*;
public class ReadMultipartMail {
public static void main(String args[]) throws Exception {
File emlFile = new
File("F:/test.eml");
InputStream source;
source = new FileInputStream(emlFile);
Properties props = System.getProperties();
props.put("mail.host", "smtp.dummydomain.com");
props.put("mail.transport.protocol", "smtp");
Session mailSession = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(mailSession, source);
System.out.println("Subject : " + message.getSubject());
System.out.println("From : " + message.getFrom()[0]);
String from = InternetAddress.toString(message.getFrom());
if (from != null) {
System.out.println("From: " + from);
String replyTo = InternetAddress.toString(message.getReplyTo());
if (replyTo != null) {
System.out.println("Reply-to: " + replyTo);
String to = InternetAddress.toString(message
.getRecipients(Message.RecipientType.TO));
if (to != null) {
System.out.println("To: " + to);
String subject = message.getSubject();
if (subject != null) {
System.out.println("Subject: " + subject);
Date sent = message.getSentDate();
if (sent != null) {
System.out.println("Sent: " + sent);
System.out.println();
System.out.println("Message : ");
Multipart multipart = (Multipart) message.getContent();
for (int x = 0; x < multipart.getCount(); x++) {
BodyPart bodyPart = multipart.getBodyPart(x);
String disposition = bodyPart.getDisposition();
if (disposition != null
&& (disposition.equals(BodyPart.ATTACHMENT))) {
System.out.println("Mail have some attachment : ");
DataHandler handler = bodyPart.getDataHandler();
System.out.println("file name : " + handler.getName());
} else {
System.out.println(bodyPart.getContent());
System.out.println();
}The msgshow.java demo program, included with JavaMail, shows how to handle attachments
of any type, including other messages. -
Issue with reading attachment in sender mail adapter
Hi, I am working on Email to file scenario, where I have to connect to exchange server and take the attachment of the email (xml file) and save it on to PI server. I have configured sender mail communication channel with following details:
Protocol: POP3
Message protocol: XIPAYLOAD
Mail attributes: keep attachments
Module:
1 localejbs/AF_Modules/PayloadSwapBean Local Enterprise Bean 1
2 localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
1 swap.keyName Content-Description
1 swap.keyName Content-Description
1 swap.keyValue attachment,filename="MailAttachment-1.xml"
1 swap.keyValue MailAttachment-1
Also, configured receiver file adapter.
Since I donu2019t have to read mail content , I havenu2019t created any design components in ESR. I have just refrred to dummy namespace, interface (both sender and receiver). in receiver determination, interface determination, sender agreement and receiver agreements.
It was working fine, not sure what changes happened. Now I could see the attachment payload in message monitor.
Under Inbound message->payloads->
MailMessage ( text/xml;charset=utf-8 )
MailAttachment-1 ( text/xml;name="****************")
But the fille that is getting created doesnu2019t have the contents of the attachment (xml file) . It has some other information, shown below:
Directory: ******
Name: ********.xml
=NextPart_002_01CB2C5B.B033B325#
content-type:text/plain;charset="us-ascii"#
content-length:30#
content-transfer-encoding:quoted-printable#
<<**********.xml>>=20#
=NextPart_002_01CB2C5B.B033B325#
content-type:text/html;charset="us-ascii"#
content-length:#
content-transfer-encoding:quoted-printable#
=NextPart_002_01CB2C5B.B033B325 #
Can you please let me know what is going wrong here.using following parameters in module resolved my problem:
MOdule name Type Module Key
AF_Modules/PayloadSwapBean Local Enterprise Bean transform sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
Module Key Parameter Name Parameter value
transform swap.keyName Payload-Name
transform swap.keyName MailAttachment-1 -
Reading Numeric UDF null value in DI
We have a UDF of Numeric(4) that can be NULL, 0, 1, 2, etc. We try to read it from DI, and if it is NULL, then set the result to be -1 (the default value we difined), so we can differentiate NULL and 0.
The C# code we have look like this:
int LineNumber = -1;
SAPbobsCOM.Company oCompany;
// Code to get Company
SAPbobsCOM.Documents oDoc = oCompany.GetBusinessObject(BoObjectTypes.oQuotations);
oDoc.GetByKey(100); // Get the document by DocEntry
LineNumber = (int)oDoc.UserFields.Fields.Item("U_XX_LN").Value;
The problem is LineNumber gets 0 even if in the database U_XX_LN is NULL. We tried the code below and got the same result because oDoc.UserFields.Fields.Item("U_XX_LN").Value.ToString() always return '0' if it is NULL.
if (string.IsNullOrEmpty(oDoc.UserFields.Fields.Item("U_XX_LN").Value.ToString()))
LineNumber = -1;
else
LineNumber = (int)oDoc.UserFields.Fields.Item("U_XX_LN").Value;
The question is: how can we set it to default -1 if in the database the value is NULL?
Thank you,
GraceHi Grace,
Unfortunately the DI API automatically converts database null values to a default value for the datatype (eg null for numeric becomes 0 and null for strings is an empty string). If you want to differentiate between null and zero you will need to query the table using the isnull command rather than reading the table through the UserTables object:
oRecordSet.DoQuery("select isnull(U_XX_LN, -1) as U_XX_LN from [@MYTABLE] where Code = 'MYCODE')
This will convert the null value to a -1 in the recordset so you can tell the difference between nulls and zeros.
Kind Regards,
Owen -
How to read attachment via function module??
Hi All,
I have to Read the content of attachment of standard task TS00407864.
For that i have used a function module SAP_WAPI_GET_ATTACHMENTS.
and i got this.
OBJECT_ID SOFM FOL32000000000004RAW340
DESCRIPT Office Document
SHORTTEXT Office Document
DEF_ATTRIB Document Not as per Accounting Stantard
OBJECT_TYP AT
Now i have to read it in internal table which function i should use and how can i pass the value to it.
Please Help!
Regards,
Purvesh Patel.Hi,
use method cl_swf_utl_convert_por=>convert_bor_to_ibf( ). Also properly defined structures will parse data without need of offset reading/parsing.
Example:
data:
lt_attachment type swrtobject,
lt_wapi_message type swr_msgtab,
ls_docid type soentryi1,
lv_subrc type sy-subrc,
lv_doc_id type sofolenti1-doc_id
field-symbols:
<ls_attachment> type swr_object
call function 'SAP_WAPI_GET_ATTACHMENTS'
exporting
workitem_id = me->mv_workitem_id
user = me->mv_username
language = me->mv_language
importing
return_code = lv_subrc
tables
attachments = lt_attachment
message_struct = lt_wapi_message
if ( lv_subrc <> 0 ).
"! Handle error / messages
endif.
loop at lt_attachment
assigning <ls_attachment>
lv_doc_id = cl_swf_utl_convert_por=>convert_bor_to_ibf( i_bor_por = <ls_attachment>-object_id ).
ls_docid = lv_doc_id.
endloop.
Maybe you are looking for
-
How do I print pictures? HP PhotoSmart plus e all in one B210
I have been trying to print pictures off my Android phone and my computer and no luck! I got one off the computer but it printed of regular paper instead of the photo slot even though I chose the photo slot... It keeps saying that my email was disc
-
User In Planning unit Hierarchy unable to see data form in editable mode
hi all, we are facing a problem in planning unit hierarchy in Hyperion planning, where we have 4 users, Hierarchy is define as hierarchy: budget approved version: approved Entity: Finance Senario:Budget haroon asghar ( owner) adeel javid (Reviewer) N
-
Hello, I'm working on a C#.net app.This is a machine interfacing software , where we use it to control the machine by interacting with it through hardware.The software works fine on all the machines that we have in our company, but fails to open on c
-
Integration Server Service 9.3.1 (EIS) entering a stopped state
Integration Server Service (EIS) is stopping multiple times during the day and sometimes during the nightly processing. There seems to be no reason to when or why it stops. Sometimes users may be running drill through reports, sometimes no one is. We
-
Hello. how do I change the contact e-mail link in a folder? Thus: where does portal get this e-mailaddress from? I thought in the user account info. But when i clear it there, the conatct link still is the same... Thx.