How to download the data in excel format directly while executing in background mode? 
If you will execute it in bacground with ws_download or download, it will be aoutomatically cancel. so what is the procedure to do this.  How is can directly read the spool from program?
 
Download from background is possible, if you could setup the environment
1. create a custom table first
    Table  : Z001
    Displayed fields:   4 of   4  Fixed columns:
       MANDT BNAME       Y_SITE    Y_PATH
       010      <userid>     <site>      cd <novell_path>
2. rewrite ws_download to z_download (light modification required, see attachment)
3. ask your basis team to make a copy of command FTP and CHMOD to ZFTP and ZCHMOD resp., make the setting according to your environment.
    1  *-----------------------------------------------------------------------
    2  * Changed By : 
    3  * Changed On : 
    4  * Changed    : NOVELL directory path based on SAP login id.
    5  *-----------------------------------------------------------------------
    6  TABLES: Y001.                                            
    7
    8  CONSTANTS: C_PATH(14) VALUE '/home/ftpuser/'.
    9
   10  DATA: BEGIN OF C_TAB,
   11          X(1) TYPE X VALUE '09',
   12        END OF C_TAB.
   13
   14  DATA: BUFFER(8000),
   15        FIELDNAME_OFFSET TYPE I,
   16  *     FULLPATH(128),
   17        FULLPATH LIKE SXPGCOLIST-PARAMETERS,
   18  *     CMDFULLPATH(128),
   19        CMDFULLPATH LIKE SXPGCOLIST-PARAMETERS,
   20        CMD(40),
   21        IBTCXPM LIKE BTCXPM OCCURS 0.
   22
   23  FUNCTION Z_DOWNLOAD.
   24  *"----------------------------------------------------------------------
   25  *"*"Local interface:
   26  *"  IMPORTING
   27  *"     VALUE(FILENAME)
   28  *"     VALUE(LOCATION)
   29  *"  TABLES
   30  *"      DATA_TAB
   31  *"      FIELDNAMES OPTIONAL
   32  *"----------------------------------------------------------------------
   33
   34    DATA: WS_LINE TYPE I.
   35
   36    FIELD-SYMBOLS: <F>.
   37
   38    CHECK NOT FILENAME IS INITIAL.
   39
   40    CONCATENATE C_PATH FILENAME INTO FULLPATH.
   41    OPEN DATASET FULLPATH IN TEXT MODE FOR OUTPUT.
   42
   43    DESCRIBE TABLE FIELDNAMES LINES WS_LINE.
   44    IF WS_LINE NE 0.
   45      PERFORM FIELDNAMES_2_BUFFER TABLES FIELDNAMES CHANGING BUFFER.
   46      FIELDNAME_OFFSET = STRLEN( BUFFER ).
   47      TRANSFER BUFFER TO FULLPATH LENGTH FIELDNAME_OFFSET.
   48    ENDIF.
   49
   50    LOOP AT DATA_TAB.
   51      CLEAR BUFFER.
   52      CLEAR FIELDNAME_OFFSET.
   53      DO.
   54        ASSIGN COMPONENT SY-INDEX OF STRUCTURE DATA_TAB TO <F>.
   55        IF SY-SUBRC NE 0.  EXIT.  ENDIF.
   56        WRITE <F> TO BUFFER+FIELDNAME_OFFSET.
   57        CONDENSE BUFFER.
   58        FIELDNAME_OFFSET = STRLEN( BUFFER ).
   59        WRITE C_TAB TO BUFFER+FIELDNAME_OFFSET(1).
   60        ADD 1 TO FIELDNAME_OFFSET.
   61      ENDDO.
   62      TRANSFER BUFFER TO FULLPATH LENGTH FIELDNAME_OFFSET.
   63    ENDLOOP.
   64
   65    CLOSE DATASET FULLPATH.
   66
   67    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
   68         EXPORTING
   69              COMMANDNAME                   = 'ZCHMOD'
   70              ADDITIONAL_PARAMETERS         = FULLPATH
   71         TABLES
   72              EXEC_PROTOCOL                 = IBTCXPM
   73         EXCEPTIONS
   74              NO_PERMISSION                 = 1
   75              COMMAND_NOT_FOUND             = 2
   76              PARAMETERS_TOO_LONG           = 3
   77              SECURITY_RISK                 = 4
   78              WRONG_CHECK_CALL_INTERFACE    = 5
   79              PROGRAM_START_ERROR           = 6
   80              PROGRAM_TERMINATION_ERROR     = 7
   81              X_ERROR                       = 8
   82              PARAMETER_EXPECTED            = 9
   83              TOO_MANY_PARAMETERS           = 10
   84              ILLEGAL_COMMAND               = 11
   85              WRONG_ASYNCHRONOUS_PARAMETERS = 12
   86              CANT_ENQ_TBTCO_ENTRY          = 13
   87              JOBCOUNT_GENERATION_ERROR     = 14
   88              OTHERS                        = 15.
   89
   90    CONCATENATE C_PATH FILENAME '_cmd' INTO CMDFULLPATH.
   91    OPEN DATASET CMDFULLPATH IN TEXT MODE FOR OUTPUT.
   92    CASE LOCATION.     "location A, B, C, D on a network
   93      WHEN 'A  '.
   94  
   95        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.         
   96        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.       
   97      WHEN 'B  '.                                            
   98        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.         
   99        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.     
  100      when 'C  '.
  101        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.
  102        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.
  103      when 'D  '.
  104        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.
  105        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.
  106      WHEN OTHERS.
  107    ENDCASE.
  108 
  109 
  110 
  111 
  112  *start>
  113    CLEAR Y001.
  114    SELECT SINGLE Y_PATH INTO Y001-Y_PATH
  115                         FROM Y001 WHERE BNAME = SY-UNAME
  116                                     AND Y_SITE = LOCATION.   
  117    TRANSFER Y001-Y_PATH TO CMDFULLPATH.
  118  *<end
  119    CONCATENATE 'lcd' C_PATH INTO CMD SEPARATED BY SPACE.
  120    TRANSFER CMD TO CMDFULLPATH.
  121    CLEAR CMD.
  122    CONCATENATE 'put' FILENAME INTO CMD SEPARATED BY SPACE.
  123    TRANSFER CMD TO CMDFULLPATH.
  124    TRANSFER 'bye' TO CMDFULLPATH.
  125    CLOSE DATASET CMDFULLPATH.
  126
  127    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  128         EXPORTING
  129              COMMANDNAME                   = 'ZCHMOD'
  130              ADDITIONAL_PARAMETERS         = CMDFULLPATH
  131         TABLES
  132              EXEC_PROTOCOL                 = IBTCXPM
  133         EXCEPTIONS
  134              NO_PERMISSION                 = 1
  135              COMMAND_NOT_FOUND             = 2
  136              PARAMETERS_TOO_LONG           = 3
  137              SECURITY_RISK                 = 4
  138              WRONG_CHECK_CALL_INTERFACE    = 5
  139              PROGRAM_START_ERROR           = 6
  140              PROGRAM_TERMINATION_ERROR     = 7
  141              X_ERROR                       = 8
  142              PARAMETER_EXPECTED            = 9
  143              TOO_MANY_PARAMETERS           = 10
  144              ILLEGAL_COMMAND               = 11
  145              WRONG_ASYNCHRONOUS_PARAMETERS = 12
  146              CANT_ENQ_TBTCO_ENTRY          = 13
  147              JOBCOUNT_GENERATION_ERROR     = 14
  148              OTHERS                        = 15.
  149
  150    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  151         EXPORTING
  152              COMMANDNAME                   = 'ZFTP'
  153  **          commandname                   = 'ZFTP'
  154              ADDITIONAL_PARAMETERS         = CMDFULLPATH
  155         TABLES
  156              EXEC_PROTOCOL                 = IBTCXPM
  157         EXCEPTIONS
  158              NO_PERMISSION                 = 1
  159              COMMAND_NOT_FOUND             = 2
  160              PARAMETERS_TOO_LONG           = 3
  161              SECURITY_RISK                 = 4
  162              WRONG_CHECK_CALL_INTERFACE    = 5
  163              PROGRAM_START_ERROR           = 6
  164              PROGRAM_TERMINATION_ERROR     = 7
  165              X_ERROR                       = 8
  166              PARAMETER_EXPECTED            = 9
  167              TOO_MANY_PARAMETERS           = 10
  168              ILLEGAL_COMMAND               = 11
  169              WRONG_ASYNCHRONOUS_PARAMETERS = 12
  170              CANT_ENQ_TBTCO_ENTRY          = 13
  171              JOBCOUNT_GENERATION_ERROR     = 14
  172              OTHERS                        = 15.
  173
  174  ENDFUNCTION.
  175
  176  *---------------------------------------------------------------------*
  177  *       FORM FIELDNAMES_2_BUFFER                                      *
  178  *---------------------------------------------------------------------*
  179  *       ........                                                      *
  180  *---------------------------------------------------------------------*
  181  *  -->  FIELDNAMES                                                    *
  182  *  -->  BUFFER                                                        *
  183  *---------------------------------------------------------------------*
  184  FORM FIELDNAMES_2_BUFFER TABLES FIELDNAMES CHANGING BUFFER.
  185    CLEAR BUFFER.
  186    CLEAR FIELDNAME_OFFSET.
  187    LOOP AT FIELDNAMES.
  188      WRITE FIELDNAMES TO BUFFER+FIELDNAME_OFFSET.
  189      CONDENSE BUFFER.
  190      FIELDNAME_OFFSET = STRLEN( BUFFER ).
  191      WRITE C_TAB TO BUFFER+FIELDNAME_OFFSET(1).
  192      ADD 1 TO FIELDNAME_OFFSET.
  193    ENDLOOP.
  194    FIELDNAME_OFFSET = FIELDNAME_OFFSET - 1.
  195    IF FIELDNAME_OFFSET >= 0.
  196      WRITE SPACE TO BUFFER+FIELDNAME_OFFSET(1).
  197    ENDIF.
  198  ENDFORM.
 
 
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP MM SD Consultant
Contact : serkurumsal@yandex.com