cancel
Showing results for 
Search instead for 
Did you mean: 

Send 1 of many attacments files in PO output message

former_member220448
Participant
0 Kudos

Hi guys,

Lets say got a PO with 2 attachment files one,

I need to send just one of those 2 in a mail (it will be chosen by the attachment title).

Now the output message its sending both files, how can I pick the files in runtime?

Its there any badi or exit I can use?

Thanks!

Nico.-

Accepted Solutions (1)

Accepted Solutions (1)

former_member233510
Active Contributor
0 Kudos

No, it's not possible. Please refer the SAP note 457497.

former_member220448
Participant
0 Kudos

Thanks for you answer Rosh,

I cenrtanlly cannot be done using the standard but I managed to do it using some ABAP code.

In case somebody else face this problem, here is the solution.

In a custom print program do this:

1st get the archive id of the file using: FM ARCHIV_GET_CONNECTIONS

2nd get the files in a binary table format with FM SCMS_AO_TABLE_GET

3rd Then use what SCMS_AO_TABLE_GET returns to call FM SCMS_XSTRING_TO_BINARY

HERE IS THE TRICK FOR XLSX, DOCX and any other 4char extention:

4th Create the document using Method CALL METHOD cl_document_bcs=>create_document

                    EXPORTING
i_type    = ‘BIN’
i_subject = put here the name file along with the extension
i_length  = from FM 'SCMS_BINARY_TO_XSTRING'
i_hex     = from FM 'SCMS_XSTRING_TO_BINARY'

                    RECEIVING
result    = o_document_attach.

Then append the resulting object to the mail

          CALL METHOD o_document->add_document_as_attachment
EXPORTING
im_document = o_document_attach.

Hope this help somebody.

former_member307359
Participant
0 Kudos

Hi Nicolas Giuffrida,

if you resolve this issue please help me, I'm also facing same kind of issue,  please send me the sample code

Note:

How to archive this point

3rd Then use what SCMS_AO_TABLE_GET returns to call FM SCMS_XSTRING_TO_BINARY

Thanks

Vimal Raj

former_member220448
Participant
0 Kudos

Hi Vimal

This is what you need to do in steps 3 and foward:

        CALL FUNCTION 'SCMS_AO_TABLE_GET'

          EXPORTING

            mandt        = sy-mandt

            arc_id       = <connect>-archiv_id

            doc_id       = <connect>-arc_doc_id

          IMPORTING

            length       = l_v_length

          TABLES

            data         = l_i_data

          EXCEPTIONS

            error_http   = 1

            error_archiv = 2

            error_kernel = 3

            error_config = 4

            OTHERS       = 5.

        IF sy-subrc EQ 0.

*Cast from binary to xstring

          CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

            EXPORTING

              input_length = l_v_length

            IMPORTING

              buffer       = l_v_xstring

            TABLES

              binary_tab   = l_i_data

            EXCEPTIONS

              failed       = 1

              OTHERS       = 2.

          IF sy-subrc EQ 0.

            REFRESH i_objbin1[].

            CLEAR v_num.

*Cast from xstring to binary into a object format

            CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

              EXPORTING

                buffer     = l_v_xstring

              TABLES

                binary_tab = i_objbin1.

After that,do this:

Note:o_document_attach its TYPE REF TO cl_document_bcs

          TRY.

              v_doc_size = l_v_length.

              CLEAR o_document_attach.

              CALL METHOD cl_document_bcs=>create_document

                EXPORTING

                  i_type    = 'BIN'

                  i_subject = l_v_subject <----- Document name with the extention,doc, docx, txt...

                  i_length  = v_doc_size

                  i_hex     = i_objbin1

                RECEIVING

                  result    = o_document_attach.

            CATCH cx_bcs INTO o_bcs_exception.

          ENDTRY.

          CALL METHOD o_document->add_document_as_attachment

            EXPORTING

              im_document = o_document_attach.

Hope this helps.

Regards,

Nico.-

former_member307359
Participant
0 Kudos

Hi Nicolas,

Thanks for your reply, Can you please tell me the type for (o_document)

please help me, I'm  getting an error.

Thanks

Vimal Raj

former_member307359
Participant
0 Kudos

Thanks Issue is resolved

Answers (0)