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

moving files across folder in application server

Former Member
0 Likes
3,649

Hi to all experts,

My requirement is to move file between folders in the application server .i'm using the fm sxpg_command_execute . the problem im facing here the file move sometimes and it doesnt move sometimes . what could be the problem..

*&---------------------------------------------------------------------*
*&      Form  process_file_on_server
*&---------------------------------------------------------------------*

form process_file_on_server .

DATA: filename(128) TYPE c.
   DATA: param LIKE sxpgcolist-parameters.

CASE sy-sysid.
  WHEN 'BO1'.
    p_arc = 'k:\\Share\MM_SCUBCode_PDAtxt_Archive'.
  WHEN 'BQ1'.
    p_arc = 'K:\\Share\MM_SCUBCode_PDAtxt_Archive'.
  WHEN OTHERS.
ENDCASE.

  CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
      full_name           = p_file
   IMPORTING
     STRIPPED_NAME       = filename
*     FILE_PATH           =
   EXCEPTIONS
     X_ERROR             = 1
     OTHERS              = 2
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
CONCATENATE p_arc filename INTO p_arc SEPARATED BY '\'.
CONCATENATE p_file p_arc INTO param SEPARATED BY space.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                         = 'ZMOVE'
   ADDITIONAL_PARAMETERS               =  param
*   OPERATINGSYSTEM                     = SY-OPSYS
*   TARGETSYSTEM                        = SY-HOST
*   DESTINATION                         =
*   STDOUT                              = 'X'
*   STDERR                              = 'X'
*   TERMINATIONWAIT                     = 'X'
*   TRACE                               =
*   DIALOG                              =
* IMPORTING
*   STATUS                              =
*   EXITCODE                            =
* TABLES
*   EXEC_PROTOCOL                       =
 EXCEPTIONS
   NO_PERMISSION                       = 1
   COMMAND_NOT_FOUND                   = 2
   PARAMETERS_TOO_LONG                 = 3
   SECURITY_RISK                       = 4
   WRONG_CHECK_CALL_INTERFACE          = 5
   PROGRAM_START_ERROR                 = 6
   PROGRAM_TERMINATION_ERROR           = 7
   X_ERROR                             = 8
   PARAMETER_EXPECTED                  = 9
   TOO_MANY_PARAMETERS                 = 10
   ILLEGAL_COMMAND                     = 11
   WRONG_ASYNCHRONOUS_PARAMETERS       = 12
   CANT_ENQ_TBTCO_ENTRY                = 13
   JOBCOUNT_GENERATION_ERROR           = 14
   OTHERS                              = 15
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear filename .
endform.                    " process_file_on_server

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,889

Hi Mohammed,

Could be due to authorization problem?

We did ever had this problem before in one of the project and we finally found out that the problem is the OS system user ID did have enough authorization those selected folders or directories.

Regards,

Lim...

Hi Mohammed,

Could be due to authorization problem?

We did ever had this problem before in one of the project and we finally found out that the problem is the OS system user ID did have enough authorization those selected folders or directories.

Regards,

Lim...

8 REPLIES 8
Read only

mvoros
Active Contributor
0 Likes
1,889

Hi,

why don't you uncomment messages in your program. You don't care about exceptions from FM and you also ignore status and exit code returned by FM. Maybe it will tell you why it failed. And one quick guess, don't you have spaces in the name of the files? If yes, then you give more parameters to that command.

Cheers

Read only

Former Member
0 Likes
1,889

Hi Martin,

I really appreciate your help. yes im having difficulty in moving application server file with space . Please can help me in adding more parameters to the files

Read only

Former Member
0 Likes
1,889

Hi,

PLEASE try this code ---

*&---------------------------------------------------------------------*
*&      Form  process_file_on_server
*&---------------------------------------------------------------------*
 
*form process_file_on_server .
 
DATA: filename(128) TYPE c.
   DATA: param LIKE sxpgcolist-parameters.
 
CASE sy-sysid.
  WHEN 'BO1'.
    p_arc = 'k:\\Share\MM_SCUBCode_PDAtxt_Archive'.
  WHEN 'BQ1'.
    p_arc = 'K:\\Share\MM_SCUBCode_PDAtxt_Archive'.
  WHEN OTHERS.
ENDCASE.                            " CASE SY-SYSID
 DO.                                      " Changed          
  CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
      full_name           = p_file
   IMPORTING
     STRIPPED_NAME       = filename
*     FILE_PATH           =
   EXCEPTIONS
     X_ERROR             = 1
     OTHERS              = 2
            .
  IF sy-subrc NE  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.          " IF SY-SUBRC NE 0
CONCATENATE p_arc filename INTO p_arc SEPARATED BY '\'.
CONCATENATE p_file p_arc INTO param SEPARATED BY space.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                         = 'ZMOVE'
   ADDITIONAL_PARAMETERS               =  param
*   OPERATINGSYSTEM                     = SY-OPSYS
*   TARGETSYSTEM                        = SY-HOST
*   DESTINATION                         =
*   STDOUT                              = 'X'
*   STDERR                              = 'X'
*   TERMINATIONWAIT                     = 'X'
*   TRACE                               =
*   DIALOG                              =
* IMPORTING
*   STATUS                              =
*   EXITCODE                            =
* TABLES
*   EXEC_PROTOCOL                       =
 EXCEPTIONS
   NO_PERMISSION                       = 1
   COMMAND_NOT_FOUND                   = 2
   PARAMETERS_TOO_LONG                 = 3
   SECURITY_RISK                       = 4
   WRONG_CHECK_CALL_INTERFACE          = 5
   PROGRAM_START_ERROR                 = 6
   PROGRAM_TERMINATION_ERROR           = 7
   X_ERROR                             = 8
   PARAMETER_EXPECTED                  = 9
   TOO_MANY_PARAMETERS                 = 10
   ILLEGAL_COMMAND                     = 11
   WRONG_ASYNCHRONOUS_PARAMETERS       = 12
   CANT_ENQ_TBTCO_ENTRY                = 13
   JOBCOUNT_GENERATION_ERROR           = 14
   OTHERS                              = 15
          .
IF sy-subrc = 0.                              " CHANGE
STOP.                                           " CHANGE
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear filename .
endform.                    " process_file_on_server
ENDDO.                    " CHANGE

Regards

Pinaki

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,889

Hi,

Refer this link, it will definitely help you.

tranfer file between folder in application server

https://www.sdn.sap.com/irj/scn/wiki?path=/display/community/transfer%252bfile%252bbetween%252bfolde...

Regards,

Tarun

Read only

Former Member
0 Likes
1,890

Hi Mohammed,

Could be due to authorization problem?

We did ever had this problem before in one of the project and we finally found out that the problem is the OS system user ID did have enough authorization those selected folders or directories.

Regards,

Lim...

Read only

0 Likes
1,889

Hi Chang.

thanks for your reply it is authorization problem operating system command which we are using in the function module sxpg_command_execute

Read only

Former Member
0 Likes
1,889

Hi,

I have the same requirement here. Is the command name "ZMOVE" used to trigger script?

Is there any other ways to move the file without triggering script?

Read only

0 Likes
1,889

no zmove is not to trigger script .It is OS command.