Skip to Content

Objective: To generate the formatted excel file which can be send or download as per below requirement.

1: User should able to download excel file when using GUI and execute in foreground mode.

2: When sending the email in foreground as well as if email is send in with background job.

3:When the ECC transaction is use as transaction launcher in SAP CRM the excel file should get generated same as it is working in SAP ECC, as in case of Transaction launcher it works as web page.

Advantage of using XML over OLE: As we can use the OLE method in ABAP to generate formatted excel but its work only in GUI foreground mode, where as we can use ‘xml’ concept in foreground as well as in background jobs for sending email etc.

Example:  I have made the transaction in ECC which takes input as Year and display all the dates with weekday and in case of weekly off i.e Saturday and Sunday the background color of the cell will be green.

xml1.JPG

If user select the first option ‘Download Excel’ system will generate the excel file, presently I have kept the excel file in temp folder and same I have executed if file save successfully and in case of ‘Send email’ system will send the same file as email attachment.

Note :  1:We cannot save the file in any PC folder in background but we can save on app. Server using open data set method.

             2: I have not added the code for email in my example we can check demo program BCS_EXAMPLE_7 to send file as email attachment.

             3: I have made this program by refereeing the existing SDN doc.   

http://wiki.scn.sap.com/wiki/display/Snippets/Formatted+Excel+as+Email+Attachment, I have use same for downloading the file in ECC frontend as well as when same is used in CRM WEB UI as transaction launcher.

              4: For checking this you can upload the attach program in your system and can check the same.

Output:

xml2.JPG

Find here the attach file of program.

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Ankit Sharma

    Hi Zafar,

    Nice post, I have seen the code, but I was just wandering, whether it is possible to create two tables in one workbook ?

    I just wanted this for some additional Excel formatting.

    Thanking You All.

    (0) 
    1. zafar karnalkar Post author

      Hi,

      Yes it is possible, you can create two tables in one workbook.

      For a new table just add some blank lines then again append data from your second tables with headings and borders.

      Regards,

      Zafar

      (0) 
      1. Ankit Sharma

        Hi Zafar,

        Thanks a lot for the help.

        I tried to create two Table Objects in one Workbook but I failed.

        What I did is,

        Created one table Object , r_table_1.

        One Row Object, r_row_1.

        One Cell Object, r_Cell_1.

        One Data Objcet, r_data_1.

        This Data Objects prints my data properly in Excel O/P.

        Again in he same workbook and worksheet,

        I am creating

        one table Object , r_table_2.

        One Row Object, r_row_2 using r_table_2,

        Few blank rows

        One Cell Object, r_Cell_2, using r_row_2,

        One Data Objcet, r_data_2. using r_cell_2.

        But this second table is not printing any thing.

        I do not know, whether it is possible even.

        May be if you can suggest me, how to merge cells this will also help me.

        Thanking You All.

        (0) 

Leave a Reply