Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Send SAP Script Form via mail

Former Member
0 Kudos

Hello All,

I read through related topics on sending SAP Smartfroms via email but I wasn't able to find topics relating to emailing SAP Script Forms.

The ticket description is that when the Dunning/Reminder/Expeditor form (MEDRUCK)is generated, user wants an email to be sent to the Purchasing Group on the PO (this I'm not sure whether internal or external mail - I have to verify it again with the functional designer) via the table T024.

Does anybody know how send a SAP Script form via mail?

Many thanks in advance!

Regards,

Kristine Sy

8 REPLIES 8

Former Member
0 Kudos

By the way, email type is an external email (just confirmed it). Many thanks!

Regards,

Kristine Sy

Former Member
0 Kudos

Convert your SAPscript output to OTF and then send it by mail. There are FM to convert as well as to send mail.

Former Member
0 Kudos

Hi Kristine,

This can be done using output type config .

There is a provision for configuring the output type to send the output as mail.

Please have a look in SPRO --> MM --> Purchasing --> PO --> Messages / Outputs ( Not sure ).

You can also take some help from any MM consultant.

But I think it can be done just by config.

Thanks,

Ram

Former Member
0 Kudos

Sanjay Shah - I tried using the function module CONVERT_OTF but I'm stucked on how to fill up the TABLES parameter 'OTF' -- the parameters TDPRINTCOM and TDPRINTPAR?

I'd appreciate your response. Thanks!

Ram Manohar Tiwari - Actually, the requirement was the output to be defaulted to 'FAX' and in addition to that, the user wants to send out an email of the Dunning letter form to the Purchasing Organization indicated in the PO.

Regards,

Tin

0 Kudos

Hi Tin,

I think it's possible through config ..

You can configure two output types and both of the output types can be determined.

Further,one of the output type will be for FAX and other one for email. Also you have the flexibility to use seperate SapScript / SmartForm for both the output types.

I think you should try it with the config first .

Cheers,

Ram

Former Member
0 Kudos

Ram,

Thanks! I will try to tell this to our functional person. Here are some points for you.

Regards,

Kristine

MariaJoãoRocha
Contributor
0 Kudos

Hi,

We sent a smart form by email using pdf format.

I think you can do it using the following:

First get the otf,

then convert the OTF to PDF using:

call function 'CONVERT_OTF'

exporting

format = 'PDF'

importing

bin_filesize = w_pdf_size

tables

otf = es_job_output_info-otfdata[]

lines = t_pdf[]

exceptions

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

others = 5.

There we use a ZFM to send the mail using the BOR:

call function 'Z_MAIL_DIALOGO'

exporting

titulo = ls_output_options-tdtitle

file_size = w_file_size

mensagem = ls_orderadm_h-object_id

tables

pdf = t_pdf[].

function z_mail_dialogo.

*"----

-


""Interface local:

*" IMPORTING

*" REFERENCE(TITULO) TYPE SOOD1-OBJDES OPTIONAL

*" REFERENCE(FILE_SIZE) TYPE SOOD1-OBJLEN OPTIONAL

*" REFERENCE(MENSAGEM) TYPE CRMT_OBJECT_ID OPTIONAL

*" TABLES

*" PDF STRUCTURE TLINE OPTIONAL

*"----

-


************************************************************************

  • macros do BOR

************************************************************************

include .

************************************************************************

  • declarações

************************************************************************

data: message type swc_object.

data: recipient type swc_object.

data: title(80).

data: att_bor_obj like swotobjid.

data: wa_pdf type tline.

data: xi_temp type standard table of soli,

wa_tmp type soli.

data: xi_pdf type standard table of tline.

data: l_lines type i,

l_temp(500) type c,

l_offset type p,

l_lineslen(2) type p,

l_mimelen(2) type p,

l_tabix like sy-tabix.

data: w_file_size type i.

data: content like soli-line occurs 0 with header line.

************************************************************************

  • containers

************************************************************************

swc_container container.

************************************************************************

  • processamento

************************************************************************

  • Criação do objecto message

swc_create_object message 'Message' space.

swc_clear_container container.

swc_set_element container 'DOCUMENTTITLE' titulo.

swc_set_element container 'DOCUMENTNAME' 'Support Desk'.

swc_set_element container 'DOCUMENTTYPE' 'INT'.

swc_set_element container 'NO_DIALOG' 'X'.

swc_set_element container 'ModifiableByAuthor' ' '.

swc_call_method message 'Create' container.

perform error_handling(rssobcitest11).

  • conversão para o formato correcto de caracteres

  • de 134 para 255

xi_pdf[] = pdf[].

clear: l_temp, l_offset, xi_temp.

describe table xi_pdf lines l_lines.

describe field wa_pdf length l_lineslen in character mode.

describe field wa_tmp length l_mimelen in character mode.

loop at xi_pdf into wa_pdf.

l_tabix = sy-tabix.

move wa_pdf to l_temp+l_offset.

if l_tabix = l_lines.

l_lineslen = strlen( wa_pdf ).

endif.

l_offset = l_offset + l_lineslen.

if l_offset ge l_mimelen.

clear wa_tmp.

wa_tmp = l_temp(l_mimelen).

append wa_tmp to xi_temp.

shift l_temp by l_mimelen places.

l_offset = l_offset - l_mimelen.

endif.

if l_tabix = l_lines.

if l_offset gt 0.

wa_tmp = l_temp(l_offset).

append wa_tmp to xi_temp.

endif.

endif.

endloop.

w_file_size = 255 * l_lines.

  • criar o attach

swc_clear_container container.

att_bor_obj-objtype = 'MESSAGE'.

swc_set_element container 'ATTACHMENT' att_bor_obj.

concatenate 'Solução_' mensagem into title.

swc_set_element container 'ATTACHMENTTITLE' title.

swc_set_element container 'AttachmentType' 'PDF'.

swc_set_element container 'DocumentSize' w_file_size.

swc_set_table container 'DocumentContent' xi_temp.

swc_call_method message 'Attach' container.

perform error_handling(rssobcitest11).

  • flag de outbox

swc_clear_container container.

swc_set_element container 'OutboxFlag' 'X'.

swc_call_method message 'SetOutboxFlag' container.

perform error_handling(rssobcitest11).

  • possibilitar a entrada dos receptores

swc_clear_container container.

swc_set_element container 'STARTING_AT_X' '5'.

swc_set_element container 'STARTING_AT_Y' '5'.

swc_call_method message 'EditRecipientList' container.

perform error_handling(rssobcitest11).

swc_free_object message.

swc_free_object recipient.

commit work.

endfunction.

Hope this helps,

Regards,

Maria João Rocha

0 Kudos

Olá Maria João.

Eu estou com um problema neste assunto.

Actualmente, o meu programa já envia um e-mail com anexo (em PDF).

No entanto, pretendo que passe a enviar também texto (3-4 linhas de texto).

Eu já defini o conteúdo do texto, e aquando da preparação do e-mail chamo a instrução:

  swc_set_table container 'DocumentContent' lt_content.

No entanto, não está a funcionar.

O e-mail está a ser enviado apenas com o anexo.

O meu código é basicamente isto:

   * Preparação do envio de mail
  swc_clear_container container.
  swc_create_object sender 'RECIPIENT' space.
  swc_set_element container 'AddressString' sy-uname.
  swc_set_element container 'TypeId' 'B'.
  swc_call_method sender 'FindAddress' container.
  swc_object_to_persistent sender sender_id.
  swc_set_table container 'DocumentContent' lt_content" CB; Conteudo do email


* Destinatário
  swc_clear_container container.
  swc_create_object recipient 'RECIPIENT' space.
  swc_clear_container container.

  swc_clear_container container.
  swc_set_element container 'AddressString' l_uname.
  swc_set_element container 'TypeId' 'B'.               " SAP user ID

   swc_call_method recipient 'CreateAddress' container.
  swc_call_method recipient 'Save' container. " New
  swc_object_to_persistent recipient recipient_id.
  swc_clear_container container.
  swc_set_element container 'StatusInfoByMail' ' '.
  swc_call_method recipient 'SetStatusInfoByMail' container.
  swc_clear_container container.
  REFRESH recipient_tab.
  swc_call_method recipient 'Expand' container.
  swc_get_table container 'ResultTable' recipient_tab.
  swc_object_to_persistent recipient_tab recipient_id.
  CLEAR linhas.
  SET PF-STATUS 'STAT'.

   CALL FUNCTION 'OPEN_FORM'
       EXPORTING
            application                 = 'TX'
            device                      = 'MAIL'
            dialog                      = space
            form                        = form
            language                    = sy-langu
            OPTIONS                     = i_itcpo
            mail_sender                 = sender_id
            mail_recipient              = recipient_id
*          MAIL_APPL_OBJECT            =
            raw_data_interface          = '*'
            itcpo-tdgetotf              = 'X'
            itcpo-tdarmod               = '1'

       EXCEPTIONS
            canceled                    = 1
            device                      = 2
            form                        = 3
            OPTIONS                     = 4
            unclosed                    = 5
            mail_options                = 6
            archive_error               = 7
            invalid_fax_number          = 8
            more_params_needed_in_batch = 9
            spool_error                 = 10
            OTHERS                      = 11.

  LOOP AT t_guias.

    CALL FUNCTION 'WRITE_FORM'
      EXPORTING
        element                  = element
        function                 = 'SET'
        type                     = 'BODY'
        window                   = 'MAIN'
            EXCEPTIONS
        element                  = 1
        function                 = 2
        type                     = 3
        unopened                 = 4
        unstarted                = 5
        window                   = 6
        bad_pageformat_for_print = 7
        spool_error              = 8
        OTHERS                   = 9.
  ENDLOOP.

  CALL FUNCTION 'CLOSE_FORM'
  "IMPORTING
        " RESULT  = i_itcpp
      TABLES
        otfdata = otfdata
    EXCEPTIONS
      unopened                 = 1
      bad_pageformat_for_print = 2
      send_error               = 3
      OTHERS                   = 4.

  COMMIT WORK AND WAIT.

   FORM obs_lower_case.
  SHIFT t_guias-obstp LEFT DELETING LEADING space.
  TRANSLATE t_guias-obstp TO LOWER CASE.
  TRANSLATE t_guias-obstp(1) TO UPPER CASE.
ENDFORM.                    " obs_lower_case

Consegue dar-me alguma ajuda com isto?

Obrigada