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: 

Reg Function Module

Former Member
0 Kudos

Hi all,

Can any one tell me what Function Module is used to rename the existing file name (excel,csv or txt file) on presentation server?

Regards,

Shalini

3 REPLIES 3

Former Member
0 Kudos

Hi,

Try this FM - KCD_CSV_FILE_TO_INTERN_CONVERT

or

call function 'SAP_CONVERT_TO_TEX_FORMAT'

exporting

i_field_seperator = ','

tables

i_tab_sap_data = itab

changing

i_tab_converted_data = itab1.

search path for '.CSV'.

if sy-subrc eq 0.

call function 'WS_DOWNLOAD'

exporting

filename = path

tables

data_tab = itab1.

else.

message e016(z4).

endif.

Just follow below logic in your custom report ;

1. Call SAP standard Report which return .xls file,

2. Download it on local presentation server internally (ws_download) on fix file path,

3. Call SAP std FM - 'SAP_CONVERT_TO_TEX_FORMAT' as describe and download it on fixed path on presentation server,

4. Upload file for second report from step no. 3.

regards

JozsefSzikszai
Active Contributor
0 Kudos

hi Shalini,

I think you have to do in two steps. First call method FILE_COPY (to make a copy with the new name) than FILE_DELETE (to delete the original). Both are in class CL_GUI_FRONTEND_SERVICES.

hope this helps

ec

Former Member
0 Kudos

refer this INDEPENDENT SUBROUTINE (FORM)

in which we pass

a) old file name

b) new file name

and it will rename the file

(This will work in WINDOWS Operating system)

(we can modify it very little for other OS also_

2. just copy paste in new program.

3.

Report abc.

*----


PERFORM MYRENAME USING 'D:\CCC.TXT' 'DDD.TXT'.

*----


  • FORM

*----


form myrename USING oldfile newfile.

data : pm(200) type c.

concatenate '/C REN ' oldfile newfile

INTO PM separated by space.

CALL FUNCTION 'GUI_RUN'

EXPORTING

COMMAND = 'CMD'

PARAMETER = pm

  • CD =

  • IMPORTING

  • RETURNCODE =

.

endform. "myrename

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

you can rename the File in this way also...

REPORT ZTEST_RENAME .

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_COPY

EXPORTING

SOURCE = 'C:\Test.txt'

DESTINATION = 'C:\Test_CP.txt'

OVERWRITE = SPACE

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

DISK_FULL = 4

ACCESS_DENIED = 5

FILE_NOT_FOUND = 6

DESTINATION_EXISTS = 7

UNKNOWN_ERROR = 8

PATH_NOT_FOUND = 9

DISK_WRITE_PROTECT = 10

DRIVE_NOT_READY = 11

NOT_SUPPORTED_BY_GUI = 12

others = 13

.

IF SY-SUBRC = 0.

data: rc type i.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE

EXPORTING

FILENAME = 'C:\Test.txt'

CHANGING

RC = rc

EXCEPTIONS

FILE_DELETE_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

FILE_NOT_FOUND = 4

ACCESS_DENIED = 5

UNKNOWN_ERROR = 6

NOT_SUPPORTED_BY_GUI = 7

WRONG_PARAMETER = 8

others = 9

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDIF.

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

Regards

vasu