cancel
Showing results for 
Search instead for 
Did you mean: 

SO_NEW_DOCUMENT_ATT_SEND_API1 in SAP iRPA

janv7306
Active Participant

Dear experts,

Could anybody check in SAP ECC system, how to use SO_NEW_DOCUMENT_ATT_SEND_API1 from SAP RPA or BPA tools with binary data (PDF file)? I tried CONTENTS_BIN and CONTENTS_HEX structures without success so far. In case of BIN the RFC function performs implicit conversion to Unicode, in case of HEX I am unable to pass the parameters due to its "wrong type".

I would appreciate your help asap as I needed to hand over my part to colleagues yesterday. ;-(

Thank you very much and kindest regards,

JV

Sandra_Rossi
Active Contributor
0 Kudos

CONTENTS_BIN is obsolete, it has been superseded with CONTENTS_HEX. You must also transfer the exact length (number of bytes) in the document parameter.

But SO_NEW_DOCUMENT_ATT_SEND_API1 is itself obsolete, you should use CL_BCS instead.

janv7306
Active Participant
0 Kudos

Dear Sandra,

Thank you very much for your prompt answer. I did look at CL_BCS class but it seems overcomplex to my requirements. Also there are tons of examples for SO_New_Doc... FM, but I can hardly find any example for remote function call of CL_BCS. Can you recommend some links, where to get more details?

Precisely: what RFC / BAPI function can I call instead of the "obsolete" one?

Thank you very much. Kind regards. JV

janv7306
Active Participant
0 Kudos

Hello Sandra,

Thanks a lot. I've got it. JV

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor
0 Kudos

More complex for you, because you are familiar with the function modules, or things like that. You can learn new things, and in the future, you will find it easier.

All the examples of CL_BCS are provided by SAP already = programs BCS_EXAMPLE_*.

But you're right concerning RFC. That would require a simple custom RFC-enabled function module, which uses BCS.

Example with BCS:

DATA(email) = cl_document_bcs=>create_document( 
        i_type    = 'RAW' 
        i_subject = 'ABAPlist' 
        i_text    = VALUE #( ( line = 'Hi,' ) ( line = 'attached you will find the list.' ) ) ).
email->add_attachment( 
        i_attachment_type    = 'TXT' 
        i_attachment_subject = 'filename.txt'
        i_att_content_text   = cl_bcs_convert=>string_to_soli( concat_lines_of( sep = |\r\n| table = VALUE string_table( 
                                ( `This is the first line` ) 
                                ( `This is the second line` ) ) ) ) ).
data(xlsx_data) = value xstring( ).
email->add_attachment( 
        i_attachment_type    = 'XLS' 
        i_attachment_subject = 'attachment.xlsx' 
        i_attachment_size    = |{ xstrlen( xlsx_data ) }|
        i_att_content_hex    = cl_bcs_convert=>xstring_to_solix( xlsx_data )
        i_attachment_header  = VALUE #( ( line = |&SO_FILENAME=List_of_roles.xlsx| ) ) ).

DATA(bcs) = cl_bcs=>create_persistent( ).
bcs->set_document( email ).
bcs->add_recipient( i_recipient = cl_cam_address_bcs=>create_internet_address( 'john.doe@sap.com' ) ).
bcs->set_send_immediately( abap_true ). " prefer avoiding that, batch it instead
bcs->send( ).
COMMIT WORK.

Answers (0)