Application Development and Automation 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: 
Read only

File upload from Application Server

Former Member
0 Likes
823

Hi,

Can anybody please tell me how we can upload a file from the application server?

Thanks in advance.

regards,

Bijesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
797

Hi

Try like this

*   Retrieve Data file from Application server(Upload from Unix)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

    OPEN DATASET i_file FOR INPUT IN TEXT MODE.
    IF sy-subrc NE 0.
      MESSAGE e999(za) WITH 'Error opening file' i_file.
    ENDIF.
    DO.
*     Reads each line of file individually
      READ DATASET i_file INTO wa_datatab.
*     Perform processing here
*     .....   
    ENDDO.

Reward all helpfull answers

REgards

Pavan

8 REPLIES 8
Read only

Former Member
0 Likes
797

hi

Use Datasets for Application server

OpenDataset,

CloseDataset,

Readdataset

and transfer.

reward points plz

Read only

Former Member
0 Likes
798

Hi

Try like this

*   Retrieve Data file from Application server(Upload from Unix)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

    OPEN DATASET i_file FOR INPUT IN TEXT MODE.
    IF sy-subrc NE 0.
      MESSAGE e999(za) WITH 'Error opening file' i_file.
    ENDIF.
    DO.
*     Reads each line of file individually
      READ DATASET i_file INTO wa_datatab.
*     Perform processing here
*     .....   
    ENDDO.

Reward all helpfull answers

REgards

Pavan

Read only

0 Likes
797

Thank You all for the quick replies,

But in my selection screen, i have 2 fields for the file name.

1. Logical File name for Upload

2. Upload file name.

I am confused with the logical filename. Can anybody please tell me what this could be?

Read only

0 Likes
797

hi Bijesh ,

generally there are 2 types of files , one is logical files , these are nothing but files present in the presentation server , and the 2nd one is sequential files , whioch are files prsent on the Application server .

I think in your case , the Upload file name is the sequential file name which should be present on the application server .

Check the txn CG3Y and may be you can understand from there .

Regards,

Ranjita

Read only

0 Likes
797

HI

YOu should use a logical file name.

Use transaction FILE to define your logical file name, and in the file-name

field you can specify the variable values you want to use in the filename, like

the <DATE>.

Then, in your abap use function module FILE_GET_NAME_AND_LOGICAL_PATH with your

logical filename, and the function module will return a FILE_NAME and

LOGICAL_PATH that you can use with OPEN DATASET ... FOR OUTPUT.

Reward all helpfull answers

REgards

Pavan

Read only

0 Likes
797

Thanks All...

I think the above reply solved my probs...

Regards,

bijesh

Read only

former_member196299
Active Contributor
0 Likes
797

hi ,

you can use transaction CG3Y for uploading files from Application server to Presentation server .

Regards,

Ranjita

Read only

Former Member
0 Likes
797

&----


*& Report ZUPLOADTAB *

*& *

&----


*& Example of Uploading tab delimited file *

*& *

&----


REPORT zuploadtab .

PARAMETERS: p_infile LIKE rlgrap-filename

OBLIGATORY DEFAULT '/usr/sap/'..

DATA: ld_file LIKE rlgrap-filename.

*Internal tabe to store upload data

TYPES: BEGIN OF t_record,

name1 like pa0002-VORNA,

name2 like pa0002-name2,

age type i,

END OF t_record.

DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,

wa_record TYPE t_record.

*Text version of data table

TYPES: begin of t_uploadtxt,

name1(10) type c,

name2(15) type c,

age(5) type c,

end of t_uploadtxt.

DATA: wa_uploadtxt TYPE t_uploadtxt.

*String value to data in initially.

DATA: wa_string(255) type c.

constants: con_tab TYPE x VALUE '09'.

*If you have Unicode check active in program attributes then you will

*need to declare constants as follows:

*class cl_abap_char_utilities definition load.

*constants:

  • con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.

************************************************************************

*START-OF-SELECTION

START-OF-SELECTION.

ld_file = p_infile.

OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

ELSE.

DO.

CLEAR: wa_string, wa_uploadtxt.

READ DATASET ld_file INTO wa_string.

IF sy-subrc NE 0.

EXIT.

ELSE.

SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1

wa_uploadtxt-name2

wa_uploadtxt-age.

MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.

APPEND wa_upload TO it_record.

ENDIF.

ENDDO.

CLOSE DATASET ld_file.

ENDIF.

************************************************************************

*END-OF-SELECTION

END-OF-SELECTION.

*!! Text data is now contained within the internal table IT_RECORD

  • Display report data for illustration purposes

loop at it_record into wa_record.

write:/ sy-vline,

(10) wa_record-name1, sy-vline,

(10) wa_record-name2, sy-vline,

(10) wa_record-age, sy-vline.

endloop.

Regards,

Pavan