Skip to Content
author's profile photo
Former Member

Problem in upload

Hi all,

i am stucked at one point while uploading file from desktop to application server.

I have uploaded multiple files but not able to save them with different names. when i upload files i have to save them dynamically with their names.for ex:

if i have uploaded 3 files together..abc.txt,,abc1.txt,,abc2.txt...

then they should save at server with their names...but

the logic that i have built is appending all the data in one file..

the logic of my code is::;

DATA: BEGIN OF t_itab OCCURS 0,

file(1000) type c,

END OF t_itab.

select-options l_file for rlgrap-filename no intervals.

loop at l_file.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

CODEPAGE = ' '

FILENAME = l_file-low

FILETYPE = 'ASC'

HEADLEN = ' '

LINE_EXIT = ' '

TRUNCLEN = ' '

USER_FORM = ' '

USER_PROG = ' '

DAT_D_FORMAT = ' '

TABLES

data_tab = t_itab

IF sy-subrc <> 0.

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

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

ENDIF.

open dataset in_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT t_itab.

TRANSFER t_itab TO in_file .

ENDLOOP.

if sy-subrc eq 0.

write:/ 'success'.

endif.

CLOSE DATASET in_file.

endloop.

this is the logic that i have built. its working good but appending the data into one file...

plz can anyone should suggest the corrections for that..means to say the logic..

thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    Sep 23, 2005 at 01:43 PM

    Everytime thru the loop you will need to set the file name.

    
    Loop at l_file.
    ....
    in_file  =  'the file path/name'.
    
    open dataset <b>in_file</b> FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    
    
    ....
    
    Endloop.
    
    
    

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Rich Heilman

      hi rich

      can you please help in this open dataset...

      if i have to upload same file name 2 times i am able to do that. But if i have to upload same file name 4 0r 5 times i am not able to built a code for that.

      User can upload ame file name 10 or 12 times together. And i have to save the file in application server in this format.._2 _2 _2 _2 for all file name that are having same name...

      so plz can u suggest the logic for that...

      *check for exsistency of file

      open dataset new_file_name for update IN TEXT MODE encoding default.

      if sy-subrc = 0.

      *if exists then append 2 again with the new filename

      concatenate new_file_name '2' into new_file_name

      separated by '_'.

      • close dataset new_file_name.

      endif.

      open dataset new_file_name for output in text mode encoding default.

      *looping on Internal table to write all data

      loop at t_itab.

      transfer t_itab to new_file_name .

      endloop.

      the above logic is working for two but not for multiples file that have same file name..

      so plz can u suggest

  • author's profile photo
    Former Member
    Sep 23, 2005 at 01:43 PM

    Hi,

    You have to change "in_file" also inside the loop every time.

    you have to fill "in_file" at the very end with l_file-low for each loop pass..

    Sri

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 23, 2005 at 01:45 PM

    You are missing one line I guess

    <u>in_file = i_file-low.</u>

    open dataset in_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    Cheers

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 23, 2005 at 02:09 PM

    Use

    CLear In_file .

    concatenate in_file stripped into in_file

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 23, 2005 at 02:12 PM
    • Here get the file name from the file path/name

    call function 'SO_SPLIT_FILE_AND_PATH'

    exporting

    full_name = l_file-low

    importing

    stripped_name = stripped

    file_path = file_path.

    • Use the file name as your file name on the app server

    • I am assuming that in_File already has the file path to

    • the app server here, just take the file path of app

    • server and the file name from presentation and

    • put them together.

    <b>clear in_file.</b>

    clear new_file_name.

    concatenate in_file stripped into new_file_name.

    open dataset new_file_name for output in text mode.

    loop at t_itab.

    transfer t_itab to <b>new_file_name</b> .

    endloop.

    if sy-subrc eq 0.

    write:/ 'success'.

    endif.

    close dataset in_file.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded