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: 

function module to move a file from a directory to directory in application server.

Former Member
0 Kudos

Hi ,

  I am trying to move a file from one location to another location on the application server. I have used FM ' ARCHIVFILE_SERVER_TO_SERVER' which is actually copying the file but not moving.

then I have tried using external commands in Windows NT.

SM49 :

Command name              ZMV

Operating system          WINDOWS NT

Operating system command CMD

Parameters for operating system command  /C MOVE E:\sapio\import\psp e:\sapio\import\psp\archive

and using FM :

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

   EXPORTING

     commandname                        = 'ZMV'

     additional_parameters              = l_para

IMPORTING

   status                              = l_stat

but it is giving an error message saying command not found.  I do not want to use OPEN DATASET concept.

would you please help me?

Murali

1 ACCEPTED SOLUTION

custodio_deoliveira
Active Contributor
0 Kudos

Hi Murali,

After the file is copied with FM ARCHIVFILE_SERVER_TO_SERVER, can't you just delete it? (delete dataset)

Regards,

Custodio

5 REPLIES 5

custodio_deoliveira
Active Contributor
0 Kudos

Hi Murali,

After the file is copied with FM ARCHIVFILE_SERVER_TO_SERVER, can't you just delete it? (delete dataset)

Regards,

Custodio

0 Kudos

Hi Custodio,

  Thank you for your reply ,I can delete using delete dataset. but how can we use external commands ?

Murali

0 Kudos

Hi,

I am using DELETE DATASET and this statement is working fine in Development and not in Quality ( Sy-subrc = 4) . do we require to use OPEN DATASET before DELETE DATASET? I am not sure about this, but I have used the OPEN DATASET statement  and strangely it is working in Developement and not in Quality ( SY-SUBRC = 😎 .  But authorization check was successful in both the systems.  any idea why it is happening?

Code:

OPEN DATASET SOURCE_PATH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. – giving sy-subrc value ‘0’ in TRD and ‘8’ in TRQ.

CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
PROGRAM                = sy-repid
ACTIVITY              
= SABC_ACT_DELETE
FILENAME              
= LV_AUTHFILE
EXCEPTIONS
NO_AUTHORITY          
= 1
ACTIVITY_UNKNOWN      
= 2
*           OTHERS                 = 3
.
IF SY-SUBRC = 1. – Authorization check is successful in both the systems.
* Implement suitable error handling here

MESSAGE E011(ZBRIM) with WA_FILES-NAME RAISING NO_AUTHORITY.

ENDIF.

Murali

0 Kudos

Hi, you can try system function calls.

This way you can call OS commands.

PARAMETERS: command TYPE string LOWER CASE.

DATA: commtext(120) ,
itab(255) OCCURS 10 WITH HEADER LINE.
commtext = command.
CALL 'SYSTEM' ID 'COMMAND' FIELD commtext ID 'TAB' FIELD itab[].
LOOP AT itab.
      WRITE itab.
ENDLOOP

Former Member
0 Kudos

Pl check in SM49 if your command has Op System as WINDOWS NT or Windows NT. If it is the 2 one change the same to all caps and try again.