ALV report output to be send to the respective users through email

Hi Gurus,
My requirement is to send the ALV report output to the respective users Email ID (Lotus notes) when the report runs in background.
Could any one suggest me with sample coding, How to send a ALV report output to the respective email ID's ( Suggest me the FM that used to send a internal table)
Regards
Paul

Hi Paul,
  Here for u the sample code:
<b>call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       exporting
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
       importing
            sent_to_all                = gd_sent_all
       tables
            packing_list               = it_packing_list
            contents_txt               = it_message
            receivers                  = it_receivers
       exceptions
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            others                     = 8.
Store function module return code
  gd_error = sy-subrc.
Get it_receivers return code
  loop at it_receivers.
  endloop.</b>
Hope this helps you.Reply for queries
Regards,
Kumar.

Similar Messages

  • How to do the ALV report output in groups and caluculate the tOTALS(URGENT

    Hi
    In my ALV report output .I have to group the output based on the DAYS field
    0-10 days in one group
    10-30 days in one group
    above 30 days one group
    There is also a field by name "AMOUNT" in my output.
    I have to calculate SUBTOTALs at the end of every group and at the end of the report i should caluculate GRAND TOTAL.
    Please remember that i should not use any any BLOCKED ALVs and for Totals i should not use the SYMBOLS provided in the application toolbar of the report
    Thanks in Advance

    Please don't repost your questions...
    Check out my answer in your other post.
    How to make the ALV report in groups  and caluculate the TOTALS
    Regards,
    Naimesh Patel

  • How to send the ALV report output in mail

    Dear all,
                        I have developed an ALV report.I need to send this output in the mail.Can anyone help me with the sample code of how to do this.

    Hi Ramya,
    Check the links below :
    http://wiki.sdn.sap.com/wiki/display/Snippets/Sending+Mail
    http://wiki.sdn.sap.com/wiki/display/Snippets/AbapEMAILProgram
    http://wiki.sdn.sap.com/wiki/display/ABAP/SendMessagetoExternalemailidandSAPUseridvia+ABAP
    They will explain you to send an email.
    Regards,
    Kittu

  • How to send the ALV report output by automated email.

    Hi All,
    Can any one advice how to send ALV report output by automated email.
    Thanks in advance.
    Vikram.
    Edited by: vikram mallavaram. on Oct 13, 2011 3:26 PM
    Moderator message: FAQ, please search for previous discussions of this topic.
    Edited by: Thomas Zloch on Oct 13, 2011 3:27 PM

    Hi Ramya,
    Check the links below :
    http://wiki.sdn.sap.com/wiki/display/Snippets/Sending+Mail
    http://wiki.sdn.sap.com/wiki/display/Snippets/AbapEMAILProgram
    http://wiki.sdn.sap.com/wiki/display/ABAP/SendMessagetoExternalemailidandSAPUseridvia+ABAP
    They will explain you to send an email.
    Regards,
    Kittu

  • Running the alv report  in  background and sending it thro email

    hi,
          i have to run the  alv report in background and send the output through email

    Hi
    Many a times there is a requirement to display ALV Grid (not ALV List) in the background Job. I have checked the SDN Forum for the same and it has been mentioned that ALV Grid cannot be displayed in Background, but the list output of ALV is possible. So user won’t have the actual Grid interface but the List interface.
    There is a workaround to display ALV Grid in Background Job. The only restriction is you can’t schedule the job through SM36. You need to execute the transaction of the report program, fill in the selection screen data and hit Execute.
    The job would be executed in background. User will be able to see the Job Log and Job Status after executing the program. User doesn’t have to go to SM37 to view the job status/log. Once the Job Status is changed to “COMPLETED”, user can click on “DISPLAY SPOOL” to view the ALV Grid.
    Limitations:
    Can’t schedulea background job
    The session should be active until the background job is completed. If the session is closed, then user won’t be able to check the output in ALV Grid. User would be able to check the output through spool or SM37
    Advantages:
    If the spool width is greater than 255 characters, then the entire width could be seen in the output because the output is directed to an ALV Grid and not to spool
    Interface of ALV Grid is available instead of ALV List even though it’s a background job.
    Program won’t give the TIME OUT error
    Steps Required:
    1. Once you execute the program, the following screen would be displayed
    2. Click “Display Job Status” to check the Status of the Background Job
    3. Click on “Display the Job Log” to check the Log
    4. Click on “Display Job Status” to check the Job Status
    5. Click on “DISPLAY SPOOL” to check the spool content once the Job Status is changed to “COMPLETED”. Output is displayed in ALV Grid
    Programs:
    1.  Two different programs needs to be created
    ZPROGRAM_ONE: This is the 1st program, where the selection screen and all the data validations would be done. Error handling for invalid data should be done in this program.
    Once the data validation is done, this program would call the 2nd program ZPROGEAM_TWO. Build the logic to display ALV Grid in this program. The logic will only display ALV in foreground and it won’t be reflected in the spool.
    ZPROGRAM_TWO: This program would fetch all the data and do all the processing. If you want the spool output along with ALV Grid output, then build the logic in this program to display ALV Grid.
    *& Report  ZPROGRAM_ONE                                                *
    REPORT  zprogram_one                            .
    PRASHANT PATIL
    TABLES : mara,
             tsp01.
    type-pools:slis.
    TYPES : BEGIN OF t_mara,
              matnr   TYPE mara-matnr,
              ersda   TYPE mara-ersda,
              ernam   TYPE mara-ernam,
              laeda   TYPE mara-laeda,
            END OF t_mara.
    DATA : i_mara       TYPE STANDARD TABLE OF t_mara,
           wa_mara      TYPE t_mara,
           wa_index     TYPE indx,        " For Index details
           wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
           i_jobsteplist     TYPE STANDARD TABLE OF tbtcstep, " For spool number
           wa_params         TYPE pri_params,  " To Get Print Parameters
           wa_jobhead        TYPE tbtcjob,     " To know the status of job
           wa_jobsteplist    TYPE tbtcstep,    " To know the spool
           w_jobname         TYPE tbtco-jobname,  " Job name for bckgrnd job
           w_jobcount        TYPE tbtco-jobcount, " Unique id for bckgrd job
           w_path            TYPE string,         " Upload path
           w_lsind           TYPE sy-lsind,       " Index
           wa_seltab         TYPE rsparams,
           i_seltab          TYPE STANDARD TABLE OF rsparams,
           wa_index1         TYPE indx,        " For Index details
           wa_index_key1     TYPE indx-srtfd VALUE 'PRG_TWO',
           i_fieldcat        TYPE slis_t_fieldcat_alv,
           wa_fieldcat       LIKE LINE OF i_fieldcat.
            CONSTANTS DECLARATION                                        *
    CONSTANTS :
             c_a(1) TYPE c VALUE 'A',
             c_m(1) TYPE c VALUE 'M',
             c_l(1) TYPE c VALUE 'L',
             c_c(1) TYPE c VALUE 'C',
             c_zfdr(4) TYPE c VALUE 'ZFDR',
             c_x(1)    TYPE c VALUE 'X',
             c_locl(4) TYPE c VALUE 'LOCL', " Destination is LOCAL
             c_f(1)    TYPE c VALUE 'F',   " Job Status - Failed
             c_s(1)    TYPE c VALUE 'S',
             c_p(1)    TYPE c VALUE 'P'.
    SELECTION SCREEN PARAMETERS
    SELECT-OPTIONS : s_matnr FOR mara-matnr.
    START-OF-SELECTION.
    Before the export, fill the data fields before CLUSTR
      wa_index-aedat = sy-datum.
      wa_index-usera = sy-uname.
      EXPORT s_matnr
           TO DATABASE indx(st) FROM wa_index ID wa_index_key.
    To Open the Job for background processing
      PERFORM open_job.
    To get the print parameters
      PERFORM get_print_parameters.
    Submit the job in background
      PERFORM job_submit.
    Close the background job
      PERFORM job_close.
    This is the output screen with the buttons ********
    Create 3 buttons DISPLAY SPOOL, STATUS, JOBLOG
      SET PF-STATUS 'ZS001'.
      WRITE: / 'The program is submitted in Background'.
      WRITE: / 'Press DISPLAY SPOOL to see the spool'.
      WRITE: / 'Press STATUS to see the status of the background'.
    AT USER-COMMAND.
    If user presses the 'BACK' button
      IF sy-ucomm = 'BAK'.
        IF  wa_jobhead-status = c_f OR
            wa_jobhead-status = c_a.
          LEAVE TO SCREEN 0.
        ENDIF.
      ENDIF.
    If the user presses the 'DISPLAY SPOOL' Button
      IF sy-ucomm = 'DISPLAY'.
        PERFORM display_spool.
      ENDIF.
    If the user presses the 'JOB STATUS' Button
      IF sy-ucomm = 'STATUS'.
        PERFORM display_status.
      ENDIF.
    If the user presses the 'JOB LOG' Button
      IF sy-ucomm = 'JOBLOG'.
        PERFORM display_job_log.
      ENDIF.
    *&      Form  open_job
          text
    -->  p1        text
    <--  p2        text
    FORM open_job .
    This is to Create a new job which is to be submitted in background to
    process sales order/delivery/invoice
    Here we would get a unique id ( Jobcount ) which identifies our job
    along with the job name which we have assigned to our job
      CONCATENATE sy-uname
                  sy-datum
                  sy-uzeit
                          INTO w_jobname .  " Assign unique jobname
      CALL FUNCTION 'JOB_OPEN'
       EXPORTING
      DELANFREP              = ' '
      JOBGROUP               = ' '
        jobname                = w_jobname
      SDLSTRTDT              = NO_DATE
      SDLSTRTTM              = NO_TIME
      JOBCLASS               =
      IMPORTING
       jobcount                = w_jobcount
    CHANGING
      RET                    =
    EXCEPTIONS
       cant_create_job        = 1
       invalid_job_data       = 2
       jobname_missing        = 3
       OTHERS                 = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " open_job
    *&      Form  get_print_parameters
          text
    -->  p1        text
    <--  p2        text
    FORM get_print_parameters .
      DATA : l_valid TYPE c.
    This is to get the Print Parameters for the job which is to be
    submitted in background to process sales order/delivery/invoice
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
       EXPORTING
      ARCHIVE_ID                   = C_CHAR_UNKNOWN
      ARCHIVE_INFO                 = C_CHAR_UNKNOWN
      ARCHIVE_MODE                 = C_CHAR_UNKNOWN
      ARCHIVE_TEXT                 = C_CHAR_UNKNOWN
      AR_OBJECT                    = C_CHAR_UNKNOWN
      ARCHIVE_REPORT               = C_CHAR_UNKNOWN
      AUTHORITY                    = C_CHAR_UNKNOWN
      COPIES                       = C_NUM3_UNKNOWN
      COVER_PAGE                   = C_CHAR_UNKNOWN
      DATA_SET                     = C_CHAR_UNKNOWN
      DEPARTMENT                   = C_CHAR_UNKNOWN
          destination                  = c_locl " LOCL
      EXPIRATION                   = C_NUM1_UNKNOWN
          immediately                  = space
      IN_ARCHIVE_PARAMETERS        = ' '
      IN_PARAMETERS                = ' '
      LAYOUT                       = C_CHAR_UNKNOWN
      LINE_COUNT                   = C_INT_UNKNOWN
      LINE_SIZE                    = C_INT_UNKNOWN
      LIST_NAME                    = C_CHAR_UNKNOWN
      LIST_TEXT                    = C_CHAR_UNKNOWN
      MODE                         = ' '
          new_list_id                  = c_x
      PROTECT_LIST                 = C_CHAR_UNKNOWN
          no_dialog                    = c_x
      RECEIVER                     = C_CHAR_UNKNOWN
      RELEASE                      = C_CHAR_UNKNOWN
      REPORT                       = C_CHAR_UNKNOWN
      SAP_COVER_PAGE               = C_CHAR_UNKNOWN
      HOST_COVER_PAGE              = C_CHAR_UNKNOWN
      PRIORITY                     = C_NUM1_UNKNOWN
      SAP_OBJECT                   = C_CHAR_UNKNOWN
      TYPE                         = C_CHAR_UNKNOWN
          user                         = sy-uname
      USE_OLD_LAYOUT               = ' '
      UC_DISPLAY_MODE              = C_CHAR_UNKNOWN
      DRAFT                        = C_CHAR_UNKNOWN
      ABAP_LIST                    = ' '
      USE_ARCHIVENAME_DEF          = ' '
      DEFAULT_SPOOL_SIZE           = C_CHAR_UNKNOWN
      PO_FAX_STORE                 = ' '
      NO_FRAMES                    = C_CHAR_UNKNOWN
       IMPORTING
      OUT_ARCHIVE_PARAMETERS       =
          out_parameters               = wa_params
       valid                        = l_valid
       EXCEPTIONS
         archive_info_not_found       = 1
         invalid_print_params         = 2
         invalid_archive_params       = 3
         OTHERS                       = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " get_print_parameters
    *&      Form  job_submit
          text
    -->  p1        text
    <--  p2        text
    FORM job_submit .
    The job which we have created & the unique id ( jobcount ) which we
    have got identifies our job. Hence those parameters are passed along
    with the name of the background program "ZPROGRAM_TWO"
    The job is submitted in background.
      CALL FUNCTION 'JOB_SUBMIT'
        EXPORTING
      ARCPARAMS                         =
        authcknam                         = sy-uname
      COMMANDNAME                       = ' '
      OPERATINGSYSTEM                   = ' '
      EXTPGM_NAME                       = ' '
      EXTPGM_PARAM                      = ' '
      EXTPGM_SET_TRACE_ON               = ' '
      EXTPGM_STDERR_IN_JOBLOG           = 'X'
      EXTPGM_STDOUT_IN_JOBLOG           = 'X'
      EXTPGM_SYSTEM                     = ' '
      EXTPGM_RFCDEST                    = ' '
      EXTPGM_WAIT_FOR_TERMINATION       = 'X'
        jobcount                          = w_jobcount
        jobname                           = w_jobname
      LANGUAGE                          = SY-LANGU
        priparams                         = wa_params
        report                            = 'ZPROGRAM_TWO'
      VARIANT                           = ' '
    IMPORTING
      STEP_NUMBER                       =
       EXCEPTIONS
         bad_priparams                     = 1
         bad_xpgflags                      = 2
         invalid_jobdata                   = 3
         jobname_missing                   = 4
         job_notex                         = 5
         job_submit_failed                 = 6
         lock_failed                       = 7
         program_missing                   = 8
         prog_abap_and_extpg_set           = 9
         OTHERS                            = 10
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " job_submit
    *&      Form  job_close
          text
    -->  p1        text
    <--  p2        text
    FORM job_close .
    Once the job is submitted in background then the job is closed
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = w_jobcount
        jobname                           = w_jobname
      LASTSTRTDT                        = NO_DATE
      LASTSTRTTM                        = NO_TIME
      PRDDAYS                           = 0
      PRDHOURS                          = 0
      PRDMINS                           = 0
      PRDMONTHS                         = 0
      PRDWEEKS                          = 0
      PREDJOB_CHECKSTAT                 = ' '
      PRED_JOBCOUNT                     = ' '
      PRED_JOBNAME                      = ' '
      SDLSTRTDT                         = NO_DATE
      SDLSTRTTM                         = NO_TIME
      STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
        strtimmed                         = c_x
      TARGETSYSTEM                      = ' '
      START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
      START_ON_WORKDAY_NR               = 0
      WORKDAY_COUNT_DIRECTION           = 0
      RECIPIENT_OBJ                     =
      TARGETSERVER                      = ' '
      DONT_RELEASE                      = ' '
      TARGETGROUP                       = ' '
      DIRECT_START                      =
    IMPORTING
      JOB_WAS_RELEASED                  =
    CHANGING
      RET                               =
       EXCEPTIONS
         cant_start_immediate              = 1
         invalid_startdate                 = 2
         jobname_missing                   = 3
         job_close_failed                  = 4
         job_nosteps                       = 5
         job_notex                         = 6
         lock_failed                       = 7
         invalid_target                    = 8
         OTHERS                            = 9
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " job_close
    *&      Form  display_spool
          text
    -->  p1        text
    <--  p2        text
    FORM display_spool .
    To Read the Job to get the spool details
      DATA : l_rqident TYPE tsp01-rqident, " Spool Number
             l_spoolno TYPE tsp01_sp0r-rqid_char.
      CLEAR : l_rqident,
              w_lsind,
              wa_jobsteplist.
      REFRESH : i_jobsteplist.
      SET PF-STATUS 'ZAR02'.
    Get the Spool Number
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Read the Job Step list to get the spool number
      READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
      CHECK wa_jobsteplist-listident <> space.
    Spool Number
      l_rqident = wa_jobsteplist-listident.
      MOVE l_rqident TO l_spoolno.
    Check the spool in TSP01
      SELECT SINGLE * FROM tsp01 WHERE rqident = l_rqident.
      IF  sy-subrc = 0.
        LEAVE TO LIST-PROCESSING.
        CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
          EXPORTING
            spoolid       = l_spoolno
        IMPORTING
          RC            =
          STATUS        =
        PERFORM show_alv.
      ENDIF.
      w_lsind = sy-lsind.
      IF sy-lsind GE 19.
        sy-lsind = 1.
      ENDIF.
    ENDFORM.                    " display_spool
    *&      Form  show_alv
          text
    -->  p1        text
    <--  p2        text
    FORM show_alv .
    Before the import, fill the data fields before CLUSTR.
      wa_index1-aedat = sy-datum.
      wa_index1-usera = sy-uname.
    To Import the selection screen data from Calling Program
      IMPORT i_mara
      FROM DATABASE indx(st) ID wa_index_key1 TO wa_index1.
      FREE MEMORY ID wa_index_key1.
    This prepares the field-catalog for ALV.
      PERFORM prepare_fieldcatalog.
    This displays the output in  ALV format .
      PERFORM display_alv.
    ENDFORM.                    " show_alv
    *&      Form  display_status
          text
    -->  p1        text
    <--  p2        text
    FORM display_status .
    To Display the STATUS of the JOB which is exectued in background
      CLEAR : wa_jobsteplist.
      REFRESH : i_jobsteplist.
      WRITE:/ 'DISPLAYING JOB STATUS'.
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    To Display the status text as per the status type
      CASE wa_jobhead-status.
        WHEN 'S'. WRITE: / 'Scheduled'.
        WHEN 'R'. WRITE: / 'Released'.
        WHEN 'F'. WRITE: / 'Completed'.
        WHEN 'A'. WRITE: / 'Cancelled'.
        WHEN OTHERS.
      ENDCASE.
      IF sy-lsind GE 19.
        sy-lsind = 1.
      ENDIF.
    ENDFORM.                    " display_status
    *&      Form  display_job_log
          text
    -->  p1        text
    <--  p2        text
    FORM display_job_log .
    To display the log of the background program
      LEAVE TO LIST-PROCESSING.
      CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
        EXPORTING
          client                    = sy-mandt
          jobcount                  = w_jobcount
          joblogid                  = ' '
          jobname                   = w_jobname
        EXCEPTIONS
          error_reading_jobdata     = 1
          error_reading_joblog_data = 2
          jobcount_missing          = 3
          joblog_does_not_exist     = 4
          joblog_is_empty           = 5
          joblog_show_canceled      = 6
          jobname_missing           = 7
          job_does_not_exist        = 8
          no_joblog_there_yet       = 9
          no_show_privilege_given   = 10
          OTHERS                    = 11.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " display_job_log
    *&      Form  prepare_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_fieldcatalog .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Material no.'.
      wa_fieldcat-outputlen    = '18'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERSDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Creation date'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERNAM'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Name of Person'.
      wa_fieldcat-outputlen    = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'LAEDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = ' Last Change'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          it_fieldcat  = i_fieldcat
        tables
          t_outtab     = i_mara.
    ENDFORM.                    " display_alv
    •     ZPROGRAM_TWO: This is the 2nd program which would be called from program ZPROGRAM_ONE.
    *& Report  ZPROGRAM_TWO                                                *
    REPORT  zprogram_two                            .
    PRASHANT PATIL
    TABLES : mara.
    TYPE-POOLS:slis.
    TYPES : BEGIN OF t_mara,
              matnr   TYPE mara-matnr,
              ersda   TYPE mara-ersda,
              ernam   TYPE mara-ernam,
              laeda   TYPE mara-laeda,
            END OF t_mara.
    DATA : i_mara        TYPE STANDARD TABLE OF t_mara,
           wa_mara       TYPE t_mara,
           wa_index      TYPE indx,        " For Index details
           wa_index_key  TYPE indx-srtfd VALUE 'PRG_ONE',
           wa_index1     TYPE indx,        " For Index details
           wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
           i_fieldcat        TYPE slis_t_fieldcat_alv,
           wa_fieldcat       LIKE LINE OF i_fieldcat.
    SELECT-OPTIONS : s_matnr FOR mara-matnr.
    Before the import, fill the data fields before CLUSTR.
    wa_index-aedat = sy-datum.
    wa_index-usera = sy-uname.
    To Import the selection screen data from Calling Program
    IMPORT s_matnr
    FROM DATABASE indx(st) ID wa_index_key TO wa_index.
    FREE MEMORY ID wa_index_key.
    SELECT matnr
           ersda
           ernam
           laeda
           FROM mara
           INTO TABLE i_mara
           WHERE matnr IN s_matnr.
    PERFORM prepare_fieldcatalog.
    PERFORM display_alv.
    Before the export, fill the data fields before CLUSTR
    wa_index1-aedat = sy-datum.
    wa_index1-usera = sy-uname.
    EXPORT i_mara
    TO DATABASE indx(st) FROM wa_index1 ID wa_index_key1.
    *&      Form  prepare_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_fieldcatalog .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '18'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERSDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERNAM'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'LAEDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = i_fieldcat
        TABLES
          t_outtab    = i_mara.
    ENDFORM.                    " display_alv
    its possible to display ALV Grid using OO ALV. Following code can be used instead of FM.
    In the PBO, add following code
    SET PF-STATUS 'ZSTAT'.
    If program is executed in background
    CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING
    e_offline = off.
    IF off IS INITIAL.
    IF container1 IS INITIAL.
    CREATE OBJECT container1
    EXPORTING
    container_name = 'CC_ALV1' .
    ENDIF.
    ENDIF.
    CREATE OBJECT g_grid1
    EXPORTING
    i_parent = container1.
    CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    i_save = 'A'
    i_default = ' '
    is_layout =
    is_print =
    IT_SPECIAL_GROUPS =
    it_toolbar_excluding =
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = i_output
    it_fieldcatalog = i_fieldcatalog
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Reward points if useful
    Regards
    Anji

  • How to send the ALV GRID output to spool by using the print button in std t

    How to send the ALV GRID output to spool by using the print button in standard tool bar.
    We have created a button in the va02 transaction.  If user click on the button the new screen will be display on that screen we are populating the alv grid output using the oops concept.  But i am unable to send the output to spool using the print button in the standard tool bar.
    I am able to display the Print parameter dialog box but i am not able to send it to spool.
    Kindly help.
    Thanks In Advance.
    G.V.Ramana

    Hi Shaik,
    There is not properties button in my print screen.
    MODULE user_command_0900 INPUT.
        WHEN 'EXCEL'.
          PERFORM excel_download.                              
        WHEN 'PRI'.
          PERFORM print_output.
    form Print_output.
    CALL FUNCTION 'RSPO_LIST_LAYOUT_FITS'
               EXPORTING
                    columns        = 80
                    device         = 'ANY '
                    lines          = 65
                    maxpenality    = 1999
               TABLES
                    layouts        = lt_layouts1
               EXCEPTIONS
                    unknown_device = 1
                    OTHERS         = 2.
          IF sy-subrc = 0.
            LOOP AT lt_layouts1.
              IF lt_layouts1-penality < 1000        AND
                 lt_layouts1-penality < l_min_penality.
                l_layout       = lt_layouts1-layout.
                l_min_penality = lt_layouts1-penality.
              ENDIF.
            ENDLOOP.
            IF NOT l_layout IS INITIAL.
              CALL FUNCTION 'GET_PRINT_PARAMETERS'
                   EXPORTING
                        mode                   = 'CURRENT'
                        line_size              = 80             "#EC *
                new_list_id            = l_new_list_id
                        no_dialog              = l_no_dialog
                        layout                 = l_layout
                   IMPORTING
                        out_archive_parameters = rs_arc_params
                        out_parameters         = rs_pri_params
                        valid                  = l_valid
                   EXCEPTIONS
                        archive_info_not_found = 1
                        invalid_print_params   = 2
                        invalid_archive_params = 3
                        OTHERS                 = 4.
              IF sy-subrc NE 0.                                 " INS SLIN
              ENDIF.                                            " INS SLIN
              IF rs_pri_params-linsz LT 80 OR
                 rs_pri_params-linsz LT gt_stack-s_lprint-width.
                gt_stack-print_line_break = 'X'.
              ELSE.
                CLEAR gt_stack-print_line_break.
              ENDIF.
              IF l_valid NE 'X'.
                rs_pri_params = ls_pri_params_sav.
                rs_arc_params = ls_arc_params_sav.
              ENDIF.
            ENDIF.
          ENDIF.
    endform.                    " Print_output
        CALL METHOD gv_cost_tot_alv_grand->set_table_for_first_display
                EXPORTING
                   is_layout         = gs_layout_cost_tot_grand
                CHANGING
                   it_fieldcatalog   = gt_fcat_cost_tot_grand[]
                   it_outtab         = gt_cost_tot_grand[].
    Please check my code

  • Problem when dowloading the ALV report output to Excel Sheet.

    Hi ,
    I am dowloading the ALV report output to Excel Sheet.
    There is field Condition Unit(KOMP-KMEIN) in the output of the ALV, this has values PC and CSE , but when I download to Excel Sheet, CSE is appearing as CSE ,but PC is appearing as ******.
    Can you please help me in knowing the reson for this.
    Regards,
    Madhu.

    hi
    refer to following link
    http://www.****************/Tutorials/ALV/ColorSALV/Demo.htm
    http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
    Cheers
    Snehi
    Edited by: snehi chouhan on Jul 11, 2008 12:42 PM

  • Adding/Enabling Totals & Subtotals Button in ALV Report Output

    Hi Guys,
    I would like to know , how to add / enable Totals & Subtotals Button on the application tool bar in alv report output.
    Regards,
    Kishan

    ok so here i am sending my code....its also interactive...
    and in second list i am displaying quantity....
    *& Report  ZINT_ALV
    REPORT  zint_alv.
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           mseg.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
         END OF itab.
    DATA:BEGIN OF itab1 OCCURS 0,
          mblnr LIKE mseg-mblnr,
          menge LIKE mseg-menge,
          meins LIKE mseg-meins,
          werks LIKE mseg-werks,
         END OF itab1.
    DATA:fcat TYPE slis_t_fieldcat_alv,
         fcat1 TYPE slis_t_fieldcat_alv,
         eve TYPE slis_t_event,
         eve1 TYPE slis_t_event.
    DATA:t_mat LIKE mara-matnr,
         s_mat LIKE mara-matnr,
         g_repid LIKE sy-repid.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr OBLIGATORY.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_fcat USING fcat.
      PERFORM build_eve.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM dis_data.
    *&      Form  build_fcat
          text
         -->T_FCAT     text
    FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_fieldname = 'MATNR'.
      wa_fcat-ref_tabname = 'MARA'.
      wa_fcat-seltext_m = 'Material'.
    wa_fcat-input = ' '.
    wa_fcat-edit = 'X'.
      wa_fcat-input = 'X'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    "build_fcat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA:t_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type           = 0
       IMPORTING
         et_events             = eve
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  get_data
          text
    FORM get_data.
      SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt
      ON maramatnr = maktmatnr
      WHERE mara~matnr IN mat.
    ENDFORM.                    "get_data
    *&      Form  dis_data
          text
    FORM dis_data.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid         "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND'
         i_grid_title                      = 'Interactive ALV'
         it_fieldcat                       = fcat
         it_events                         = eve
        TABLES
          t_outtab                          = itab
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "dis_data
    *&      Form  user_command
          text
         -->U_COM      text
    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
      CLEAR fcat1.
      CASE u_com.
        WHEN '&IC1'.
          READ TABLE itab INDEX sel_field-tabindex.
          IF sel_field-fieldname = 'MATNR'.
            IF sy-subrc = 0.
              t_mat = itab-matnr.
              PERFORM build_cat1 USING fcat1.
              PERFORM build_eve1.
              PERFORM get_data1.
              PERFORM dis_data1.
            ENDIF.
          ENDIF.
         SET PARAMETER ID 'MAT' FIELD t_mat.
         CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  build_fcat1
          text
         -->T_FCAT1    text
    FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat1 TYPE slis_fieldcat_alv.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MBLNR'.
      wa_fcat1-seltext_m = 'Material Doc.'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MENGE'.
      wa_fcat1-seltext_m = 'Quantity'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MEINS'.
      wa_fcat1-seltext_m = 'UOM'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'WERKS'.
      wa_fcat1-seltext_m = 'Plant'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
    ENDFORM.                    "build_fcat1
    *&      Form  build_eve1
          text
    FORM build_eve1.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = eve1
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    "build_eve1
    *&      Form  get_data1
          text
    FORM get_data1.
      SELECT mblnr menge meins werks FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab1
      WHERE matnr = t_mat.
    ENDFORM.                                                    "get_data1
    *&      Form  dis_data1
          text
    FORM dis_data1.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid              "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND1'
         it_fieldcat                       = fcat1
         it_events                         = eve1
        TABLES
          t_outtab                          = itab1
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    "dis_data1

  • Mailing ALV report OUTPUT

    Hi Experts,
    Can you give an example program on mailing ALV report output to any ID.
    Thanks in advance.
    Regards,
    Ram

    Hi ram
    Here i'm posting u sample code try to execute it. It will convert all the data in the related tables to excel format and transfer it to respective mail id
    *& Report  ZTESTMAIL                                                   *
    REPORT  ZTESTMAIL                               .
    tables: ekko.
    parameters: p_email type somlreci1-receiver default
    '[email protected]'.
    types: begin of t_ekpo,
    ebeln type ekpo-ebeln,
    ebelp type ekpo-ebelp,
    aedat type ekpo-aedat,
    matnr type ekpo-matnr,
    end of t_ekpo.
    data: it_ekpo type standard table of t_ekpo initial size 0,
    wa_ekpo type t_ekpo.
    types: begin of t_charekpo,
    ebeln(10) type c,
    ebelp(5) type c,
    aedat(8) type c,
    matnr(18) type c,
    end of t_charekpo.
    data: wa_charekpo type t_charekpo.
    data: it_message type standard table of solisti1 initial size 0
    with header line.
    data: it_attach type standard table of solisti1 initial size 0
    with header line.
    data: t_packing_list like sopcklsti1 occurs 0 with header line,
    t_contents like solisti1 occurs 0 with header line,
    t_receivers like somlreci1 occurs 0 with header line,
    t_attachment like solisti1 occurs 0 with header line,
    t_object_header like solisti1 occurs 0 with header line,
    w_cnt type i,
    w_sent_all(1) type c,
    w_doc_data like sodocchgi1,
    gd_error type sy-subrc,
    gd_reciever type sy-subrc.
    t_object_header = 'Text.xls'. append t_object_header.
    *START_OF_SELECTION
    start-of-selection.
    * Retrieve sample data from table ekpo
    perform data_retrieval.
    * Populate table with detaisl to be entered into .xls file
    perform build_xls_data_table.
    *END-OF-SELECTION
    end-of-selection.
    * Populate message body text
    perform populate_email_message_body.
    * Send file by email as .xls speadsheet
    perform send_file_as_email_attachment
    tables it_message
    it_attach
    using p_email
    'Example .xls documnet attachment'
    'XLS'
    'filename'
    changing gd_error
    gd_reciever.
    * Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    * Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp aedat matnr
    up to 10 rows
    from ekpo
    into table it_ekpo.
    endform. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    * Build data table for .xls document
    form build_xls_data_table.
    *CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
    *con_tab TYPE x VALUE '09'. "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    constants:
    con_tab type c value cl_abap_char_utilities=>horizontal_tab,
    con_cret type c value cl_abap_char_utilities=>cr_lf.
    concatenate 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    loop at it_ekpo into wa_charekpo.
    concatenate wa_charekpo-ebeln wa_charekpo-ebelp
    wa_charekpo-aedat wa_charekpo-matnr
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    endloop.
    endform. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    * Send email
    form send_file_as_email_attachment tables pit_message
    pit_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
    data: ld_error type sy-subrc,
    ld_reciever type sy-subrc,
    ld_mtitle like sodocchgi1-obj_descr,
    ld_email like somlreci1-receiver,
    ld_format type so_obj_tp ,
    ld_attdescription type so_obj_nam ,
    ld_attfilename type so_obj_des ,
    ld_sender_address like soextreci1-receiver,
    ld_sender_address_type like soextreci1-adr_typ,
    ld_receiver like sy-subrc.
    ld_email = p_email.
    ld_mtitle = p_mtitle.
    ld_format = p_format.
    ld_attdescription = p_attdescription.
    ld_attfilename = p_filename.
    ld_sender_address = p_sender_address.
    ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
    w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = 'SAPRPT'.
    w_doc_data-obj_descr = ld_mtitle .
    w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
    clear w_doc_data.
    read table it_attach index w_cnt.
    w_doc_data-doc_size =
    ( w_cnt - 1 ) * 255 + strlen( it_attach ).
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = 'SAPRPT'.
    w_doc_data-obj_descr = ld_mtitle.
    w_doc_data-sensitivty = 'F'.
    clear t_attachment.
    refresh t_attachment.
    t_attachment[] = pit_attach[].
    * Describe the body of the message
    clear t_packing_list.
    refresh t_packing_list.
    t_packing_list-transf_bin = space.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 0.
    t_packing_list-body_start = 1.
    describe table it_message lines t_packing_list-body_num.
    t_packing_list-doc_type = 'RAW'.
    append t_packing_list.
    * Create attachment notification
    t_packing_list-transf_bin = 'X'.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 1.
    t_packing_list-body_start = 1.
    describe table t_attachment lines t_packing_list-body_num.
    t_packing_list-doc_type = ld_format.
    t_packing_list-obj_descr = ld_attdescription.
    t_packing_list-obj_name = ld_attfilename.
    t_packing_list-doc_size = t_packing_list-body_num * 255.
    append t_packing_list.
    * Add the recipients email address
    clear t_receivers.
    refresh t_receivers.
    t_receivers-receiver = ld_email.
    t_receivers-rec_type = 'U'.
    t_receivers-com_type = 'INT'.
    t_receivers-notif_del = 'X'.
    t_receivers-notif_ndel = 'X'.
    append t_receivers.
    call function 'SO_DOCUMENT_SEND_API1'
    exporting
    document_data = w_doc_data
    put_in_outbox = 'X'
    sender_address = ld_sender_address
    sender_address_type = ld_sender_address_type
    commit_work = 'X'
    importing
    sent_to_all = w_sent_all
    tables
    object_header = t_object_header
    packing_list = t_packing_list
    contents_bin = t_attachment
    contents_txt = it_message
    receivers = t_receivers
    exceptions
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    others = 8.
    * Populate zerror return code
    ld_error = sy-subrc.
    * Populate zreceiver return code
    loop at t_receivers.
    ld_receiver = t_receivers-retrn_code.
    endloop.
    endform.
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    * Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
    wait up to 2 seconds.
    submit rsconn01 with mode = 'INT'
    with output = 'X'
    and return.
    endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    * Populate message body text
    form populate_email_message_body.
    refresh it_message.
    it_message = 'Please find attached a list test ekpo records'.
    append it_message.
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    *PARAMETERS: psubject(40) type c default 'Testing',
    *p_email(40) type c default '[email protected]'. "use ur email id
    *data: it_packing_list like sopcklsti1 occurs 0 with header line,
    *it_contents like solisti1 occurs 0 with header line,
    *it_receivers like somlreci1 occurs 0 with header line,
    *it_attachment like solisti1 occurs 0 with header line,
    *gd_cnt type i,
    *gd_sent_all(1) type c,
    *gd_doc_data like sodocchgi1,
    *gd_error type sy-subrc.
    *data: it_message type standard table of SOLISTI1 initial size 0
    *with header line.
    **START-OF-SELECTION.
    *START-OF-SELECTION.
    *Perform populate_message_table.
    **Send email message, although is not sent from SAP until mail send
    **program has been executed(rsconn01)
    *PERFORM send_email_message.
    **Instructs mail send program for SAPCONNECT to send email(rsconn01)
    *perform initiate_mail_execute_program.
    **& Form POPULATE_MESSAGE_TABLE
    ** Adds text to email text table
    *form populate_message_table.
    *Append 'Line1' to it_message.
    *Append 'Line2' to it_message.
    *Append 'Line3' to it_message.
    *Append 'Test- 1' to it_message.
    *endform. " POPULATE_MESSAGE_TABLE
    **& Form SEND_EMAIL_MESSAGE
    ** Send email message
    *form send_email_message.
    ** Fill the document data.
    *gd_doc_data-doc_size = 1.
    ** DATA: TAB_LINES LIKE sy-tabix.
    ** DESCRIBE TABLE it_message LINES TAB_LINES.
    ** READ TABLE it_message INDEX TAB_LINES.
    ** gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )
    ** Populate the subject/generic message attributes
    *gd_doc_data-obj_langu = sy-langu.
    *gd_doc_data-obj_name = 'SAPRPT'.
    *gd_doc_data-obj_descr = psubject.
    *gd_doc_data-sensitivty = 'F'.
    ** Describe the body of the message
    ** Information about structure of data tables
    *clear it_packing_list.
    *refresh it_packing_list.
    *it_packing_list-transf_bin = space.
    *it_packing_list-head_start = 1.
    *it_packing_list-head_num = 0.
    *it_packing_list-body_start = 1.
    *describe table it_message lines it_packing_list-body_num.
    *it_packing_list-doc_type = 'RAW'.
    *append it_packing_list.
    ** Add the recipients email address
    *clear it_receivers.
    *refresh it_receivers.
    *it_receivers-receiver = p_email.
    *it_receivers-rec_type = 'U'.
    ** it_receivers-com_type = 'INT'.
    ** it_receivers-notif_del = 'X'.
    ** it_receivers-notif_ndel = 'X'.
    *append it_receivers.
    ** Call the FM to post the message to SAPMAIL
    *call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    *exporting
    *document_data = gd_doc_data
    *put_in_outbox = 'X'
    *importing
    *sent_to_all = gd_sent_all
    *tables
    *packing_list = it_packing_list
    *contents_txt = it_message
    *receivers = it_receivers
    *exceptions
    *too_many_receivers = 1
    *document_not_sent = 2
    *document_type_not_exist = 3
    *operation_no_authorization = 4
    *parameter_error = 5
    *x_error = 6
    *enqueue_error = 7
    *others = 8.
    ** Store function module return code
    *gd_error = sy-subrc.
    ** Get it_receivers return code
    *loop at it_receivers.
    *endloop.
    *endform. " SEND_EMAIL_MESSAGE
    **& Form INITIATE_MAIL_EXECUTE_PROGRAM
    ** Instructs mail send program for SAPCONNECT to send email.
    *form initiate_mail_execute_program.
    *wait up to 2 seconds.
    *if gd_error eq 0.
    *submit rsconn01 with mode = 'INT'
    *with output = 'X'
    *and return.
    *endif.
    *endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    Rewards if helpfull
    Regards
    Pavan

  • Deletion of extra space in ALV report output

    Hi Experts,
    I have one issue where i have to delete the extra space in the output of  ALV report.
    Please let me know the possible way... Its very urgent.
    Thanks in advance
    Siri

    Hi Siri,
    Try these following steps in your report...... i think, it will lead you to solve your problem.
    1. Give output length of alv column as 10.
    2. OUTPUTLEN is there in Field catalogue
    3. "gt_layout TYPE lvc_s_layo" -  use this one field col_opt
    Reward if useful.
    Regards,
    Harish

  • Tab not working on ALV report output in Persona

    In normal SAP GUI we can move the cursor position on ALV report output between different column by pressing TAB on keyboard. But in case of persona 2.00, TAB doesn't work and we have to click on each cell of the report output whatever we want to highlight. Is there any settings or SAP note we can implement to so TAB will work on persona.
    Thanks,
    harkamal

    Hi Devendra Singh,
    I think it's not possible to show all field values in another Language (Eg Thai) But it's possible if it's short Text, Long Text etc
    SE63 and follow menu
    Translation
    ABAP Objects
    Short Text / Long Text Etc..
    AND
    Translation
    NON ABAP Objects
    For that also you have to maintain it first in SE63..
    [SAP Help1|http://help.sap.com/erp2005_ehp_04/helpdata/EN/77/5719d2492011d1894a0000e829fbbd/frameset.htm]
    [SAP Help2|http://help.sap.com/erp2005_ehp_04/helpdata/EN/b4/54601d77f38e429ffad9e3e11c1b25/frameset.htm]
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • ALV Report output in Excel format

    Hi ,
    I am facing a different behaviour in two computers , while trying to take an Excel format of an ALV report output. After generating the ALV output ,in one , when I click on the Excel Format button - the Excel spreadsheet opens with the output data. In the second computed , under the same action , a blank Excel sheet opens .
    Could someone tell me a solution . What aspect is responsible for this ?
    Regards ,
    Sujata

    Reduce the MACRO security settings in the Excel to Medium.
    Open an execl sheet, Chose from menu Tootls->Macro->Security.
    Chose the radio-buton medium. Close the file and all excel applications.Then try downloading again.
    Regards,
    Ravi

  • How to give  push button in alv report  output

    hi,
    my requirement is that , i have to give push button in alv report output(item level) not in application toolbar, i am using reuse_alv_grid_display FM, can any body provide me sample code
    regards,
    siva kumar

    have a look at this thread, also has a sample report at the end from Uwe Schieferstein.
    [button on alv list|How to add and program a pushbutton on ALV grid line;
    seems not to work try this:
    How to add and program a pushbutton on ALV grid line
    Edited by: Micky Oestreich on May 15, 2008 10:20 PM

  • Select  mutiple rows in ALV report output

    Hi All,
    I want to select the Multiple records i in ALV report output with out holding the CNTL(Control Key).
    Is there any options in Layout?
    Please let me know
    regards,
    Ajay
    Edited by: Ajay reddy on May 30, 2010 3:27 PM

    Hi Ajay,
    To select several rows without Control button, if the rows are adjacent:
    - select the first and the last of the desired rows with Shift button pressed
    or
    - select a row, keep the mouse button pressed, and pass over the desired rows
    I don't know an option without Control if the rows are not adjacent.
    http://help.sap.com/saphelp_bw/helpdata/en/d1/7d9d37664e4d45e10000009b38f8cf/content.htm
    Regards,
    Paulo Carvalho

  • How to Print Selection-Screen along with ALV Report output

    Hi,
    I have a requirement wherein i need to also print the Selection Screen of a report when I print the ALV report output.
    Basically i need to print the ALV output along with selection screen.
    Could you plz suggest me the way.
    Regards,
    Nitin

    Hi,
    My selection Screen is a very big one. It contains around 30 select-options.
    So is their any standard method in which you can choose whether you want to take the output printout with or without Selection screen.
    Regards,
    Nitin

Maybe you are looking for