How can I send purchase order through SAP mail ?
How can I send purchase order through SAP mail ? Can any one explain whts the NACE settings?
just do it as <b>Anji reddy</b> said to you ...or else ... in the purchase order trascation ...print it ... so that it will generate the spool request for that purchase order ....
so the the belwo program is for sending <b>the Spool Request data as Email to any Email id ...</b>
The code below demonstrates how to retrieve a spool request and email it as a PDF document. Please note for the below program to process a spool request the program must be executed in background otherwise no spool request will be created. Once you have had a look at this there is an modified version of the program which works in both background and foreground. Also see transaction SCOT for SAPConnect administration.
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
*** Alternative way could be to submit another program and store spool
*** id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
* Get spool id from program called above
* IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
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.
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.
ENDFORM.
* FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
* perform send_email using p_email2.
ENDFORM.
* FORM send_email *
* --> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
* Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
* If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_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.
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.
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[] = 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 = '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
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.
Girish
Similar Messages
-
Sending purchase order through e-mail
Hi,
I need to send purchase order in PDF through e-mail. I know it is possible to automatically have it sent to the vendor, but my requirement is different. PO is created as conversion of PREQ, so I need to send it not to vendor directly, but to the PREQ creator first (for possible corrections etc.) Is this somehow possible? I'm using exit EXIT_SAPMM06E_020 where I'd like to paste call to the function module (in update task), which would send the e-mail.
Thanks in advance.
TomasHi,
Use this program
*& Report YMSL_ORDER_ACCEPTANCE
REPORT YMSL_ORDER_ACCEPTANCE.
*********Variable Declarations *****************************
DATA: GV_FORM_NAME TYPE RS38L_FNAM, " Used to store the function module generated by Smartform
GV_BIN_FILESIZE TYPE I, " Store the file size
GV_POS TYPE I,
GV_LEN TYPE I,
GV_TAB_LINES TYPE I,
gv_desc_lines type i.
********Constants *******************************************
DATA : GC_TEXT(11) TYPE C VALUE 'Form Output',
GC_TST(3) TYPE C VALUE 'TST',
GC_TESTING(20) TYPE C VALUE 'Order Acceptance'.
*********Work Area Declarations *****************************
DATA: GS_DOCDATA TYPE SODOCCHGI1, " Data of an object which can be changed
GS_CTRLOP TYPE SSFCTRLOP, " Smart Forms: Control structure
GS_OUTOPT TYPE SSFCOMPOP, " SAP Smart Forms: Smart Composer (transfer) options
GS_OTFDATA TYPE SSFCRESCL, " Smart Forms: Return value at end of form printing
GS_RECLIST TYPE SOMLRECI1, " SAPoffice: Structure of the API Recipient List
GS_PDF_TAB TYPE TLINE, " Workarea for SAP Script Text Lines
GS_OBJBIN TYPE SOLISTI1, " SAPoffice: Single List with Column Length 255
GS_OBJPACK TYPE SOPCKLSTI1. " SAPoffice: Description of Imported Object Components
DATA : w_doc_chng typE sodocchgi1.
*********Internal tables Declarations *****************************
DATA : I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: GT_RECLIST TYPE TABLE OF SOMLRECI1, " SAPoffice: Structure of the API Recipient List
GT_PDF_TAB TYPE TABLE OF TLINE, " SAPscript: Text Lines
GT_OTF TYPE TABLE OF ITCOO, " OTF Structure
GT_OBJBIN TYPE TABLE OF SOLISTI1, " SAPoffice: Single List with Column Length 255
GT_OBJPACK TYPE TABLE OF SOPCKLSTI1. " SAPoffice: Description of Imported Object Components
DATA : BEGIN OF IT_ADR6 OCCURS 0,
SMTP_ADDR TYPE ADR6-SMTP_ADDR,
END OF IT_ADR6.
DATA : W_FILE_NAME TYPE STRING,
W_FILE_PATH TYPE STRING,
W_FULL_PATH TYPE STRING.
CLEAR : GV_FORM_NAME,
GS_CTRLOP,
GS_OUTOPT,
GS_OTFDATA,
GV_BIN_FILESIZE,
GV_POS,
GV_LEN,
GV_TAB_LINES.
SELECTION-SCREEN: BEGIN OF SCREEN 1001 AS WINDOW TITLE scr_ttl .
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TXT_B1 NO INTERVALS.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(15) TX_VBELN.
PARAMETER : P_VBELN TYPE VBAK-VBELN .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
*SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TXT_B2 .
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R_OUT RADIOBUTTON GROUP R1 DEFAULT 'X' USER-COMMAND RAD11 .
SELECTION-SCREEN COMMENT 5(20) TXT_OUT. " roles by t-code
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER R_PDF RADIOBUTTON GROUP R1 .
SELECTION-SCREEN COMMENT 5(20) TXT_PDF.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER R_MAIL RADIOBUTTON GROUP R1 .
SELECTION-SCREEN COMMENT 5(15) TXT_MAIL.
*SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(7) TXT_MAL1.
PARAMETER : P_MAIL TYPE ADR6-SMTP_ADDR MODIF ID M1 .
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN: END OF SCREEN 1001 .
CALL SELECTION-SCREEN 1001 STARTING AT 20 5 ENDING AT 105 10.
*SET PF-STATUS 'STATUS'.
INITIALIZATION.
TX_VBELN = 'Order'.
TXT_B1 = 'Selection Criteria '.
TXT_B2 = 'Output Criteria '.
scr_ttl = 'Order Acceptance'.
TXT_OUT = 'Print Output'.
TXT_PDF = 'Save To PDF'.
TXT_MAIL = 'Mail the Output'.
TXT_MAL1 = 'E-mail'.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF R_MAIL <> 'X'.
IF SCREEN-GROUP1 = 'M1'.
SCREEN-INVISIBLE = 1.
SCREEN-INPUT = 0. " Disable for input.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MAIL.
PERFORM TABLE_HELP.
START-OF-SELECTION..
IF P_VBELN IS NOT INITIAL.
PERFORM GET_SF.
IF R_PDF = 'X' .
PERFORM CONVERT_OTF.
PERFORM SAVE_DIALOG.
PERFORM DOWNLOAD.
ELSEIF R_MAIL = 'X'.
IF P_MAIL IS NOT INITIAL.
PERFORM CONVERT_OTF.
PERFORM SEND_MAIL.
ELSE.
MESSAGE 'Please Enter Email Address' TYPE 'S'.
CALL TRANSACTION 'YMSL20'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ELSE.
MESSAGE 'Please Enter Order No' TYPE 'S'.
CALL TRANSACTION 'YMSL20'.
LEAVE LIST-PROCESSING.
*ENDIF.
END-OF-SELECTION.
*& Form TABLE_HELP
FORM TABLE_HELP .
IF R_MAIL = 'X'.
SELECT SMTP_ADDR FROM ADR6 INTO TABLE IT_ADR6.
SORT IT_ADR6.
DELETE ADJACENT DUPLICATES FROM IT_ADR6 COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'IT_ADR6-SMTP_ADDR'
PVALKEY = ' '
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'EMAIL'
STEPL = 0
WINDOW_TITLE = 'SELECT MAIL ADDRESS'
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = IT_ADR6
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM. " TABLE_HELP
*& Form GET_SF
FORM GET_SF .
*u2022 Generate Function Module name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'Z_CHK'
IMPORTING
FM_NAME = GV_FORM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*u2022 Assigning values to Form Control Structure and Form Composer
IF R_OUT <> 'X'.
GS_CTRLOP-GETOTF = 'X'.
GS_CTRLOP-NO_DIALOG = 'X'.
GS_OUTOPT-TDNOPREV = 'X'.
ENDIF.
*/1BCDWB/SF00000368
CALL FUNCTION GV_FORM_NAME "'/1BCDWB/SF00000368'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = GS_CTRLOP
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = GS_OUTOPT
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = GS_OTFDATA
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION GV_FORM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = GS_CTRLOP
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = GS_OUTOPT
USER_SETTINGS = 'X'
TEMP_VBELN = P_VBELN
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = GS_OTFDATA
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_SF
*& Form CONVERT_OTF
FORM CONVERT_OTF .
*u2022 Assigning the OTFDATA to OTF Structure table
CLEAR GT_OTF.
GT_OTF[] = GS_OTFDATA-OTFDATA[].
*u2022 Convert the OTF DATA to SAP Script Text lines
CLEAR GT_PDF_TAB.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = GV_BIN_FILESIZE
BIN_FILE =
TABLES
OTF = GT_OTF
LINES = GT_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*t_otf[] = t_otf_from_fm-otfdata[].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
*CALL FUNCTION 'CONVERT_OTF'
*EXPORTING
*FORMAT = 'PDF'
*MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
*IMPORTING
*BIN_FILESIZE = W_bin_filesize
BIN_FILE =
*TABLES
*otf = T_OTF
*lines = T_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.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
ENDFORM. " CONVERT_OTF
*& Form SAVE_DIALOG
FORM SAVE_DIALOG .
To display File SAVE dialog window
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = 'Download to PDF '
DEFAULT_EXTENSION = '(*.PDF)'
DEFAULT_FILE_NAME = 'file.pdf'
FILE_FILTER = 'PDF Format(*.PDF)'
INITIAL_DIRECTORY = 'C:\Documents and Settings\Administrator\Desktop'
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
FILENAME = W_FILE_NAME
PATH = W_FILE_PATH
FULLPATH = W_FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 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.
ENDFORM. " SAVE_DIALOG
*& Form DOWNLOAD
FORM DOWNLOAD .
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = GV_BIN_FILESIZE
FILENAME = W_FULL_PATH
FILETYPE = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = GT_PDF_TAB
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DOWNLOAD
*& Form SEND_MAIL
FORM SEND_MAIL .
***changes by rajan
*DATA : v_first TYPE USER_ADDR-NAME_FIRST,
V_LAST TYPE USER_ADDR-NAME_LAST.
DATA : detail TYPE STRING.
*SELECT SINGLE NAME_FIRST NAME_LAST FROM
USER_ADDR INTO (V_FIRST,V_LAST)
WHERE BNAME = syst-UNAME.
CONCATENATE v_first V_LAST INTO detail SEPARATED BY space.
data : v_po_no TYPE vbkd-bstkd,
v_po_date TYPE vbkd-bstdk.
data : day TYPE STRING,
month type STRING,
year TYPE STRING.
data : date TYPE STRING.
SELECT SINGLE BSTKD BSTDK
FROM VBKD
INTO (v_po_no,v_po_date)
WHERE VBELN = P_VBELN.
day = v_po_date+6(2).
month = v_po_date+4(2).
year = v_po_date+0(4).
CONCATENATE day '/' month '/' year INTO date.
CONCATENATE 'Please Find attached Order Acceptance against your P.O.No.' v_po_no 'dated' date '.' INTO detail SEPARATED BY
space.
**u2022 Assigning the Description of the object sent in the mail
CLEAR GS_DOCDATA.
GS_DOCDATA-OBJ_NAME = GC_TST.
GS_DOCDATA-OBJ_DESCR = GC_TESTING.
*u2022 Assigning the email id to Structure of the API Recipient List table
CLEAR : GT_RECLIST, GS_RECLIST.
GS_RECLIST-RECEIVER = P_MAIL. "
GS_RECLIST-REC_TYPE = 'U'."'G' ."'O'. "'B'. "'U'.
APPEND GS_RECLIST TO GT_RECLIST.
mail body rajan
I_OBJTXT = 'Dear Sir/Madam.'.
APPEND I_OBJTXT.
I_OBJTXT = detail.
APPEND I_OBJTXT.
I_OBJTXT = ''.
APPEND I_OBJTXT.
I_OBJTXT = 'Thanks.'.
APPEND I_OBJTXT.
I_OBJTXT = 'Best Regards,'.
APPEND I_OBJTXT.
I_OBJTXT = 'For Bilcare Ltd.'.
APPEND I_OBJTXT.
DESCRIBE TABLE i_objtxt LINES gv_desc_lines.
*DESCRIBE TABLE i_objtxt LINES v_lines_txt.
CLEAR I_OBJTXT.
READ TABLE I_OBJTXT INDEX gv_desc_lines.
if sy-subrc = 0.
Document information.
GS_DOCDATA-obj_name = 'ord_accept'.
GS_DOCDATA-expiry_dat = sy-datum + 10.
GS_DOCDATA-obj_descr = 'Order Acceptance'.
GS_DOCDATA-sensitivty = 'F'. "Functional object
GS_DOCDATA-doc_size = gv_desc_lines * 255.
CLEAR Gs_OBJPACK-transf_bin.
Start line of object header in transport packet
GS_OBJPACK-TRANSF_BIN = 'X'.
GS_OBJPACK-doc_size = gv_desc_lines * 255.
GS_OBJPACK-HEAD_START = 1.
GS_OBJPACK-HEAD_NUM = 0.
GS_OBJPACK-BODY_START = 1.
GS_OBJPACK-BODY_NUM = gv_desc_lines.
GS_OBJPACK-DOC_TYPE = 'RAW'.
GS_OBJPACK-OBJ_NAME = 'ORDER_ACCEPTANCE'.
GS_OBJPACK-OBJ_DESCR = 'ORDER_ACCEPTANCE.PDF'.
APPEND GS_OBJPACK TO GT_OBJPACK.
GS_OBJPACK-HEAD_START = 1.
GS_OBJPACK-HEAD_NUM = 0.
GS_OBJPACK-BODY_START = 1.
GS_OBJPACK-doc_type = 'RAW'.
*APPEND GS_OBJPACK TO GT_OBJPACK.
ENDIF.
*u2022 Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
CLEAR : GS_OBJBIN, GS_PDF_TAB.
LOOP AT GT_PDF_TAB INTO GS_PDF_TAB.
GV_POS = 255 - GV_LEN.
IF GV_POS > 134. "length of pdf_table
GV_POS = 134.
ENDIF.
GS_OBJBIN+GV_LEN = GS_PDF_TAB(GV_POS).
GV_LEN = GV_LEN + GV_POS.
IF GV_LEN = 255. "length of out (contents_bin)
APPEND GS_OBJBIN TO GT_OBJBIN.
CLEAR: GS_OBJBIN, GV_LEN.
IF GV_POS < 134.
GS_OBJBIN = GS_PDF_TAB+GV_POS.
GV_LEN = 134 - GV_POS.
ENDIF.
ENDIF.
ENDLOOP.
IF GV_LEN > 0.
APPEND GS_OBJBIN TO GT_OBJBIN.
ENDIF.
*u2022 Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE GT_OBJBIN LINES GV_TAB_LINES.
CLEAR GS_OBJBIN.
READ TABLE GT_OBJBIN INTO GS_OBJBIN INDEX GV_TAB_LINES.
IF SY-SUBRC = 0.
GS_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255 + STRLEN( GS_OBJBIN ).
GS_OBJPACK-TRANSF_BIN = 'X'.
GS_OBJPACK-HEAD_START = 1.
GS_OBJPACK-HEAD_NUM = 0.
GS_OBJPACK-BODY_START = 1.
GS_OBJPACK-BODY_NUM = GV_TAB_LINES.
GS_OBJPACK-DOC_TYPE = 'PDF'.
GS_OBJPACK-OBJ_NAME = 'ORDER_ACCEPTANCE'.
GS_OBJPACK-OBJ_DESCR = 'Order Acceptance'.
APPEND GS_OBJPACK TO GT_OBJPACK.
ENDIF.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = GS_DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
PACKING_LIST = GT_OBJPACK
OBJECT_HEADER = I_OBJTXT
CONTENTS_BIN = GT_OBJBIN
CONTENTS_TXT = I_OBJTXT
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS = GT_RECLIST
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.
ELSE.
WRITE 'Sent Successfully'.
MESSAGE 'Sent Successfully' TYPE 'I'.
CALL TRANSACTION 'YMSL20'.
LEAVE LIST-PROCESSING.
ENDIF.
SUBMIT RSCONN01
WITH MODE EQ 'INT'
AND RETURN.
ENDFORM. " SEND_MAIL
Thanks
Ankur Sharma -
Im trying to send out a word document via email. It tells me it cannot send because I have not yet set up an account with enterage. My email is active already with Apple regular mail program. How can I send it out through reg mail?
Save the Word document. Create your email in your normal mail application (Mail?), click on the add attachment icon (the paperclip if you are using Mail). Navigate to where you saved the Word file and select it. It should now appear as an attachment in your email. If you are sending it to a PC user and you are using Mail make sure 'Send Windows-friendly attachments' is selected in the edit menu. And if you don't want the attachment to display inline within the body of the email Control+Click on it and select 'view as icon'.
-
How to send purchase order via e-mail.
Please could someone let me know how to send purchase order via e-mail.
I am an BC.
e-mailing is functionning however I am not very familiar in settings for MMNo, you do not need to touch ME_PRINT_PO. You need to put code before and after ME_PRINT_PO in the print program.
Step 1 - Copy the standard print program SAPFM06P to make a Z version, lets call it ZSAPFM06P
Step 2 - Copy include FM06PE02 to make a Z version, lets call that ZFM06PE02.
Step 3 - ZSAPFM06P change the statement "Include FM06PE02" to read "Include ZFM06PE02".
Step 4 - In include ZFM06PE02 you will find a subroutine called "ENTRY_NEU". In this subroutine you will see it first calls ME_READ_PO_FOR_PRINTING then calls ME_PRINT_PO. Before it calls ME_PRINT_PO just put:
l_nast-nacha = 1.
CLEAR l_nast-dimme.
This means that ME_PRINT_PO will not e-mail, it will create a spool request.
Step 5 - Still in ZFM06PE02, after ME_PRINT_PO has been called, add new code. First check that ent_retco EQ 0. If it does not then exit.
Step 6 - Get the spool ID created by ME_PRINT_PO by either moving sy-msgv1 to a variable or select from NAST.
Step 7 - Call function CONVERT_OTFSPOOLJOB_2_PDF using the spool ID from step 6, and put the result from table PDF into an internal table you can use later. ALso store the export variable pdf_bytecount, you will need it later.
Step 8 - Call function SX_TABLE_LINE_WIDTH_CHANGE using the table from step 7 as content_in and put the results from content_out into a new internal table.
Step 9 - Add some text into a internal table of type solisti1, this will be the body text of the e-mail.
Step 10 - Add whatever receivers you want into an internal table of type somlreci1. If you just want it to go to the address that the PO would have gone to anyway, select the e-mail address from ADR6 where the address number = l_doc-xekko-adrnr, that is the data from the PO.
Step 11 - Populate an internal table of type sopcklsti1 with data relevant to your PDF table from step 8 and the text table from step 9. You will have to put the size of the PDF from step 7 (pdf_bytecount) on the PDF line and the size of the text will be the number of lines of text * 255.
Step 12 - Add info to a structure of type sodocchgi1. You can add the e-mail title in here, field obj_descr. Also add the size of the PDF and the size of the text from step 12 into doc_size, and give the doc a name in field obj_name. This can be anything, ZPDFPO for example.
Step 13 - Call SO_DOCUMENT_SEND_API1 using the tables from steps 8, 9, 10 and 11 and the structure from step 12. You can amend the sending e-mail also. Set commit_work to space.
Step 14 - That is all you need, but I actually call function RSPO_R_RDELETE_SPOOLREQ to delete the spool request created in step 4, then call NAST_PROTOCOL_UPDATE to add some more messages to the processing log of the PO.
That is all. -
Option sends Purchase Order through mail
Dear All,
My client wants Option sends Purchase Order through mail.
Please tell me what the process for above scenario is.
Thanks in advance,
Nagi ReddyHi,
For sending PO via mail, first check if output determintation in properly set in customization settings. Also If you are using customized program for printing, check if code is maintained in program for sending ouput via mails.
If all is maintained in customizing, in PO select output medium as "Mail" and take print. This can also done by using condition records in MN04. Then try sending the output via mail.
Thanks
Alex -
Can we create purchase order through report programming?
hi experts.....
can we create purchase order through report programming?If yes plz give me the thread details?Hi,
Use this code in a program by using a BAPI function module
Anothe rway is using classical/ALV report using call transaction from a report for changing the PO
loop at i_header.
header-ref_1 = i_header-legacy.
headerx-ref_1 = c_x.
header-doc_type = i_header-bsart.
headerx-doc_type = c_x.
header-comp_code = i_header-bukrs.
headerx-comp_code = c_x.
header-purch_org = i_header-ekorg.
headerx-purch_org = c_x.
header-pur_group = i_header-ekgrp.
headerx-pur_group = c_x.
header-vendor = i_header-lifnr.
headerx-vendor = c_x.
concatenate i_header-bedat+4(4)
i_header-bedat+0(2)
i_header-bedat+2(2)
into header-doc_date.
headerx-doc_date = c_x.
header-created_by = i_header-ernam.
headerx-created_by = c_x.
header-currency = i_header-waers.
headerx-currency = c_x.
concatenate i_header-kdatb+4(4)
i_header-kdatb+0(2)
i_header-kdatb+2(2)
into header-vper_start.
headerx-vper_start = c_x.
loop at i_items where legacy = i_header-legacy.
item-po_item = i_items-ebelp.
itemx-po_item = i_items-ebelp.
itemx-po_itemx = c_x.
if i_header-bsart = 'NB'.
item-material = i_items-ematn.
itemx-material = c_x.
schedule-quantity = i_items-menge * 1000.
schedulex-quantity = c_x.
else.
item-short_text = i_items-ematn.
itemx-short_text = c_x.
item-matl_group = '1000'.
itemx-matl_group = c_x.
schedule-quantity = '1'.
schedulex-quantity = c_x.
endif.
item-plant = i_items-werks.
itemx-plant = c_x.
schedule-po_item = i_items-ebelp.
schedule-sched_line = '1'.
schedulex-po_item = i_items-ebelp.
schedulex-sched_line = '1'.
schedulex-po_itemx = c_x.
schedulex-sched_linex = c_x.
concatenate i_items-eildt+0(2)
i_items-eildt+2(2)
i_items-eildt+4(4)
into schedule-delivery_date.
schedulex-delivery_date = c_x.
item-price_unit = i_items-peinh * 100.
itemx-price_unit = c_x.
item-tax_code = i_items-mwskz.
itemx-tax_code = c_x.
item-shipping = i_items-evers.
itemx-shipping = c_x.
account-po_item = i_items-ebelp.
accountx-po_item = i_items-ebelp.
accountx-po_itemx = c_x.
if i_header-bsart = 'FO'.
item-pckg_no = sy-tabix.
itemx-pckg_no = 'X'.
limits-pckg_no = sy-tabix.
limits-limit = i_items-overalllimit.
limits-exp_value = i_items-expectedoverall.
posrvaccessvalues-pckg_no = sy-tabix.
posrvaccessvalues-line_no = '0'.
posrvaccessvalues-serno_line = '00'.
posrvaccessvalues-percentage = '100.0'.
posrvaccessvalues-serial_no = '01'.
account-serial_no = '1'.
accountx-serial_no = '1'.
accountx-serial_nox = c_x.
account-quantity = '1'.
accountx-quantity = c_x.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_items-kostl
importing
output = account-costcenter.
accountx-costcenter = c_x.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_items-sakto
importing
output = account-gl_account.
accountx-gl_account = c_x.
item-acctasscat = i_items-knttp.
itemx-acctasscat = c_x.
item-item_cat = i_items-epstp.
itemx-item_cat = c_x.
endif.
append:item,itemx,schedule,schedulex,account,accountx,limits,posrvaccessvalues.
clear :item,itemx,schedule,schedulex,account,accountx,limits,posrvaccessvalues.
endloop.
call function 'BAPI_PO_CREATE1'
exporting
poheader = header
poheaderx = headerx
* POADDRVENDOR =
* TESTRUN =
* MEMORY_UNCOMPLETE =
* MEMORY_COMPLETE =
* POEXPIMPHEADER =
* POEXPIMPHEADERX =
* VERSIONS =
* NO_MESSAGING =
* NO_MESSAGE_REQ =
* NO_AUTHORITY =
* NO_PRICE_FROM_PO =
importing
exppurchaseorder = ponumber
* EXPHEADER =
* EXPPOEXPIMPHEADER =
tables
return = return
poitem = item
poitemx = itemx
* POADDRDELIVERY =
poschedule = schedule
poschedulex = schedulex
poaccount = account
* POACCOUNTPROFITSEGMENT =
poaccountx = accountx
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
polimits = limits
* POCONTRACTLIMITS =
* POSERVICES =
posrvaccessvalues = posrvaccessvalues.
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
if ponumber eq space.
loop at return where type = 'E'.
clear buffer.
move-corresponding return to e_return.
concatenate i_header-legacy e_return into buffer.
transfer buffer to p2_file.
endloop.
move-corresponding i_header to i_eheader.
transfer i_eheader to p3_file.
loop at i_items where legacy = i_header-legacy.
move-corresponding i_items to i_eitems.
transfer i_eitems to p4_file.
endloop.
else.
commit work and wait.
endif.
clear:ponumber,header,headerx,item,itemx,account,accountx,limits,return,schedule,schedulex,posrvaccessvalues.
refresh:item,itemx,account,accountx,limits,return,schedule,schedulex,posrvaccessvalues.
endloop.
close dataset p2_file.
close dataset p3_file.
close dataset p4_file.
Regards
Krishna -
How can I send a MIDP through MMS??
Hi there,
I need to know how can I send a JAR through MMS,
I'm not talking about WMA API..... please, understand that I don't
want do send a MMS through JAVA or J2ME or MIDP.
I want to send my compiled midp in a JAR, in a MMS.https://itunes.apple.com/us/app/id314894105?mt=8
https://itunes.apple.com/us/app/id306273816?mt=8
They have some limitations though. They have paid versions that remove those limitations -
My amp has an USB input but when I attach my mac pro to it, and set the input to the USB setting, no sound comes out. I looked at the system settings, but none of them produce a different outcome. How can I send the music through the USB out to USB in?
AFAIK cameras offer their own built-in format utility for inserted SD cards. You should use that. Otherwise, refer to the manual that came with your camera to determine precisely how your SD cards need to be formatted to work properly. Personally, I'd suggest Partition Scheme: MBR, and Filesystem: FAT32.
Try to limit the number of formats you perform on the SD cards, though, as you're reducing their lifespan. I believe formatting causes re-writes to a portion of the SD card that has fewer read/write cycles than the rest of the card as a whole. -
How can i send a document through my email with a ipod touch 2nd generation?
How can i send a document through my email with a ipod touch 2nd generation?
https://itunes.apple.com/us/app/id314894105?mt=8
https://itunes.apple.com/us/app/id306273816?mt=8
They have some limitations though. They have paid versions that remove those limitations -
Sending purchase order through internet.
hi, all of u,
please tell me how to send purchase order to supplier through mail.
thanks
rgds
sudhir pawar.Hello,
I suggest you to use addon outlook integration if you are curently using SAP Business One. Post your message in SAP R/3 forum if you use it. Other tools is SBO mailer.
This question should be posted to functional forum:
https://www.sdn.sap.com/irj/sdn/businessone-forums
Rgds, -
How can we send the smartform output to mail.
Dear Friends,
My query is how can we send the smart form output to mail.
In my company,payslip are given to the employee in printed format.instead of that we need to send payslip in mail.how can i do..plz help me.
[email protected]The code below demonstrates how to retrieve a spool request and email it as a PDF document. Please note to process a spool request the program can be executed in background or foreground. Because of the additional functionality to allow this to work in both background and foreground it has made it a little more confusing soyou might want to start by looking at the background only program. Also see transaction SCOT for SAPConnect administration.
*& Report ZSPOOLTOPDF2 *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program can be run in background or online and a spool request *
*& will still be created *
REPORT zspooltopdf2.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX,
p_online no-display.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i,
w_spool_nr like sy-spono.
%_print LIKE pri_params.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
If p_online = 'X'.
Processing performed when program calls itself when run online
gd_spool_nr = sy-spono.
EXPORT gd_spool_nr TO MEMORY ID 'SPOOLTOPDF'.
EXIT.
endif.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
ELSE.
gd_spool_nr = sy-spono.
If executed online, it submits a program to perform the write statements
instructing it to create a spool request, this could be another program
which just performs the write statements and then exports sy-spono
to memory. But in this example it calls itself passing X to parameter
p_online, which takes it down an alternative procesing path.
submit ZSPOOLTOPDF2
with p_online = 'X'
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
ENDIF.
Get spool id from program called above
IMPORT gd_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
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.
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.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_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.
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.
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[] = 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 = '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
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.
Regards,
Shakti Barath -
Dear all,
I have created one message condition type ZMAI copying from NEU for purchase order output and assigned output mode as 5-External send.Communication strategy i have given as CS01.Condition records i have maintained in MN04.My purchase orders are not picking this output type.What needs to be done for sending purchase orders thorugh mail mode(external send)
Regards,
Milton.IAre you already assign it to your PO message schema?
Please check to below link:
Re: Need send PO to the vender by e-mail using not default e-mail (ex. 2-nd ID)
PO By email
Out put Message for PO's
Re: PO Output Message
Regards,
w1n -
How to Send Purchase Order through EDI/IDOC.
Hi Experts,
We are using SAP ECC.5. And intending to send the Purchase Order to Supplier through EDI/IDOC and Receive the Inbound Acknowledgement.
Appreciate, if you could help me, the required Configuration details for outbound and inbound (PO & Acknowledgement).
Reg
KumarHi Kiran
Many thanks for the response. It is true that by changing the message type to EDI can generate idoc. What is not clear is any other config we need to do interms of Message generation, Resubmitting failed IDOC etc..
Out requirement is that we would generate the IDOC for New and changed docs and send to external EDI converter.
Inbound, receive the IDoc and post the acknowledgement.
Appreciate, if you could forward any document link which can explain the details.
Reg
Kumar -
EDI IDOC OUTBOUND send Purchase Orders from sap to vendors
Hi Experts,
I am new to EDI IDOCS, but i got object on this. So my requirement is purchase orders are send to vendors from sap (OUTBOUND) through EDI-850 format. and also i have to add some more fields to standard idoc type ORDERS05, one more condition is if vendor type is not EDI, then the POs should send through fax, email, how can we solve this condition.
So plaese send some sample code on this object.
Thanks in advance,
S ReddyHi ,
You can send the purchase order to the vendors using different outytpes configurations in NACE transaction .
If you define a particular output type where you need to give medium 6 and define partner functions within this you can also set condition which partner needs to recieve EDI output and which one FAX or email all this will be done by Functional expert.
For adding extra segments to your basic type ORDERS05 you need to extend the idoc you can do it via WE30 and WE31 .Link you message type to basic type and extension . Please follow below tcodes for further help . Create all the requested steps in the tcodes mentioned below.
we20:patner profile
we21:port
we30:idoc creation
we30:segment creation
we81:message type
we82:link message with idoc type.
we02:to status of idocs.
Now you need to write code for filling those extra segments you have added to you extension type. For that you need to check where your new segment is placed in Idoc structure . There will be a exit avaliable to attach your code to fill those segments .
Please go through previous SDN links to see more info.
One the settings are done in the NACE , issue output from PO transction and once your output is processed check your Idoc in WE02 to see if the segments are coming with the desired data.
Regards
Vikas -
Sending purchase order through fax
What points to be considered in configuring the option of sending fax to supplier ?
Follow the steps below
1.Use tcode SCOT to config your SAP server for Fax
2.Use tcode NACE to config your Fax output type for PO
3. and MAintain you MN04 for your faxt putput type
MG -MM - Purchasing - Messages - Output control - Message types - Define Message Types for Purchase Order
Define new message type for Fax
4.5.10 Output type Configuration (MM)
Use
In this activity you will create the output type configuration (MM).
Procedure
1. Start the following activity:
Transaction Code SPRO
IMG Menu Materials Management  Purchasing Messages  Output Control  Message Types  Define Message Types for Purchase Order
2. On the Change View Procedures Overview screen, make the following entries, followed by Save:
Output Type Trans
mission
Medium Appln Program FORM routine Form Name
NEU 1 EV /SMB40/FM06P ENTRY_NEU /SMB11/BL_MMCON_L
3. In output table V_166U make the following entries, followed by Save:
LA Operation Cat Type Title Doc.Typ Heading No
EN 1 A AN Request for Quotation RFQ number/date
EN 2 A AN Change to Purchase RFQ RFQ number/date
EN 3 A AN Reminder relating to Purchase RFQ RFQ number/date
EN 4 A AN Rejection letter relating to Purchase RFQ RFQ number/date
4. In Output table VN_TNAPR make the following entries, followed by Save:
Out Med App Program FORM routine
NEU 8 EF ENTRY_BLANK
5. In Output table VN_T685B make the following entries, followed by Save:
Usage Ap Out AcSq P1 Prnt
Paremtr criteria Time Med Cond
Acc LA Name
B ME WA01 0003 X 7 4 1 X EN GI Note Vers.1.
0003 X 7 4 1 X
6. In Output table V_T685 make the following entries, followed by Save:
Usage App CTyp AcSq LA Name
H ME ME01 ME01 EN MovType/Plnt/MatlNo.
H ME ME02 ME02 EN Plant
7. In Output table V_159N make the following entries, followed by Save:
Program P Act Form
RM07IDRU 4 X /SMB11/BL_INVENT
8. In Output table V_TNAD7 make the following entries, followed by Save:
App CTyp Plnt SLoc ODev I
ME WA01 BP01 0002 LOCL X
ME WA01 BP01 0003 LOCL X
ME WA01 BP01 0005 LOCL X
ME WA01 BP01 0002 LOCL X
ME WA01 BP01 0003 LOCL X
ME WA01 BP01 0005 LOCL X
9. In Output table VN_TNAPN make the following entries, followed by Save:
App Out Med Function
EF NEU 5 LF
Maybe you are looking for
-
Connecting printer through wireless Print Server
Wireless Dlink DPR-1260, hooked up to network. ( using Linksys wireless router and Windows XP Home) Two usb printer ports. Loaded HP laserjet 2300 series using the print server software wizard.. works fine...prints remotely. The P.S. created the tcp/
-
How do I uninstall 6.0.2 & update and go back to version 5?
Fire 6.0.2 awful experiences and just want go back to version 5 (period)
-
Java 2 Platform Standard Edition wont install
Error number: 0x80070725 Description: Incompatible version of the RPC stub. Setup will now terminate whats a RPC stub how do i fix this problem?
-
Hi everyone, i have noticed a strange behavious of Filter Views in the Dashboard. When i click on the view link on my dashboard, the referenced filters are not visible. This happened only for a single filter, while the other filters shows fine. In th
-
Interaction ID is used in multiple projects / can´t overwrite Interaction ID
Hi folks, I have several projects in Captivate. No I tried to customize the Interaction ID in one of my newest projects. The quizes consist of 20 questions each. I have to face following issues: - When I open up quiz A and change question 16 from Int