How to send ALV Report in excel format from SAP

Hi Gurus,
We are using SAP 4.7 and using different SAP reports.Now I want to send SAP ALV report in excel format directly from SAP in background.Now we send these reports in background weekly by using autimetic scheduling but this is PDF format.Now I want to change this pdf format to excel format.In SCOT T.Code I am able to find any excel format.Please help me out.
I am waiting for your reply.
Advance Thanks
Nirmal

Hi Nirmal,
I have done the same in my previous organisation.For this particular solution you need to ask your basis guys to upgrade the support package so that BCS classes could be available in the system.
API interafces five some problem with attachemnts and SAP has recommended to use BCS classes.
Currently BCS classes won't be availbale in 4.7.
Once the BCS classes are available
use below code
   CONSTANTS:
    lc_tab          TYPE c VALUE cl_bcs_convert=>gc_tab,
    lc_crlf         TYPE c VALUE cl_bcs_convert=>gc_crlf,
   lc_codepage     TYPE abap_encod VALUE '4103',
data :
   lv_string      TYPE string,
   binary_content TYPE solix_tab,
   size           TYPE so_obj_len,
   *" Set Heading of Excel File
  CONCATENATE 'Employee DATA'
               lc_crlf lc_crlf
               INTO lv_string.
   *" Set Header for Excel Fields
  CONCATENATE lv_string
              lc_header1 lc_tab
              lc_header2 lc_tab
              lc_header3 lc_tab
              lc_header4 lc_tab
              lc_header5 lc_tab
              lc_header6 lc_tab
              lc_header7 lc_tab
              lc_header8 lc_tab
              lc_header9 lc_tab
              lc_header10 lc_crlf
              INTO lv_string.
"lc_header1 to 10 could be your field headers
   "Move Internal table data
  LOOP AT gt_final1 INTO gwa_final1.
    CONCATENATE lv_string
                gwa_final1-field1     lc_tab
                gwa_final1-field2      lc_tab
                gwa_final1-field3    lc_crlf
                INTO lv_string.
  ENDLOOP.
   *" convert the text string into UTF-16LE binary data including
*" byte-order-mark. Mircosoft Excel prefers these settings
*" all this is done by new class cl_bcs_convert (see note 1151257)
  TRY.
      cl_bcs_convert=>string_to_solix(
        EXPORTING
          iv_string   = lv_string
          iv_codepage = lc_codepage  "suitable for MS Excel, leave empty
          iv_add_bom  = abap_true     "for other doc types
        IMPORTING
          et_solix  = binary_content
          ev_size   = size ).
    CATCH cx_bcs.
      MESSAGE e445(so).
  ENDTRY.
  TRY.
*" create persistent send request
      send_request = cl_bcs=>create_persistent( ).
      document = cl_document_bcs=>create_document(
        i_type    = lc_doc
        i_text    = main_text
        i_subject = lc_sub  ).     
      document->add_attachment(
        i_attachment_type    = lc_attach                    "#EC NOTEXT
        i_attachment_subject = lc_sub                       "#EC NOTEXT
        i_attachment_size    = size
        i_att_content_hex    = binary_content ).
   send_request->set_document( document ).
   recipient = cl_cam_address_bcs=>create_internet_address( email ).
   CALL METHOD send_request->add_recipient
          EXPORTING
            i_recipient = recipient.
   IF recipient IS NOT INITIAL.
        sent_to_all = send_request->send( i_with_error_screen = abap_true ).
        COMMIT WORK.
*        MESSAGE text-014 TYPE gc_succ  .
      ENDIF.
    CATCH cx_bcs INTO bcs_exception.
      MESSAGE i865(so) WITH bcs_exception->error_type.
  ENDTRY.
For BCS decalartion u can go to se 38 and see program BCS_EXAMPLE_1 to BCS_EXAMPLE_7.
Rewrads if helpful.
Cheers
Ramesh Bhatt

