Upload file in Web Dynpro and add to Workflow container as SOFM object

Hi!
I have a Web Dynpro for ABAP application that should send attachments of uploaded files to a workflow container. I have already managed to do this, and it works fine for TXT files, but when I try to attach a WORD (.DOC) file the file looks corrput when I open it from the SAP inbox.
When uploading files in Web Dynpro it is as an XSTRING. I have tried out the following alternatives regarding convertion of the XSTRING before it is inserted in the SOFM object:
1) Convert from XSTRING to STRING using codepage 4110.
Then it is split into a string table of 255 chars
2) Convert from XSTRING to STRING using codepage 4102
Then it is split into a string table of 255 chars
3) Convert from XSTRING to BINARY format
I use function module 'SWL_SOFM_CREATE_WITH_TABLE'
and then swf_create_object lr_sofm 'SOFM' ls_sofm_key.
before I call some macros to fill the container.
Anyone else who have tried to do this with success? I'm greatful for any help.
Regards, Tine

Hi,
I had the same problem in the last days and finally I got a quite simple solution:
I had a look at the FM SWL_SOFM_CREATE_WITH_TABLE an noticed that it calls another FM (SO_DOCUMENT_INSERT_API1) which has a tables parameter for HEX data and is actually able to  create a SOFM object from HEX data.
I simply copied SWL_SOFM_CREATE_WITH_TABLE as a customer FM and applied a few changes to make it accept HEX data:
First I added a new table parameter in the interface which gets the HEX data from the calling application (uploaded data using BIN format):
OBJECT_CONTENT_HEX     LIKE     SOLIX
Here is the code of the FM (I marked all additional and changed lines with a comment):
function z_test_sofm_create_with_table .
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(NOTE_TITLE) LIKE  SODOCCHGI1-OBJ_DESCR OPTIONAL
*"     VALUE(DOCUMENT_TYPE) LIKE  SOODK-OBJTP DEFAULT SPACE
*"  EXPORTING
*"     VALUE(SOFM_KEY) LIKE  SWOTOBJID-OBJKEY
*"  TABLES
*"      NOTE_TEXT STRUCTURE  SOLISTI1 OPTIONAL
*"      OBJECT_CONTENT_HEX STRUCTURE  SOLIX OPTIONAL
*"  EXCEPTIONS
*"      ERROR_SOFM_CREATION
  data: region like sofd-folrg.
  data: folder_id like soodk.
  data: l_folder_id like soobjinfi1-object_id.
  data: document_data like sodocchgi1.
  data: document_info like sofolenti1.
  data: object_content like solisti1 occurs 0 with header line.
  data: lines like sy-tabix.
*- set default
  if document_type is initial.
    document_type = 'RAW'.
  endif.
*- create office object
*-- get dark folder
  region = 'B'.
  call function 'SO_FOLDER_ROOT_ID_GET'
    exporting
      region                = region
    importing
      folder_id             = folder_id
    exceptions
      communication_failure = 1
      owner_not_exist       = 2
      system_failure        = 3
      x_error               = 4
      others                = 5.
  if sy-subrc ne 0.
    message e696(wl)                       "<== Add message class
            raising error_sofm_creation.
  endif.
*- get description
  if note_title is initial.
    read table note_text index 1.
    note_title = note_text.
  endif.
*-- create office document
  document_data-obj_name = 'ATTACHMENT'.
  document_data-obj_descr = note_title.
  document_data-obj_langu = sy-langu.
  object_content[] = note_text[].
  describe table object_content lines lines.
  document_data-doc_size = ( lines - 1 ) * 255 + strlen( object_content ).
  if object_content[] is initial.                     "<== insert
    describe table object_content_hex lines lines.    "<== insert
    document_data-doc_size = lines * 255.             "<== insert
  endif.                                              "<== insert
  l_folder_id = folder_id.
  call function 'SO_DOCUMENT_INSERT_API1'
    exporting
      folder_id                  = l_folder_id
      document_data              = document_data
      document_type              = document_type
    importing
      document_info              = document_info
    tables
      object_content             = object_content
      contents_hex               = object_content_hex   " <== Insert line
    exceptions
      folder_not_exist           = 1
      document_type_not_exist    = 2
      operation_no_authorization = 3
      parameter_error            = 4
      x_error                    = 5
      enqueue_error              = 6
      others                     = 7.
  if sy-subrc ne 0.
    message e696(wl)                              "<== Add message class
            raising error_sofm_creation.
  endif.
