Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

To upload file

Former Member
0 Kudos

Hi,

We have a requirement to upload a file from the presentation server C:\xxx to the application server.

Can any body share the code snippet.

Thanks.

13 REPLIES 13

former_member555112
Active Contributor
0 Kudos

Hi,

There is a standard transaction CG3Z available for the same.

You can check the same.

Regards,

Ankur Parab

Former Member
0 Kudos

Hi,

If its a simple upload without any validation then can use the standard tcode CG3Z, to upload file from presentation server to application server.

Regards,

Nikhil

Former Member
0 Kudos

Use Transaction CG3Z to upload file from Presentation Server to Application Server

For reading file from presentation server use FM GUI_UPLOAD

Former Member
0 Kudos

Hi,

Try calling T code CZ3Z / CZ3Y to upload/download files .

0 Kudos

Hi,

Thank you for you prompt replies.

Scenario is - I have downloaded a file using tcode FDTA.

That got stored in C:\documentsandsetting\sapworkdir .

Now can we build a code in this tcode FDTA using exits or anyother way so that when ever a user runs this tcode , after downloading to presentation it will get stored in application.

So can i submit any report in exit.

Thanks.

0 Kudos

Hi,

Thank you for you prompt replies.

Scenario is - I have downloaded a file using tcode FDTA.

That got stored in C:\documentsandsetting\sapworkdir .

Now can we build a code in this tcode FDTA using exits or anyother way so that when ever a user runs this tcode , after downloading to presentation it will get stored in application.

So can i submit any report in exit.

Thanks.

former_member229729
Active Participant
0 Kudos

Hello,

Use the transaction:

CG3Z  --> for Upload
CG3Y -->  for Download

Rgds,

RamaniN

0 Kudos

Hi,

Thank you for you prompt replies.

Scenario is - I have downloaded a file using tcode FDTA.

That got stored in C:\documentsandsetting\sapworkdir .

Now can we build a code in this tcode FDTA using exits or anyother way so that when ever a user runs this tcode , after downloading to presentation it will get stored in application.

So can i submit any report in exit.

Thanks.

0 Kudos

Hi,

User exists ar basically to update certain data which SAP is allowing us in that particualr exits.

Do not submit any report in any exit.

In your exit you can try to extract the file on desktop using GUI_UPLOAD and then using OPEN DATASET and TRANSFER statements you can pass the fille to the application server.

Regards,

Ankur Parab

Former Member
0 Kudos

Use Function module GUI_UPLOAD or

Have a look at transaction FILE and the logic of logical filenames.

Looks like the best option

Former Member
0 Kudos

Hi,

Can you please tell me the format in which you want to upload the file?

The below code uploads file in the CSV format on application server

you can specify your separator in the variable lv_file_separator.


  DATA: lv_file_separator TYPE c.
  lv_file_separator = ','.
  CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
    EXPORTING
      i_field_seperator    = lv_file_separator
    TABLES
      i_tab_sap_data       = tb_output1_file
    CHANGING
      i_tab_converted_data = tb_converted
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.
  IF sy-subrc <> 0.
*     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  DATA: lv_app_server_file TYPE string.
  lv_file_name = pa_filep.
  OPEN DATASET lv_app_server_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
  LOOP AT tb_converted INTO wa_converted.
    TRANSFER wa_converted TO lv_app_server_file.
  ENDLOOP.
  CLOSE DATASET lv_app_server_file.

Regards,

Manish

Former Member
0 Kudos

Hi,

CG3Z transaction is to upload filr from presentation server to application server.

OR

use GUI_UPLOAD fm

Regards,

Jyothi CH.

Former Member
0 Kudos

Hi,

It is possible with CG3Z transaction.

It is also possible with Opendataset statement.

Pass the data into table and in open dataset statement loop the table, here is sample code:

OPEN DATASET <filename in application server> FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc EQ 0.
    LOOP AT <table with upload data> INTO <field string>.
      TRANSFER <fieldstring> TO <filename>.
    ENDLOOP.
    CLOSE DATASET <filename>.
  ENDIF.

Hope this helps you.

Regards,

Rajani