Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

ABAP
ABAP Introduction
ABAP Transaction
ABAP Function Module
ABAP FILE PROCESS
ABAP Object
ABAP Syntax 1
ABAP Syntax 2
ABAP Syntax 3
ABAP Syntax 4
ABAP Query
Abap Mail

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


ABAP


Previoushome






SAP is a robust system, which gives many facilities in the form of Function Modules (FMs) for connecting to external systems or for use within the system. With a clever use of these FMs we can achieve a lot of things through ABAP code.

A D V E R T I S E M E N T

This article focuses on ways to send E-mails and SAP Mails using ABAP code.

First SAP Mail

A SAP mail is a mail internal to the SAP system. It is a very good forum to exchange information with other users. Using a SAP mail in ABAP code facilitates exchange of automatic messages at various stages of the business process. It is easy to use and saves many hassles involved in using workflows for exchanging messages.

The ABAP code to send a sap mail is built around the FM SO_OBJECT_SEND which has the following pattern.

call function 'SO_OBJECT_SEND'

exporting

* EXTERN_ADDRESS = ' '

* FOLDER_ID = ' '

* FORWARDER = ' '

* OBJECT_FL_CHANGE = ' '

* OBJECT_HD_CHANGE = ' '

* OBJECT_ID = ' '

* OBJECT_TYPE = ' '

* OUTBOX_FLAG = ' '

* OWNER = ' '

* STORE_FLAG = ' '

* DELETE_FLAG = ' '

* SENDER = ' '

* CHECK_ALREADY_SENT = ' '

importing

object_id_new =

sent_to_all =

tables

* OBJCONT =

* OBJHEAD =

* OBJPARA =

* OBJPARB =

receivers =

* PACKING_LIST =

* ATT_CONT =

* ATT_HEAD =

* NOTE_TEXT =

exceptions

active_user_not_exist = 1

communication_failure = 2

component_not_available = 3

folder_not_exist = 4

folder_no_authorization = 5

forwarder_not_exist = 6

note_not_exist = 7

object_not_exist = 8

object_not_sent = 9

object_no_authorization = 10

object_type_not_exist = 11

operation_no_authorization = 12

owner_not_exist = 13

parameter_error = 14

substitute_not_active = 15

substitute_not_defined = 16

system_failure = 17

too_much_receivers = 18

user_not_exist = 19

x_error = 20

others = 21.


Import Parameters Name and Description Field name Field function
Object_hd_change (structure)

Contains the process to be done when SAP mail is marked for execution.

When the Execute Icon in the SAP mail is clicked the corresponding object is executed

vmtyp ‘D’ for dialog module

‘F’ for function module

‘R’ for report

‘T’ for transaction

‘U’ for transaction with export

  Acnam Name of the object which is to be executed, like name of transaction/report
  Skips ‘X’ to execute first screen in background
  Objsns Indicates sensitivity of the object.

‘P’ for private object

‘F’ for functional object

‘O’ for confidential object

‘C’ for company confidential object

Sensitivity level is restricted to ‘O’ for documents in shared folders

  Objla Language of the document

‘E’ for English

sy-langu for system language

  Objnam Name of the document
  Objdes Short description (Title) of the document
  Objsrt Name of the sort field. This is used to group documents based on certain criteria
Object_type

Type of document to be sent with mail

  ‘RAW’ for raw text (default)

‘DOC’ for word file

‘XLS’ for excel file

All classes can be used except for folders (‘FOL’) and distribution lists (‘DLI’)

Outbox_flag   ‘X’ to indicate that mail should also be stored in outbox of the user after sending (default ‘ ‘)
Owner   Sap login of the user responsible for transmission
Table Parameters Name and Description Field Name Field function
Objcont

Table to hold the body of the mail

Line Text lines up to 255 characters
Objhead

Table to hold number of lines in the body of the mail, i.e size of the table in lines

Line Text lines up to 255 characters
Objpara

Table to hold the set/get parameters to be transferred to the processing element

Name Name of the parameter. Only first three characters are used
  Option Not used
  Low Value of the parameter in name
  High Not used
Objparb

Table to hold information for mails to which a certain processing type is assigned. For a report or transaction with transfer of values to global memory, the table has to contain the parameters with relevant values. The memory id is taken from the first row. For a FM or dialog module, data in table will be transferred as table parameter msgdial

Name For report or transaction with transfer of values to global memory, the field for first row should hold the name of the memory id used for export and the other rows should hold the parameter names. For FM or dialog module this field should hold the values as per the usage of the module
  Value For report or transaction with transfer of values to global memory, the field for first row should remain empty and the other rows should hold values of the parameters. For FM or dialog module this field should hold the values as per the usage of the module
