cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload a file in R/3 system through RFC using WebDynpro Java

Former Member
0 Kudos

Hi There,

we need to pass a file(mostly xml) using file upload feature in Webdynpro and then need to pass the file in R/3 system using RFC. What should be importing parameters for RFC and how should i implement the fileUploadUi in this case.

I have already seen example of how to add this in a table input form.

Any pointers will be great help.

Regards,

Sudhir

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Closing old messages, not relevant now.

Former Member
0 Kudos

Hi Sudhir:

I have a similar kind of requirement, have been searching for this solution for quite awhile...

Could someone help us out...

Thanks in advance

Former Member
0 Kudos

Hi,

The RFC will have the input parameters as File Content, File Name, File Type and Content Type, Which accepts the byte content of the file from webdynpro (IWDResource). The RFC then combines the file contents, converts to the original format and form the attachement in SAP System.

Regards,

Krishnaveni.

Former Member
0 Kudos

Hi Krishnaveni:

Thanks for the input.

I guess we map the file name and pass the file type, the file content should be taken by the GUI_UPLOAD FM or similar type of FM right???

Correct me if iam wrong, please provide more information (If you can document what you have done, please email to sapk0708@gmail.com).

Iam able to pass the file name to the FM, but receive the following dump:

" Termination occurred in the ABAP program "SAPLCNDP" - in "DP_CONTROL_ASSIGN_TABLE". The main program was

"SAPMSSY1 ". In the source code you have the termination point in line 1 of the (Include) program "LCNDPU10".

Thanks and Regards.

Former Member
0 Kudos

DSMOPMSGATTACH is the structure we have used in the ABAP for reading the content from webdynpro. I have send you the code.

Former Member
0 Kudos

Thanks Krishnaveni, got your email... Thanks for the inputs..

Let me try this and get back to you.

Thanks and Regards.

Former Member
0 Kudos

I got this working.

As said, just pass the file contents to the RFC parameter (XSTRING).

By few conversions, i could read the data and upload succesfully.

Anyone getting stuck here, let me know.

Thanks

Former Member
0 Kudos

Dear SAPK

Can I get sample code of Webdynpro JAVA and ABAP???

I need this code desperately..

I would be appreciate if u can send this samle code to me?

Thanks in advance

Former Member
0 Kudos

Dear SAPK:

my question is conversions.

u201CBy few conversions, i could read the data and upload succesfully.u201D

how to convert RFC parameter(xstring) into the file?

i want to convert RFC parameter(xstring) into a file on servers,can i?

if u know,pls hlep me,thanks a lot

Former Member
0 Kudos

Hi,

I am trying to upload a file to R/3 system through RFC using WebDynpro Java. Can you help me by providing samples?

Former Member
0 Kudos

Hi,

Go through this link and watch the section

Uploading and Downloading Files

/docs/DOC-8061#41

Thanks & Regards

Padma N

Former Member
0 Kudos

Dear Spak,

can you kindly show me some light in getting this done? i need to upload file to r/3 using RFC as well..Thank you...

Former Member
0 Kudos

Use this code to convert the file content to bytes in WDJ:

-


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 byte10 * 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.

-


Use this code in your R/3 function module to convert the data.

-


*" VALUE(XCONTENT) TYPE XSTRING OPTIONAL

OUTSTRING TYPE STRING,

CONV TYPE REF TO CL_ABAP_CONV_IN_CE.

  • Convert data passed from WD Application.

CONV = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = XCONTENT ).

CONV->READ( IMPORTING DATA = OUTSTRING ).

SPLIT OUTSTRING AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE IT_DATA.

DELETE ADJACENT DUPLICATES FROM IT_DATA.

-


Let me know if you run into issues, please award points accordingly.