Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 11, 2008 at 08:52 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Apr 29, 2009 at 03:23 AM

    Closing old messages, not relevant now.

    Add comment
    10|10000 characters needed characters exceeded