Sap: How does one output data to excel in the ABAP program? Call function 'ws _ Excel'

Source: Internet
Author: User

It mainly involves the use of a function:Call function 'ws _ Excel'

However, the problem is not solved yet. That is, an Excel file is generated after this function is called, but if you do not close this Excel file and run your program again, when you call this function again, the system will report an error. I do not know how to solve this problem yet. That is, after a call, you must close the opened Excel file before calling it again. Otherwise, an error occurs. Or it cannot be called twice in a row.

Example:

Form output_excel.
* "For testing
If chk_dtl EQ 'x '.
Clear out_excel [].

Out_excel-field01 = 'Company Code '.
Out_excel-field02 = 'employee no '.
Out_excel-field03 = 'elastic' (y/n )'.
Out_excel-field04 = 'rating '.
Out_excel-field05 = 'salary increase % '.

Append out_excel.

Loop at it_detail.
Out_excel-field01 = it_detail-bukrs.
Out_excel-field02 = it_detail-pernr.
Out_excel-field03 = it_detail-eligible.
Out_excel-field04 = it_detail-rating.
Out_excel-field05 = it_detail-percentage.

Append out_excel.
Clear out_excel.
Endloop.

Call function 'ws _ Excel'
Exporting
Filename = 'd:/emprating.xls'
Tables
Data = out_excel.
Endif.
Endform. "output_excel

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.