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: 

How to store files in shared-folder in background mode

former_member652338
Participant

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

14 REPLIES 14

former_member187748
Active Contributor
0 Kudos

Hi Tousif,

can you please share your code, only relevant code.

0 Kudos

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,



0 Kudos

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

0 Kudos

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

0 Kudos

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,

0 Kudos

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,

0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

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,

0 Kudos

your path to the file is incorrect. Maintain in AL11 as suggested by others

sivaganesh_krishnan
Contributor
0 Kudos

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

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2...

Regards,

Sivaganesh

former_member289261
Active Contributor
0 Kudos

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

former_member652338
Participant
0 Kudos

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

0 Kudos

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