cancel
Showing results for 
Search instead for 
Did you mean: 

upload a file into R/3

Former Member
0 Kudos

I'm sorry I've used different tutorials on this site but I just can't get to UPLOAD a file to the R/3...

Could anyone explain an plain and simple way to do it ?

I'm using a RFC BAPI, with a string or a binary type but neither will accept connection with the 'Resource' context attribute...

Please help me on that

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Philippe,

U can follow these steps:

Apart from the resource context attribute create a context attribute of type binary.

get the data from resource & convert it to binary & pass that to RFC. U can use this code for conversion

byte fileData[] = null;

try{

InputStream fileIs = wdContext.currentAttachCVElement().getFileData().read(false);

ByteArrayOutputStream bOut = new ByteArrayOutputStream();

int length;

byte[] part = new byte[10 * 1024];

while ((length = fileIs.read(part)) != -1) {

bOut.write(part, 0, length);

}

fileIs.close();

fileData = bOut.toByteArray();

bOut.close();

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportSuccess(e.toString());

}

Here getFileData reffers to the attribute of type resource. rest of the code u can use directly.

regards

Sumit

Answers (2)

Answers (2)

Former Member
0 Kudos

yeah

thanks a lot it worked

you've got your points !

Former Member
0 Kudos

Hi Philippe:

I tried the same code and it worked like a charm.

Iam converting the xstring format to string format in the corresponding RFC.

My question is if the file has mutilple records (input file) how are you handling???

Do we have any standard RFC which would split the String format and append to internal table???

Please advice.

Thanks!

Former Member
0 Kudos

I could get this done myself.

Sumit Malhotra, the code was very useful. Thank you!

Former Member
0 Kudos

thanks

i'm trying his

Former Member
0 Kudos

Hi Philippe,

Is ur problem solved??

regards

Sumit