05-21-2014 6:19 AM
Hello All,
My requirement seems to be simple but I have tried many ways in achieving this, but failed. So require the help in accomplishing this task.
Requirement
I have to create a program in SE38 which will create a internal table with data in it in .XML format(which I can achieve).
My requirement is this .XML file needs to be placed in a shared-folder in "BACKGROUND MODE".
I have tried using GUI_DOWNLOAD function module, but this FM only runs in Foreground mode and fails in Background mode. I have tried convincing my client that I will keep the file in Application Server as it is achievable using OPEN DATASET statements, but they are not willing to accept this.
So can you please help me in achieving this task as I am not getting any solution how to keep the file in Shared-folder in BACKGROUND mode itself(not Foreground).
Best Regards,
Tousif
05-21-2014 6:26 AM
05-21-2014 6:46 AM
Hi Sanjeev,
I have just used normal GUI_DOWNLOAD FM. Please find my sample code below
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'D:\Users\baigtomx\Desktop\TOUSIF.XML'
* FILETYPE = 'ASC'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = lt_wo
* FIELDNAMES =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
When I run this program in foreground mode, the file gets saved(here in the above example I have just used my desktop path. but the actual requirement is to store file in shared-folder i-e Network Drive).
But when i run the same program in background mode, No file is getting stored.
Regards,
05-21-2014 7:04 AM
Hi Tousif,
please uncomment the file type and also uncomment the exceptions, and see is it working
or not, or atleast see is it giving any errors, then please revert with your answer.
EXPORTING
* BIN_FILESIZE =
filename = 'D:\Users\baigtomx\Desktop\TOUSIF.XML'
FILETYPE = 'ASC'
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
05-21-2014 7:04 AM
Hi Tousif,
Few months back i was looking for the same in SCN and saw few suggestions like
1) Linking your Network Drive as a path in AL11 transaction
2) After which you can save the files in Application Server to the corresponding path
3) And the files get save in the Network Drive.
Try this with the help of your BASIS team for linking the Network Drive to your Application Server and using the OPEN DATASET.
Regards,
AyyamPerumal
05-21-2014 7:12 AM
Hi Sanjeev,
I have tried your above suggestions but unfortunately it does not work.
It does not give any error while running the file in background mode. When I go and check it sm37, it simply says that job is successful, but when i saw the file path, the file does not get stored here.
Regards,
05-21-2014 7:15 AM
Hi Ayyam,
Thanks for your suggestion. But can you please tell me if this was achieved by you. I mean were your BASIS team able to map the Network Drive to the AL11 transaction?
Regards,
05-21-2014 7:32 AM
Hi Tousif,
No i haven't tried that as i was looking out of my own interest.
And the above were the suggestions that were opted and shared to you.
Regards,
Ayyamperumal
05-21-2014 7:14 AM
1. GUI_DOWNLOAD has "GUI" in it's name. Of course there is no GUI / client when run in background. Even if there was any, download means transfer SAP => CLIENT.
2. what is the shared folder - transaction SBWP? If so, you are not uploading files to any place in the application server, rather you are using (in most cases suitable) sap office documents uploaded to the specific place.
You can try using FM SO_FOLDER_ROOT_ID_GET - for a particular user this returns ID of the folder, which belongs to the "shared folder" folder in SBWP. Then you can play around with FM SO_DOCUMENT_INSERT of the binary / hex data to the specific folder (parameter parent_id specifies, where to put the file). So probably here is your first problem - you want to upload the files in background, which means first generating it (I suppose you have already the .xml data).
3. if shared folder is something on the network (not SBWP shared folder), once you have got mapped the folder and enough authorization, you can upload it using OPEN DATASET... In this case searching for solution should be your first step.
05-21-2014 7:21 AM
Hi Jozef,
Shared-folder I meant for is Network Drive. Like its a common drive which can be accessed across all the client location's system by everyone whoever has the access to it.
It is just like a hard disk drive, but will be available and accessible to all.
And I have tried using Open Dataset statements to save the files in the Network drive, but the Open Dataset statement itself gives me sy-subrc = 4.
So if you have achieved this scenario earlier, can you share your code. It would be very helpful.
Regards,
05-21-2014 8:39 AM
your path to the file is incorrect. Maintain in AL11 as suggested by others
05-21-2014 7:20 AM
Hi Tousif,
A file can be saved on desktop/presentation server only when the program is run in foreground using GUI_Download.
Are you try to download a file to desktop in background job ?
If your answer is yes .. please check the below link
Regards,
Sivaganesh
05-21-2014 8:17 AM
Hi,
Ayyam has provided the correct solution above.
You need to configure the network folder to SAP system using T-Code AL11.
After which you can use DATASET statement normally for the folder.
Regards,
Ashish
06-05-2014 8:58 AM
Hi Everyone,
I have had a big discussion with my BASIS team on it and the solution for this is to Place the files in Application server itself. These files will be then extracted from the Application server to the Network Drive through a small Unix program(written by the Unix team).
So in this case the files which will be stored in Application server will get physically present in Network Drive.
Best Regards,
Tousif
07-28-2020 1:12 PM
Hi Tousif,
I am having the same issue. So can you please let me know the procedure you have used to resolve your problem.
Regards,
Ravivarman P