Similar Messages

  • Download alv report in excel format in Linux

    Hi All,
    I am working on SAP GUI for Java in Linux PC. I have installed
    Open Office.
    After executing an alv report there is no spreadsheet option
    to download the report in excel format .
    Also, when doing Save as Local File -> Spreadsheet ,
    the report is not downloaded in proper format.
    So, how to download the alv reports in excel format ?

    Hi Vinod ,
    Save as Local File -> Spreadsheet
    It will ask for Directory and file name with .xls format . Give proper name e.g. test.xls and save, and after saving file right click on the file and click on Open with "OpenOffice.org calc".
    It will definetly work.
    Abhijeet

  • Getting a report in excel format from oracle report builder 10gDS release2

    I want to get a report in excel format from oracle report builder 10gDS release2.
    Is there ne method by which minimum effort is required for changing already made reports .
    I have searched for it on internet :-
    http://www.oracle.com/webapps/online-help/reports/10.1.2/state/content/navId.3/navSetId._/vtTopicFile.htmlhelp_rwbuild_hs%7Crwwhthow%7Cwhatare%7Coutput%7Coutput_a_simpleexcel~htm/
    Example, given in the last of the page opened from the above url, is not working.
    Can neone plz explain the example and how to use it
    Thanks & Regards
    JD

    Ok, for the release 2 its quite straightfoward, in your calling form you would have something like this code:
    declare
         pl_id ParamList;
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    v_rep_status VARCHAR2(20);
    v_repsrv     VARCHAR2(100):= 'yourreportserver';
    v_serv varchar2(50) := 'yourservername' ;
    begin
    pl_id := Get_Parameter_List('tmpdata');
    if not id_null(pl_id) then
    Destroy_Parameter_List( pl_id );
    end if;
    pl_id := Create_Parameter_List('tmpdata');
    Add_Parameter(pl_id,'DESTYPE' ,TEXT_PARAMETER,'Screen' );
    Add_Parameter(pl_id,'PARAMFORM' ,TEXT_PARAMETER,'NO' );
    repid := FIND_REPORT_OBJECT('yourreport');     SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER, v_repsrv);
    set_report_object_property(repid,REPORT_DESTYPE,CACHE );
    set_report_object_property(repid,REPORT_DESFORMAT,'SPREADSHEET' );
    v_rep := RUN_REPORT_OBJECT(repid,pl_id);
    v_rep := substr(v_rep,length(v_repsrv)+2,10 ) ;
    end;
    I have plenty of reports being formated to excel with this same method so it should work for you, the only diference with my previous code is this line.
    set_report_object_property(repid,REPORT_DESFORMAT,'SPREADSHEET' );
    The rest remains untouched.
    Hope it helps.

  • Code generate report in excel format from portal(Application Server)

    Hi all
    Please give some solution with code generate report in excel format from
    oracle portal(Application Server).

    Not feasible.
    Why? Because "the Excel format" is a binary and proprietary Microsoft file format. And writing a generator to generate Excel files will be complex, and resource expensive. In the vast majority of cases this will not be justified.
    As an alternative the very basic Microsoft XML office format can be used. But note that this is not a a ISO standard (it has been shot down in flames) - and effort and resources for that would be better spend on the Open Document XML standard (which very likely will be ratified as the ISO standard instead).
    Of course, you could have meant a CSV file - in which case, you need to play close attention to details. CSV is not an Excel format. A software designers and developers, our success is determined by attention to technical detail. In which case you are not paying any attention to technical detail by confusing CSV with Excel.

  • Unable to export report to excel file from SAP

      Hi all,
    I have a problem to download data from a report. The XL gets downloaded in a different format than my colleague.
    We are using the same XL version but two weeks back the SAP GUI 730 got reinstalled to my machine and since then the problem
    started.
    Can you please confirm is there is any particular user settings for this?
    I have login in any different working ( SAP Export ) machine with my login ID and Password and try to export the report to excel file from SAP, and I have same issue . Same we have requested another user to login in my machine with their ID and Password and check the same, They have tried and its working for then in my machine.
    see screenshots attached.
    Thanks.

    Execute report>
    Right click anywhere in the report output and select Spreadsheet.
    A pop up box will appear, select which export option you would like to use and click green check.
    NOTE: If you don't see this option then goto Settings>Switch List then try above said.
    Thanks,
    Kumar

  • Subject: How to get MB5B report in excel format

    Dear experts,
    Please help me how I get automatically MB5B Report in excel format. In Layout there is no option to convert excel format.
    regards,
    rss
    Edited by: rs_sharma on Jun 26, 2011 10:16 AM

    Dear experts,
    Please help me how I get automatically MB5B Report in excel format. In Layout there is no option to convert excel format.
    regards,
    rss
    Edited by: rs_sharma on Jun 26, 2011 10:16 AM

  • How to convert ALV report to Excel ??

    Hi,
    My requirement is to show ALV report in the excel .
    I have 2 radio buttons in Selection screen :
    1)  ALV  format                           2) Excel.
    If excel is selected then user will give a path : C :\newexcelreport.xls
    I knew that there is a way to download report through ALV report using download into local file. But the requirement is to create a report in Excel same like ALV report .
    I tried using GUI_Download . But it is displaying some fields wrongly, ex : Date , Time, without header .
    Date is showing year month date format in the excel .
    time is showing in a numeric format.
    But the ALV report is showing correct report . When I download into local then the report is showing correct results .
    Is there any function module to download exact ALV report into excel .??
    Thanks & Regards,
    Varma

    Use the FM - ALV_XXL_CALL. here is the sample -
    REPORT  ZSKC_ALV_XXL.
    TYPE-POOLS : KKBLO.
    DATA : ITAB LIKE T100 OCCURS 0,
           T_FCAT_LVC TYPE LVC_S_FCAT OCCURS 0 WITH HEADER LINE,
           T_FCAT_KKB TYPE KKBLO_T_FIELDCAT.
    START-OF-SELECTION.
    Get data.
      SELECT * UP TO 20 ROWS
      FROM   T100
      INTO   TABLE ITAB
      WHERE  SPRSL = SY-LANGU.
      CHECK SY-SUBRC EQ 0.
    Create the field catalog.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
          I_STRUCTURE_NAME             = 'T100'
        CHANGING
          CT_FIELDCAT                  = T_FCAT_LVC[]
        EXCEPTIONS
          INCONSISTENT_INTERFACE       = 1
          PROGRAM_ERROR                = 2
          OTHERS                       = 3.
      CHECK SY-SUBRC EQ 0.
    make sure you pass the correct internal table name in the field catalog.
      t_fcat_lvC-tabname = 'ITAB'.
      MODIFY T_FCAT_LVC TRANSPORTING TABNAME WHERE TABNAME NE SPACE.
    Transfer to KKBLO format.
      CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          IT_FIELDCAT_LVC                 = T_FCAT_LVC[]
        IMPORTING
          ET_FIELDCAT_KKBLO               = T_FCAT_KKB
       EXCEPTIONS
         IT_DATA_MISSING                 = 1
         IT_FIELDCAT_LVC_MISSING         = 2
         OTHERS                          = 3.
      CHECK SY-SUBRC EQ 0.
    Call XXL.
      CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          I_TABNAME                    = 'ITAB'
          IT_FIELDCAT                  = T_FCAT_KKB
        TABLES
          IT_OUTTAB                    = ITAB[]
        EXCEPTIONS
          FATAL_ERROR                  = 1
          NO_DISPLAY_POSSIBLE          = 2
          OTHERS                       = 3.
      IF SY-SUBRC <> 0.
      ENDIF.

  • How to Export SSRS report into Excel format using query string

    Hello all,
    I am new to SSRS world.
    Last night i was trying to add a hyperlink  on the SSRS report (.rdl) file, by clicking which we can export the report into "Excel" format, but with no luck.
    Can anybody tell me how to form the hyperlink, so that we can export the report with its current content ( I mean the report content generated by selecting some parameter values)

    Hi Suman85,
    Based on your scenario, you want to add a link on the SSRS report file, and then click it you can export the report into “Excel” format.
    Just as kishan1901 said , you can add a textbox to your report and type in the words “Click here and export the report
    to excel” .Then right-click the textbox and select Properties. Switch to Navigation tab, click the radiobutton of ‘Jump to URL’ and type in the expression ,here is just a example:
     ="http://vyof1884200/ReportServer$youhoo?/My+Adventure+Works/Product+Sales+and+Profitability+by+Month&rs:Command=Render&rs:Format=excel"
    Then preview the report ,you will see
    Click here and export the report to excel 
    when you move the mouse to it ,the mouse will become a hand ,then left-click, it will jump out a dialog box to indicate user whether the excel file should be saved , opened or canceled. 
    I think this is what you want, if you have any further requirement, could you please describe it in more detail? We would give you some resolution or workaround.
    Regards,
    Challen Foo

  • How to create a report in excel format having two tab

    Hi All,
    I have Business requirement where customer wants to create a report in excel format having two tab.
    Please let me know if it is possible?
    I am using 10.1.4.3.2 version of BIP.
    Thanks & Regards,
    Edited by: 862749 on May 20, 2013 7:36 PM

    I have Business requirement where customer wants to create a report in excel format having two tab.
    Can anybody suggest if it is possible in BI Publisher or not?yes
    look at excel template
    also you can use xsl-xml or xsl-fo template
    check it for your requirements

  • How to extract the data into Excel / PDF from SAP

    Hi,
    We have spool number of a report output.
    We want to extract the data into Excel / PDF from SAP directly...
    Plz guide...

    Hi ,
    Please check this [Thread|HOW TO DOWNLOAD SAP OUTPUT TO EXCEL FILE;. Hope your problem will be solved.
    You can check [this also.|http://wiki.sdn.sap.com/wiki/display/sandbox/ToConvertSpoolDataintoPDFandExcelFormatandSenditinto+Mail]
    Thanks,
    Abhijit

  • How to send ALV report Output through mail in background !

    Hi ,
    I had an ALV Report. I want to send this report output to patricular email id every day ! Presenty i do this manually. I run the report and send the output to the particular email address. Now i want to schecule the report daily in background and the out put of the report should be mailed to particular email ids in background itself. How can i do this ?
    Is there and method or setting through which we can do this ?
    Regards

    Hi Nau,
    For this requirement you will have to write another program.
    This program will convert the spool requests into PDF document and sends an email  to the recipients that you specify.
    These are the threads which are already posted in The SDN.
    *http://wiki.sdn.sap.com/wiki/display/Snippets/Converts+spool+request+into+PDF+document+and+emails*
    *<a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="353650"></a>*
    *<a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="902985"></a>*
    You need to use the Function module :
    -- Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    I will provide you with the code to get this functionality.
    *&      Form  SEND_EMAIL
    form SEND_EMAIL .
    DATA:   t_mailpack   TYPE sopcklsti1 OCCURS 0 WITH HEADER LINE,
              t_mailhead   TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailbin    TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailtxt    TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailrec    TYPE somlreci1  OCCURS 0 WITH HEADER LINE.
      DATA: wa_maildata    TYPE sodocchgi1,
            l_filename(50) TYPE c,
            l_fldname(30)  TYPE c,
            l_fldval(100)  TYPE c,
            l_lines        TYPE i,
            l_text         TYPE text128 .
      DATA: w_email_subrc  TYPE i.
      DATA: w_ship like vbfa-vbeln.
      CLEAR: wa_maildata,
             t_mailtxt,
             t_mailbin,
             t_mailpack,
             t_mailhead,
             t_mailrec.
      REFRESH: t_mailtxt,
               t_mailbin,
               t_mailpack,
               t_mailhead,
               t_mailrec.
    *-- Fill output file
    *- Fill header
      CLEAR: t_mailbin.
    *  t_mailbin[] = pdf_tab[].
      t_mailbin[] = it_att[].     "Uthaman
    *This line is added to get the shipment no in Subject Line
    SELECT SINGLE * FROM vbfa WHERE vbelv EQ nast-objky
                                AND vbtyp_v EQ c_vbtyp_v_j
                                AND vbtyp_n EQ c_vbtyp_n_8.
    w_ship = vbfa-vbeln.
    shift w_ship left deleting leading '0'.
    *-- File name
    if nast-kschl EQ 'ZFPL'.
      CLEAR l_filename.
      CONCATENATE 'Packing List -'
                  sy-datum+4(2) sy-datum+6(2) sy-datum(4) '.PDF' INTO l_filename.
    *-- Creation of the document to be sent File Name
      wa_maildata-obj_name = 'Packing List'.
    *-- Mail Subject
      CONCATENATE l_filename '-' 'Shipment No -' w_ship INTO wa_maildata-obj_descr SEPARATED BY space.
    *-- Mail Contents
      t_mailtxt-line = 'Packing List'.
      APPEND t_mailtxt.
    ENDIF.
    if nast-kschl EQ 'ZFBA'.
      CLEAR l_filename.
      CONCATENATE 'Booking Advice -'
                  sy-datum+4(2) sy-datum+6(2) sy-datum(4) '.PDF'
                  INTO l_filename.
    *-- Creation of the document to be sent File Name
      wa_maildata-obj_name = 'Booking Advice'.
    *-- Mail Subject
      CONCATENATE l_filename '-' 'Shipment No -' w_ship INTO wa_maildata-obj_descr SEPARATED BY space.
    *-- Mail Contents
      t_mailtxt-line = 'Packing List'.
      APPEND t_mailtxt.
    ENDIF.
    *-- Prepare Packing List
    *-- Write Packing List (Main Subject)
      CLEAR: l_lines, t_mailpack.
      DESCRIBE TABLE t_mailtxt LINES l_lines.
    *  READ TABLE t_mailtxt INDEX l_lines.
      t_mailpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( t_mailtxt ).
    *  CLEAR t_mailpack-transf_bin.
      t_mailpack-transf_bin = ' '.
      t_mailpack-head_start = 1.
      t_mailpack-head_num = 0.
      t_mailpack-body_start = 1.
      t_mailpack-body_num = l_lines.
      t_mailpack-doc_type = 'RAW'.
      APPEND t_mailpack.
      t_mailhead = l_filename.
      APPEND t_mailhead.
    *-- Write Packing List (Attachment)
      CLEAR: l_lines, t_mailpack.
      DESCRIBE TABLE pdf_tab[] LINES l_lines.
    *  READ TABLE pdf_tab INDEX l_lines.
      t_mailpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( t_mailbin ).
      t_mailpack-transf_bin = 'X'.
      t_mailpack-head_start = 1.
      t_mailpack-head_num = 1.
      t_mailpack-body_start = 1.
      t_mailpack-body_num = l_lines.
      t_mailpack-doc_type = 'PDF'.
      t_mailpack-obj_name = l_filename.
      t_mailpack-obj_descr = l_filename.
      t_mailpack-obj_langu = 'E'.
      APPEND t_mailpack.
    *-- Set recipients
    tables :  ztotcemail.
    SELECT SINGLE * FROM vbfa WHERE vbelv EQ nast-objky
                                AND vbtyp_v EQ c_vbtyp_v_j
                                AND vbtyp_n EQ c_vbtyp_n_8.
    CLEAR vttk.
    SELECT SINGLE * FROM vttk WHERE tknum EQ vbfa-vbeln.
    SELECT SINGLE * FROM ztotcemail WHERE tplst = vttk-tplst
                                      AND lifnr = vttk-tdlnr.
    IF SY-SUBRC EQ 0.
      t_mailrec-receiver = ztotcemail-smtp_addr. "'Here you will give the email address'.
      t_mailrec-rec_type  = 'U'.
      APPEND t_mailrec.
    ENDIF.
    **-- Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_maildata
          put_in_outbox              = 'X'
    *      commit_work                = 'X'  " N-16
        TABLES
          packing_list               = t_mailpack
          object_header              = t_mailhead
          contents_bin               = t_mailbin[]
          contents_txt               = t_mailtxt[]
          receivers                  = t_mailrec
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      w_email_subrc = sy-subrc.
      IF sy-subrc EQ 0.
        MESSAGE s000(zotc) WITH 'Email output sent successfully'.
      ELSE.
        MESSAGE s000(zotc) WITH 'Can not send email output'.
      ENDIF.
    endform.                    " SEND_EMAIL
    Hope the above information will be helpful.
    Regards,
    Kittu

  • How to send ALV report by Email

    Hi.
    we have developed a block ALV report which has 3 reports i.e Detail report , summary report and Error report. Currently user run the report in background.However there is need to send this report by Email . I can use FM:SO_OBJECT_SEND . I want how to pass this report to FM and how to handle if there are multiple email ids. I think we can create a group of the user with email id in business workplace and pass the group to FM.
    I need help in how to assign the report and user group to this FM

    Hi,
    You may use the code given by Amit in this link -
    MAil Attachment.
    It is perfect to handle any type of email requirement.
    Regards,
    Amit
    Reward all helpful replies.

  • How to send ALV report by mail

    Hi everybody,
    I would like to know how i can donwload the ALV report to an internal table so i can send it by mail?
    the fact of sending by mail it's already solved.. i tried sending the internal table of the ALV and it was OK, but what i need is to send all the display of the report..i mean..titles..columns,..totals... as i see on the screen.
    for a normal report i used the %_list to send the report to an internal table but for an ALV it doesn't work.
    Regards,
    Vanessa

    Hi Vanessa,
    If you have used Method (Container /Classes) for your ALV.
    You can find "SEND" when you drop down the "Download(UCOMM = %PC)" button at Container. Select "SEND" Option this will bring you Create Document and Send screen.
    Please enter reciepient and send the report.
    Hope this may help you.
    Lanka
    Message was edited by: Lanka Murthy

  • How to send Oracle report automatically in format pdf by email with subject and body?

    Hello,
    How to send e-mail attachment and mail other details like from ,subject,cc,to,mail body. In Oracle Developer Suite 10g?
    Regards.

    did you try to run report parameter form = yes ,
    put to the parameter form following system parameters  and set et.
    run report  with belove value
        - DESTYPE = MAIL
        - DESFORMAT = PDF
        - DESNAME =  mail adres
    then according to the result ,rearrange your report forms side  while invoke report from forms
         -  SET_REPORT_OBJECT_PROPERTY(  reportobject_id , DESTYPE          , mail ) ;
         -  SET_REPORT_OBJECT_PROPERTY(  reportobject_id , DESFORMAT     , PDF ) ;
         -  SET_REPORT_OBJECT_PROPERTY(  reportobject_id , DESNAME          , mail adres ) ;

  • How to send ALV report by email, in the body of the email?

    Hello friends,
    I need to send a report ALV by email. First, the user wanted it attached as PDF file, but now he wants it in the body of the email.
    Does anybody have any solution?
    P.S.: I am using methods to send the email.
    Thanks in advance.
    Karla.

    Thank you Jan,
    I used the following solution to get the report in HTML code:
    I use submit to export the list to memory
    SUBMIT zsdr006_alv EXPORTING LIST TO MEMORY AND RETURN.
    Them I get the list from memory
      CALL FUNCTION 'LIST_FROM_MEMORY'
    Finaly I convert the list to HTML code
      CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
    The problem is when I send the email, it is still not going on the body of the email.
    I tried taking off the attach method, but the email goes blank in the body.
    Actually to SOST the message goes with the HMTL report in the body, just like I need, but when send to any e-mail address, it does not go on the body of the message.
    Does any body could check this out?
      TRY.
        -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
        -------- create and set document with attachment ---------------
        create document from internal table with text
          IF p_pdf EQ 'X'.
            l_type = 'RAW'.
            APPEND text-t01 TO text.
            IF NOT s_erdat-low IS INITIAL.
              CONCATENATE s_erdat-low6(2) '.' s_erdat-low4(2) '.' s_erdat-low(4) INTO ls_text-line.
              IF NOT s_erdat-high IS INITIAL.
                CONCATENATE ls_text-line 'a' INTO ls_text-line SEPARATED BY space.
                CONCATENATE ls_text-line s_erdat-high+6(2) INTO ls_text-line SEPARATED BY space.
                CONCATENATE ls_text-line '.' s_erdat-high+4(2) '.' s_erdat-high(4) INTO ls_text-line.
              ENDIF.
              CONCATENATE 'Período:' ls_text-line INTO ls_text-line SEPARATED BY space.
              APPEND ls_text TO text.
            ENDIF.
          ELSEIF p_htm EQ 'X'.
            l_type = 'HTM'.
            LOOP AT gt_ascdata INTO ls_ascdata.
              ls_text = ls_ascdata-line.
              APPEND ls_text TO text.
            ENDLOOP.
          ENDIF.
          subject = text-t01.
          document = cl_document_bcs=>create_document(
                          i_type    = l_type
                          i_text    = text
                          i_length  = '12'
                          i_subject = subject ).
        add attachment to document
        BCS expects document content here e.g. from document upload
        binary_content = ...
          IF p_pdf EQ 'X'.
            CALL METHOD document->add_attachment
              EXPORTING
                i_attachment_type    = 'PDF'
                i_attachment_subject = g_filename
                i_att_content_hex    = binary_content.
          ELSEIF p_htm EQ 'X'.
            CALL METHOD document->add_attachment
              EXPORTING
                i_attachment_type    = 'HTM'
                i_attachment_subject = g_filename
                i_att_content_text   = gt_ascdata.
          ENDIF.
        add document to send request
          CALL METHOD send_request->set_document( document ).
        --------- set sender -------------------------------------------
        note: this is necessary only if you want to set the sender
              different from actual user (SY-UNAME). Otherwise sender is
              set automatically with actual user.
         sender = cl_sapuser_bcs=>create( sy-uname ).
          lv_email = g_email.
          sender = cl_cam_address_bcs=>create_internet_address( lv_email ).
          CALL METHOD send_request->set_sender
            EXPORTING
              i_sender = sender.
        --------- add recipient (e-mail address) -----------------------
        create recipient - please replace e-mail address !!!
          LOOP AT s_email.
            lv_email = s_email-low.
            recipient = cl_cam_address_bcs=>create_internet_address( lv_email ).
        add recipient with its respective attributes to send request
            CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient = recipient
                i_express   = 'X'.
          ENDLOOP.
        ---------- send document ---------------------------------------
          CALL METHOD send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = sent_to_all ).

Maybe you are looking for