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

Archiving Files

former_member382811
Participant
0 Likes
1,376

Hi Experts,

My Requirement is created one folder in that folders created 5 more folder, 4 folders related to Module wise folders and one more folder is for Archiving purpose up to this done folders.Every day files are placed by client or users each and every folder,so at the end of the day i have to move or archiving files from 4 folders into 1 archive folder background.Please suggest me how to do.i have to develop abap code or by using file archiving concept.

1 folder---->\DIR_XXX\MAINFOLDER\MM\XXXXX.csv

2 Floder---->\DIR_XXX\MAINFOLDER\SD\XXXXXX.csv

         |

         |

5 Floder---->\DIR_XXX\MAINFOLDER\ARCHIVE

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,214

In case you wish to create in the application server then you can try this code

DATA: l_com TYPE rlgrap-filename,
       directory LIKE  BTCH0000-TEXT80.

directory = 'DIR_MAIN\MAIN_FOLDER\SD_DIR'.

CALL FUNCTION 'PFL_CHECK_DIRECTORY'
    EXPORTING
      directory         = directory
    EXCEPTIONS
      pfl_dir_not_exist = 1.

IF sy-subrc = 1.
    CONCATENATE 'cmd /c mkdir' directory INTO l_com SEPARATED BY space.
    CALL 'SYSTEM' ID 'COMMAND' FIELD l_com.
ENDIF.


A folder is created in Windows SAP Server c:\usr\sap\YAS\DVEBMGS00\work\DIR_MAIN\MAIN_FOLDER\SD_DIR

6 REPLIES 6
Read only

Former Member
0 Likes
1,214

Hi Venu,

Where do you wanted to create folders?

On the application server or user system

Read only

Former Member
0 Likes
1,215

In case you wish to create in the application server then you can try this code

DATA: l_com TYPE rlgrap-filename,
       directory LIKE  BTCH0000-TEXT80.

directory = 'DIR_MAIN\MAIN_FOLDER\SD_DIR'.

CALL FUNCTION 'PFL_CHECK_DIRECTORY'
    EXPORTING
      directory         = directory
    EXCEPTIONS
      pfl_dir_not_exist = 1.

IF sy-subrc = 1.
    CONCATENATE 'cmd /c mkdir' directory INTO l_com SEPARATED BY space.
    CALL 'SYSTEM' ID 'COMMAND' FIELD l_com.
ENDIF.


A folder is created in Windows SAP Server c:\usr\sap\YAS\DVEBMGS00\work\DIR_MAIN\MAIN_FOLDER\SD_DIR

Read only

0 Likes
1,214

Hi Abdul,

yes folders are created by basiss  that was linked to AL11 means Application server,now question is we specified one folder for Archiving(this is also linked to Application server) means old files or Already processed files,those files we need to move to Archiving folder.So end of the day this process will be done by background.So How can i do this.

Read only

0 Likes
1,214

Hi You need to create a custom utility program with usage of FM 'SXPG_CALL_SYSTEM' to call unix command MV for the same.

Related Transaction code is : SM69

Thanks!

Anil Sahni

Read only

0 Likes
1,214

Hi Anil,

Yes by using possible to run External commands.operating system is Windows can you suggest how to move file from 1folder to another and how to create OS Command in SM69.i tried OS Command like Move command with Parameters for Operating System Command.can you suugest how to do and not only one file 4floders files move to one Archive folder every end of the day..

Read only

0 Likes
1,214

Hi,

Give a custom command name like : ZMV

Assign External command: MV

Select additional parameters allowed.

You need to assign op.system as well.

Before calling   SXPG_CALL_SYSTEM.

CONCATENATE  lv_source " Source Path

                lv_destination       " Destination Path

                INTO lv_parameters SEPARATED BY space.

Then Pass lv_parameters to FM SXPG_CALL_SYSTEM as in  additional_parameters with Command.


something like below..


CALL FUNCTION 'SXPG_CALL_SYSTEM'

     EXPORTING

       commandname                      = 'ZMV'

       additional_parameters            = lv_parameters

Thanks!

Anil Sahni