cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload in CRM2007 web-ui

Former Member
0 Kudos

Hello All,

I have a requirement where I have to upload an XML from from my local machine to the CRM 2007 web-ui.

I have created a button in the front-end of the order screen and on clicking of the button, some process (which I need to know actually) will happen in the backend, which will upload the file from the path which will be specified in the program.

I have tried it out with normal SAP FMs like GUI_UPLOAD and other standard methods, but they do not work as they work specifically for SAP GUI and not for web-clients.

Please help me out in this problem.

Thanks,

Paul.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

have a look at component CRM_THTMLB_COMP for some examples (you also can test it).

The file upload is used in view CRM_THTMLB_COMP/FileUploadTag.

But you cannot specify a path where to upload from.

It's a web application and here the user always have to select a path manually.

The only possibility to specify a path could be using Java Applets / Active X / ...

Regards,

Claudia

Answers (1)

Answers (1)

suchita_phulkar
Active Contributor
0 Kudos

Hi,

In WEB UI , GUI_UPLOAD can not work( its for SAP GUI only hence the name GUI ).

In your program , if you have the file path with you , then you can use following function module :

RZL_READ_FILE as follows


CALL FUNCTION 'RZL_READ_FILE'
  EXPORTING
   DIRECTORY            = 'Directory path and not file path'
*   FROMLINE             = 0
    name                 = 'File Name'
*   NRLINES              = 50
*   SRVNAME              = ' '
  tables
    line_tbl             = lt_lines
* EXCEPTIONS
*   ARGUMENT_ERROR       = 1
*   NOT_FOUND            = 2
*   SEND_ERROR           = 3
*   SYSTEM_FAILURE       = 4
*   OTHERS               = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

in DIRECTORY parameter , give the path to directory and not file ,but path till the directory that contains file.

If the file is on client machine, it will me like say 'C:\My_data' . If the file is on server then path will be

'\\server name ( e.g. SAPCRD ) \Folder1\Folder2\Folder3' 

etc.

In NAME parameter, just mention the file name as 'myfile.xml' etc.

In TABLE parameter, lt_lines, you will get all the lines from the file. Lt_lines will be type table of string.

Obviously, since you are reading XML file, lt_lines will have all XML tag wise content.

Now you will need to parse though these XML to get the values in internal table or so.

Since i dont know what you want to do with XML, i cant explain ahead. If you dont know how to parse XML file, the let me know, I can give you the code for that.

Hope this informations helps you to real your file on click of button.

Regards,

Suchita

P.S. Your can also call this FM in event handler of your button click.

Also i would suggest that initially execute this FM in se37 by supplying directoy and file name. you will immediately come to know the result or error . Once you got the result, then go ahead and implement it in you event handler or other WEB UI method.

Former Member
0 Kudos

Hi Suchita,

Thanks for the reply. But when I try to execute the function module independently, it throws an exception that "File Not Found". I have used the parameters as you have mentioned. Could u please help me in the same.

Thanks in advance,

Pradipta Paul.

suchita_phulkar
Active Contributor
0 Kudos

Hi there,

Can you show me your code of your call to the function ?

I am using the same function to read a file on server and its working fine. If its file not found error then there must be some parameter passing issue.

Plz paste your call.

Thanks,

Suchita

Former Member
0 Kudos

Hi Suchita,

Thanks for the response.

Pls find below what i am trying to use -

  • DATA: BEGIN OF LT_LINES OCCURS 100.

  • INCLUDE STRUCTURE SPFLIST.

  • DATA: END OF LT_LINES.

*

  • CALL FUNCTION 'RZL_READ_FILE'

  • EXPORTING

  • DIRECTORY = 'C:\Documents and Settings\pradipta\Desktop'

    • FROMLINE = 0

  • NAME = 'pp.txt'

    • NRLINES = 50

    • SRVNAME = ' '

  • TABLES

  • LINE_TBL = LT_LINES

  • EXCEPTIONS

  • ARGUMENT_ERROR = 1

  • NOT_FOUND = 2

  • SEND_ERROR = 3

  • SYSTEM_FAILURE = 4

  • OTHERS = 5.

*

  • IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

The file pp.txt is on the deskop and even if i run the FM independently , it throws an exception that 'file not found'. Could u please help me in this regard.

Thanks in advance,

Pradipta

Former Member
0 Kudos

Hi Suchita,

I am using web ui .

I have a requirement of converting an internal table to xml file & download it to desktop .

I have converted the file to xml but not able to save the file to desktop .I am currently using CL_CRM_FRONTEND_SERVICES=>GUI_DOWNLOAD method to download on desktop , but it is throwing an exception of "flush" but at the same time if i am calling this method from a report through SE38, it is working fine .

Is there any other method that is to be used for CRM WEB UI to download a file on desktop / application server .

dhruv_mehta
Active Contributor
0 Kudos

Hi Suchita ,

Can You Please Tell me how should i Open File Upload Dialog and then after I call

RZL_READ_FILE to get data from file but i am stuck in First step as i need a dialog to browse file.

Help is appropriated..

Thanks

Dhruvin

Former Member
0 Kudos

Hi Suchita,

My requirement was In Sales order screen in Item level we added one button if we click on that it should go directly to our own directory, so we have to create one directory path and also we need to upload images for particular sales order line item.