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: 

not getting mail for special function medium PO

Former Member
0 Kudos

I  am  doing  coding  as  below  for  getting  PO  changes    as  PDF  and  sending  mail  to  requestor  .

i  am    getting  mail    when  i  go  to  me22n  and  change  PO  any  field  and  saving  it  and  then  clicking  on  print  preview button .

but  my  client  wants mail  if  po  changes   and  clicking  on  save  button   as  pdf  (  here  without  clicking on print preview button   )

and   in  nace  i  maintained  z message  type  for  EF   and  also  2  processing   mediums  ,  1  is  for  print  output  and  other  special  function  .

but   i  am  not  getting  mail  when  i  change  any  field  in  PO  and  save  it  (  here  i  am  not  clicking  on  print  preview  button  ) because  this  is  for

special  function medium ,

please  suggest  what  to  do  here  for  getting  mail  for  special  function  medium  ,  is  it  functional  issue  or  technical  issue.

  data: l_druvo like t166k-druvo,
l_nast 
like nast,

        l_from_memory,

        l_doc  
type meein_purchase_doc_print.



 
clear ent_retco.

 
if nast-aende eq space.

    l_druvo =
'1'.

  else.

    l_druvo =
'2'.

  endif.

  call function 'ME_READ_PO_FOR_PRINTING'

      
exporting

            ix_nast        = nast

            ix_screen      = ent_screen

      
importing

            ex_retco       = ent_retco

            ex_nast        = l_nast

            doc            = l_doc

      
changing

            cx_druvo       = l_druvo

            cx_from_memory = l_from_memory.



 
check ent_retco eq 0.




call function 'ECP_PRINT_PO'
       exporting
            ix_nast        = l_nast
            ix_druvo       = l_druvo
            doc            = l_doc
            ix_screen      = ent_screen
           ix_from_memory = l_from_memory
           ix_toa_dara    = toa_dara
          ix_arc_params  = arc_params
          ix_fonam       = tnapr-fonam         
     importing
            ex_retco       = ent_retco.


CALL FUNCTION 'READ_OTF_FROM_MEMORY'
  EXPORTING
   memory_key   = l_nast-objky  " PO Number
    TABLES
    otf          =
lt_otf





* Convert OTF Data into PDF format

 
CALL FUNCTION 'CONVERT_OTF'

   
EXPORTING

     
format                = 'PDF'

      max_linewidth         =
132

   
IMPORTING

      bin_filesize          = l_bin_filesize

   
TABLES

      otf                   = lt_otf

     
lines                 = lt_pdf_tab

   
EXCEPTIONS

      err_max_linewidth     =
1

      err_format            =
2

      err_conv_not_possible =
3

      err_bad_otf           =
4

     
OTHERS                = 5.



 
IF sy-subrc <> 0.

    p_retcode = sy-subrc.

   
PERFORM protocol_update.

    EXIT.

  ENDIF.


* Convert 132 line sized output internal table into 255 line sized output internal table

 
REFRESH lt_pdf[].



 
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

   
EXPORTING

      line_width_dst              =
'255'

   
TABLES

      content_in                  = lt_pdf_tab

      content_out                 = lt_pdf

   
EXCEPTIONS

      err_line_width_src_too_long =
1

      err_line_width_dst_too_long =
2

      err_conv_failed             =
3

     
OTHERS                      = 4.

 
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.
* Set the parameters before passing it to the function module




* Object with main text of the mail.

  lwa_objtxt = text-100 .                                 
"Find  the attached  output of the smart form''

 
APPEND lwa_objtxt TO lt_objtxt.

  lwa_objtxt = text-101.                                  
"'Regards,'

 
APPEND lwa_objtxt TO lt_objtxt.

  lwa_objtxt = text-102.                                  
"'Rama Mekala'

 
APPEND lwa_objtxt TO lt_objtxt.



 
DESCRIBE TABLE lt_objtxt LINES l_objtxt_lines.

 
DESCRIBE TABLE lt_pdf_tab LINES l_pdftab_lines.


* Document information

  lwa_doc_chng-obj_name = text-103.                        
"'Smartform'

  lwa_doc_chng-expiry_dat = sy-datum +
10.

  lwa_doc_chng-obj_descr = text-104.                       
"'Smart form output'

  lwa_doc_chng-sensitivty =
'F'. "Functional object

  lwa_doc_chng-doc_size = l_pdftab_lines *
255.




* Content information about the attachament

 
CLEAR lwa_objpack-transf_bin.

  lwa_objpack-head_start =
1.

  lwa_objpack-head_num =
0.

  lwa_objpack-body_start =
1.

  lwa_objpack-body_num = l_objtxt_lines.

  lwa_objpack-doc_type =
'RAW'.

 
APPEND lwa_objpack TO lt_objpack.





  lwa_objpack-transf_bin =
'X'.

  lwa_objpack-head_start =
1.

  lwa_objpack-head_num =
1.

  lwa_objpack-body_start =
1.

  lwa_objpack-body_num = l_pdftab_lines.

  lwa_objpack-doc_type =
'PDF'.

  lwa_objpack-obj_name =
'Smartform'.

 
CONCATENATE 'Smartform_output'

              
'.pdf'

         
INTO lwa_objpack-obj_descr.

  lwa_objpack-doc_size = l_pdftab_lines *
255.

 
APPEND lwa_objpack TO lt_objpack.


* Receiver

 
CLEAR lwa_receivers.


* Get the E-Mail address of vendor

 
SELECT SINGLE

         smtp_addr

   
FROM adr6

   
INTO g_smtp_addr

  
WHERE smtp_addr = '00001'.



  lwa_receivers-receiver  = g_smtp_addr.

  lwa_receivers-rec_type  =
'U'.

  lwa_receivers-express =
'X'.

 
APPEND lwa_receivers TO lt_receivers.




*Send an email with attachment

 
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

   
EXPORTING

      document_data                    = lwa_doc_chng

     put_in_outbox                    =
'X'

     commit_work                      =
'X'

   
TABLES

      packing_list                     = lt_objpack

     object_header                    =  lt_objhead

     contents_bin                     = lt_pdf

     contents_txt                     = lt_objtxt

      receivers                        = lt_receivers

  
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

            .

 
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.
















4 REPLIES 4

Former Member
0 Kudos

and   also  i  set  break  point  and  checked  and  when  i  click  on  print preview  button  then  debugging  starts  and  if  i  dont  click  on print  preview  button  debugger  dont  start .

VijayCR
Active Contributor
0 Kudos

Hi veer,

     Please check the standard program by debugging and find out the exact position where you can write the exact code. and make the changes there if you can afford access key.

Thank you,

Vijay.

former_member200345
Contributor
0 Kudos

Hi,

The Output type is automatically triggered based on the condition records maintained. Check with your functional team and make sure that the condition records are maintained for your Output type.

Regards,

Vijaymadhur.

0 Kudos

Now   i  am  able  to  debug  , but  now  issue  is  that PDF  document  is  not  opening in  SOST ,  it  is  telling  that  file  is  corrupted.

Please  help.