*- set export parameter
  sofm_key = document_info-doc_id.
endfunction.
The returned  SOFM key I added to a container element. The element refers to event parameter of type OBJ_RECORD in my ABAP OO Class
Using this function I was able to raise an event by using Method cl_swf_evt_event=>raise
that invoked a workitem containing an Excel-File i had uploaded as binary file and passed to the FM z_test_sofm_create_with_table as document type 'XLS'.
In the woritem preview when clicking on the attachment the file was opened directly in Excel.
Actually the new lines for calculation the file size is not yet quite correct. At first glance it does not seem to cause any trouble, but I will stll check that. In FM SO_OBJECT_INSERT the size is again checked and calculated if initial, so leaving size initial might also be an option.
I hope this helps anyone having a similar issue.
Greetings,
Michael Gulitz

Similar Messages

  • Upload File in Web Dynpro Java CO and store it in the context

    Hi Guys!
    I have developed a web dynpro CO form, and I need to be able to upload a file in an action and then be able to download that file in further actions.. I have evaluated saving the file in the backend via RFC, in KM and also creating a CAF project.. but I think there must be a simpler way : saving it in the context of GP.
    Does someone knows if it is possible to do that?
    best regards,
    Marco.

    Hi Marco
    In webdynpro java, there are UI elements File Upload and File Download. You can use these UI's to upload and download attachments. From NetWeaver 7.0 onwards, you have IWDResource interface which can be used to upload attachments. But in GP if you want to pass attachment to another action you must use Binary as a data source. Bind the File upload UI element to Binary. In addition, you should define input and out parameters in getDescription method.
    Thanks
    Ghazanfar

  • Error uploading file to web before and after updating

    Hi,
    I'm running adobe muse on a mac 2013 yosemite. I changed from the original version of adobe muse to the 2014.2 version, just to let you all know.
    Earlier today, I woke up and one of my two websites I've created in the original version of adobe muse had lost the information required to upload to FTP Host. I retyped in my information, and it started to upload my website. Eventually it hit the 61% mark, and said that it was "connecting to the FTP host" for a really, really long time. I waited about 20 minutes- nothing happened. So I then decided to update adobe muse to the 2014.2 version.
    After updating, I tried uploading my site to the web again. I put in virtually the same information as before, and now I'm getting an error message saying "Could not sign in. Check your network connection and try again. If this problem persists, try again later."
    Can anybody help me here? My website is hosted by GoDaddy.com, just to let you know.
    Thanks in advance,
    Gavin

    Muse 2014.3 was released last week , please tr y to update Muse and then check.
    Thanks,
    Sanjit

  • Upload and Reading Excel File in Web Dynpro

    Hi all,
    I have a requirement in my application( in 04s), where in, i need to upload an excel from a client through a web dynpro application(using fileupload UI) and read each and every the content of that excel file in web dynpro and process the data accordingly.
    The format of the excel is fixed and pre-defined.
    I went through a lot of blogs, but could not find a direct and exact solution to this requirement.
    Please help me.
    Looking forward to your contribution
    Thank you,
    Gita KC.

    Reading Excel Sheet from Java without using any Framework
    Enhanced File Upload - Uploading and Processing Excel Sheets
    Reading Multiple Sheets of Excel Sheet from Java
    nikhil

  • Reading contents of uploaded excel file in web dynpro java

    Hi All.
    I am aware how to provide facility to upload files in web dynpro java. But my requirement is that on uploading a particular file (for eg. an excel file having 10 columns), I need to read the contents of that file and store it in a table in R/3.Can anyone suggest a way how I can read the contents of the uploaded file?
    Thanks and Regards,
    Saurabh.

    Hi.
    I am having the following requirement : I have a FileUpload UI element where user clicks Browse button, selects a file from the local system and presses a Upload button. Upon pressing Upload, the name of the selected file and the contents of the file should be shown.
    In the View context, I have two value attributes: FileName of type String and FileResource of type binary.
    This is the code that I have in the Upload button action handler :
      public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUpload(ServerEvent)
        IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(
                 IPrivateReadExcelView.IContextElement.FILE_RESOURCE);
        IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attributeInfo.
                 getModifiableSimpleType();
        IPrivateReadExcelView.IContextElement element = wdContext.createContextElement();
        String fname = binaryType.getFileName();
        wdComponentAPI.getMessageManager().reportSuccess("File selected - "+fname);  //Statement 1
         try {
              wdComponentAPI.getMessageManager().reportSuccess("Successful");    // Statement 2
              InputStream in = new FileInputStream(fname);
              HSSFWorkbook wb = new HSSFWorkbook(in);
              wdComponentAPI.getMessageManager().reportSuccess("Successful");    //Statement 3
              int sheetsNo = wb.getNumberOfSheets();
              for (int i=0;i<sheetsNo;i++) {
                   HSSFSheet sheet = wb.getSheetAt(i);
                   Iterator rowsNo = sheet.rowIterator();
                   while(rowsNo.hasNext()) {
                        HSSFRow rows = (HSSFRow)rowsNo.next();
                        Iterator colsNo = rows.cellIterator();
                        while(colsNo.hasNext()) {
                             HSSFCell cell = (HSSFCell)colsNo.next();
                             wdComponentAPI.getMessageManager().reportSuccess("File uploaded" +
                                  "successfully");
                             if(cell.getCellType()==1) {
                                  wdComponentAPI.getMessageManager().reportSuccess("00000"+
                                       cell.getStringCellValue());
                             else if(cell.getCellType()==0) {
                                  String str=""+cell.getNumericCellValue();
                                  wdComponentAPI.getMessageManager().reportSuccess("11111"+str);
         catch(Exception e) { wdComponentAPI.getMessageManager().raisePendingException();
        //@@end
    On pressing Upload button, name of selected file is being shown(Statement 1). I am also getting Statement 2 in the output. However I am not getting Statement 3 onwards.
    Where am I going wrong? Can anyone shed some light on this?

  • Download files through web Dynpro

    Hai All,
      Now i am working in web Dynpro2.0.9. "IWDResource" property is used to download and upload files in web Dynpro. "IWDResource" is not supported by web Dynpro2.0.9.what is the alternative way for to download files other than using "IWDResource" property.If you have sample codings send it.
    Thanks in Advance,
    s.v.selva Bala.

    Hallo Anilkumar,
    read my tutorial on Uploading/Downloading Files in Web Dynpro NW04:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d2201c20-0801-0010-49b3-94fca8f590d5">Uploading and Downloading Files (39)</a>
    You are right, that the new on-demand-stream concept based on the IWDResource-API (Resource Simple Type) is not applicable in NW04.
    Regards, Bertram

  • Adding Word attachment to a SOFM object and then to Workflow container

    Hi!
    I have a Web Dynpro for ABAP application that should send attachments of uploaded files to a workflow container. I have already managed to do this, and it works fine for TXT files, but when I try to attach a WORD (.DOC) file the file looks corrput when I open it from the SAP inbox.
    When uploading files in Web Dynpro it is as an XSTRING.  I have tried out the following alternatives regarding convertion of the XSTRING before it is inserted in the SOFM object:
    1) Convert from XSTRING to STRING using codepage 4110.
    Then it is split into a string table of 255 chars
    2) Convert from XSTRING to STRING using codepage 4102
    Then it is split into a string table of 255 chars
    3) Convert from XSTRING to BINARY format
    I use function module 'SWL_SOFM_CREATE_WITH_TABLE'
    and then  swf_create_object lr_sofm 'SOFM' ls_sofm_key.
    before I call some macros to fill the container.
    Anyone else who have tried to do this with success? I'm greatful for any help.
    Regards, Tine

    Hello there.
    This is probably an usability question that you should ask Microsoft, not us. In any case, you probably need to open the document (it's probably a document that can't be open inside Firefox, so use the appropriate software) and copy it from there.
    I'm sorry I can't be of more help.

  • Uploading excel file in Web Dynpro for ABAP

    Hello Gurus,
                       I need to upload a excel file in my Web Dynpro (ABAP) program. Can anyone please tell me how do i do this. Kindly help.
    Regards,
    Aditya.

    Hi Aditya,
    Please search the forum...
    Please check this link
    Uploading Data from Excel File To Dynpro
    Excel Upload via Web dynpro ABAP
    Upload and Reading Excel File in Web Dynpro
    Best regards,
    raam

  • HI Masters , I need information for file upload program in web dynpro java

    Hi masters,
           i need some inforamtion and documentation on file upload program in web dynpro java

    Hi surya,
    You can follow this procedure to upload the file
    i) Take One Context Attribute named as "D1" of Type "binary".
    ii) Take one FileUpload UI Element in the Layout Tab.
    iii) Bind FileUpload UI Element's data Property to the taken Context Attribute. Here it is "D1".
    iv) Take one Button UI Element in the Layout Tab named "Upload" and in the Action of that Button write the following Code.
    v) The following code Generates one Folder in the Server & inside that Folder given file is Uploaded.
    File ff=new File("FolderXYZ"); // Creates One Folder with the given Name ( Here Folder name is "FolderXYZ")
    ff.mkdir();
    try
    byte b[]=null;
    IWDAttributeInfo objAttinfo=null;
    IWDModifiableBinaryType binType=null;
    File f=null;
    FileOutputStream fos=null;
    if(wdContext.currentContextElement().getD1()!=null)
    b=wdContext.currentContextElement().getD1();
    objAttinfo=wdContext.getNodeInfo().getAttribute(IPrivateAttachView.IContextElement.D1);
    binType=(IWDModifiableBinaryType)objAttinfo.getModifiableSimpleType();
    f=new File(ff.getName()+"
    "+binType.getFileName());
    fos=new FileOutputStream(f);
    fos.write(b);
    fos.flush();
    fos.close();
    objMessageManager.reportSuccess("File uploaded to server");
    } catch (Exception e)
    objMessageManager.reportException("Unable to upload file to server, error is:"+e,false);
    return;
    The Uploaded file is stored in the folder & that folder is stored in the Server's following Path.
    <Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0
    You can access your Uploaded file from the following Path
    <Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0\FolderXYZ
    Regards
    Sagar Ingalwar

  • File Visibility in uploading the file using web DynPro java

    hello,
    i have gone through the tutorial " uploading & downloading the file using web DynPro java".
    the upload functionalty is working fine. but i need to know thw path where these files are getting uploaded ??
    Waiting for the reply..
    Regards,
    Viren Gupta

    Hi Viren,
    Are you are refering to the below tutorial for upload and download:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f?QuickLink=index&overridelayout=true
    If yes, then answer is that the file is stored in the context of the application only as "com.sap.ide.webdynpro.uielement-definitions.Resource" object. Please read through the tutorial to understand the full process.
    WD doesn't really upload to server automatically unless there is any explicit code written. All it does is to store the file in a temp context which you can access and write your own code to store it in a particular location.
    Regards,
    Mahesh

  • Is there a way to save an image file as a jpeg and add -web or -print to the file name?

    I am trying to find a way to save my image file as a jpeg and add -web or -print to the existing file name.  This way I can easily see which files are lower resolution for web posting or high resolution for printing.

    Jason,
    I helped somebody do a very similar thing about a week ago.
    The trick is to use the Batch command's ability to construct a file name.
    Tell the batch to append, e.g. "-x" without quotes, to the name of each saved file.
    The batch runs an Action which does a save as JPEG, resize image, add logo, save as JPEG, then close document.
    The output is "<document name>-x.jpg" and "<document name>-x-x.jpeg".
    Then use Windows Explorer to rename "*-x-x.jpg" to "*-print.jpg".
    Then rename "*-x.jpg" to "*-web.jpg".
    See http://forums.adobe.com/thread/1038992?start=32
    The name construction that I used there was just an "x" appended to the document name. Use whatever you like. Also juliew subsequently referred to the method as a "double-batch" run, although it is not. One run of the batch will output two JPEGs for each input document.
    I hope the disagreements in that thread don't cause too much disruption.
    If you want, the Batch command itself can be recorded in another Action which would store the parameters of the batch, then you could run that Action anytime without having to set up the details of the batch each time. It would always output to one specific folder, though.

  • How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA

    Hi All,
    Please let me know "How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA"
    Regards,
    Ganga.

    Hi ,
    pl go through this note "Integrating a virus scan into SAP applications 817623 "
    SAP Virus Scan Interface
    http://help.sap.com/saphelp_nw2004s/helpdata/en/30/42c13a38b44d5e8d1b140794e8e850/frameset.htm
    Sample Application
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6e1c4221-0901-0010-63ba-b1f9459d6e74
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f2681486-0a01-0010-8497-c778eac80da5
    Regards
    Ayyappparaj

  • Error While uplaoding a EXCEL file in Web dynpro - HR_KR_XSTRING_TO_STRING

    Hi,
        I am getting an error while uploading an excel file in web Dynpro application. i am using the HR_KR_XSTRING_TO_STRING this function. I am getting the following error message 'Unable to interpret    as a number'.

    First of all, are you sure you know what you are working with here.  If this is standard Excel file in the Microsoft binary/propriatery format there is not function module or class in ABAP that can magically just transform this to a character string.  You should search the forums as this has been discussed extensively.  On that topic, please also do not post duplicate threads.  I have already locked your other thread with the same basic question.
    Instead of the binary/propriatery format of Excel, the file should be saved on the client as a text based format - like XML or Text Tab Delimited. You can then use several different options on the server to convert the XSTRING to STRING and process the content (becuase it was text based to begin with).  You could use CL_BCS_CONVERT, the function modules in the function group SCMS_CONV, or the class CL_ABAP_CONV_IN_CE.

  • Import data from excel/csv file in web dynpro

    Hi All,
    I need to populate a WD table by first importing a excel/CSV file thru web dynpro screen and then reading thru the file.Am using FileUpload element from NW04s.
    How can I read/import data from excel / csv file in web dynpro table context?
    Any help is appreciated.
    Thanks a lot
    Aakash

    Hi,
    Here are the basic steps needed to read data from excel spreadsheet using the Java Excel API(jExcel API).
    jExcel API can read a spreadsheet from a file stored on the local file system or from some input stream, ideally the following should be the steps while reading:
    Create a workbook from a file on the local file system, as illustrated in the following code fragment:
              import java.io.File;
              import java.util.Date;
              import jxl.*;
             Workbook workbook = Workbook.getWorkbook(new File("test.xls"));
    On getting access to the worksheet, once can use the following code piece to access  individual sheets. These are zero indexed - the first sheet being 0, the  second sheet being 1, and so on. (You can also use the API to retrieve a sheet by name).
              Sheet sheet = workbook.getSheet(0);
    After getting the sheet, you can retrieve the cell's contents as a string by using the convenience method getContents(). In the example code below, A1 is a text cell, B2 is numerical value and C2 is a date. The contents of these cells may be accessed as follows
    Cell a1 = sheet.getCell(0,0);
    Cell b2 = sheet.getCell(1,1);
    Cell c2 = sheet.getCell(2,1);
    String a1 = a1.getContents();
    String b2 = b2.getContents();
    String c2 = c2.getContents();
    // perform operations on strings
    However in case we need to access the cell's contents as the exact data type ie. as a numerical value or as a date, then the retrieved Cell must be cast to the correct type and the appropriate methods called. The code piece given below illustrates how JExcelApi may be used to retrieve a genuine java double and java.util.Date object from an Excel spreadsheet. For completeness the label is also cast to it's correct type. The code snippet also illustrates how to verify that cell is of the expected type - this can be useful when performing validations on the spreadsheet for presence of correct datatypes in the spreadsheet.
      String a1 = null;
      Double b2 = 0;
      Date c2 = null;
                        Cell a1 = sheet.getCell(0,0);
                        Cell b2 = sheet.getCell(1,1);
                        Cell c2 = sheet.getCell(2,1);
                        if (a1.getType() == CellType.LABEL)
                           LabelCell lc = (LabelCell) a1;
                           stringa1 = lc.getString();
                         if (b2.getType() == CellType.NUMBER)
                           NumberCell nc = (NumberCell) b2;
                           numberb2 = nc.getValue();
                          if (c2.getType() == CellType.DATE)
                            DateCell dc = (DateCell) c2;
                            datec2 = dc.getDate();
                           // operate on dates and doubles
    It is recommended to, use the close()  method (as in the code piece below)   when you are done with processing all the cells.This frees up any allocated memory used when reading spreadsheets and is particularly important when reading large spreadsheets.              
              // Finished - close the workbook and free up memory
              workbook.close();
    The API class files are availble in the 'jxl.jar', which is available for download.
    Regards
    Raghu

  • How to import an xdp-File to Web Dynpro Interactive Forms

    Hi Experts
    I am working with Web Dynpro and Interactive Form. With Adobe Lifecycle Designer I do an import of an MS Word-Document and convert it to the XDP-Format. How do I import this XDP-File into an Interactive Form inside Web Dynpro? The form shouldn't be created with Web Dynpro. So far, what I did was creating an empty form from within Web Dynpro and overwriting it with my xdp-File. But this doesn't seem to be a secure and robust solution. Do you have any suggestions?
    Thanks for helping
    Kind regards
    Bettina Hepp

    Hi Bettina,
    I can understand what problem you are facing.
    Please follow these steps and let me know if it has solved your problem or not
    1. Open the XDP file in Adobe Life Cycle Designer and go to File Menu ->Save As ->
    Save the file as PDF.
    2. NWDS Webdynpro Edit the interactive form and now you can import the same PDF file.
    This will solve your problem and let me know if you are facing any other issue.
    Cheers
    Satya

