Skip to Content
author's profile photo Former Member
Former Member

Problem while sending Abap list to mail in the background

Hi all,

I am sending abap list to email in the background.

My code as folllows:

DATA: so_ali LIKE solisti1 OCCURS 100 WITH HEADER LINE.

DATA: listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.

DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.

DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.

DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

DATA: doc_chng LIKE sodocchgi1.

DATA: tab_lines LIKE sy-tabix.

DATA: lt_user TYPE soud3 OCCURS 0 WITH HEADER LINE.

*Start of modification Tix 14411 for transport request D82K929044

DATA: it_user like SODLIENTI1 occurs 0 with header line.

*End of modification for Tix 14411 for transport request D82K929044

CLEAR: listobject, so_ali, objpack, objhead, objtxt, reclist, doc_chng.

REFRESH :

listobject, so_ali, objpack, objhead, objtxt, reclist.

  • creation of the document to be sent

doc_chng-obj_name = 'BOFAREPORT'.

WRITE sy-datum TO doc_chng-obj_descr.

CONCATENATE 'Bank Activity Report for :'(025)

company_itab_tr-company_code '-' doc_chng-obj_descr INTO

doc_chng-obj_descr. "AN052799

objtxt = 'This is the bank activity report received for'(026).

APPEND objtxt.

CONCATENATE company_itab_tr-company_code '-'

company_itab_tr-company_name '-'

company_itab_tr-company_city INTO

objtxt.

APPEND objtxt.

WRITE sy-datum TO objtxt.

CONCATENATE 'Date Received : '(027) objtxt INTO objtxt.

APPEND objtxt.

WRITE sy-uzeit TO objtxt.

CONCATENATE 'Time Received : '(028) objtxt INTO objtxt.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

  • Creation of the entry for the compressed document

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'RAW'.

APPEND objpack.

  • Creation of the document attachment

CALL FUNCTION 'SAVE_LIST'

EXPORTING

list_index = '0'

TABLES

listobject = listobject

EXCEPTIONS

list_index_invalid = 1

OTHERS = 2.

CALL FUNCTION 'TABLE_COMPRESS' "Schneller Tabellencopy

TABLES

in = listobject

out = so_ali.

DESCRIBE TABLE so_ali LINES tab_lines. "objbin

objhead = 'BOFA-REPORT'. APPEND objhead.

  • Creation of the entry for the compressed attachment

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'ALI'.

objpack-obj_name = 'BOFAREPORT'.

objpack-obj_descr = 'Bank Activity Report'.

objpack-doc_size = tab_lines * 255.

APPEND objpack.

  • Completing the recipient list

SELECT * FROM zwfi_yefap_paypr WHERE

bukrs = company_itab_tr-company_code.

IF NOT ( zwfi_yefap_paypr-list1 IS INITIAL ).

clear it_user[].

CALL FUNCTION 'SO_DLI_READ_API1'

EXPORTING

DLI_NAME = zwfi_yefap_paypr-list1

  • DLI_ID = ' '

SHARED_DLI = 'X'

  • IMPORTING

  • DLI_DATA =

TABLES

DLI_ENTRIES = it_user

EXCEPTIONS

DLI_NOT_EXIST = 1

OPERATION_NO_AUTHORIZATION = 2

PARAMETER_ERROR = 3

X_ERROR = 4

OTHERS = 5

.

IF SY-SUBRC = 0.

loop at it_user.

if it_user-member_typ = 'A'.

reclist-receiver = it_user-member_adr.

reclist-rec_type = 'U'.

reclist-com_type = 'INT'.

reclist-notif_del = 'X'.

reclist-notif_ndel = 'X'.

append reclist.

elseif it_user-member_typ = ''.

reclist-receiver = it_user-member_nam.

reclist-rec_type = 'B'.

reclist-express = 'X'.

append reclist.

Endif.

endloop.

ENDIF.

*

ENDIF.

IF NOT ( zwfi_yefap_paypr-list2 IS INITIAL ).

clear it_user[].

CALL FUNCTION 'SO_DLI_READ_API1'

EXPORTING

DLI_NAME = zwfi_yefap_paypr-list2

  • DLI_ID = ' '

SHARED_DLI = 'X'

  • IMPORTING

  • DLI_DATA =

TABLES

DLI_ENTRIES = it_user

EXCEPTIONS

DLI_NOT_EXIST = 1

OPERATION_NO_AUTHORIZATION = 2

PARAMETER_ERROR = 3

X_ERROR = 4

OTHERS = 5

.

