Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

2 alv-lists in one batch job

andreas_mann3
Active Contributor
0 Kudos
146

How can I create 2 ALV-lists in one batch job

with fm REUSE_ALV_LIST_DISPLAY ?

kind regards

Andreas

1 ACCEPTED SOLUTION

former_member196079
Active Contributor
0 Kudos
80

Hi Andreas

check this link

regards

Marco

5 REPLIES 5

former_member196079
Active Contributor
0 Kudos
81

Hi Andreas

check this link

regards

Marco

0 Kudos
80

thanks but not with 2 custom containers and alv-grid

but with alv-list...

Former Member
0 Kudos
80

Try this...


* In SELECTION-SCREEN area, define type of email and recepient.
PARAMETERS: p_email  TYPE somlreci1-receiver,   "Name of Shared Distribution List
            p_rectyp TYPE so_escape.    "Type C for Shared Distribution List 

* In body of program, call 1st alv grid, send the spool to the recepient, call 2nd alv grid, send the spool to the recepient.

    PERFORM 03display_data.
    PERFORM send_spool_2_user USING sy-spono.
    PERFORM 04display_data.
    PERFORM send_spool_2_user USING sy-spono.


* Form to sent the spool to the recepient.
FORM send_spool_2_user  USING    p_spono.
  spool_number = p_spono.
  IF sy-batch = x AND spool_number IS NOT INITIAL.
    IF p_email IS NOT INITIAL
    AND p_rectyp IS NOT INITIAL.
*PARAMETERS: p_email  TYPE somlreci1-receiver DEFAULT 'ZDALLEN',
*            p_rectyp type so_escape  DEFAULT 'C'.

      PERFORM set_spool_title_name.
      PERFORM build_txt_data_table.

      PERFORM populate_email_message_body.

* Send file by email as .txt speadsheet
      PERFORM send_file_as_email_attachment
        TABLES it_message
               it_attach
        USING p_email
              v_spl_title                         "Title of Email
              'ALI'                                             "File Format (ALI=List)
              v_spl_name                  "File Name (Can't see how this is used)
              v_spl_name                  "Description on Attachment max 12 characters
              ' '
              ' '
        CHANGING gd_error
              gd_reciever.

* Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.

    ENDIF.
  ENDIF.
ENDFORM.                    " send_spool_2_user

*&---------------------------------------------------------------------*
*& 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 = 'C'.
  t_receivers-com_type = '   '.
  t_receivers-notif_del = ' '.
  t_receivers-notif_ndel = ' '.
  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
      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.                    "SEND_FILE_AS_EMAIL_ATTACHMENT
*&---------------------------------------------------------------------*
*& 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

Edited by: Deborah Allen on May 11, 2010 12:36 AM

Former Member
0 Kudos
80

Why does the code markup statements not work?

andreas_mann3
Active Contributor
0 Kudos
80

use fm's

REUSE_ALV_BLOCK_LIST_INIT

REUSE_ALV_BLOCK_LIST_APPEND..

REUSE_ALV_BLOCK_LIST_APPEND..

REUSE_ALV_BLOCK_LIST_DISPLAY