Skip to Content
0
Former Member
Jan 12, 2007 at 01:28 PM

Problem while sending Abap list to mail in the background

68 Views

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