Receivers

Table to hold recipient details

Recnam SAP login of the recipient. Append all the recipients to this table
  Sndcp X for sending mail as a copy
  Sndex X for sending as express document. This will prompt a logged on recipient saying that he or she has received an express mail
  Recesc ‘B’ for SAP user

‘E’ for external email address

‘U’ for unix address

Export Parameters Name and Description Field name Field function
Object_id_new

Contains object id of document created during send process

   
Sent_to_all

X indicates that document was sent to all recipients. Flag is not activated if sending fails in one or more cases

   
Main Exceptions Name and Description Description
Too_much_receivers Number of recipients is greater than number for which sender is authorised to send
Object_not_sent Document was not delivered to any of the recipients
Object_not_exist Document class specified does not exist or cannot be sent
Object_no_authorisation Document could not be sent as one of the required authorisations does not exist
Parameter_error Invalid combination of parameter values transferred to FM
X_error Internal error occurred


Once all the parameters and table interfaces are properly filled, call the function module to send the SAP mail to the recipient inbox.

Care should be taken to report the status of execution of the function module to the user using one of the exceptions defined (refer function module pattern above)

Though SAP mail is a very robust method of interacting with users within SAP system, it is always good to receive email in Microsoft inbox. This also works like an additional notification to users in case they do not check SAP mail regularly. The next article covers sending E-mails using ABAP.

Sending Email to a non-SAP system:

Though SAP mail is a very robust method of interacting with users within SAP system, it is always good to receive email in Microsoft inbox. This also works like an additional notification to users in case they do not check SAP mail regularly.

Sending an email to the Microsoft Inbox is a way of interacting with a non SAP system through ABAP code and hence is very interesting. A fair knowledge of UNIX shell scripting is assumed here.

The ABAP code to send an email to Microsoft inbox revolves around following UNIX script

Echo "From:" "<"$1">" >

Echo "To:" "<"$2">" >>

Echo "Subject:" "<"$3">" >>

Cat $4 >>

Uuencode $5 $6 >>

Cat | /usr/sbin/sendmail –f $fraddr $toaddr

(Note : the commands in the above script can be case sensitive. Check the actual case on the unix installation in question)

Let us understand the various parts of the above script.

$1 = Sender email address

$2 = Recipient email address

$3 = Subject of the email

$4 = Path of unix server file having email body

Form email body as an internal table in ABAP program, download it to a unix server file

$5 = Path of unix server file to be sent as email attachment

$6 = Name to be given to the attachment (like test1.doc, test1.xls). The corresponding Microsoft icon

will be shown in the email for the type of file attached ( Word document, excel document etc)

The script builds a temporary file and pipes the file to the sendmail command to achieve the mission.

This script can be invoked from SAP to send the mail to the intended recipient. Store this small script on the unix server. (Assume script name is sndmail )

To do this we should define a link in the SAP system between a customized command and this unix script.

The FM to define a customized command in SAP system has the following pattern.

call function 'SXPG_CALL_SYSTEM'

exporting

commandname =

PARAMETERS = ' '

importing

status =

tables

exec_protocol =

exceptions

no_permission = 1

command_not_found = 2

parameters_too_long = 3

security_risk = 4

wrong_check_call_interface = 5

program_start_error = 6

program_termination_error = 7

x_error = 8

parameter_expected = 9

too_many_parameters = 10

illegal_command = 11

others = 12.
 
Import Parameters Name and Description Field name Field function
Commandname

Name of unix shell script or command to be executed by SAP

  Name of unix shell script to be invoked
Parameters   The parameters to be sent to unix shell script ($1, $2 etc). Send parameters as a concatenated string separated by space and length not exceeding 128 characters

For eg in UNIX environment the above shell script would be executed as

Sndmail sender@a.com receiver@b.com Trial /home/test.doc testmail.

We will be simulating this command using the FM from SAP system

Table Parameters Name and Description Field Name Field function
Exec_protocol (structure)

Table to get messages from unix server after shell script is executed

Length Length of the message from external program i.e unix
  Message Log message from external program i.e unix
Export Parameters Name and Description Field name Field function
Status

Contains the status of execution of external program

  Scheduling status of external program i.e unix


Once the above FM is invoked with the necessary parameters the unix program sendmail will send a mail to the inbox of the recipient in Microsoft.

