cancel
Showing results for 
Search instead for 
Did you mean: 

file attached in R/3 is empty when passed to RFC in binary format

Former Member
0 Kudos

Hi All

My application Scenario is like this:

I attach a file and pass it to R/3 in binary format. But the problem is an empty file gets attached in R/3.The contents in the file are missing.

The data type of backend variable is RAW to which I am passing binary data.

I have used the same kind of code of passing file attachment to R/3 in binary format which is given in SDN forums.

How to rectify this.

Please help.

Thanks & Regards

Prajakta

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185086
Active Contributor
0 Kudos

Hi

Which thread you are refering ??Post the code here.

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Satish

I have used either of the following two ways:

1. Blog : [http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/7626] [original link is broken] [original link is broken] [original link is broken]; in this I have used code of converting byte array to 1024.bytes

2. IPrivateSummaryView.ICtx_vn_attchDocumentsElement ele = null;

IWDResource l_fileResource = wdContext.nodeCtx_vn_attach().getCtx_vn_attachElementAt(i).getCtx_va_resource();

try {

InputStream l_ipStream = l_fileResource.read(true);

ByteArrayOutputStream l_opStream = new ByteArrayOutputStream();

IOUtil.copyStream(l_ipStream, l_opStream);

ele = wdContext.nodeCtx_vn_attchDocuments().createCtx_vn_attchDocumentsElement();

ele.setCtx_va_binary1(l_opStream.toByteArray());

wdContext.nodeCtx_vn_attchDocuments().addElement(ele);

Tbl1024 binary_obj = new Tbl1024();

binary_obj.setLine(wdContext.currentCtx_vn_attchDocumentsElement().getCtx_va_binary1());

inp.addT_Binary2(binary_obj);

l_ipStream.close();

l_opStream.flush();

l_opStream.close();

Regards

Prajakta

former_member185086
Active Contributor
0 Kudos

Ok

what is the data-Type of RFC parameter (as you said its RAW is it binary at webdynpro ??)

as you are copying the items as

IOUtil.copyStream(l_ipStream, l_opStream);

rather , take it directly from context as

byte[] fileRes = wdContext.nodeCtx_vn_attach().getCtx_vn_attachElementAt(i).getCtx_va_resource();

Before doing plz ensure

1. Data type of RFC reflected in WD must be of type binary

2.Check the size if the birary chunk(data to upload) after uoploading it in WD.

[Other Help|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71?quicklink=index&overridelayout=true]

Best Regards

Satish Kumar