Maybe you are looking for

  • To initialize the liveCache instance LCA

    Hi all, I am getting error in initialize the liveCache instance LCA. I am doing a post livecache installation activity. Please see below error "Server: usalpapsq339 Users: DDIC Logical Command: DBMRFC Parameter: exec_lcinit -e unicode init Name and S

  • Unable to Enable User Profile Disks in RDP server 2012R2

    I am setting up a new Windows server that will act as an RDP server. The server has been built with Windows Server 2012R2.  I have the following roles and services working on the server: RD Web Access, RD Gateway, RD Licencing (with 30 user cal licen

  • Lesezeichen auf externe Dokumente aus Word erzeugen?

    Hallo Profis, nachdem ich regelmässig größere Mengen an Word-Dokumenten mit Acrobat pro 9 konvertiere  und dort dann manuell noch Lesezeichen zur Navigation auf übergeordnete PDF's einfügen muss, wollte ich einmal nachfragen, ob man das nicht vereinf

  • Pay_us_wages_w2_v is not picking current year data?

    Hi, pay_us_wages_w2_v tabe is not getting current year data, only is getting previous year data. Like SELECT sum(w2_wages_tips_compensation) FROM   pay_us_wages_w2_v puw WHERE  puw.assignment_id = 40291--:assignment_id1 AND puw.year      = '2013'--TO

  • Downloading report in excel file

    When I download reoprt in excel file then if material no is 0002134 then in the excel file this becomes 2134, I am saving file from the Menu System->Save-> Local fiie and then selecting spreadsheet. When I save as text file then it is not removing le