Skip to Content
0

Data Services Script to move excel file

Nov 02, 2016 at 05:09 PM

321

avatar image
Former Member

Hi All,

I'm new to Data Services and need some help in creating a script that will sit at the end of a workflow which will move an excel file (.xls) from one folder location to an archive folder. The file move needs to complete so that when the workflow is executed the following day, the dataflow before the script picks up the new file (hence the wildcard * in the file name)


exec('cmd.exe','Move \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Daily CDN Export*.xls \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Archive',1);

The workflow validates and executes but I get error 50306.

I don't want to go down the route of creating a .bat file on the server

Kind Regards
Wardie

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Dirk Venken
Dec 08, 2016 at 10:25 AM
1

You don't need a script. Simply use the file_move built-in fundtion. From the SAP Data Services Reference Guide:

"

Moves an existing file to a different location using the same file name or a different file name. Moves a group of files indicated by a wildcard to a different existing directory. Overwrites any existing target file(s) when overwrite flag is set to 1. Original file does not exist in the original location after file_move.

"

There are a couple of examples in that guide, too.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 03, 2016 at 04:57 AM
0

try this

exec('cmd','Move \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Daily CDN Export*.xls \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Archive');

Thanks

Murali

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the input Murali put unfortunately your suggestion didn't work.

The exec function requires a Flag integer at the end of the statement. I've also tried the Flag integer 8 which does validate and states that its run successfully but it hasn't moved the file at all. The Flag integer 8 basically overrides an error code if ones occurred or not

0
avatar image
Former Member Nov 04, 2016 at 04:54 AM
0

Hi Gavin,

with out flat we can move file from one location to another location,I have been implemented in my job and successfully moved file. try with print function using flag

print(exec('cmd','Move \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Daily CDN Export*.xls \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Archive',8));

Hope it should be work and if it get's error, the error will be print.

Thanks,Murali

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 07, 2016 at 11:33 PM
0

Has anyone successfully setup a file move script before? If so, could you send me step by step instructions with screenshots please?

Your help would be much appreciated

Kind Regards

Wardie

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Below shell script should help.

$Variable = exec('sh',' -c "mv <FilePath>/<FileName> <ArchicePath>"',8);

0
avatar image
Former Member Feb 27, 2017 at 09:49 AM
0

TRy exec('cmd','Move \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Daily CDN Export*.xls \\FAS2050N1\Groups\Reports\Business Intelligence\Excel Based Feeds\AACC\Warehouse Feed\Archive',8) should work..

Share
10 |10000 characters needed characters left characters exceeded