Download in XLSX format:
My Problem Statement:
Whenever I have tried to attach XLS document to email or download XLS document from any ABAP report to presentation server. I have faced a warning message while opening the XLS file, mentioned below.
[ We can run SAP Program ‘BCS_EXAMPLE_7’ to simulate the scenario ]
My Client was pretty uncomfortable with the pop-up message and asked me to change some code in ABAP such that he doesn’t want to see this pop-up message in Excel. Initially, I thought to myself that “How can I possible remove a pop-up message in Excel from ABAP ?”
Moving from format XLS to XLSX has solved this issue for me.
Transform internal table into XML (XSTRING) and convert XML into Binary. Use this Binary file for attachments or downloading.
Include – TEST_GHO_DATA_UPLD_DWLD_FILF01
Form – EXTRACT_TO_EXCEL
Above mentioned Form in the include has the code on how to transform an internal table to XML and then convert XML into Binary.
[ I came to know about this information from a blog, unfortunately I couldn’t recollect that URL of the blog ]
Upload in XLSX Format:
I was breaking my head on how to upload a XLSX file into SAP. Then I have found a document written by Benu Mariantony on how to upload a XLSX file into SAP.
I have followed the blog and simulated the code and it worked for me. On other day, when I tried with different XLSX file, the program gave dump. Then I remembered the possible issue mentioned by Matthew Billingham in the wiki page. I have exactly ran into the same issue. The sequence of folders in “XL” folder has changed.
I have used similar logic to differentiate the folders. Code snippet mentioned below.
**--After getting all Parts/Folders available in Folder 'XL' into LO_PART2 **--Loop on no of folders and check the relationship type DO lv_count1 TIMES. "No of Sub folders in Folder 'Xl' DATA(lo_part2) = lo_parts1->get_part( sy-index - 1 ). "Get the each and every folder IF lo_part2 IS BOUND. DATA(lv_rel_type) = lo_part2->get_relationship_type( ). "Check relationship type IF lv_rel_type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet'. "Worksheet XML lv_index_sheet = sy-index - 1. ELSEIF lv_rel_type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings'. "Shared XML lv_index_shared = sy-index - 1. ENDIF. ENDIF. ENDDO.