Skip to Content
avatar image
Former Member

Export data to Excel through a ABAP program run in batch mode

Dear Experts,

The requirement is that a ABAP report should run through background job, which will do the followiing :

1) Collect data from predifined CRM tables ( Activity , Order for example ).

2) Create a Excel file in a Application Server ( physical file server location ) location.

3) Push the data collected in the step 1 to the Excel file.

I have found 2 function modules which does the export to Excel after creating the Excel file. They are :

a) XXL_FULL_API

b) MS_EXCEL_OLE_STANDARD_DAT

But it seems that the ABAP report needs to run in the foreground ( correct me if i am wrong ) in order to create the Excel file.

Please can anyone suggest a possible ABAP code to achieve OR how to use these FMs in background mode ?

The excel creation needs to be automated and send to a administrator email id every day, so the need of exporting the data in background mode arises.

Thanks and regards,

Sudipta

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jan 05, 2009 at 09:02 AM

    Hi,

    In FM XXL_FULL_API there is a parameter NO_START its default is space try populating 'X' and it should help you to only store and not start the ALV.

    santhosh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 05, 2009 at 09:07 AM

    hi,

    In SM36, you can create a job(give your report prog name)..

    call the fun. module by storing all the values into final int. table it_data.

    but u need to open one excel file in your desktop...

    v_file = 'C:\file.xls'. " path should be like this...

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = v_file

    filetype = 'xls'

    has_field_separator = 'X'

    • HEADER_LENGTH = 0

    • read_by_line = 'X'

    • DAT_MODE = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • CHECK_BOM = ' '

    • VIRUS_SCAN_PROFILE =

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    TABLES

    data_tab = it_data

    EXCEPTIONS

    file_open_error = 1

    file_read_error = 2

    no_batch = 3

    gui_refuse_filetransfer = 4

    invalid_type = 5

    no_authority = 6

    unknown_error = 7

    bad_data_format = 8

    header_not_allowed = 9

    separator_not_allowed = 10

    header_too_long = 11

    unknown_dp_error = 12

    access_denied = 13

    dp_out_of_memory = 14

    disk_full = 15

    dp_timeout = 16

    OTHERS = 17

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    regards

    vijay

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Vijay,

      Thanks for the reply. But the requirement is to create the Excel file automatically , as the whole process will be run as a background job every day .

      How to go about it ?

      Regards,

      Sudipta

  • avatar image
    Former Member
    Jan 05, 2009 at 09:10 AM

    Hi,

    U can use the FM : XXL_FULL_API to down load the data into the XL file.

    But to my knowledge the file will not stored in the application server even if u run in the foreground or back ground. u can set the value for the parametr NO_START as X or space to run in the baack ground

    or fore goround mode.

    The process is like this when u run the program using this FM, The file will be stored in the SAP INBOX.

    There u can check the file after running the program in the back ground.

    Hope this helps you.

    Regards

    John.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 05, 2009 at 09:26 AM

    Sudipta...

    I dont know how to download into excel in background....but may be you can try this..........

    In background mode, the system field SY-BATCH is set to 'X'.... so check for this and use CALL TRANSACTION statement and call the tcode '%PC', and try using SET or GET PARAMETER to set the radiobutton .. to SPREADSHEET...

    This transaction is generally used to download the ALV data into EXCEL file....

    Add comment
    10|10000 characters needed characters exceeded