‎2007 Jul 18 5:38 AM
Hello Friends,
Please can anybody provide me a sample code of send mail.
My requirement is, in selection screen I am entering file path in one field and email id in another field, when I submit the file needs to send to the email id mentioned in the eselction screen.
Thanks,
Shreekant
‎2007 Jul 18 5:41 AM
Hi,
refer this codes, u may need to create email id in SCOT tcode.
*&---------------------------------------------------------------------*
*& Report ZMBJ_EMAIL_ATTACH
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zmbj_email_attach.
tables: ekko.
parameters: p_email type somlreci1-receiver default 'jogdand.machindra@arteriatech.com'.
types: begin of t_ekpo,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
aedat type ekpo-aedat,
matnr type ekpo-matnr,
end of t_ekpo.
data: it_ekpo type standard table of t_ekpo initial size 0,
wa_ekpo type t_ekpo.
types: begin of t_charekpo,
ebeln(10) type c,
ebelp(5) type c,
aedat(8) type c,
matnr(18) type c,
end of t_charekpo.
data: wa_charekpo type t_charekpo.
data: it_message type standard table of solisti1 initial size 0
with header line.
data: it_attach type standard table of solisti1 initial size 0
with header line.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1,
gd_error type sy-subrc,
gd_reciever type sy-subrc.
t_object_header = 'Text.xls'. append t_object_header.
************************************************************************
*START_OF_SELECTION
start-of-selection.
* Retrieve sample data from table ekpo
perform data_retrieval.
* Populate table with detaisl to be entered into .xls file
perform build_xls_data_table.
************************************************************************
*END-OF-SELECTION
end-of-selection.
* Populate message body text
perform populate_email_message_body.
* Send file by email as .xls speadsheet
perform send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
' '
' '
' '
changing gd_error
gd_reciever.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.
select ebeln ebelp aedat matnr
up to 10 rows
from ekpo
into table it_ekpo.
endform. " DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*& Form BUILD_XLS_DATA_TABLE
*&---------------------------------------------------------------------*
* Build data table for .xls document
*----------------------------------------------------------------------*
form build_xls_data_table.
*CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
*con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>horizontal_tab,
con_cret type c value cl_abap_char_utilities=>cr_lf.
concatenate 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
into it_attach separated by con_tab.
concatenate con_cret it_attach into it_attach.
append it_attach.
loop at it_ekpo into wa_charekpo.
concatenate wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
into it_attach separated by con_tab.
concatenate con_cret it_attach into it_attach.
append it_attach.
endloop.
endform. " BUILD_XLS_DATA_TABLE
*&---------------------------------------------------------------------*
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
*&---------------------------------------------------------------------*
* Send email
*----------------------------------------------------------------------*
form send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
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.
ld_email = p_email.
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[] = pit_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 = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = '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
object_header = t_object_header
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 zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
loop at t_receivers.
ld_receiver = t_receivers-retrn_code.
endloop.
endform.
*&---------------------------------------------------------------------*
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------*
* Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------*
form initiate_mail_execute_program.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------*
*& Form POPULATE_EMAIL_MESSAGE_BODY
*&---------------------------------------------------------------------*
* Populate message body text
*----------------------------------------------------------------------*
form populate_email_message_body.
refresh it_message.
it_message = 'Please find attached a list test ekpo records'.
append it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODYJogdand M B
‎2007 Jul 18 5:46 AM
Hi,
Check this code
PARAMETERS: psubject(40) type c default Hello,
p_email(40) type c default test@sapdev.co.uk .
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
&
*& Form POPULATE_MESSAGE_TABLE
&
Adds text to email text table
-
form populate_message_table.
Append Email line 1′ to it_message.
Append Email line 2′ to it_message.
Append Email line 3′ to it_message.
Append Email line 4′ to it_message.
endform. POPULATE_MESSAGE_TABLE
&
*& Form SEND_EMAIL_MESSAGE
&
Send email message
-
form send_email_message.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = SAPRPT.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = F.
Describe the body of the message
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = RAW.
append it_packing_list.
Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = U.
it_receivers-com_type = INT.
it_receivers-notif_del = X.
it_receivers-notif_ndel = X.
append it_receivers.
Call the FM to post the message to SAPMAIL
call function SO_NEW_DOCUMENT_ATT_SEND_API1′
exporting
document_data = gd_doc_data
put_in_outbox = X
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
receivers = it_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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
endform. SEND_EMAIL_MESSAGE
&
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
&
Instructs mail send program for SAPCONNECT to send email.
-
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = INT
with output = X
and return.
endif.
endform. INITIATE_MAIL_EXECUTE_PROGRAM
http://www.thespot4sap.com/articles/SAP_Mail_UNIX_Example_ABAP.asp
http://www.thespot4sap.com/articles/SAP_Mail_Example_ABAP.asp
also check these thread
Regards
Gaurav
‎2007 Jul 18 5:54 AM
Hi Shreekant
Please find the sample code:
*----
*
Change History
*
Programmer Date Change Request Description
*
FKHURRAM 9/16/02 DU1K920151 Upgrade changes.
Use ADRC for Address Data
*----
*
*----
*
Print of an order confirmation by SAPscript
*----
*
REPORT rvador01 LINE-COUNT 100 MESSAGE-ID vn.
TABLES: komk, "Communicationarea for conditions
komp, "Communicationarea for conditions
komvd, "Communicationarea for conditions
vbco3, "Communicationarea for view
vbdka, "Headerview
vbdpa, "Itemview
vbdpau, "Subitemnumbers
conf_out, "Configuration data
sadr, "Addresses
tvag, "Reason for rejection
vedka, "Servicecontract head data
vedpa, "Servicecontract position data
vedkn, "Servicecontract head notice data
vedpn, "Servicecontract pos. notice data
vbpa, "Sales Document: Partner
kna1, "General Data in Customer Master
riserls, "Serialnumbers
komser, "Serialnumbers for print
tvbur, "Sales office
tvko, "Sales organisation
adrs, "Communicationarea for Address
fpltdr. "billing schedules
INCLUDE yzrvadtabl.
*INCLUDE RVADTABL.
INCLUDE yzrvdirekt.
*INCLUDE RVDIREKT.
INCLUDE yzvedadata.
*INCLUDE VEDADATA.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DATA: retcode LIKE sy-subrc. "Returncode
DATA: repeat(1) TYPE c.
DATA: xscreen(1) TYPE c. "Output on printer or screen
DATA: BEGIN OF steu, "Controldata for output
vdkex(1) TYPE c,
vdpex(1) TYPE c,
kbkex(1) TYPE c,
kbpex(1) TYPE c,
END OF steu.
DATA: BEGIN OF tvbdpa OCCURS 0. "Internal table for items
INCLUDE STRUCTURE vbdpa.
DATA: END OF tvbdpa.
DATA: BEGIN OF tkomv OCCURS 50.
INCLUDE STRUCTURE komv.
DATA: END OF tkomv.
DATA: BEGIN OF tkomvd OCCURS 50.
INCLUDE STRUCTURE komvd.
DATA: END OF tkomvd.
DATA: BEGIN OF tvbdpau OCCURS 5.
INCLUDE STRUCTURE vbdpau.
DATA: END OF tvbdpau.
DATA: BEGIN OF tkomcon OCCURS 50.
INCLUDE STRUCTURE conf_out.
DATA: END OF tkomcon.
DATA: BEGIN OF tkomservh OCCURS 1.
INCLUDE STRUCTURE vedka.
DATA: END OF tkomservh.
DATA: BEGIN OF tkomservp OCCURS 5.
INCLUDE STRUCTURE vedpa.
DATA: END OF tkomservp.
DATA: BEGIN OF tkomservhn OCCURS 5.
INCLUDE STRUCTURE vedkn.
DATA: END OF tkomservhn.
DATA: BEGIN OF tkomservpn OCCURS 5.
INCLUDE STRUCTURE vedpn.
DATA: END OF tkomservpn.
DATA: BEGIN OF tkomser OCCURS 5.
INCLUDE STRUCTURE riserls.
DATA: END OF tkomser.
DATA: BEGIN OF tkomser_print OCCURS 5.
INCLUDE STRUCTURE komser.
DATA: END OF tkomser_print.
DATA: BEGIN OF tfpltdr OCCURS 5.
INCLUDE STRUCTURE fpltdr.
DATA: END OF tfpltdr.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DATA: pr_kappl(01) TYPE c VALUE 'V'. "Application for pricing
DATA: BEGIN OF char_val OCCURS 0,
atnam LIKE cabn-atnam,
atwrt LIKE ausp-atwrt,
END OF char_val.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FORM entry USING return_code us_screen.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing.
IF retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "ENTRY
*----
*
FORM PROCESSING *
*----
*
........ *
*----
*
FORM processing.
PERFORM get_data.
CHECK retcode = 0.
PERFORM form_open USING xscreen vbdka-land1.
CHECK retcode = 0.
PERFORM logo_selection.
PERFORM form_title_print.
CHECK retcode = 0.
PERFORM write_header_info.
PERFORM validity_print.
CHECK retcode = 0.
PERFORM header_data_print.
CHECK retcode = 0.
PERFORM header_serv_print.
CHECK retcode = 0.
PERFORM header_notice_print.
CHECK retcode = 0.
PERFORM header_inter_print.
CHECK retcode = 0.
PERFORM header_text_print.
CHECK retcode = 0.
PERFORM item_print.
CHECK retcode = 0.
PERFORM end_print.
CHECK retcode = 0.
PERFORM form_close.
CHECK retcode = 0.
*********************changes on 12/04/2007****************
TABLES: tsp01.
TYPES: BEGIN OF t_spool,
rqident TYPE tsp01-rqident,
END OF t_spool.
DATA: i_spool TYPE STANDARD TABLE OF t_spool,
wa_spool TYPE t_spool.
SELECT rqident FROM tsp01
INTO TABLE i_spool
WHERE rqowner = sy-uname.
SORT i_spool DESCENDING BY rqident.
LOOP AT i_spool INTO wa_spool.
ENDLOOP.
data: l_rqident type tsp01-rqident.
*
SELECT SINGLE rqident FROM tsp01 INTO l_rqident
WHERE rqowner = sy-uname.
DATA: l_spoolno LIKE tsp01-rqident VALUE '0000024884'.
TYPES: l_ty_tab_pdf TYPE tline OCCURS 0.
DATA: l_pdf TYPE l_ty_tab_pdf,
l_spool TYPE tsp01-rqident.
Type for binary attachment table.
TYPES: l_ty_tab_objbin TYPE solisti1 OCCURS 0.
DATA: l_objbin TYPE l_ty_tab_objbin.
l_spool = l_spoolno.
l_spool = l_rqident.
l_spool = wa_spool-rqident.
**/ Call the standard function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF' "#EC ARGCHECKED
EXPORTING
src_spoolid = l_spool
no_dialog = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
LIST_PAGECOUNT =
btc_jobname = jobname
btc_jobcount = jobcount
TABLES
pdf = l_pdf
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.
IF sy-subrc <> 0.
WRITE: / 'error', sy-subrc.
ENDIF.
**/ Convert the PDF format to the table type required for the
*attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = l_pdf
t_target_tab = l_objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'error', sy-subrc.
ENDIF.
TABLES : soli.
TABLES : zpsdsalrep.
DATA: v_email TYPE soli-line.
DATA: v_email1 TYPE soli-line.
DATA: l_adrnr LIKE kna1-adrnr.
DATA: l_objky TYPE nast-objky.
DATA: l_zzterrmg TYPE zpsdsalrep-zzterrmg.
DATA: l_zsupervisor TYPE zpsdsalrep-zsupervisor.
DATA: l_kunnr TYPE kna1-kunnr.
DATA: l_kunnr1 TYPE vbak-kunnr.
SELECT SINGLE kunnr FROM vbak INTO l_kunnr1
WHERE vbeln = nast-objky.
SELECT SINGLE adrnr FROM kna1 INTO l_adrnr
WHERE kunnr = l_kunnr1.
CHECK sy-subrc IS INITIAL.
SELECT SINGLE smtp_addr FROM adr6 INTO v_email
WHERE addrnumber = l_adrnr.
SELECT SINGLE zzterrmg FROM zpsdsalrep INTO l_zzterrmg
WHERE zzsalesrep = l_kunnr1.
SELECT SINGLE zsupervisor FROM zpsdsalrep INTO l_zsupervisor
WHERE zzterrmg = l_zzterrmg.
SELECT SINGLE kunnr FROM kna1 INTO l_kunnr
WHERE sortl = l_zsupervisor.
SELECT SINGLE adrnr FROM kna1 INTO l_adrnr
WHERE kunnr = l_kunnr.
CHECK sy-subrc IS INITIAL.
SELECT SINGLE smtp_addr FROM adr6 INTO v_email1
WHERE addrnumber = l_adrnr.
DATA: l_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
DATA: l_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: l_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA: l_doc_chng LIKE sodocchgi1.
DATA: l_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: l_tab_lines LIKE sy-tabix.
CONSTANTS: k_true TYPE boolean_flg VALUE 'X'.
DATA: l_mail TYPE somlreci1-receiver.
DATA: l_mail1 TYPE somlreci1-receiver.
DATA: k_mail2 TYPE somlreci1-receiver.
DATA: k_mail TYPE somlreci1-receiver.
l_mail = v_email.
l_mail1 = v_email1.
k_mail2 = text-006.
k_mail = text-007.
Creation of the document to be sent
File Name
l_doc_chng-obj_name = 'SENDFILE'.
Mail Subject
l_doc_chng-obj_descr = text-001.
Completing the recipient list
l_reclist-receiver = l_mail.
l_reclist-rec_type = 'U'.
APPEND l_reclist.
l_reclist-receiver = l_mail1.
l_reclist-rec_type = 'U'.
APPEND l_reclist.
l_reclist-receiver = k_mail.
l_reclist-rec_type = 'U'.
APPEND l_reclist.
l_reclist-receiver = k_mail2.
l_reclist-rec_type = 'U'.
APPEND l_reclist.
Mail Contents
l_objtxt = text-002.
APPEND l_objtxt.
CLEAR l_objtxt. " put in a blank line
APPEND l_objtxt.
l_objtxt = text-003.
APPEND l_objtxt.
l_objtxt = text-004 .
APPEND l_objtxt.
Calculate email size in bytes
DESCRIBE TABLE l_objtxt LINES l_tab_lines.
READ TABLE l_objtxt INDEX l_tab_lines.
l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_objtxt ).
Creation of the entry for the compressed document
for the email text
CLEAR l_objpack-transf_bin.
l_objpack-head_start = 1.
l_objpack-head_num = 0.
l_objpack-body_start = 1.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_type = 'RAW'.
APPEND l_objpack.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
DESCRIBE TABLE l_objbin LINES l_tab_lines.
l_objhead = text-001 .
APPEND l_objhead.
CLEAR l_objpack.
**/ Creation of the entry for the compressed/attached document
l_objpack-transf_bin = k_true.
l_objpack-head_start = 1.
l_objpack-head_num = 1.
l_objpack-body_start = 1.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_type = 'PDF'.
l_objpack-obj_name = text-005.
l_objpack-obj_descr = text-001.
l_objpack-doc_size = l_tab_lines * 255.
APPEND l_objpack. "/ .
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' "/ .
EXPORTING
document_data = l_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = l_objpack
object_header = l_objhead
contents_bin = l_objbin
contents_txt = l_objtxt
receivers = l_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
WRITE: / 'unsuccessful', sy-subrc.
ELSE.
WRITE: / 'successful'.
ENDIF.
**/Take_note it is a requirement to do a commit work for the
email to go into transaction SOST.
COMMIT WORK. "/Take_note .
************************************************************************
ENDFORM. "PROCESSING
***********************************************************************
S U B R O U T I N E S *
***********************************************************************
*----
*
FORM ALTERNATIVE_ITEM *
*----
*
A text is printed, if the item is an alternative item. *
*----
*
FORM alternative_item.
CHECK vbdpa-grpos CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ALTERNATIVE_ITEM'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ALTERNATIVE_ITEM
*----
*
FORM CHECK_REPEAT *
*----
*
A text is printed, if it is a repeat print for the document. *
*----
*
FORM check_repeat.
CLEAR repeat.
SELECT * INTO *nast FROM nast WHERE kappl = nast-kappl
AND objky = nast-objky
AND kschl = nast-kschl
AND spras = nast-spras
AND parnr = nast-parnr
AND parvw = nast-parvw
AND nacha BETWEEN '1' AND '4'.
CHECK *nast-vstat = '1'.
repeat = 'X'.
EXIT.
ENDSELECT.
ENDFORM. "CHECK_REPEAT
*----
*
FORM DELIVERY_DATE *
*----
*
If the delivery date in the item is different to the header *
date and there are no scheduled quantities, the delivery date *
is printed in the item block. *
*----
*
FORM delivery_date.
IF vbdka-lfdat = space AND
vbdpa-lfdat NE space AND
vbdpa-etenr_da = space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_DELIVERY_DATE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "DELIVERY_DATE
*----
*
FORM DIFFERENT_CONSIGNEE *
*----
*
If the consignee in the item is different to the header con- *
signee, it is printed by this routine. *
*----
*
FORM different_consignee.
CHECK vbdka-name1_we NE vbdpa-name1_we
OR vbdka-name2_we NE vbdpa-name2_we
OR vbdka-name3_we NE vbdpa-name3_we
OR vbdka-name4_we NE vbdpa-name4_we.
CHECK vbdpa-name1_we NE space
OR vbdpa-name2_we NE space
OR vbdpa-name3_we NE space
OR vbdpa-name4_we NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_CONSIGNEE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "DIFFERENT_CONSIGNEE
*----
*
FORM DIFFERENT_REFERENCE_NO *
*----
*
If the reference number in the item is different to the header*
reference number, it is printed by this routine. *
*----
*
FORM different_reference_no.
CHECK vbdpa-vbeln_vang NE vbdka-vbeln_vang
OR vbdpa-vbtyp_vang NE vbdka-vbtyp_vang.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_REFERENCE_NO'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "DIFFERENT_REFERENCE_NO
*----
*
FORM DIFFERENT_TERMS *
*----
*
If the terms in the item are different to the header terms, *
they are printed by this routine. *
*----
*
FORM different_terms.
*
DATA: us_vposn LIKE vedpa-vposn.
DATA: us_text(1) TYPE c. "Flag for Noticetext was printed
*
IF vbdpa-zterm NE vbdka-zterm AND
vbdpa-zterm NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_PAYMENT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
IF vbdpa-inco1 NE space.
IF vbdpa-inco1 NE vbdka-inco1 OR
vbdpa-inco2 NE vbdka-inco2.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_DELIVERY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDIF.
Print different validity-data for the position
READ TABLE tkomservp WITH KEY vbdpa-posnr.
IF sy-subrc EQ 0.
vedpa = tkomservp.
IF vedpa-vbegdat NE space AND
vedpa-venddat NE space AND
NOT vedpa-vbegdat IS INITIAL AND
NOT vedpa-venddat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV1'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSEIF vedpa-vbegdat NE space AND
NOT vedpa-vbegdat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV2'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV3'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDIF.
Notice-rules for the positions.
MOVE vbdpa-posnr TO us_vposn.
CLEAR us_text.
LOOP AT tkomservpn WHERE vposn = us_vposn.
vedpn = tkomservpn.
IF us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_NOTTXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
us_text = charx.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_NOTICE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDLOOP.
IF NOT us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMPTY_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "DIFFERENT_TERMS
*----
*
FORM END_PRINT *
*----
*
*
*----
*
FORM end_print.
PERFORM get_header_prices.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
PERFORM header_price_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'END_VALUES'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUPPLEMENT_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "END_PRINT
*----
*
FORM FORM_CLOSE *
*----
*
End of printing the form *
*----
*
FORM form_close.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
retcode = 1.
ENDIF.
SET COUNTRY space.
ENDFORM. "FORM_CLOSE
*----
*
FORM FORM_OPEN *
*----
*
Start of printing the form *
*----
*
--> US_SCREEN Output on screen *
' ' = printer *
'X' = screen *
--> US_COUNTRY County for telecommunication and SET COUNTRY *
*----
*
FORM form_open USING us_screen us_country.
INCLUDE yzrvadopfo.
INCLUDE RVADOPFO.
ENDFORM. "FORM_OPEN
*----
*
FORM FORM_TITLE_PRINT *
*----
*
Printing of the form title depending of the field VBTYP *
*----
*
FORM form_title_print.
CASE vbdka-vbtyp.
WHEN 'A'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_A'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'B'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_B'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'C'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_C'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'E'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_E'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'F'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_F'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'G'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_F'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'H'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_H'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'K'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_K'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'L'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_L'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN OTHERS.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_OTHERS'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDCASE.
IF repeat NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REPEAT'
window = 'REPEAT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "FORM_TITLE_PRINT
*----
*
FORM GET_DATA *
*----
*
General provision of data for the form *
*----
*
FORM get_data.
*
DATA: us_veda_vbeln LIKE veda-vbeln.
DATA: us_veda_posnr_low LIKE veda-vposn.
*
CALL FUNCTION 'RV_PRICE_PRINT_REFRESH'
TABLES
tkomv = tkomv.
CLEAR komk.
CLEAR komp.
vbco3-mandt = sy-mandt.
vbco3-spras = nast-spras.
vbco3-vbeln = nast-objky.
vbco3-kunde = nast-parnr.
vbco3-parvw = nast-parvw.
CALL FUNCTION 'RV_DOCUMENT_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
kopf = vbdka
TABLES
pos = tvbdpa.
Fetch servicecontract-data and notice-data for head and position.
us_veda_vbeln = vbdka-vbeln.
us_veda_posnr_low = posnr_low.
CALL FUNCTION 'SD_VEDA_GET_PRINT_DATA'
EXPORTING
i_document_number = us_veda_vbeln
i_language = sy-langu
i_posnr_low = us_veda_posnr_low
TABLES
print_data_pos = tkomservp
print_data_head = tkomservh
print_notice_pos = tkomservpn
print_notice_head = tkomservhn.
PERFORM get_controll_data.
PERFORM sender.
PERFORM check_repeat.
PERFORM tvbdpau_create.
ENDFORM. "GET_DATA
*----
*
FORM GET_ITEM_BILLING_SCHEDULES *
*----
*
In this routine the billing schedules are fetched from the *
database. *
*----
*
FORM get_item_billing_schedules.
*
REFRESH tfpltdr.
CHECK NOT vbdpa-fplnr IS INITIAL.
*
CALL FUNCTION 'BILLING_SCHED_PRINTVIEW_READ'
EXPORTING
i_fplnr = vbdpa-fplnr
i_language = nast-spras
TABLES
zfpltdr = tfpltdr.
*
ENDFORM. "GET_ITEM_BILLING_SCHEDULES
*&----
*
*& Form ITEM_BILLING_SCHEDULES_PRINT
*&----
*
This routine prints the billing shedules of a salesdocument *
position. *
*----
*
FORM item_billing_schedules_print.
*
DATA: first_line(1) TYPE c.
*
first_line = charx.
LOOP AT tfpltdr.
fpltdr = tfpltdr.
Output of the following printlines
IF NOT fpltdr-perio IS INITIAL.
periodische Fakturen
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERIODIC'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
bei periodischen nur eine Zeile
EXIT.
ELSEIF fpltdr-fareg CA '14'.
prozentuale Teilfakturierung
IF NOT first_line IS INITIAL.
CLEAR first_line.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERCENT_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERCENT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ELSEIF fpltdr-fareg CA '235'.
wertmäßige Teilfakturierung
IF NOT first_line IS INITIAL.
CLEAR first_line.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_VALUE_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_VALUE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ELSEIF fpltdr-fareg CA '3'.
Schlußrechnung
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_BILLING_SCHEDULES_PRINT
*eject
*----
*
FORM GET_ITEM_CHARACTERISTICS *
*----
*
In this routine the configuration data item is fetched from *
the database. *
*----
*
FORM get_item_characteristics.
REFRESH tkomcon.
CHECK NOT vbdpa-cuobj IS INITIAL.
CALL FUNCTION 'CUD0_GET_CONFIGURATION' "#EC EXISTS
EXPORTING
instance = vbdpa-cuobj
language = nast-spras
TABLES
configuration = tkomcon
EXCEPTIONS
OTHERS = 4.
ENDFORM. "GET_ITEM_CHARACTERISTICS
*----
*
FORM GET_ITEM_PRICES *
*----
*
In this routine the price data for the item is fetched from *
the database. *
*----
*
FORM get_item_prices.
CLEAR: komp,
tkomv.
IF komk-knumv NE vbdka-knumv.
CLEAR komk.
komk-mandt = sy-mandt.
komk-kalsm = vbdka-kalsm.
komk-kappl = pr_kappl.
komk-waerk = vbdka-waerk.
komk-knumv = vbdka-knumv.
komk-vbtyp = vbdka-vbtyp.
ENDIF.
komp-kposn = vbdpa-posnr.
CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
EXPORTING
comm_head_i = komk
comm_item_i = komp
language = nast-spras
IMPORTING
comm_head_e = komk
comm_item_e = komp
TABLES
tkomv = tkomv
tkomvd = tkomvd.
ENDFORM. "GET_ITEM_PRICES
*----
*
FORM GET_HEADER_PRICES *
*----
*
In this routine the price data for the header is fetched from *
the database. *
*----
*
FORM get_header_prices.
CALL FUNCTION 'RV_PRICE_PRINT_HEAD'
EXPORTING
comm_head_i = komk
language = nast-spras
IMPORTING
comm_head_e = komk
TABLES
tkomv = tkomv
tkomvd = tkomvd.
ENDFORM. "GET_HEADER_PRICES
*&----
*
*& Form HEADER_DATA_PRINT
*&----
*
Printing of header data like terms, weights .... *
*----
*
FORM header_data_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_DATA'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. " HEADER_DATA_PRINT
*----
*
FORM HEADER_PRICE_PRINT *
*----
*
Printout of the header prices *
*----
*
FORM header_price_print.
LOOP AT tkomvd.
AT FIRST.
IF komk-supos NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_SUM'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'UNDER_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDAT.
komvd = tkomvd.
IF komvd-koaid = 'D'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TAX_LINE'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUM_LINE'.
ENDIF.
ENDLOOP.
DESCRIBE TABLE tkomvd LINES sy-tfill.
IF sy-tfill = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'UNDER_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "HEADER_PRICE_PRINT
*----
*
FORM HEADER_TEXT_PRINT *
*----
*
Printout of the headertexts *
*----
*
FORM header_text_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "HEADER_TEXT_PRINT
*----
*
FORM ITEM_CHARACERISTICS_PRINT *
*----
*
Printout of the item characteristics -> configuration *
*----
*
FORM item_characteristics_print.
LOOP AT tkomcon.
conf_out = tkomcon.
IF sy-tabix = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_CONFIGURATION_HEADER'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_CONFIGURATION'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_CHARACTERISTICS_PRINT
*----
*
FORM ITEM_DELIVERY_CONFIRMATION *
*----
*
If the delivery date is not confirmed, a text is printed *
*----
*
FORM item_delivery_confirmation.
CHECK vbdpa-lfdat = space.
CHECK vbdpa-kwmeng NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_DELIVERY_CONFIRMATION'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_DELIVERY_CONFIRMATION
*----
*
FORM ITEM_PRICE_PRINT *
*----
*
Printout of the item prices *
*----
*
FORM item_price_print.
LOOP AT tkomvd.
komvd = tkomvd.
IF sy-tabix = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_PRICE_QUANTITY'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_PRICE_TEXT'.
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_PRICE_PRINT
*----
*
FORM ITEM_PRINT *
*----
*
Printout of the items *
*----
*
FORM item_print.
DATA: da_subrc LIKE sy-subrc,
da_dragr LIKE tvag-dragr.
CALL FUNCTION 'WRITE_FORM' "First header
EXPORTING element = 'ITEM_HEADER'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
CALL FUNCTION 'WRITE_FORM' "Activate header
EXPORTING element = 'ITEM_HEADER'
type = 'TOP'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
LOOP AT tvbdpa.
vbdpa = tvbdpa.
TVAG lesen um festzustellen ob abgesagte Positionen gedruckt werden
sollen
PERFORM tvag_select(sapmv45a) USING vbdpa-abgru
da_dragr
space
da_subrc.
IF da_dragr EQ space. "Print rejected item?
IF vbdpa-posnr_neu NE space. "Item
PERFORM get_item_serials.
PERFORM get_item_characteristics.
PERFORM get_item_billing_schedules.
PERFORM get_item_prices.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE'.
PERFORM item_rejected.
PERFORM item_price_print.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
PERFORM item_text_print.
PERFORM item_serials_print.
PERFORM item_characteristics_print.
PERFORM alternative_item.
PERFORM delivery_date.
PERFORM item_delivery_confirmation.
PERFORM item_billing_schedules_print.
PERFORM different_reference_no.
PERFORM different_terms.
PERFORM different_consignee.
PERFORM schedule_header.
PERFORM main_item.
ELSE.
PERFORM schedule_print.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM' "Deactivate Header
EXPORTING element = 'ITEM_HEADER'
function = 'DELETE'
type = 'TOP'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_PRINT
*----
*
FORM ITEM_REJECTED *
*----
*
A text is printed, if the item is rejected *
*----
*
FORM item_rejected.
CHECK NOT vbdpa-abgru IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_REJECTED'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_REJECTED
*----
*
FORM MAIN_ITEM *
*----
*
A text is printed, if the item is a main item *
*----
*
FORM main_item.
READ TABLE tvbdpau WITH KEY vbdpa-posnr BINARY SEARCH.
CHECK sy-subrc = 0.
vbdpau = tvbdpau.
IF vbdpau-uposb IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ONE_SUBITEM'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SEVERAL_SUBITEMS'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "MAIN_ITEM
*----
*
FORM ITEM_TEXT_PRINT *
*----
*
Printout of the item texts *
*----
*
FORM item_text_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_TEXT_PRINT
*----
*
FORM PROTOCOL_UPDATE *
*----
*
The messages are collected for the processing protocol. *
*----
*
FORM protocol_update.
CHECK xscreen = space.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = syst-msgid
msg_nr = syst-msgno
msg_ty = syst-msgty
msg_v1 = syst-msgv1
msg_v2 = syst-msgv2
msg_v3 = syst-msgv3
msg_v4 = syst-msgv4
EXCEPTIONS
OTHERS = 1.
ENDFORM. "PROTOCOL_UPDATE
*----
*
FORM SCHEDULE_HEADER *
*----
*
If there are schedules in the item, then here is printed the *
header for the schedules. *
*----
*
FORM schedule_header.
CHECK vbdpa-etenr_da NE space.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_SCHEDULE_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "SCHEDULE_HEADER
*----
*
FORM SCHEDULE_PRINT *
*----
*
This routine prints the schedules for an item. *
*----
*
FORM schedule_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_SCHEDULE_PRINT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "SCHEDULE_PRINT
*----
*
FORM SENDER *
*----
*
This routine determines the address of the sender (Table VKO) *
*----
*
FORM sender.
SELECT SINGLE * FROM tvko WHERE vkorg = vbdka-vkorg.
IF sy-subrc NE 0.
syst-msgid = 'VN'.
syst-msgno = '203'.
syst-msgty = 'E'.
syst-msgv1 = 'TVKO'.
syst-msgv2 = syst-subrc.
PERFORM protocol_update.
EXIT.
ENDIF.
SELECT SINGLE * FROM sadr WHERE adrnr = tvko-adrnr
AND natio = space.
vbdka-sland = sadr-land1.
IF sy-subrc NE 0.
syst-msgid = 'VN'.
syst-msgno = '203'.
syst-msgty = 'E'.
syst-msgv1 = 'SADR'.
syst-msgv2 = syst-subrc.
PERFORM protocol_update.
ENDIF.
SELECT SINGLE * FROM tvbur WHERE vkbur = vbdka-vkbur.
IF sy-subrc NE 0.
syst-msgid = 'VN'.
syst-msgno = '203'.
syst-msgty = 'E'.
syst-msgv1 = 'TVBUR'.
syst-msgv2 = syst-subrc.
PERFORM protocol_update.
ENDIF.
ENDFORM. "SENDER
*----
*
FORM TVBDPAU_CREATE *
*----
*
This routine is creating a table which includes the subitem- *
numbers *
*----
*
FORM tvbdpau_create.
CLEAR tvbdpau.
REFRESH tvbdpau.
LOOP AT tvbdpa.
IF tvbdpa-uepos IS INITIAL.
Eintrag der letzten Positon merken
IF tvbdpau-uposv > 0.
APPEND tvbdpau.
CLEAR tvbdpau.
ENDIF.
Neuen Eintrag anfangen
tvbdpau-posnr = tvbdpa-posnr.
ELSE.
IF tvbdpau-uposv IS INITIAL OR
tvbdpau-uposv > tvbdpa-posnr.
tvbdpau-uposv = tvbdpa-posnr.
ENDIF.
IF tvbdpau-uposb < tvbdpa-posnr AND
tvbdpau-uposv < tvbdpa-posnr.
tvbdpau-uposb = tvbdpa-posnr.
ENDIF.
ENDIF.
ENDLOOP.
IF tvbdpau-uposv > 0.
APPEND tvbdpau.
ENDIF.
SORT tvbdpau.
ENDFORM. "TVBDPAU_CREATE
*----
*
FORM VALIDITY_PRINT *
*----
*
This routine is printing the period of validity for offers *
and contracts *
*----
*
FORM validity_print.
CHECK steu-vdkex EQ space.
CASE vbdka-vbtyp.
WHEN 'B'.
IF vbdka-angdt CN '0' OR
vbdka-bnddt CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'VALIDITY_OFFER'
window = 'VALIDITY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
WHEN 'E'.
IF vbdka-guebg CN '0' OR
vbdka-gueen CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'VALIDITY_CONTRACT'
window = 'VALIDITY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
WHEN 'F'.
IF vbdka-guebg CN '0' OR
vbdka-gueen CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'VALIDITY_CONTRACT'
window = 'VALIDITY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
WHEN 'G'.
IF vbdka-guebg CN '0' OR
vbdka-gueen CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'VALIDITY_CONTRACT'
window = 'VALIDITY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. "VALIDITY_PRINT
*&----
*
*& Form HEADER_NOTICE_PRINT
*&----
*
This routine prints the notice-rules of the contract-header. *
*----
*
--> p1 text
<-- p2 text
*----
*
FORM header_notice_print.
*
DATA: us_text(1) TYPE c. "Kz. falls Text für Kündigungsbed.
*
Kündigungsbedingungen auf Kopfebene.
CLEAR us_text.
LOOP AT tkomservhn.
vedkn = tkomservhn.
IF us_text IS INITIAL.
For the first time a headertext is printed.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TERMS_OF_NOTTXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
us_text = charx.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TERMS_OF_NOTICE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDLOOP.
If notice-rules exists a empty line is printed.
IF NOT us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMPTY_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
*
ENDFORM. " HEADER_NOTICE_PRINT
*eject
*&----
*
*& Form GET_ITEM_SERIALS
*&----
*
This routine give back the serialnumbers of salesdocument *
position. The numbers are processed as print-lines in the *
table KOMSER_PRINT. *
*----
*
--> US_VBELN Salesdocument
--> US_POSNR Position of the salesdocument
*----
*
FORM get_item_serials.
Read the Serialnumbers of a Position.
REFRESH tkomser.
CALL FUNCTION 'SERIAL_WV_PRINT'
EXPORTING
posnr = vbdpa-posnr
vbeln = vbdka-vbeln
TABLES
isernr = tkomser.
Process the stringtable for Printing.
CALL FUNCTION 'PROCESS_SERIALS_FOR_PRINT'
EXPORTING
i_boundary_left = '(_'
i_boundary_right = '_)'
i_sep_char_strings = ',_'
i_sep_char_interval = '_-_'
i_use_interval = 'X'
i_boundary_method = 'C'
i_line_length = 50
i_no_zero = 'X'
i_alphabet = sy-abcde
i_digits = '0123456789'
i_special_chars = '-'
i_with_second_digit = ' '
TABLES
serials = tkomser
serials_print = tkomser_print
EXCEPTIONS
boundary_missing = 01
interval_separation_missing = 02
length_to_small = 03
internal_error = 04
wrong_method = 05
wrong_serial = 06
two_equal_serials = 07
serial_with_wrong_char = 08
serial_separation_missing = 09.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
*
ENDFORM. " GET_ITEM_SERIALS
*eject
*&----
*
*& Form ITEM_SERIALS_PRINT
*&----
*
This routine prints the serialnumbers of a salesdocument *
position. *
*----
*
FORM item_serials_print.
*
DATA: first_line(1) TYPE c.
*
first_line = charx.
LOOP AT tkomser_print.
komser = tkomser_print.
IF NOT first_line IS INITIAL.
Output of the Headerline
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_SERIAL_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
CLEAR first_line.
ELSE.
Output of the following printlines
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_SERIAL'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDLOOP.
If serialnumbers exists a empty line is printed.
IF first_line IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMPTY_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
*
ENDFORM. " ITEM_SERIALS_PRINT
*eject
*&----
*
*& Form HEADER_INTER_PRINT
*&----
*
Prints the message that if other condition for the positions *
exists they are printed there. *
*----
*
--> p1 text
<-- p2 text
*----
*
FORM header_inter_print.
*
CHECK NOT steu-vdkex IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TERMS_OF_TXTEND'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
*
ENDFORM. " HEADER_INTER_PRINT
*&----
*
*& Form GET_CONTROLL_DATA
*&----
*
Checks if servicedata for the header exists. *
Checks if servicedata for the position exists. *
Checks if noticedata for the header exists. *
Checks if noticedata for the position exists. *
*----
*
FORM get_controll_data.
*
DATA: lines TYPE i.
*
Exists servicedata for the header?
DESCRIBE TABLE tkomservh LINES lines.
IF lines GT 0.
steu-vdkex = 'X'.
ENDIF.
Exists servicedata for the position?
DESCRIBE TABLE tkomservp LINES lines.
IF lines GT 0.
steu-vdpex = 'X'.
ENDIF.
Exists noticedata for the header?
DESCRIBE TABLE tkomservhn LINES lines.
IF lines GT 0.
steu-kbkex = 'X'.
ENDIF.
Exists noticedata for the position?
DESCRIBE TABLE tkomservpn LINES lines.
IF lines GT 0.
steu-kbpex = 'X'.
ENDIF.
*
ENDFORM. " GET_CONTROLL_DATA
*eject
*&----
*
*& Form HEADER_SERV_PRINT
*&----
*
Output of the validity of a service-contract. *
*----
*
FORM header_serv_print.
*
CHECK NOT steu-vdkex IS INITIAL.
READ TABLE tkomservh INDEX 1.
MOVE tkomservh TO vedka.
Output of the validity.
IF NOT vedka-venddat IS INITIAL OR
vedka-venddat EQ space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TERMS_OF_SERV1'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSEIF vedka-vbegdat NE space AND
NOT vedka-vbegdat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TERMS_OF_SERV2'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TERMS_OF_SERV3'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
*
ENDFORM. " HEADER_SERV_PRINT
*&----
*
*& Form WRITE_HEADER_INFO
*&----
*
FORM write_header_info.
PERFORM get_ship_to_info.
PERFORM get_dea_number.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_CONSGNEE'
window = 'INFO1'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'DEA_NUM'
window = 'DEA_NUM'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'INFO'
window = 'INFO'.
ENDFORM. " WRITE_HEADER_INFO
*&----
*
*& Form GET_DEA_NUMBER
*&----
*
FORM get_dea_number.
CALL FUNCTION 'Z_GET_DEA_NUMBER_CUSTOMER'
EXPORTING
cust_num = vbco3-kunde
TABLES
char_val = char_val
EXCEPTIONS
customer_not_found = 1
OTHERS = 2.
LOOP AT char_val.
CASE char_val-atnam.
WHEN 'DEA_NUMBER'.
PERFORM set_text_symbol USING char_val-atwrt '&DEA_NUM&'.
WHEN 'DEA_EXPIRATION_DATE'.
PERFORM set_text_symbol USING char_val-atwrt '&EXP_DATE&'.
ENDCASE.
ENDLOOP.
ENDFORM. " GET_DEA_NUMBER
*&----
*
*& Form SET_TEXT_SYMBOL
*&----
*
FORM set_text_symbol USING value name.
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
name = name
value = value
EXCEPTIONS
OTHERS = 1.
ENDFORM. " SET_TEXT_SYMBOL
*&----
*
*& Form GET_SHIP_TO_INFO
*&----
*
FORM get_ship_to_info.
SELECT SINGLE * FROM vbpa WHERE vbeln = vbdka-vbeln
AND posnr = '000000'
AND parvw = 'WE'.
IF NOT vbpa-adrnr IS INITIAL.
*{ REPLACE DU1K920151
SELECT SINGLE * FROM SADR WHERE ADRNR = VBPA-ADRNR.
TABLES: addr1_sel.
CLEAR: addr1_sel, sadr.
addr1_sel-addrnumber = vbpa-adrnr.
CALL FUNCTION 'ADDR_GET'
EXPORTING
address_selection = addr1_sel
IMPORTING
sadr = sadr
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
version_not_exist = 3
internal_error = 4
OTHERS = 5.
*} REPLACE
MOVE: sadr-anred TO vbdka-anred_we,
sadr-name1 TO vbdka-name1_we,
sadr-name2 TO vbdka-name2_we,
sadr-name3 TO vbdka-name3_we,
sadr-name4 TO vbdka-name4_we,
sadr-stras TO vbdka-stras_we,
sadr-pfach TO vbdka-pfach_we,
sadr-pstl2 TO vbdka-pstl2_we,
sadr-pfort TO vbdka-pfort,
sadr-pstlz TO vbdka-pstlz_we,
sadr-ort01 TO vbdka-ort01_we,
sadr-ort02 TO vbdka-ort02_we,
sadr-regio TO vbdka-regio_we,
sadr-land1 TO vbdka-land1_we,
sadr-land1 TO vbdka-sland.
ELSE.
SELECT SINGLE * FROM kna1 WHERE kunnr = vbpa-kunnr.
MOVE: kna1-anred TO vbdka-anred_we,
kna1-name1 TO vbdka-name1_we,
kna1-name2 TO vbdka-name2_we,
kna1-name3 TO vbdka-name3_we,
kna1-name4 TO vbdka-name4_we,
kna1-stras TO vbdka-stras_we,
kna1-pfach TO vbdka-pfach_we,
kna1-pstl2 TO vbdka-pstl2_we,
kna1-pfort TO vbdka-pfort,
kna1-pstlz TO vbdka-pstlz_we,
kna1-ort01 TO vbdka-ort01_we,
kna1-ort02 TO vbdka-ort02_we,
kna1-regio TO vbdka-regio_we,
kna1-land1 TO vbdka-land1_we,
kna1-land1 TO vbdka-sland.
ENDIF.
MOVE vbpa-kunnr TO vbco3-kunde.
ENDFORM. " GET_SHIP_TO_INFO
*&----
*
*& Form LOGO_SELECTION
*&----
*
FORM logo_selection.
CALL FUNCTION 'Z_UCB_LOGO_SELECTION'
EXPORTING
vkorg = vbdka-vkorg
EXCEPTIONS
invalid_sales_organization = 1
OTHERS = 2.
ENDFORM. " LOGO_SELECTION
Regards,
Sree
‎2007 Jul 18 6:17 AM
Hi Shreekant,
Let me share my points with you.
For this just do one thing. Execute SE37 and enter sendmail* in that. Now it will display all the FMs. Select one as per u r requirement. By using where used list we can check how many program are used taht FM. Now observe those program.
Hope this helps you. Reply for queries, shall post the updates.
Regards.
Kumar.