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: 

uploading files from desktop to internal table

Former Member
0 Kudos

hi all,

i have to upload 4-5 text files from folder placed in my desktop into internal table so that i can send those files through attachment.

please guide me how to proceed further.

5 REPLIES 5

former_member223537
Active Contributor
0 Kudos

Hi,

Create a report program and use FM "GUI_UPLOAD" for uploading each file.

Best regards,

Prashant

amit_khare
Active Contributor
0 Kudos

You cannot call all the files at once.

Use GUI_UPLOAD as many time required.

Regards,

Amit

Reward all helpful replies.

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Use FM: <b>GUI_UPLOAD</b>

as many time you have as many file.

Regards,

Sree

0 Kudos

but i have to upload files according to search createria from folder.

Former Member
0 Kudos

Hi Manish ,

Just Used This Program and tell whether it is working or not , Also i am give the Flat file below.

REPORT ZN_gui_upload.

DATA : xfile TYPE string.

DATA : BEGIN OF record OCCURS 0,

empno(4),

first(10),

last(10),

qual(6),

desg(10),

place(15),

comp(15),

END OF record.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-000.

SELECTION-SCREEN SKIP 1.

PARAMETERS : pfile TYPE rlgrap-filename OBLIGATORY.

  • DATA: ptype TYPE STRING.

SELECTION-SCREEN END OF BLOCK blk1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PFILE.

PERFORM get_file.

START-OF-SELECTION.

MOVE pfile TO xfile.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = xfile

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = record

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17 .

IF sy-subrc <> 0.

WRITE : ' fm not executed successfully ! '.

ELSE.

LOOP AT record .

WRITE: / sy-vline,

record-empno , sy-vline,

record-first, sy-vline,

record-last, sy-vline,

record-qual, sy-vline,

record-desg, sy-vline,

record-place, sy-vline,

record-comp, sy-vline.

ENDLOOP.

ENDIF.

&----


*& Form get_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_file .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

  • EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

file_name = pfile

  • EXCEPTIONS

  • MASK_TOO_LONG = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

WRITE : ' fm not executed successfully ! '.

ENDIF.

FLAT FILE IN NOTEPAD.

1001 KAYA SHARMA BE P1 MUMBAI IBM

1002 DEEYA VARMA BE P2 DELHI BG

1003 DEEPA SINGH BE P1 CHENNAI CGI

1004 SMITA KAUR BE P2 AGRA DHL

1005 RAVI RAO BE P1 NAGPUR SATYAM

1006 KEDAR RAUT BE P2 MUMBAI INFY

1007 RAMA ROY BE P1 DELHI WIPRO

1008 KRISHNA JOSHI BE P2 CHENNAI PATNI

1009 SHIVA DOSHI BE P1 AGRA SIEMENS

1010 NEHA PANDEY BE P2 NAGPUR CGI

Regards,

Nihar Swain.