cancel
Showing results for 
Search instead for 
Did you mean: 

creating Attachment in send mail step

former_member201532
Participant
0 Kudos

Hi,

My requirement is to send all the item details as attchement in mail to sap inbox .

i am getting all sales order item details into internal table to workflow container element ZITEMS.

1.created workflow container element ZATTCH of object type SOFM

2. Binding ZATTCH element to ATTACHMENT in mail task step

but i am unable do the bellow steps

3.How to pass data from ZITEMS element to ZATTACH which conatins all item details.

                                               or

4. i need to display all sales order item details in body of email but item details are multipule.

please tell me how to acheive these requirement.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member201532
Participant
0 Kudos

Hi,

i tried with bellow code for text file attachment it is working but i am unable to do PDF or XL attachement.

select VBELN POSNR from vbap into TABLE lt_vbap UP TO 20 rows.

DATA:I_CHAR TYPE String.
data:i_soli TYPE STANDARD TABLE OF SOLI WITH HEADER LINE.

LOOP AT lt_vbap INTO ls_vbap.
CONCATENATE LS_VBAP-VBELN LS_VBAP-POSNR I_CHAR INTO I_CHAR SEPARATED BY SPACE.
ENDLOOP.

v_att_header-file_type = 'T'.
v_att_header-file_name = 'TEST'.                     "v_docname_only.
v_att_header-file_extension = 'RAW'.              "v_doc_extension.
v_att_header-language = sy-langu.
V_XSTRING = V_STRING.

               CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
                 EXPORTING
                   WORKITEM_ID            = w_i
                  ATT_HEADER             = v_att_header
                  ATT_TXT                = I_CHAR
*                  ATT_BIN                = V_XSTRING
                  DOCUMENT_OWNER         = SY-UNAME
                  LANGUAGE               = SY-LANGU

                  DO_COMMIT              = 'X'
*                  COMMENT_SEMANTIC       = ' '
               IMPORTING
*                  RETURN_CODE            =
                  ATT_ID                 = v_att_id
*                TABLES
*                  MESSAGE_LINES          =
*                  MESSAGE_STRUCT         =
                         .

can anyone tell how to do PDF or XL attachment using above function module.

can we do PDF attachment without SPOOL ID ?

Thanks,

former_member185167
Active Contributor
0 Kudos
former_member201532
Participant
0 Kudos

Hi Rick,

my internal table contains sales order item details , so it is text only.

by using this &ABC##& we can display but if salesorder conatins mutipule items.

so i am trying for attachment.

anjan_paul
Active Contributor
0 Kudos

Hi,

   Did you try with  &ABC##&.. What you got the result? it should work

former_member201532
Participant
0 Kudos

Hi,

i am trying to attach internal table data as attachemnt to mail step but it is not working.

i try to send it as text data but it is not showing attachment.

if i pass xstring data it is showing attachment but data is unreadable format.

please tell me what is wrong in these code

swc_get_element container 'W_I' w_i.

select * from vbap into TABLE lt_vbap UP TO 20 rows.
*i_solix = lt_vbap.
CALL FUNCTION 'SCMS_TEXT_TO_BINARY'
* EXPORTING
*   FIRST_LINE            = 0
*   LAST_LINE             = 0
*   APPEND_TO_TABLE       = ' '
*   MIMETYPE              = ' '
*   ENCODING              =
* IMPORTING
*   OUTPUT_LENGTH         =
  TABLES
    TEXT_TAB              = lt_vbap
    BINARY_TAB            = i_solix[]
* EXCEPTIONS
*   FAILED                = 1
*   OTHERS                = 2
          .

DESCRIBE TABLE I_SOLIX LINES V_TAB_LINES. "get index
READ TABLE I_SOLIX INTO V_WA_SOLIX INDEX V_TAB_LINES.
V_DOC_SIZE = ( 255 * V_TAB_LINES ). "whole lines

CALL FUNCTION 'SCMS_BINARY_TO_STRING'
   EXPORTING
     INPUT_LENGTH        = v_doc_size
*    FIRST_LINE          = 0
*    LAST_LINE           = 0
*    MIMETYPE            = ' '
*    ENCODING            =
  IMPORTING
    TEXT_BUFFER         = v_string
*    OUTPUT_LENGTH       =
   TABLES
     BINARY_TAB          = i_solix
*  EXCEPTIONS
*    FAILED              = 1
*    OTHERS              = 2
           .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

* convert binary to xstring
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = v_doc_size
IMPORTING
buffer = v_xstring
TABLES
binary_tab = i_solix.

v_att_header-file_type = 'B'.
v_att_header-file_name = 'TEST'.                     "v_docname_only.
v_att_header-file_extension = 'XLS'.              "v_doc_extension.
v_att_header-language = sy-langu.
V_XSTRING = V_STRING.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = w_i
att_header = v_att_header
*ATT_TXT = v_string
att_bin = v_xstring
IMPORTING
att_id = v_att_id.
* pass attachment id and internal document number for SOFM
swc_set_element container 'ATT_ID' v_att_id.
swc_set_element container 'SOFM' v_att_id-doc_id.

former_member185167
Active Contributor
0 Kudos

Hello,

What happens if you use e.g.

&ABC##&

to put the contents of the internal table into the text, and not use an attachment at all?


What are the contents of this internal table? Is it all text?


regards

Rick Bakker

former_member185167
Active Contributor
0 Kudos

Hello,

"4. i need to display all sales order item details in body of email but item details are multipule."

All elements of a multiline element can be displayed as follows:

&USERLIST.USER##&

regards

Rick Bakker

former_member201532
Participant
0 Kudos

Hi Rick,

i am getting sales order details into conatiner element ZVBAK.

but i am unable to print using &ZVBZKLIST.ZVBAK##&.

i am printing them using &ZVBAK##& in mail body but we must use &ZVBAK& in subject of mail also then only it is displaying data in mail.

1.can you please explain how to use  &USERLIST.USER##&

2."3.How to pass data from ZITEMS element to ZATTACH which conatins all item details."  for attachment in mail.

please help

former_member185167
Active Contributor
0 Kudos

Hello,

It's very simple - if a container element is multiline then you can display all of the lines with e.g.:

&ABC##&

If an attribute is multiline then you can display all of the lines with e.g.:

&ABC.DEF##&

"How to pass data from ZITEMS element to ZATTACH"

Binding them should do it. What's the problem?

regards

Rick Bakker