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

Reading the document name.

Former Member
0 Likes
876

Hi all,

I have a requirement where in a number of documents (.doc,pdf,xls,txt...etc) are placed in a fixed folder in C drive .

i have to upload these documents to application server.

The problem here is how to read the file names with file type through a normal report program.

Help me plz .....

thanks in advance.

1 ACCEPTED SOLUTION
Read only

former_member404244
Active Contributor
0 Likes
836

Hi,

Use CG3Z transaction code to uplaod ur files to application server.

Regards,

Nagaraj

8 REPLIES 8
Read only

Former Member
0 Likes
836

Hi,,

You can upload XLS USING

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

PDF

CALL FUNCTION 'TEXT_CONVERT_PDF_TO_SAP'

TXT

CALL FUNCTION 'GUI_UPLOAD'

Thanks

Arun Kayal

Read only

former_member404244
Active Contributor
0 Likes
837

Hi,

Use CG3Z transaction code to uplaod ur files to application server.

Regards,

Nagaraj

Read only

0 Likes
836

hi nagaraj,

thanks for ur timely reply.

As u said we can upload the files using CG3Z , yes we can

but the problem here is i donno the file names which are to be uploaded

Read only

0 Likes
836

Use Class CL_GUI_FRONTEND_SERVICES

Methods DIRECTORY_LIST_FILES to get file attributes

data: v_dir_path type string.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

EXPORTING

DIRECTORY = v_dir_path

  • FILTER = '.'

  • FILES_ONLY =

  • DIRECTORIES_ONLY =

CHANGING

FILE_TABLE = v_files

COUNT = v_count

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • DIRECTORY_LIST_FILES_FAILED = 2

  • WRONG_PARAMETER = 3

  • ERROR_NO_GUI = 4

  • NOT_SUPPORTED_BY_GUI = 5

  • others = 6

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

Read only

Former Member
0 Likes
836

HI BRO....

for TXT/BIN use

CALL FUNCTION 'GUI_UPLOAD'

for PDF use

CALL FUNCTION 'TEXT_CONVERT_PDF_TO_SAP'

for XLS use

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

REGARDS.

Read only

Former Member
0 Likes
836

hi,

FM text_convert_xls_sap. for excel sheet

FM gui_upload for text file

example code

OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

LOOP AT t_bkpf INTO fs_bkpf.

CONCATENATE fs_bkpf-bukrs

fs_bkpf-belnr

fs_bkpf-gjahr

fs_bkpf-blart

fs_bkpf-bldat

INTO line

SEPARATED BY space

IN CHARACTER MODE .

TRANSFER line TO w_file.

CLEAR line.

ENDLOOP.

This way a file from presentation server can be uploaded to application server

Read only

Former Member
0 Likes
836

Hi,

Read the length of the string first as shown below

data : v type i,

abc1 type c.

parameter : p_abc like filetype.

v = strlen(p_abc).

v = v - 3.

abc = p_abc+v(3).

translate abc in uppercase.

if abc = 'XLS'

use the excel reading function module.

elseif abc = 'PDF'.

use the respective function modules.

etc.

Regards,

Naresh

Read only

Subhankar
Active Contributor
0 Likes
836

Hi ,

You can do it from the transaction CG3Z or CG3Y.