The restriction on the parameter string length of 128 characters can be removed to make way for very long email addresses and subjects. Build the parameters into an internal table and download it as a file on the unix server. Instead of passing each parameter individually, pass the unix server path of this file as the parameter to the unix shell script (sndmail mentioned above). Modify the shell script to read every line of this parameter file as variables to be used in the shell script.

REPORT ZTSAPMAIL.

DATA: X_OBJECT_TYPE LIKE SOOD-OBJTP.

DATA: BEGIN OF X_OBJECT_HD_CHANGE.

INCLUDE STRUCTURE SOOD1.

DATA: END OF X_OBJECT_HD_CHANGE.

DATA: BEGIN OF X_OBJCONT OCCURS 10.

INCLUDE STRUCTURE SOLI.

DATA: END OF X_OBJCONT.

DATA: BEGIN OF X_OBJHEAD OCCURS 0.

INCLUDE STRUCTURE SOLI.

DATA: END OF X_OBJHEAD.

DATA: BEGIN OF RAW_HEAD.

INCLUDE STRUCTURE SORH.

DATA: END OF RAW_HEAD.

DATA: BEGIN OF X_RECEIVERS OCCURS 0.

INCLUDE STRUCTURE SOOS1.

DATA: END OF X_RECEIVERS.

PARAMETERS: RECEIVER LIKE X_RECEIVERS-RECNAM. " Name

*BUILD MESSAGE HEADER

MOVE 'Sort field goes here' TO X_OBJECT_HD_CHANGE-OBJSRT. " Sort field

MOVE 'Name of the object goes here' TO X_OBJECT_HD_CHANGE-OBJNAM. " Name

MOVE 'Document title goes here' TO X_OBJECT_HD_CHANGE-OBJDES. " Title

MOVE 'F' TO X_OBJECT_HD_CHANGE-OBJSNS. " Functional OBJECT

MOVE 'E' TO X_OBJECT_HD_CHANGE-OBJLA. " Language

* Object type of the new document

MOVE 'RAW' TO X_OBJECT_TYPE.

CLEAR X_OBJCONT.

MOVE 'Contents of mail' TO X_OBJCONT-LINE.

APPEND X_OBJCONT.

CLEAR X_OBJCONT-LINE. APPEND X_OBJCONT.

MOVE 'More contents' TO X_OBJCONT-LINE.

APPEND X_OBJCONT.

MOVE 'Still more contents'

to x_objcont-line.

APPEND X_OBJCONT.

MOVE ' ' TO X_OBJCONT-LINE.

APPEND X_OBJCONT.

* Specific header (Dependent on the object type, here RAW)

REFRESH X_OBJHEAD.

DESCRIBE TABLE X_OBJCONT LINES RAW_HEAD-RAWSIZ.

MOVE RAW_HEAD TO X_OBJHEAD.

APPEND X_OBJHEAD.

*RECEIVERS table

CLEAR X_RECEIVERS.

REFRESH X_RECEIVERS.

MOVE RECEIVER TO X_RECEIVERS-RECNAM. " Name

MOVE 'B' TO X_RECEIVERS-RECESC. " Receiver type

MOVE 'X' TO X_RECEIVERS-SNDCP. " Send as a copy

MOVE 'X' TO X_RECEIVERS-SNDEX. " EXPRESS DOCUMENT

APPEND X_RECEIVERS.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

* folder_id = 'OUTBOX'

* forwarder = x_forwarder

* object_fl_change = x_object_fl_change

OBJECT_HD_CHANGE = X_OBJECT_HD_CHANGE

* object_id = x_object_id

OBJECT_TYPE = X_OBJECT_TYPE

OUTBOX_FLAG = 'X'

OWNER = SY-UNAME

* store_flag = x_store_flag

* importing

* object_id_new = x_object_id_new

* sent_to_all = x_sent_to_all "May need to use

TABLES

OBJCONT = X_OBJCONT

OBJHEAD = X_OBJHEAD

* objpara = x_objpara

* objparb = x_objparb

RECEIVERS = X_RECEIVERS.
 



Be the first one to comment on this page.




  ABAP eBooks
More Links » »
 
 ABAP FAQs
More Links » »
 
 ABAP Interview Questions
More Links » »
 
 ABAP Articles
More Links » »
 
 ABAP News
More Links » »
 
 ABAP Jobs
More Links » »

Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome

Keywords:SAP ABAP, SAP-BUSINESS-WAREHOUSE, SAP ABAP Tutorial, SAP ABAP tutorial, SAP ABAP tutorial pdf, history of SAP Basis, learn SAP ABAP

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright ? 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World | Important Websites
Copyright ? 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.