IF SY-SUBRC = 0.

loop at it_user.

if it_user-member_typ = 'A'.

reclist-receiver = it_user-member_adr.

reclist-rec_type = 'U'.

reclist-com_type = 'INT'.

reclist-notif_del = 'X'.

reclist-notif_ndel = 'X'.

append reclist.

elseif it_user-member_typ = ''.

reclist-receiver = it_user-member_nam.

reclist-rec_type = 'B'.

reclist-express = 'X'.

append reclist.

Endif.

endloop.

ENDIF.

endif.

ENDSELECT.

CLEAR error_text.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = 'X'

COMMIT_WORK = 'X'

TABLES

packing_list = objpack

object_header = objhead

contents_bin = so_ali "objbin

contents_txt = objtxt

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

CASE sy-subrc.

WHEN 0.

  • write: / 'Result of the send process:'.

LOOP AT reclist.

  • write: / reclist-receiver(48), ':'.

IF reclist-retrn_code <> 0.

  • write 'The document was sent'.

  • else.

CONCATENATE 'The document could not be sent to : '(029)

reclist-receiver(48) INTO error_text.

ENDIF.

ENDLOOP.

WHEN 1.

error_text = text-030.

WHEN 2.

error_text = 'Document could not be sent to any recipient'(031).

WHEN 4.

error_text = 'No send authorization'(032).

WHEN OTHERS.

error_text = 'Error occurred while sending'(033).

ENDCASE.

IF NOT ( error_text IS INITIAL ).

CONCATENATE 'Mail send Error : '(034) error_text INTO error_text.

  • PERFORM WRITE_LOG(YEFAP_APERAK) USING ERROR_TEXT.

PERFORM write_log(zwfi_yefap_bank_report) USING error_text.

ENDIF.

CALL FUNCTION 'LIST_FREE_MEMORY'

TABLES

listobject = listobject

EXCEPTIONS

OTHERS = 1.

When I excute the same program in the foreground, Attachment in the mail is showing all the pages of the report output.

But when I excute the same program in the background only last page is shown in the mail attachemnt.

I think the problem is with the function module SAVE_LIST function module.

I replaced the SAVE_LIST function module with LIST_TO_MEMORY and LIST_FROM_MEMORY function modules.

It is also giving the same result.

In the foreground excution email attachemnt showing all the pages and in the background excution only last page is shown in the attachemnt.

I want all the pages dispalyed in the background mode excution in the email attachment.

How to slove this issue.

Thanks in advance.

Raja

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 01:58 PM

    Raja,

    You are not populating "listobject" anywhere in this code. You clear and refresh it, however. Then SAVE_LIST and COMPRESS it... but it is empty the whole time.

    I am confused on purpose.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 12, 2007 at 02:06 PM

    I have seen this problem before. Please have a look at this example program. This works very well when ran in background as well as foreground

    
    * This program works in the background, 
    
    
    report zrich_0003 .
    
    data: maildata like sodocchgi1.
    data: mailtxt like solisti1 occurs 10 with header line.
    data: mailrec like somlrec90 occurs 0 with header line.
    data: list type table of abaplist with header line.
    data: ascilines(1024) type c occurs 0 with header line.
    data: htmllines type table of w3html with header line.
    
    parameters: p_check.
    
    start-of-selection.
    
      submit zrich_0004 exporting list to memory and return.
    
      call function 'LIST_FROM_MEMORY'
           tables
                listobject = list
           exceptions
                not_found  = 1
                others     = 2.
    
      call function 'LIST_TO_ASCI'
           tables
                listobject         = list
                listasci           = ascilines
           exceptions
                empty_list         = 1
                list_index_invalid = 2
                others             = 3.
    
      call function 'WWW_HTML_FROM_LISTOBJECT'
           tables
                html       = htmllines
                listobject = list.
    
    
      clear: maildata, mailtxt, mailrec.
      refresh: mailtxt, mailrec.
    
      maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test Subject'.
    
      loop at htmllines.
        mailtxt = htmllines.
        append mailtxt.
      endloop.
    
      mailrec-receiver = 'rich.heilman@yorktwn.com'.
      mailrec-rec_type = 'U'.
      append mailrec.
    
      call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              = maildata
                document_type              = 'HTM'
                put_in_outbox              = 'X'
           tables
                object_header              = mailtxt
                object_content             = mailtxt
                receivers                  = mailrec
           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.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    
      commit work.
      wait up to 2 seconds.
      submit rsconn01 with mode = 'INT'
                   with output = 'X'
                              and return.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.