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: 

How to send dunning letter to customer by mail?

Former Member
0 Kudos

Hi Guys,

I really need to know how to send dunning letter to customer by mail,

I use the standard sapscript form F150_DUNN_01

need help

thanks

simo

3 REPLIES 3

Former Member
0 Kudos

Hi,

follow these steps.

1. Print the Form in background.

2. Get the Spool file.

  • Sometimes there is a delay in creating the spool file

wait up to 5 seconds.

  • Using the program name get the spool file

select * from tbtcp into table it_tbtcp

  • where progname = 'YISU_RT_VALUATION_INTERFACE'

where progname = text-154

and sdldate = sy-datum.

sort it_tbtcp by listident descending.

read table it_tbtcp into wa_tbtcp index 1.

3. Convert the spool file to PDF format.

data: lv_spool like tsp01-rqident.

  • Convert the spool file to PDF format

read table it_tbtcp into wa_tbtcp index 1.

if sy-subrc eq 0.

move wa_tbtcp-listident to lv_spool.

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = lv_spool

no_dialog = c_no

dst_device = c_device

IMPORTING

pdf_bytecount = gd_bytecount

TABLES

pdf = it_pdf_output

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

others = 12.

endif.

check sy-subrc = 0.

  • Transfer the 132-long strings to 255-long strings

loop at it_pdf_output.

translate it_pdf_output using ' ~'.

concatenate gd_buffer it_pdf_output into gd_buffer.

endloop.

translate gd_buffer using '~ '.

do.

it_mess_att = gd_buffer.

append it_mess_att.

shift gd_buffer left by 255 places.

if gd_buffer is initial.

exit.

endif.

enddo.

4. Send the mail with attachement.

data : ld_error type sy-subrc,

ld_reciever type sy-subrc,

ld_mtitle like sodocchgi1-obj_descr,

ld_email like somlreci1-receiver,

ld_format type so_obj_tp ,

ld_attdescription type so_obj_nam ,

ld_attfilename type so_obj_des ,

ld_sender_address like soextreci1-receiver,

ld_sender_address_type like soextreci1-adr_typ,

ld_receiver like sy-subrc,

w_sent_all type c length 1,

w_doc_data like sodocchgi1,

lt_users like agr_users occurs 0 with header line,

p_sender like somlreci1-receiver.

ld_email = lt_users-uname.

ld_mtitle = p_mtitle.

ld_format = p_format.

ld_attdescription = p_attdescription.

ld_attfilename = p_filename.

ld_sender_address = p_sender_address.

ld_sender_address_type = p_sender_addres_type.

  • Fill the document data.

w_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle .

w_doc_data-sensitivty = 'F'.

  • Fill the document data and get size of attachment

clear w_doc_data.

read table it_attach index w_cnt.

w_doc_data-doc_size =

( w_cnt - 1 ) * 255 + strlen( it_attach ).

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle.

w_doc_data-sensitivty = 'F'.

clear t_attachment.

refresh t_attachment.

t_attachment[] = it_attach[].

  • Describe the body of the message

clear t_packing_list.

refresh t_packing_list.

t_packing_list-transf_bin = space.

t_packing_list-head_start = 1.

t_packing_list-head_num = 0.

t_packing_list-body_start = 1.

describe table it_message lines t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

append t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

describe table t_attachment lines t_packing_list-body_num.

t_packing_list-doc_type = ld_format.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

append t_packing_list.

  • Add the recipients email address

clear t_receivers.

refresh t_receivers.

t_receivers-receiver = ld_email.

t_receivers-rec_type = 'B'.

t_receivers-com_type = ' '.

t_receivers-notif_del = C_X.

t_receivers-notif_ndel = C_X.

append t_receivers.

call function 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = w_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

IMPORTING

sent_to_all = w_sent_all

TABLES

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

receivers = t_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.

  • Populate error return code

ld_error = sy-subrc.

Regards,

Jyothi

Former Member
0 Kudos

Hi, thanks for help

but I found a user exit in dunning program SAPF150D, the exit is EXIT_SAPF150D_001.

please refer to the following link.

[url];url]

thanks

Simo

Former Member
0 Kudos

hello, you can go to transaction FIBF and find event 1040.(from Enviroment-Infosystem processes)

Hope that this will help you.

Best regards

Pari