Thursday, June 11, 2015

SAP ABAP - Sending a message (email) to the business workplace

This post will let you know how coding the call to the FM SO_NEW_DOCUMENT_SEND_API1 in order to be able to send a message to a business workplace.  If you want to send a message to an internet mail, just change the rec_type and make sure that all the proper configuration is done in transaction SCOT.  Email sent to external addresses can be viewed on TCODE SOST.
-----------------------------------------------------------------------------------------------------------------
Este post le permitirá saber cómo codificar la llamada a la funcion SO_NEW_DOCUMENT_SEND_API1  con el fin de enviar un mensaje al business workplace de un SAP user. Si desea enviar un mensaje a un correo de Internet, basta con cambiar el valor de rec_type y asegúrese de que toda la configuración adecuada se realiza en la SCOT. El correo electrónico enviado a direcciones externas se puede ver en la transaccion  SOST.

Here a the sample ABAP code/ Aquí un código ABAP la muestra:


**************************
* SEND RESULTS
**************************
    clear : maildata, mailtxt, mailrec.
    refresh:mailtxt, mailrec.

    maildata-obj_name = 'Mail Name'.
    maildata-obj_descr = 'Mail description'.
    maildata-obj_langu = sy-langu.

    concatenate 'Message:' lv_data into mailtxt-line.
    append mailtxt.
    loop at it_table_data into wa_table_data.
      mailtxt-line = wa_table_data-text.
      append mailtxt.
    endloop.

    mailrec-receiver = sy-uname.
    mailrec-rec_type = 'B'.
    append mailrec.

    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        document_data              = maildata
        DOCUMENT_TYPE              = 'RAW'
        PUT_IN_OUTBOX              = ' '
        COMMIT_WORK                = 'X'
*      IMPORTING
*       SENT_TO_ALL                =
*       NEW_OBJECT_ID              =
      tables
        OBJECT_HEADER              = mailtxt
        OBJECT_CONTENT             = mailtxt
*       CONTENTS_HEX               =
*       OBJECT_PARA                =
*       OBJECT_PARB                =
        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.
  ENDIF.

If you find this useful, please do not hesitate in like and share it!

No comments:

Post a Comment

Python - borrar lineas extra de archivos .txt en un directorio

 Aqui el codigo Python para borrar lineas extra en un archivo plano: import os path = "c:\\temp" path_new='c:\\temp\\CleanFile...