Quantcast
Channel: SCN : Document List - ABAP Connectivity
Viewing all 63 articles
Browse latest View live

ABAP Connectivity: Methods and Services

$
0
0

ABAP as a foundation for many applications offers a broad range of integration and connectivity technologies for remote SAP- and non-SAP systems. Universal internet protocols like HTTP(s) and data formats like XML and SOAP can be used as well as SAP-proprietary protocols and formats like RFC/BAPI, IDoc and ALE/EDI.
Developers can expose ABAP-based functionality as a Web or enterprise service by publishing the service definition in the Enterprise Service Repository, creating a server-side proxy, and implementing the service using the ABAP programming language. To consume existing Web Services, the creation of Consumer Services (Proxy), based on the WSDL document, is supported by a wizard.
For regularly updated information, see the wiki on ABAP connectivity.

 

ABAP Service Provisioning and Consumption

SAP NetWeaver Application Server ABAP provides business logic for many applications, such as SAP Business Suite and SAP Business ByDesign, and therefore must necessarily be able to communicate with other ABAP and non-ABAP application servers. In the course of time, the format for exchanged data has altered from ABAP-only to universal. Nowadays, data will mostly be exchanged between servers using universal Internet protocols like HTTP, HTTPS, XML or SOAP. Due to their historical roots and their wide spreading, SAP- proprietary formats like RFC, IDoc, ALE/EDI or BAPI still continue to have a right to exist.

Web Services for ABAP

Web services represent the strategy for communication within SAP NetWeaver and between other systems. They are a uniform technology that allows you provide and consume services independently of implementation and the underlying protocol. Furthermore, you can do so both within SAP NetWeaver and in the communication with other systems.
The ABAP Workbench offers an environment where you can publish, search for, and call Web services. It enables the SAP NetWeaver Application Server to act both as a server and as a client for Web services.
Web Service Framework

To get started, see the following link:

Enterprise Services

Enterprise services are basically highly integrated Web services combined with business logic and semantics that can be accessed and used repeatedly to support a particular business process. Enterprise services provide business processes or business process steps that can be used to compose business scenarios while ensuring business integrity and ease of reuse. For storage the Enterprise Service Repository and Registry are provided by SAP NetWeaver.To get started, see the following links:

 

Other Methods of Connectivity

Remote-Function-Call (RFC) is known as a reliable and very fast protocol to communicate between SAP systems/SAP Connectors (available for various computer languages) for tightly coupled applications:
  • Connections can be kept open easily
  • Connection loss is easily recognizable
  • ABAP transaction/locking concept can be leveraged
  • Different connection models available (synchronous, asynchronous, queued)
  • Flexible (low-very high data amount possible, fast and slow connections supported, compatible and incompatible changes of interfaces possible)
  • High-Performance due to lack of need for data transformation
RFC is the foundation for BAPI technique as well as for typical ALE scenarios.

RFC (Remote Function Call)

Communication between applications of different systems in the SAP environment includes connections between SAP systems as well as between SAP systems and non-SAP systems.ABAP function modules with attributes "remote enabled" can be called from other systems using the SAP-proprietary RFC-protocol. Different patterns like synchronous or transactional calls are possible. Non-ABAP systems can use the RFC library to implement RFC server or RFC client programs.To get started, see the following links:

BAPI (Business Application Programming Interface)

BAPIs are still available, but will be replaced by Enterprise Services technology (ESR), in future. The most important BAPIs are already available as Enterprise Services.To get started, see the following links:
  • BAPIs (in SAP Help Portal)
  • BAPI User Guide (in SAP Help Portal)
    Get an impression on what BAPIs are and how to program with them from this library chapter.

 

Taken from the chapter introduction: "BAPIs (Business Application Programming Interface) are specific methods for SAP business objects, which are stored in the Business Object Repository (BOR) of the SAP system and are used for carrying out particular business tasks.In the SAP system, BAPIs are stored as RFC-capable function modules in the ABAP Workbench Function Builder. BAPIs have standard business interfaces that enable external applications (with the help of SAP business objects) to access SAP processes, functions and data."

ALE (Application Link Enabling) / IDOCS (Intermediate Documents)

ALE is the overall term for exchanging data packages (called IDocs) between systems, be it SAP or non-SAP. The data exchange is always asynchronous, and different ways can be used to transfer the IDocs, e.g. transactional RFC (tRFC) or file transfer, depending on the capabilities of the systems involved. EDI (Electronic Data Interchanged) is another scenario where IDocs are used to run distributed applications.To get started, see the following links:

How to Create Endpoints for Multiple ABAP Webservices using Soamanger

$
0
0

Using this document you can create multiple services definition endpoints via single button press in soamanager transaction.

View Document

Connecting to External Database from SAP

$
0
0

Scenario

 

In today's business scenario, at the time of SAP implementation, it is required that we need to fetch data from the customer's existing third party application.  For example the customer is having some websites where the enquiries are being stored. Or The company employees who are on tour log their requests for leave in the portal.  In such case we may have to provide an interface between their existing application to the upcoming SAP system.  It is possible that the system is using a differetn database altogather.  So in that situation how a connectivity is established between the SAP database and External Application database.

  1. First step is to provide the network / firewall / security related settings between these two servers. That is from the SAP ystem the designated database servers are accessible.
  2. In SAP system - configure the connection detail. Execute T-Code  DBCO
  3. Enter appropriate details as follows:
    • In the box, DB Connection, give any name of the connection. - the name in our SAP programs to connect to the oracle system.
    • In DBMS, choose the option ORA for oracle system.
    • In the user name box, give the name of the oracle system user. You will notice two boxes for DB password – one is the password box and the other one is the confirm password box. Give the password in both the boxes.
    • In Conn. Info box, give the name of the Oracle server – you may ask your database Administrator to get the name of the server
    • Check the check box Permanent to make the connection permanent and
    • Finally the connection limit as 5.
  4. Go to SE38 - to write a test program

   REPORT  ZSAP2ORACLE.
  data: l_record(20).

          * opening the connection to database
  EXEC SQL.
     CONNECT TO 'MYCONNECTION'
  ENDEXEC.*executing the select command
  EXEC SQL.
     SELECT ars_no into :l_record FROM arsdata
  ENDEXEC.*closing the connection
  EXEC SQL.
     DISCONNECT :'MYCONNECTION'
  ENDEXEC.
  WRITE: / l_record.

This should work and you should be able to fetch data from the external database.

SAP Connectivity with MS Excel

$
0
0

Data from SAP to MS Office Applications

1.jpg

         

Using the connection SAP with MS Office, users spreads data from SAP application to right within Microsoft Office desktop applications, including Excel, Outlook, Word and Power point.

With the SAP-MS Office connectivity, end-users can interact with SAP transactions directly within their Excel spreadsheet, their Outlook e-mail screen, and their Word documents and on their Power point presentations.

Here we have a simple application to connect SAP with MS-office tool’s Excel.
But before that……Why? How? And Use!

 

Why Data from SAP to MS Office Applications

2.jpg

In spite of large moneys in SAP, most business users continue to be unsatisfied with it because data from SAP is not easily accessible in their favorite desktop productivity tools -- Microsoft Excel, Microsoft Outlook and Microsoft Word. Since Microsoft Office Applications are not connected to SAP, users are forced to

  • Use error-prone cut-copy-paste to populate their Excel spreadsheets.
  • Switch screens from Outlook to gather data and take decisions as they respond to e-mails.
  • Manually update data from Excel Spreadsheets to enterprise applications.


  Benefits of Data from SAP to Microsoft Office Applications
SAP-MS Office Connectivity extends data from SAP to Microsoft Excel, Microsoft Outlook and Microsoft Word using a SOA based    Information Delivery Server and Microsoft Office Add-ins, and provides the following benefits
 

  • Eliminates cut-and-paste based data collecting mechanism from SAP to Microsoft Excel.
  • Enables users to get real-time data from SAP within Excel with a single-click Refresh.
  • Enables users to query and update SAP transactions from within Outlook screens.
  • Allows the users to update SAP from within Excel, Outlook and Word.
  • Avoids any data-integrity issues with copying and reduces compliance issues.


  Who Benefits  

  • Production and Logistics Managers who want to create Excel reports from latest SAP data.
  • Managers who want to track projects and status automatically as they receive status e-mails.
  • Analysts who want to combine data from SAP and other enterprise data stores for budgeting purposes.

 

Example:

3.jpg

Here is the main part comes up. We shall take simple scenario for SAP with MS Excel connectivity.  So let’s begin!!

Just before start, I would like to give little overview on what we are actually going to do. So, here are the scenarios!!

Excel File Scenarios

  • Create a MS excel file for user input.
  • Create user interface in excel sheet to input data for the customer master and output cells.
  • Apply VB code to make connection with SAP.
  • Read the input data for customer master from the excel file sheet.
  • Fetch data from SAP using connection code from SAP.
  • Display output within excel sheet itself.

SAP Scenarios

  • Create a function module in ABAP that is “Remote Enabled”.
  • Create IMPORT, EXPORT and TABLES parameters as per requirement from MS excel.
  • Write logic to display customer master details based on input from Excel file.
  • Activate the function module.

Well……………“A picture says thousand words”. So, let’s begin!

 
 

MS Excel – User Interface

  First of all, lets create MS excel file with customer master input. We shall create simple selection screen for user input.

4.jpg

Well……filling cell values are simple here but how to add buttons (Get Address and Reset Output) here? This was also new in my case since new version of MS office.


Just follow following steps for this:


Click MS office button and select “Excel Options” button from the menu.

 

5.jpg

You will see here a new tab named “Developer”

 

6.jpg

 

Click on “Insert” and then select “Button” from the form control. Later on you can double click on the button and set its properties (Caption, Color, etc.)

Congratulations! Our input screen is finished here. Let’s design our output screen now.

 

7.jpg

I have created my output screen just after the input screen. You can create anywhere in the excel file. Here terms ‘anywhere’ descries to other worksheet also.

The output screen is simple as you see. Nothing much to do here. I just simple colored the cells for better look.

Great! Looks like we finished user interface here. (Did we miss something...’Naah’ for now!)

 

 

SAP – Select Data

Since we are taking simple example to fetch detail from customer master, let’s create a function module for it.

 

 

Create a function module.

8.jpg

Enter function group and Short text.

 

9.jpg

Make sure your function module is “Remote Enabled”.

 

10.jpg


Now let’s create “Tables” parameters:

 

11.jpg



Here we have two “Tables” parameters

  • ET_KUNNR (Input) : Customer numbers pass in to the function module
  • ET_CUST_LIST (Output): Data will be fetched in function module and display on the excel sheet.
    • Note: We have created a Z structure (ZNM_CUST_LIST) for the output list. Here are the fields for the structure:

12.jpg


We are all set with input and output structures.

Now, let’s fetch the data. Here is the only coding part came up in SAP. Look at below screen.

 

13.jpg


Here, we are selecting all the customer details from the KNA1 (customer master) table from the input table (ET_KUNNR) from excel file and return to the table (ET_CUST_LIST).

Now we have all the records in the table ET_CUST_LIST.

So, again congratulation friends! You have completed most of the things. The remaining step now is to display the list in the excel file.

 

 

Let’s now connect the SAP and MS Excel.

Go to the ‘Developer’ tab and click on “Visual Basic” icon.

 

14.jpg


The VB editor will be opened and we are going to write the code for connection of excel and SAP with sending and receiving data.

Here is the variable declaration list.  These are the global variables. Let’s understand each of them.

 

15.jpg

 

 

 

Variable

Description

objBAPIControl

For creating object to access SAP functions.

objgetaddress

To make BAPI function call via objBAPIControl.

 

vLastRow

Last row of output list

vRows

Total number of records returned from the SAP

 

vcount_add

Variable for increment records

Index_add

Variable for next record (Index)

 

objaddress

Object for SAP table (for customer master output)

objkunnr

Object for SAP table (for customer master input)

Here are the properties for the “Get Address” button.

 

16.jpg

 

Let’s code when “Get Address” button is clicked.

Setup the local variables

 

17.jpg

 


Variable

Description

LogonControl

Logon control is to make login in SAP.

R3Connection

Ro make connection to SAP R/3 using logon control.

retcd

Return Code

SilentLogon

If ‘True’ no popup will ask to enter SAP login details

 

Now let’s setup the connection with SAP R/3 using following code.

18.jpg

 

 

Let’s do SAP Login here.

 

19.jpg

 

Perfect!! We have made the connection with SAP R/3. Now we are able to send and receive the data from MS Excel to SAP R/3 and vice versa.

But how to send my customer details and receive? Hmmm…..we need to use internal tables those are created in SAP function module. (Do you remember?....NO?... checkout Tables parameters in  function ZNM_GET_CUSTOMER_DETAILS). So, let’s do this.

20.jpg

 

Here, ZNM_GET_CUSTOMER_DETAILS is our function module created in SAP.

ET_KUNNR: Customer details input details

ET_CUST_LIST: Customer output details.

21.jpg

We are reading here each cell from excel worksheet for input.

22.jpg

 

Here we have called the FM and passed the input details to process.

Result:

23.jpg

 

vcount_add returns total number of records from the SAP. And we have already set the loop to display records in the cells.

Here, R3Connection.Logoff is to sign off from your SAP account.

Here is the output screen:

 

24.jpg

 

 

Wow!! We have output result. Good job!! But what is the use of another button “Reset Output” here? Yes…good question.

The “Reset Output” button will clear all the data and messages from the screen. Look at below code:

 

25.jpg

 

 

-----------------------------------------------------------------------------------------------------------------------

Now we have completed the entire example here. N’ joy.

 

Here is the entire code:

Option Explicit

Dim objBAPIControl, objgetaddress As Object

Dim vLastRow, vRows As Integer

Dim vcount_add, index_add As Integer

Public objaddress, objkunnr As SAPTableFactoryCtrl.Table

 

Private Sub GetAddress_Click()

'Local variables

  Dim LogonControl As SAPLogonCtrl.SAPLogonControl

  Dim R3Connection As SAPLogonCtrl.Connection

  Dim retcd        As Boolean

  Dim SilentLogon  As Boolean

 

'Set Connection

  Set LogonControl = CreateObject("SAP.LogonControl.1")

  Set objBAPIControl = CreateObject("SAP.Functions")

  Set R3Connection = LogonControl.NewConnection

 

'SAP connection

  R3Connection.Client = "810"

  R3Connection.ApplicationServer = "10.226.33.14"

  R3Connection.Language = "EN"

  R3Connection.User = "238499"

  R3Connection.Password = "xxx"

  R3Connection.System = "EC6"

  R3Connection.SystemNumber = "00"

  R3Connection.UseSAPLogonIni = False

  SilentLogon = False

 

  retcd = R3Connection.Logon(0, SilentLogon)

  If retcd <> True Then MsgBox "Logon failed": Exit Sub

  objBAPIControl.Connection = R3Connection

 

'Assign the Parameters

  Set objgetaddress = objBAPIControl.Add("ZNM_GET_CUSTOMER_DETAILS")

  Set objkunnr = objgetaddress.Tables("ET_KUNNR")

  Set objaddress = objgetaddress.Tables("ET_CUST_LIST")

 

'Assign customer

  If ThisWorkbook.ActiveSheet.Cells(6, "B").Value <> "" Then

    objkunnr.Rows.Add

    objkunnr.Value(1, "SIGN") = ThisWorkbook.ActiveSheet.Cells(6, 2).Value

    objkunnr.Value(1, "OPTION") = ThisWorkbook.ActiveSheet.Cells(6, 3).Value

    objkunnr.Value(1, "LOW") = ThisWorkbook.ActiveSheet.Cells(6, 4).Value

    objkunnr.Value(1, "HIGH") = ThisWorkbook.ActiveSheet.Cells(6, 5).Value

  End If

 

  objgetaddress.call

 

  vcount_add = objaddress.Rows.Count

    For index_add = 1 To vcount_add

      vRows = 11 + index_add

      ActiveSheet.Cells(vRows, 2) = objaddress.Value(index_add, "KUNNR")

      ActiveSheet.Cells(vRows, 3) = objaddress.Value(index_add, "LAND1")

      ActiveSheet.Cells(vRows, 4) = objaddress.Value(index_add, "NAME1")

      ActiveSheet.Cells(vRows, 5) = objaddress.Value(index_add, "ORT01")

      ActiveSheet.Cells(vRows, 6) = objaddress.Value(index_add, "PSTLZ")

      ActiveSheet.Cells(vRows, 7) = objaddress.Value(index_add, "REGIO")

      ActiveSheet.Cells(vRows, 8) = objaddress.Value(index_add, "KTOKD")

      ActiveSheet.Cells(vRows, 9) = objaddress.Value(index_add, "TELF1")

      ActiveSheet.Cells(vRows, 10) = objaddress.Value(index_add, "TELFX")

    Next index_add

  'If address not exist then show error

  If vcount_add = "" Then

    ActiveSheet.Cells(10, 11) = "Invalid Input"

  Else

    ActiveSheet.Cells(10, 12) = "BAPI Call is successfull"

    ActiveSheet.Cells(11, 12) = vcount_add & " rows are returned"

  End If

 

  R3Connection.Logoff

End Sub

 

Private Sub ResetOutput_Click()

vLastRow = Cells(Rows.Count, "B").End(xlUp).Row

For vRows = 12 To vLastRow

 

ThisWorkbook.ActiveSheet.Cells(vRows, 2).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 3).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 4).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 5).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 6).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 7).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 8).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 9).Value = ""

ThisWorkbook.ActiveSheet.Cells(vRows, 10).Value = ""

Next vRows

ThisWorkbook.ActiveSheet.Cells(10, 12).Value = ""

ThisWorkbook.ActiveSheet.Cells(11, 12).Value = ""

End Sub

 

(Note: Button properties need to be set)

Using SAP .Net Connector to Call RFC

$
0
0

I have used the SAP .Net Connector on multiple projects in the past.  I will say that I am very impressed with it's robust ability to handle large volumes of data.  I will insert a small video demo of how to create a very simple RFC call to an RFC function module.  The function I will call is in all SAP implementations and is already configured as an RFC.  The function module is called: FLIGHT_LIST.  The full source code for the web page is also included here. 

 

 

Output of running this example:

sdn1.jpg

 

Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO

 

Public Class FLIGHT_LIST1
    Inherits System.Web.UI.Page

 

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conStr As String = "ASHOST=<your server> SYSNR=?? CLIENT=?? USER=???????? PASSWD=????????"

        Dim ERR_MSG As String
        Dim O_MSG As String
        Dim O_WDR_FLIGHTSTable As New WDR_FLIGHTSTable
        Dim RFC_FLIGHT_LIST As New FLIGHT_LIST(conStr)

        Try
            RFC_FLIGHT_LIST.Flight_List1("FRANKFURT", "NEW YORK", "18000101", "20120101", O_MSG, O_WDR_FLIGHTSTable)
            If Not O_WDR_FLIGHTSTable Is Nothing And O_WDR_FLIGHTSTable.Count > 0 Then
                DataGrid1.DataSource = array_to_ds(O_WDR_FLIGHTSTable)
                DataGrid1.DataBind()
            End If
        Catch ex As Exception
            ERR_MSG = ex.Message
        End Try
    End Sub

 

    Public Function array_to_ds(ByVal array_in As Object) As DataSet
        Dim ds As New DataSet
        Dim xmlSerializer As XmlSerializer = New XmlSerializer(array_in.GetType)
        Dim writer As StringWriter = New StringWriter
        xmlSerializer.Serialize(writer, array_in)
        Dim reader As StringReader = New StringReader(writer.ToString)

        ds.ReadXml(reader)
        Return ds
    End Function

 

End Class

Automatic Master Data distribution using Change Pointers and IDOC

$
0
0

Introduction:

This article will describe in detail how to distribute the master data automatically and how to create and active the change pointers using IDOC.

In this article, we will take the example of material master data with the message type as “MATMAS”.


Steps to be followed:

 

Step 1: Activate the Change Pointers

Before we actually active the change pointers for the message type through which we will be distributing the master data. To do this, go to the transaction BD50 and search for the Message type.

  Since in this example we are considering the Material Master data distribution, we will consider the message type “MATMAS”. Please refer below screenshot.

 

1.JPG

Step 2: Adding the Segment name and the fields which we want to be distributed.  

In order to add the segment name and fields, we have the transaction code BD66.

 

2.JPG


Click Ok. After that add the respective entry and save.

 

3.JPG

Step 3: Create a BATCH JOB which will trigger after every 15 minutes and distribute data via IDOC.  

In order to create batch job, go to transaction SM36 and fill the required fields as shown below.

 

4.JPG

After that set the “Start Condition” and the follow the instruction. Please refer below screenshot for reference.

 

5.JPG


It will execute after every 15 mins and check if there are any changes to the material master data using standard program RBDMIDOC.


In case you want to test your development changes without using the batch job; please follow below steps. Once everything is working as expected; activate the batch job and it will distribute the data.


Batch job will execute the REPORT RBDMIDOC (tcode BD21) for your MESSAGE TYPE to create IDOC. 

 

6.JPG


Beginners guide to IDoc development in SD Module

$
0
0
SD Flow
Activity

Message Type

InboundOutbound

Process codeFM triggered
Enhancement
Process code
FM triggered
Enhancement

InquiryCreateREQOTEREQOIDOC_INPUT_REQOTEVEDQ0001Not applicable
INQUIRY_CREATEFROMDATA2BAPIBAPI_INQUIRY_CREATEFROMDATA2

Quotation
QUOTESNot ApplicableSD12IDOC_OUTPUT_QUOTESVEDE0001
CreateQUOTATION_CREATEFROMDATA2BAPIBAPI_QUOTATION_CREATEFROMDATA2
Not applicable
Sales OrderCreateORDERSORDEIDOC_INPUT_ORDERSVEDA0001Not applicable
SALESORDER_CREATEFROMDAT2BAPIBAPI_SALESORDER_CREATEFROMDAT2
ChangeORDCHGORDCIDOC_INPUT_ORDCHGVEDB0001Order response message type is reused

Acknow

ledgement

ORDRSPNot ApplicableSD10IDOC_OUTPUT_ORDRSPSDEDI001
Outbound DeliveryCreateSHP_OBDLV_SAVE_REPLICABAPIBAPI_OUTB_DELIVERY_SAVEREPLICAV50B0001Not applicable
ASNDESADVNot applicableDELVIDOC_OUTPUT_DELVRYV56K0001
Billing/Invoice
INVOICNot applicableSD09IDOC_OUTPUT_INVOICLVEDF001

 

 

Implemented Successfully
Tested Successfully

Calling RFC in another R/3 client

$
0
0

Introduction


The objective of this simple document is to show how to make an RFC call in another client of the R/3 system. Let´s start with a quick review of some concepts by taking a look at the classic figure below. Since the repository is client independent and most part of the tables are client dependent, we´ll be calling an RFC in another client to get data from its database.

 

 

 

Client Creation and Copy


The first step is to create another client. If you do not already have one, start a creation of it through transaction SCC4 according to the print below:

 

 

Fulfill the data below. You´ll need to create a logical system in using the customizing or transaction SALE.

After that, make a copy of your main client to your client target through transaction SCCL. You will need to change system default parameter login/no_automatic_user_sapstar to 0 in order to logon with SAP* in your new client.


 

 

Tables


We could use any table for this turorial. We´ll be using the table below. If it is a table in customer namespace remember to create it before making the copy of the client, so that you´ll have it in both clients. The main client in this tutorial will be 001 and the target client will be 100.


 

The print below show that in client 001 we do not have any records for table ZJTM001:


 

But in client 100 which is the RFC target system we have data fulfilled:



RFC destination


Before creating the FM let´s create the RFC destination in client 001 in transaction SM59. I am using Netweaver trial so I just addressed my localhost and checked the remote connection for client 100.

 

Remember to address the user in the target:

 

 

Checking the connection:

 

 

 

Function Module


Create in your package in client 001 a function group and a FM as remote:

 

 

Create the import and export parameters with the “pass by value” since all parameters are passed by reference:

 

 

In this tutorial we have the following code to retrieve the data:

 

 

 

 

Report


Create the following report in client 001 and activate it:

 

REPORT  Z_RFC_CLIENT_100.

parameters: matric TYPE zjmt001-matricula,
func
TYPE zjmt001-funcionario,
dest
TYPE rfcdes-rfcdest DEFAULT 'logsys100'.

DATA: zjmt001t TYPE zjmt001_t,
wa
type zjmt001,
"sysid LIKE sy-sysid,
mess
(80).

START
-OF-SELECTION.

CALL FUNCTION 'Z_RFC_CLIENT_ZJMT001'
DESTINATION dest
EXPORTING
matricula
= matric
funcionario
= func
IMPORTING
zjmt001t
= zjmt001t
" sys      = sysid
EXCEPTIONS
invalid_data
= 1
communication_failure
= 2 message mess
SYSTEM_FAILURE
= 3 MESSAGE mess.

CASE sy-subrc.

WHEN 0.
"  WRITE: / text-004, "sys-id COLOR 5.
SKIP.

loop at zjmt001t into wa.
WRITE: wa-matricula, wa-funcionario,
wa
-cargo, wa-hierarquia.
ENDLOOP.

WHEN 1.
WRITE: 'COM FAILURE'.

WHEN 2.
WRITE: / mess.

WHEN 3.
WRITE: / mess.

ENDCASE.

 

 

DEMO


Run the report and fill the requested data:

 

 

There you go!

 


PHP SAP communication

$
0
0

Introduction

 

This document refers the Moodle installation in windows system and enabling the SOAP web service for PHP and communicating with SAP. In this document we are going to communicate with SAP from PHP program using Moodle database. We are not using Moodle web services here for sap communication. This document contains process of fetching student details from sap system to Moodle database using background job. This background job will execute recurrently depend on our requirement.

This document also contains additional program steps used in php to get data from SAP. Back ground job will run using software moodle_cron. Moodle_cron is a small software which will do background jobs based on time interval what we mention. You can download moodle_cron.exe form the site.

Requirements

 

To install Moodle in windows system below are the prerequisites.

  1. Xampp latest version setup files(xampp is bundle of Apache server and MySQL database you can download from Here)

Enabling web services in xampp server

To Communicate with SAP we use SOAP web service. Below is the process to enable SOAP web service in PHP.

  1. To enable SOAP module open php.ini file form the path C:\xampp\php

phpini.jpg

  1. Search for the line “extension=php_soap.dll” in php.ini if not exists add it under Dynamic Extension. If already present uncomment it by removing  ; symbol in front of the line.

 

  1. Restart the Apache server.

 
  

  1. After restarting the server open phpinfo () page from local host link looks like: http://localhost/xampp/   left side in the menu select the phpinfo ().

soap.png

  1. Check in the page soap module enables or not as shown in the below figure.

 

Setting up SOAP in SAP and Connecting with PHP

For more information see the YouTube video: http://www.youtube.com/watch?v=GG85rUbhXMg&feature=player_embeddedSAP Setup
In transaction
SICFactive the following services
  sicf.jpg

  1. Create your function modules in SE80/ SE37don’t forget these must be remote-enabled
      RFC.jpg
  2. Optionally Create Service User.
  3. From within the transactionsoamanager:
    Business administration – Web Service Administration.
      soamanger.jpg
  4. Find your web service and choose the Overview Tab. Get the WSDL URL from the link “Open WSDL document for selected binding” http://www.mattbartlett.co.uk/wp-content/uploads/2011/12/overview-wsdl-url.png

webservice.jpg

 

Optionally you can also setup authentication here.

 


Run PHP code by calling WSDL link

  php code.jpg

             

Single Euro Payments Area (SEPA) Implementation of Direct Debit-Technical Design

$
0
0

Single Euro Payments Area (SEPA) Implementation of DD(Direct Debit)(Technical)

Sep, 2013

Introduction

SEPA stands for ‘Single Euro Payment Area’. It’s a system that is designed to create financial efficiency for countries using the currency Euro by providing a unified system in which to perform financial transactions. The SEPA seeks to create a better system for credit transfers, an improved debit system and a cheaper way for individuals and firms to make transactions within member countries or regions. Implementation of SEPA makes the customers life easier. Irrespective of the national area customers will be able to use the same card for all euro payments and also they need only one bank account in euro area.

Introduction to SEPA process:

The below mentioned should be done for Implementation of SEPA business in any SAP system:

1.    SEPA_Activation_Mandate_Management

Following are the activities which are to be done as part of this:

i.        SEPA mandate management has to be activated for the usage with SDD CORE and SDD B2B from FI-AR payment processing.  Apart from activating the SEPA Mandate management we need to maintain the SEPA Mandate management modifiable fields.

 

Below is the path for activating the SEPA Mandate Management and maintain the modifiable fields.

IMG -> Financial Accounting -> Accounts Receivable and Account Payable -> Business Transactions -> Incoming Payments -> Management of SEPA Mandates -> General Settings.

screen1.png

IMG -> Financial Accounting -> Accounts Receivable and Account Payable -> Business Transactions -> Incoming Payments -> Management of SEPA Mandates -> Define Modifiable Fields

screen2.png                                                                                                                                                                  

ii.        Creation of new DMEE Payment Format tree for SEPA credit transfer and SEPA direct debit.

·         SEPA_CT and SEPA_DD are the DMEE formats provided by SAP.

·         As we will be dealing with multiple countries it is always better to copy the DMEE formats and create new ones. If there is any custom requirement for any country create a user exit and assign to the field that needs to be changed dynamically.

2.  Pre Notification with payment run  :

With a direct debit pre-notification, Markets can inform a payer in writing in advance of the debiting of his account. To do this, one has to schedule a run for the creation of direct debit pre-notifications before the payment run, meaning before clearing the open items and creation of payment media. These correspond in structure to the payment advice notes, and therefore contain details of the run date, the amount to be collected, mandate ID, Unified Creditor Identifier etc.

Following are the SAP notes to be implemented for SEPA Pre-notification.

SAP Note

Description

1679118

F110:  Custom Selection for Batch Input

1760564

F110S:  Selection Check for Customers and Vendors

1770425

F111/SEPA: Mandate rejected as invalid after change

1771071

FBCJ : Reversal possible despite cleared item

1776076

F110/F111 : BADI for SEPA Mandate usage

1780941

SEPA: Direct debit Pre-Notification

1792691

Valid SEPA mandate is not found in the system during payment proposal processing

 

As part of the Note implementation 1780941, we need to implement manual steps given below for importing the Standard SAP Form.

·    SAP has provided text file by using this file we need to import the object F110_DD_PRENOTIF into SAP by executing program RSTXCRP.  This is standard SAP form which will be used for sending PreNotifications.

·    SAP has provided XML file by using this file we need to import the object F110_DD_PRENOTIF into SAP using SFP transaction code. Once it is uploaded, activate the form.

Once all the relevant OSS Notes are implemented for SEPA Direct debit pre-notification, we will get option of checkbox for Pre-notification in F110 transaction and also pre-notification relevant standard program RFFOAVIS_DD_PRENOTIF and script form (F110_DD_PRENOTIF) available in the system.

screen3.png

The above check box is checked if we need to do SEPA prenotification.

screen4.png

 

RFFOAVIS_DD_PRENOTIF: This is the payment advice print program that is used to print the pre-notifications the pre-notification

F110_DD_PRENOTIF: This is the standard SAP script which is used to send the pre-notifications.

scrren61.png

          Based on the user requirement, the form name can be changed

·      The new "direct debit pre-notification" object is visible in the payment run (F110), in the document display (FB03), in the line item display (FBL5N) and in mandate display (FSEPA_M4). It can be deleted again if the direct debit pre-notification customer objects to it (for example, because the customer pays the bill himself). Otherwise, the posting run and the payment medium creation are performed after the end of the specified wait time based on the direct debit pre-notifications.

3.  Creation of SEPA Mandates for payment transactions :

·       Before doing any transaction for any SEPA customer we need to have a mandate create for the Customer.

·       Before creating a mandate the Customer Should have IBAN number.

·       Transactions used :

Creation

FSEPA_M1

Change

FSEPA_M2

Display

FSEPA_M3,FSEPA_M4

NOTE: Mandates can also be created from the payment tab of the Customer Master XD01, FD01, XD02,FD02.

NOTE: Mandate Number can be either External or Internal Number.

·       To make our work easier technically we can use the below procedure using the below BAPI's:

·       The table that is Master for all the SEPA mandates is SEPA_MANDATE.

·       SEPA_MANDATE: This is the Standard Smart form used to print the mandate details for any customer.

·       Assume a file with the Customer and mandate Information is available

Ø  Check if the customer is created by checking in the KNB1 table.

Ø  If the Customer is present then check if the Customer has IBAN and BIC number.

Ø  Check if the mandate is not created for Customer with the mandate number using the BAPI SEPA_MANDATES_API_GET.

Ø  For the BAPI SEPA_MANDATES_API_GET pass the customer number in the importing parameter to check if there is any mandate information present for the Customer SEPA_GET_CRITERIA_MANDATE-snd_id = Customer Number .

screen6.png

Ø  ET_MANDATES contains the mandate information that is fetched from BAPI based on the Customer Number.

scrren71.png

NOTE :   SEPA_MANDATES_API_GET FM cannot be used for multiple mandate scenario. We can write take MGUID from REGUH table and go to SEPA_MANDATE table and get the IBAN number and mandate number.

 

Three BAPI'S are majorly used to Creation and updating of the mandate details of the Customer.

To fetch the Mandate information for a particular Customer from the table SEPA_MANDATE table

SEPA_MANDATES_API_GET

Create the Mandate for a Customer

BAPI_SEPA_MANDATE_CREATE1

Modification of Mandate details for a customer

BAPI_SEPA_MANDATE_CHANGE1

 

·       Mandate Creation:

Ø Use the BAPI BAPI_SEPA_MANDATE_CREATE1 to create the mandate .

Ø BAPI_S_SEPA_MANDATE_COMMON structure which is importing parameter to the above mentioned BAPI has to be filled with the mandate information .This contains both the Sender (Customer Details ) and  receiver details (Company code data ).

screen-8.png

Ø Then collect all the address information either from the file provided or from the customer master data and fill the Sender information in the structure BAPI_S_SEPA_MANDATE_COMMON.

Ø Then based on the company code fetch the address details of the Company code and fill the Receiver information in the structure BAPI_S_SEPA_MANDATE_COMMON.

Ø ES_MANDATE_CREATED exporting parameter in the above BAPI gives a success message if the mandates are correctly created for the customer.

Ø  Error handling can be done with the return exporting parameter.

screen9.png

 

·       If the mandate already exists then check if there is any change in the mandate information.

Mandate modification:

Ø  Use the BAPI BAPI_SEPA_MANDATE_CHANGE1 to change the already existing mandate.

Ø  BAPI_S_SEPA_MANDATE_CHANGE structure which is importing parameter to the above mentioned BAPI has to be filled with the mandate information .This contains both the Sender (Customer Details) and  receiver details (Company code data ).

screen9.png

Ø  In case ofupdation is failed it can handled by  return parameter of the BAPI

screen-10.png

  Display of Mandates :

Ø  The created mandates can be checked by FSEPA_M3 Give the Mandate number or Customer Number and check for the Mandate information.

screen11.png

On Click on Enter the below Screen appears which displays all the information.

screen12.png

 

Ø We can also check the Mandate information through Customer master display  using transaction fd02,xd02,xd03,fd03.screen13.png

Click on the Tab to check and create the mandate Details from Customer master

Display the List of Mandates:

Ø  Use the transaction FSEPA_M4 to display a list for customers for a particular company code.

screen14.png

Ø  Mention the company code in the below transaction and then execute all the mandates present for the company code will be displayed.

Ø  A list of mandates will be displayed as shown in the below screen shot.

screen15.png

The above lights depicts different status of the mandates below are the differnent status of mandates.

0         

Entered

1

Active

2

To Be Confirmed

3

Locked

4

Canceled

5

Obsolete

6

CompletedCompleted

Ø  If we need to print a particular mandate information then select the Print mandate button on the top right corner of the list .

screen16.png

Ø  For this SAP has provided a smartform SEPA_MANDATE.This can be customized at central level and the thus the mandate can be created and mandate information can be printed.

screen17.png

All the inforamtion related to the mandate is available in the table SEPA_MANDATE.

Accessing an External MSSQL Data using Simple ABAP Program

$
0
0

Let us see how we can connect an External MSSQL DB and access it via a simple ABAP Program.

 

Assumption:

 

SAP is running on Windows and the required DLL is already present / installed.

The MSSQL DB is on the Same Network where SAP is residing.

 

First we need to Create a DB Connection for the External MSSQL DB in SAP.

 

        Goto DBCO, Create a New Entry and enter the details.

     DBCO.JPG

          DB Connection -  Give any name, which will be used later in the ABAP Program.

          DBMS               -  Select "MSS" as we are going to access MS SQL.

          User Name       -  User Name to connect with the MS SQL - will be provided by your DBA.

          DB Password    -  Password to connect to the DB, enter same password in both the fields.

          Conn. info        -  Syntax is MSSQL_SERVER=HostName MSSQL_DBNAME=DataBaseName. You can get this details from DBA.

 

          Once, the entries are done, Save and Exit.

 

Now, we shall see how we can access the Data using an ABAP Program.

 

          Goto SE38 and Create an Executable Program.

 

REPORT  Z_MSSQL_ACCESS.

DATA: user_id TYPE String.

EXEC SQL.                                    " All statements between EXEC SQL and ENDEXEC are SQL Statements

CONNECT TO 'DB_CONXN_NAME'  " DB Connection Name, Note there is no PERIOD in the SQL Statements

ENDEXEC.

EXEC SQL.

SELECT field_name into :user_id from Table_Name where first_name = 'Subu' and last_name = 'Subu'     

ENDEXEC.

EXEC SQL.

DISCONNECT :'DB_CONXN_NAME'                    "Disconnecting the Connection

ENDEXEC.

WRITE: / USER_ID.

 

The above Program will fetch the User id from the external MS SQL DB and Displays it.

Email Sending Functionality for Different Business Process in Sap

$
0
0

Email Sending Functionality for Different Business Process in Sap

Nov, 2013

 

 

Introduction

Every Business Process in SAP Follow different communication types to communicate with its Business partners like Print and send via post, Fax, and Email (Internet).Several E-mail communications need to be sent to Vendors & Customers who are the business partners for the organization which contains several Business Processes like Payment Advice, Dunning forms and PO’s etc., with PDF and Excel as attachment, which is a very eco-friendly way. Presently many are using the process of taking a print out and sending it through the post. This Process has lot of paper wastage. So instead of this we can send a mail which saves lot of paper wastage .This process enables the Go green Initiative and reduces lot of manual effort. With the recent releases in SAP all the Business process are enhanced with Email sending functionality.

Introduction to Email Processes

Every Standard FI process like Dunning and Payment and collection advice has a default way of sending there notices to the customer or vendor by post. Sending a mail is not a standard SAP functionality; in order to achieve this nonstandard Functionality we have BTE.  This is an enhancement technique (Open FI) that was developed for Financial Accounting component. This functionality is primarily used in FI in the areas of dunning, Payment advice Customer and Vendor Statement etc. Each of them has their own Function modules which will not interfere with each other.

           Each of these has a BTE’s enabled to fill the FINNA-NACHA structure to determine whether the output should be sent as fax, print via post or email, i.e., if FINAA-NACHA = 1 - print via post and FINAA-NACHA = ‘I’ its email and if its ‘2’ FAX.

This Document contains how this mail functionality can be achieved by using the BTE’s for Different applications in FI.

1. Application Area: FI - Accounts payable and Accounts receivable – Dunning

     Application of the process BTE event '00001040' -

· This process BTE is useful during a dunning run when a dunning notice needs to be sent to the customer by the medium of an electronic form (EMAIL).
As a default property, the dunning notice gets printed and is sent to the customer either by scanning the copy or via 'POST'.

· This same dunning notice could be a very beneficial if it is sent by means of electronic form directly after the dunning has been carried out.

· So, to achieve this non-standard functionality we need to enhance the standard process.

      Transaction - FIBF -> Environment -> Info systems (Processes)

· Click on execute,

 

· Select the BTE 00001040 as it deals with the Output device/medium

Fig1.jpg

· Change the Already Present function module to Z function Module.

fig2.jpg

Now, technically the BTE is ready to work as we have registered the BTE.

As a functional aspect, the following things are needed to be taken care of.

· Standard communication option - to 'EMAIL' in the 'General' Tab in customer master 'XD02/01'.

fig3.jpg

· After configuring these basic steps, the BTE is complete to trigger for dunning run for this particular customer.

     Dunning Run

· SAPF150D2-This Program can be used to execute the Dunning form by giving the Run date and identification and the logic in the FM's can be checked by placing the debugger.

· Best way is to check in the debugger,

fig4.jpg

Ø  FINAA-NACHA - For Communication Medium (I- Internet, 1-Print Out, 2-Fax)

Ø  FINAA_INTAD – Email Address to send the PDF

 

Fig5.jpg

Ø Process the next step by confirming the 'Send to mail' dialog,

Ø If 'C_FINAA-INTAD' is left blank the system will pick from the customer master 'Clerks internet', else it will take from the value 'C_FINAA-INTAD'. This enables the PDF sending functionality which enables is standard process and the logic to send excel can be written in the above FM only. Also if you need to fill the Subject of Email use itcpo-tdtitle structure which of 50 characters. If we need to send the Body also Maintain the standard text as mentioned in the below screen shot.

fig6.jpg

NOTE: If we need to send many attachments other than PDF we have to write the code in the above FM call the common mail sending functionality. In this case first a mail will be sent with Excel or some other as attachment then the standard PDF functionality is called.

This is a very eco-friendly means of informing the customers for their over-due items.

 

 

2. Application Area: FI – Payment Advice and Collection Advice:

     Application of the process BTE event '00002040' –

This BTE is called in the standard include RFFORI06 as shown below.

fig7.png

· In the transaction FIBF Select the BTE 00002040 as it deals with the Output device/medium sample_process_00002040 will be assigned.

 

· Since this is not a standard functionality we need to enhance the FM so copy the

sample_process_00002040 into Zsample_process_00002040.

Logic in the FM

Check if customer or Vendor has Email Maintained in the Master Data. If it’s maintained then

· The structure c_finna included the internet address.

          We set the transmission medium to ‘I’ as below.

          c_finaa-nacha = 'I'.

          c_finaa-intad = l_smtp_addr(130). [The email Obtained from the master data]

·    Later the mail sending functionality can be called after the close_form as shown in the below screen shot or By OTF data and excel can be created using the tab_regup structure in the   form avis_schreiben.

3. Application Area: FI – Customer/Vendor Balance Confirmation:

     Application of the process BTE event '00002410' –

· This process BTE is useful during a Customer/Vendor Balance Confirmation form which needs to be sent to the Customer/Vendor by an electronic form (EMAIL). By default, the form is sent to the Customer/Vendor either by Fax or via 'POST'.

· But as an environmental aspect to avoid wastage of paper, the same Statement could be sent by means of electronic form directly after the Customer/Vendor Statement run has been carried out.

· So, to achieve this functionality we need to enhance the standard process.

     Transaction - FIBF -> Environment -> Info Systems (Processes)

· Click on Execute.

· Select BTE 00002410 as it deals with Determining the Output Device

fig8.png

· Click on Sample Function Module. The FM 'SAMPLE_PROCESS_00002410' is assigned. In order to include the mail sending functionality, Copy the Function Module into a Z Function Module and make the required changes to enable the mail sending functionality.

     Logic in the FM:

Check if the Customer or Vendor has Email Maintained in the Master Data. If it is maintained then

· The structure c_finna includes the internet address.

We set the transmission medium to ‘I’ as below.

          C_finaa-nacha = 'I'.

         C_finaa-intad = l_smtp_addr(130). [Email Obtained from the master data]

· Later the mail sending functionality can be called after the Close_form as shown in the below screen shot or By OTF data, and excel can be created using the Structure HBSIDH for Customer and HBSIKH for Vendor.

Fig9.png

4. How to achieve Mail Functionality Technically:

Create a Common Functionality for sending mail using classes

i) For sending the subject greater than 255 characters   

· At present using the FM SO_DOCUMENT_SEND_API1 has the capability of sending only 50 characters but using the below method of the class the subject more than 255 characters.

· So cl_bcs class is used for the below purpose.

· There is also any option of changing the sender ID in case the requirement is not    to use the           

· SAP master User ID using the cl_bcs  class.

· Create the below object of type cl_bcs  and call the method  set_message_subject        

          w_send_request     TYPE REF TO cl_bcs           VALUE IS INITIAL,      
     
CALL METHOD w_send_request->set_message_subject
       
EXPORTING
          ip_subject = subject.

ii) For Sending Multiple Attachments like PDF and Excel

· In case multiple attachments the below method add_attachment attachment can be used by looping on the attachments obtained to this function module.

     f_ATTACHMENTS    TYPE      RMPS_T_POST_CONTENT

      w_document       TYPE REF TO cl_document_bcs  VALUE IS INITIAL,

     
LOOP AT attachments INTO f_attachment.


        w_attachment_subject = f_attachment-subject.
        w_filesize = f_attachment-docsize.

· This Method will have the option to take input as method subject, filesize and
        w_document->add_attachment(
       
EXPORTING
        i_attachment_type    = f_attachment-doc_type
        i_attachment_subject = w_attachment_subject
        i_attachment_size    = w_filesize
        i_att_content_text   = f_attachment-cont_text[] ).

      ENDLOOP.

    iii) For Sending Email to multiple recipients like To, BCC and CC,

· The below Logic can applied to provide cc bcc and to as like multiple receivers. The method

add_recipient   has the option to give blind_copy, Copy and recipient.

w_recipient      TYPE REF TO if_recipient_bcs VALUE IS INITIAL,

· Loop at the multiple receivers

LOOP AT receivers INTO f_receivers.

          w_recipient_mail = f_receivers-receiver .

· The below method sets them mail ID of the Receiver.
          w_recipient = cl_
cam_address_bcs=>create_internet_address(
                         w_recipient_mail).

        w_send_request->add_recipient(
           
EXPORTING
            i_recipient = w_recipient
            i_express =
'X'
            i_copy = f_receivers-copy
            i_blind_copy = f_receivers-blind_copy).
ENDLOOP.

ABAP Connectivity: Methods and Services

$
0
0

ABAP as a foundation for many applications offers a broad range of integration and connectivity technologies for remote SAP- and non-SAP systems. Universal internet protocols like HTTP(s) and data formats like XML and SOAP can be used as well as SAP-proprietary protocols and formats like RFC/BAPI, IDoc and ALE/EDI.
Developers can expose ABAP-based functionality as a Web or enterprise service by publishing the service definition in the Enterprise Service Repository, creating a server-side proxy, and implementing the service using the ABAP programming language. To consume existing Web Services, the creation of Consumer Services (Proxy), based on the WSDL document, is supported by a wizard.
For regularly updated information, see the wiki on ABAP connectivity.

 

ABAP Service Provisioning and Consumption

SAP NetWeaver Application Server ABAP provides business logic for many applications, such as SAP Business Suite and SAP Business ByDesign, and therefore must necessarily be able to communicate with other ABAP and non-ABAP application servers. In the course of time, the format for exchanged data has altered from ABAP-only to universal. Nowadays, data will mostly be exchanged between servers using universal Internet protocols like HTTP, HTTPS, XML or SOAP. Due to their historical roots and their wide spreading, SAP- proprietary formats like RFC, IDoc, ALE/EDI or BAPI still continue to have a right to exist.

Web Services for ABAP

Web services represent the strategy for communication within SAP NetWeaver and between other systems. They are a uniform technology that allows you provide and consume services independently of implementation and the underlying protocol. Furthermore, you can do so both within SAP NetWeaver and in the communication with other systems.
The ABAP Workbench offers an environment where you can publish, search for, and call Web services. It enables the SAP NetWeaver Application Server to act both as a server and as a client for Web services.
Web Service Framework

To get started, see the following link:

Enterprise Services

Enterprise services are basically highly integrated Web services combined with business logic and semantics that can be accessed and used repeatedly to support a particular business process. Enterprise services provide business processes or business process steps that can be used to compose business scenarios while ensuring business integrity and ease of reuse. For storage the Enterprise Service Repository and Registry are provided by SAP NetWeaver.To get started, see the following links:

 

Other Methods of Connectivity

Remote-Function-Call (RFC) is known as a reliable and very fast protocol to communicate between SAP systems/SAP Connectors (available for various computer languages) for tightly coupled applications:
  • Connections can be kept open easily
  • Connection loss is easily recognizable
  • ABAP transaction/locking concept can be leveraged
  • Different connection models available (synchronous, asynchronous, queued)
  • Flexible (low-very high data amount possible, fast and slow connections supported, compatible and incompatible changes of interfaces possible)
  • High-Performance due to lack of need for data transformation
RFC is the foundation for BAPI technique as well as for typical ALE scenarios.

RFC (Remote Function Call)

Communication between applications of different systems in the SAP environment includes connections between SAP systems as well as between SAP systems and non-SAP systems.ABAP function modules with attributes "remote enabled" can be called from other systems using the SAP-proprietary RFC-protocol. Different patterns like synchronous or transactional calls are possible. Non-ABAP systems can use the RFC library to implement RFC server or RFC client programs.To get started, see the following links:

BAPI (Business Application Programming Interface)

BAPIs are still available, but will be replaced by Enterprise Services technology (ESR), in future. The most important BAPIs are already available as Enterprise Services.To get started, see the following links:
  • BAPIs (in SAP Help Portal)
  • BAPI User Guide (in SAP Help Portal)
    Get an impression on what BAPIs are and how to program with them from this library chapter.

 

Taken from the chapter introduction: "BAPIs (Business Application Programming Interface) are specific methods for SAP business objects, which are stored in the Business Object Repository (BOR) of the SAP system and are used for carrying out particular business tasks.In the SAP system, BAPIs are stored as RFC-capable function modules in the ABAP Workbench Function Builder. BAPIs have standard business interfaces that enable external applications (with the help of SAP business objects) to access SAP processes, functions and data."

ALE (Application Link Enabling) / IDOCS (Intermediate Documents)

ALE is the overall term for exchanging data packages (called IDocs) between systems, be it SAP or non-SAP. The data exchange is always asynchronous, and different ways can be used to transfer the IDocs, e.g. transactional RFC (tRFC) or file transfer, depending on the capabilities of the systems involved. EDI (Electronic Data Interchanged) is another scenario where IDocs are used to run distributed applications.To get started, see the following links:

How to Create Endpoints for Multiple ABAP Webservices using Soamanger

$
0
0

Using this document you can create multiple services definition endpoints via single button press in soamanager transaction.

View Document

Searching messages in R3 based on XPath value

$
0
0

 

Searching messages based on XPath value

 

Report name:

ROPS_SE_PUR_SELECT_MESSAGES

Selection Screen:

Length of Output List: It should be blank or 0 to include all messages.

Date Range: Enter a start and end date for messages to be searched.

XPath: Enter the XPath in this field (detailed information in section how to use XPath)

Value: Enter the value which should match the XPath query without any quotes.

image002.jpg

 

How to use XPath for searching

Generic view of XML document:

image004.jpg

Normal XPath used everywhere:

/*[local-name()='CreditCommitmentNotification' and namespace-uri()='http://sap.com/xi/SAPGlobal/Global']/CreditCommitment/DebtorParty/InternalID/text()

XPath for using in report:

Normal XPath query will not work for this report. Some changes are required in XPath.

Only values will be searched, attributes are not searched using this report.

1.      Remove the root node, this is added by the system automatically.

The query now becomes like this: /CreditCommitment/DebtorParty/InternalID/text()

2.      The leading ‘/’ is also not required.

The query is: CreditCommitment/DebtorParty/InternalID/text()

3.      Also the ‘/text()’ is not required.

The query becomes: CreditCommitment/DebtorParty/InternalID

 


Email Sending Functionality for Different Business Process in Sap

$
0
0

Email Sending Functionality for Different Business Process in Sap

Nov, 2013

 

 

Introduction

Every Business Process in SAP Follow different communication types to communicate with its Business partners like Print and send via post, Fax, and Email (Internet).Several E-mail communications need to be sent to Vendors & Customers who are the business partners for the organization which contains several Business Processes like Payment Advice, Dunning forms and PO’s etc., with PDF and Excel as attachment, which is a very eco-friendly way. Presently many are using the process of taking a print out and sending it through the post. This Process has lot of paper wastage. So instead of this we can send a mail which saves lot of paper wastage .This process enables the Go green Initiative and reduces lot of manual effort. With the recent releases in SAP all the Business process are enhanced with Email sending functionality.

Introduction to Email Processes

Every Standard FI process like Dunning and Payment and collection advice has a default way of sending there notices to the customer or vendor by post. Sending a mail is not a standard SAP functionality; in order to achieve this nonstandard Functionality we have BTE.  This is an enhancement technique (Open FI) that was developed for Financial Accounting component. This functionality is primarily used in FI in the areas of dunning, Payment advice Customer and Vendor Statement etc. Each of them has their own Function modules which will not interfere with each other.

           Each of these has a BTE’s enabled to fill the FINNA-NACHA structure to determine whether the output should be sent as fax, print via post or email, i.e., if FINAA-NACHA = 1 - print via post and FINAA-NACHA = ‘I’ its email and if its ‘2’ FAX.

This Document contains how this mail functionality can be achieved by using the BTE’s for Different applications in FI.

1. Application Area: FI - Accounts payable and Accounts receivable – Dunning

     Application of the process BTE event '00001040' -

· This process BTE is useful during a dunning run when a dunning notice needs to be sent to the customer by the medium of an electronic form (EMAIL).
As a default property, the dunning notice gets printed and is sent to the customer either by scanning the copy or via 'POST'.

· This same dunning notice could be a very beneficial if it is sent by means of electronic form directly after the dunning has been carried out.

· So, to achieve this non-standard functionality we need to enhance the standard process.

      Transaction - FIBF -> Environment -> Info systems (Processes)

· Click on execute,

 

· Select the BTE 00001040 as it deals with the Output device/medium

Fig1.jpg

· Change the Already Present function module to Z function Module.

fig2.jpg

Now, technically the BTE is ready to work as we have registered the BTE.

As a functional aspect, the following things are needed to be taken care of.

· Standard communication option - to 'EMAIL' in the 'General' Tab in customer master 'XD02/01'.

fig3.jpg

· After configuring these basic steps, the BTE is complete to trigger for dunning run for this particular customer.

     Dunning Run

· SAPF150D2-This Program can be used to execute the Dunning form by giving the Run date and identification and the logic in the FM's can be checked by placing the debugger.

· Best way is to check in the debugger,

fig4.jpg

Ø  FINAA-NACHA - For Communication Medium (I- Internet, 1-Print Out, 2-Fax)

Ø  FINAA_INTAD – Email Address to send the PDF

 

Fig5.jpg

Ø Process the next step by confirming the 'Send to mail' dialog,

Ø If 'C_FINAA-INTAD' is left blank the system will pick from the customer master 'Clerks internet', else it will take from the value 'C_FINAA-INTAD'. This enables the PDF sending functionality which enables is standard process and the logic to send excel can be written in the above FM only. Also if you need to fill the Subject of Email use itcpo-tdtitle structure which of 50 characters. If we need to send the Body also Maintain the standard text as mentioned in the below screen shot.

fig6.jpg

NOTE: If we need to send many attachments other than PDF we have to write the code in the above FM call the common mail sending functionality. In this case first a mail will be sent with Excel or some other as attachment then the standard PDF functionality is called.

This is a very eco-friendly means of informing the customers for their over-due items.

 

 

2. Application Area: FI – Payment Advice and Collection Advice:

     Application of the process BTE event '00002040' –

This BTE is called in the standard include RFFORI06 as shown below.

fig7.png

· In the transaction FIBF Select the BTE 00002040 as it deals with the Output device/medium sample_process_00002040 will be assigned.

 

· Since this is not a standard functionality we need to enhance the FM so copy the

sample_process_00002040 into Zsample_process_00002040.

Logic in the FM

Check if customer or Vendor has Email Maintained in the Master Data. If it’s maintained then

· The structure c_finna included the internet address.

          We set the transmission medium to ‘I’ as below.

          c_finaa-nacha = 'I'.

          c_finaa-intad = l_smtp_addr(130). [The email Obtained from the master data]

·    Later the mail sending functionality can be called after the close_form as shown in the below screen shot or By OTF data and excel can be created using the tab_regup structure in the   form avis_schreiben.

3. Application Area: FI – Customer/Vendor Balance Confirmation:

     Application of the process BTE event '00002410' –

· This process BTE is useful during a Customer/Vendor Balance Confirmation form which needs to be sent to the Customer/Vendor by an electronic form (EMAIL). By default, the form is sent to the Customer/Vendor either by Fax or via 'POST'.

· But as an environmental aspect to avoid wastage of paper, the same Statement could be sent by means of electronic form directly after the Customer/Vendor Statement run has been carried out.

· So, to achieve this functionality we need to enhance the standard process.

     Transaction - FIBF -> Environment -> Info Systems (Processes)

· Click on Execute.

· Select BTE 00002410 as it deals with Determining the Output Device

fig8.png

· Click on Sample Function Module. The FM 'SAMPLE_PROCESS_00002410' is assigned. In order to include the mail sending functionality, Copy the Function Module into a Z Function Module and make the required changes to enable the mail sending functionality.

     Logic in the FM:

Check if the Customer or Vendor has Email Maintained in the Master Data. If it is maintained then

· The structure c_finna includes the internet address.

We set the transmission medium to ‘I’ as below.

          C_finaa-nacha = 'I'.

         C_finaa-intad = l_smtp_addr(130). [Email Obtained from the master data]

· Later the mail sending functionality can be called after the Close_form as shown in the below screen shot or By OTF data, and excel can be created using the Structure HBSIDH for Customer and HBSIKH for Vendor.

Fig9.png

4. How to achieve Mail Functionality Technically:

Create a Common Functionality for sending mail using classes

i) For sending the subject greater than 255 characters   

· At present using the FM SO_DOCUMENT_SEND_API1 has the capability of sending only 50 characters but using the below method of the class the subject more than 255 characters.

· So cl_bcs class is used for the below purpose.

· There is also any option of changing the sender ID in case the requirement is not    to use the           

· SAP master User ID using the cl_bcs  class.

· Create the below object of type cl_bcs  and call the method  set_message_subject        

          w_send_request     TYPE REF TO cl_bcs           VALUE IS INITIAL,      
     
CALL METHOD w_send_request->set_message_subject
       
EXPORTING
          ip_subject = subject.

ii) For Sending Multiple Attachments like PDF and Excel

· In case multiple attachments the below method add_attachment attachment can be used by looping on the attachments obtained to this function module.

     f_ATTACHMENTS    TYPE      RMPS_T_POST_CONTENT

      w_document       TYPE REF TO cl_document_bcs  VALUE IS INITIAL,

     
LOOP AT attachments INTO f_attachment.


        w_attachment_subject = f_attachment-subject.
        w_filesize = f_attachment-docsize.

· This Method will have the option to take input as method subject, filesize and
        w_document->add_attachment(
       
EXPORTING
        i_attachment_type    = f_attachment-doc_type
        i_attachment_subject = w_attachment_subject
        i_attachment_size    = w_filesize
        i_att_content_text   = f_attachment-cont_text[] ).

      ENDLOOP.

    iii) For Sending Email to multiple recipients like To, BCC and CC,

· The below Logic can applied to provide cc bcc and to as like multiple receivers. The method

add_recipient   has the option to give blind_copy, Copy and recipient.

w_recipient      TYPE REF TO if_recipient_bcs VALUE IS INITIAL,

· Loop at the multiple receivers

LOOP AT receivers INTO f_receivers.

          w_recipient_mail = f_receivers-receiver .

· The below method sets them mail ID of the Receiver.
          w_recipient = cl_
cam_address_bcs=>create_internet_address(
                         w_recipient_mail).

        w_send_request->add_recipient(
           
EXPORTING
            i_recipient = w_recipient
            i_express =
'X'
            i_copy = f_receivers-copy
            i_blind_copy = f_receivers-blind_copy).
ENDLOOP.

How to Create Endpoints for Multiple ABAP Webservices using Soamanger

$
0
0

Using this document you can create multiple services definition endpoints via single button press in soamanager transaction.

View Document

Email Sending Functionality for Different Business Process in Sap

$
0
0

Email Sending Functionality for Different Business Process in Sap

Nov, 2013

 

 

Introduction

Every Business Process in SAP Follow different communication types to communicate with its Business partners like Print and send via post, Fax, and Email (Internet).Several E-mail communications need to be sent to Vendors & Customers who are the business partners for the organization which contains several Business Processes like Payment Advice, Dunning forms and PO’s etc., with PDF and Excel as attachment, which is a very eco-friendly way. Presently many are using the process of taking a print out and sending it through the post. This Process has lot of paper wastage. So instead of this we can send a mail which saves lot of paper wastage .This process enables the Go green Initiative and reduces lot of manual effort. With the recent releases in SAP all the Business process are enhanced with Email sending functionality.

Introduction to Email Processes

Every Standard FI process like Dunning and Payment and collection advice has a default way of sending there notices to the customer or vendor by post. Sending a mail is not a standard SAP functionality; in order to achieve this nonstandard Functionality we have BTE.  This is an enhancement technique (Open FI) that was developed for Financial Accounting component. This functionality is primarily used in FI in the areas of dunning, Payment advice Customer and Vendor Statement etc. Each of them has their own Function modules which will not interfere with each other.

           Each of these has a BTE’s enabled to fill the FINNA-NACHA structure to determine whether the output should be sent as fax, print via post or email, i.e., if FINAA-NACHA = 1 - print via post and FINAA-NACHA = ‘I’ its email and if its ‘2’ FAX.

This Document contains how this mail functionality can be achieved by using the BTE’s for Different applications in FI.

1. Application Area: FI - Accounts payable and Accounts receivable – Dunning

     Application of the process BTE event '00001040' -

· This process BTE is useful during a dunning run when a dunning notice needs to be sent to the customer by the medium of an electronic form (EMAIL).
As a default property, the dunning notice gets printed and is sent to the customer either by scanning the copy or via 'POST'.

· This same dunning notice could be a very beneficial if it is sent by means of electronic form directly after the dunning has been carried out.

· So, to achieve this non-standard functionality we need to enhance the standard process.

      Transaction - FIBF -> Environment -> Info systems (Processes)

· Click on execute,

 

· Select the BTE 00001040 as it deals with the Output device/medium

Fig1.jpg

· Change the Already Present function module to Z function Module.

fig2.jpg

Now, technically the BTE is ready to work as we have registered the BTE.

As a functional aspect, the following things are needed to be taken care of.

· Standard communication option - to 'EMAIL' in the 'General' Tab in customer master 'XD02/01'.

fig3.jpg

· After configuring these basic steps, the BTE is complete to trigger for dunning run for this particular customer.

     Dunning Run

· SAPF150D2-This Program can be used to execute the Dunning form by giving the Run date and identification and the logic in the FM's can be checked by placing the debugger.

· Best way is to check in the debugger,

fig4.jpg

Ø  FINAA-NACHA - For Communication Medium (I- Internet, 1-Print Out, 2-Fax)

Ø  FINAA_INTAD – Email Address to send the PDF

 

Fig5.jpg

Ø Process the next step by confirming the 'Send to mail' dialog,

Ø If 'C_FINAA-INTAD' is left blank the system will pick from the customer master 'Clerks internet', else it will take from the value 'C_FINAA-INTAD'. This enables the PDF sending functionality which enables is standard process and the logic to send excel can be written in the above FM only. Also if you need to fill the Subject of Email use itcpo-tdtitle structure which of 50 characters. If we need to send the Body also Maintain the standard text as mentioned in the below screen shot.

fig6.jpg

NOTE: If we need to send many attachments other than PDF we have to write the code in the above FM call the common mail sending functionality. In this case first a mail will be sent with Excel or some other as attachment then the standard PDF functionality is called.

This is a very eco-friendly means of informing the customers for their over-due items.

 

 

2. Application Area: FI – Payment Advice and Collection Advice:

     Application of the process BTE event '00002040' –

This BTE is called in the standard include RFFORI06 as shown below.

fig7.png

· In the transaction FIBF Select the BTE 00002040 as it deals with the Output device/medium sample_process_00002040 will be assigned.

 

· Since this is not a standard functionality we need to enhance the FM so copy the

sample_process_00002040 into Zsample_process_00002040.

Logic in the FM

Check if customer or Vendor has Email Maintained in the Master Data. If it’s maintained then

· The structure c_finna included the internet address.

          We set the transmission medium to ‘I’ as below.

          c_finaa-nacha = 'I'.

          c_finaa-intad = l_smtp_addr(130). [The email Obtained from the master data]

·    Later the mail sending functionality can be called after the close_form as shown in the below screen shot or By OTF data and excel can be created using the tab_regup structure in the   form avis_schreiben.

3. Application Area: FI – Customer/Vendor Balance Confirmation:

     Application of the process BTE event '00002410' –

· This process BTE is useful during a Customer/Vendor Balance Confirmation form which needs to be sent to the Customer/Vendor by an electronic form (EMAIL). By default, the form is sent to the Customer/Vendor either by Fax or via 'POST'.

· But as an environmental aspect to avoid wastage of paper, the same Statement could be sent by means of electronic form directly after the Customer/Vendor Statement run has been carried out.

· So, to achieve this functionality we need to enhance the standard process.

     Transaction - FIBF -> Environment -> Info Systems (Processes)

· Click on Execute.

· Select BTE 00002410 as it deals with Determining the Output Device

fig8.png

· Click on Sample Function Module. The FM 'SAMPLE_PROCESS_00002410' is assigned. In order to include the mail sending functionality, Copy the Function Module into a Z Function Module and make the required changes to enable the mail sending functionality.

     Logic in the FM:

Check if the Customer or Vendor has Email Maintained in the Master Data. If it is maintained then

· The structure c_finna includes the internet address.

We set the transmission medium to ‘I’ as below.

          C_finaa-nacha = 'I'.

         C_finaa-intad = l_smtp_addr(130). [Email Obtained from the master data]

· Later the mail sending functionality can be called after the Close_form as shown in the below screen shot or By OTF data, and excel can be created using the Structure HBSIDH for Customer and HBSIKH for Vendor.

Fig9.png

4. How to achieve Mail Functionality Technically:

Create a Common Functionality for sending mail using classes

i) For sending the subject greater than 255 characters   

· At present using the FM SO_DOCUMENT_SEND_API1 has the capability of sending only 50 characters but using the below method of the class the subject more than 255 characters.

· So cl_bcs class is used for the below purpose.

· There is also any option of changing the sender ID in case the requirement is not    to use the           

· SAP master User ID using the cl_bcs  class.

· Create the below object of type cl_bcs  and call the method  set_message_subject        

          w_send_request     TYPE REF TO cl_bcs           VALUE IS INITIAL,      
     
CALL METHOD w_send_request->set_message_subject
       
EXPORTING
          ip_subject = subject.

ii) For Sending Multiple Attachments like PDF and Excel

· In case multiple attachments the below method add_attachment attachment can be used by looping on the attachments obtained to this function module.

     f_ATTACHMENTS    TYPE      RMPS_T_POST_CONTENT

      w_document       TYPE REF TO cl_document_bcs  VALUE IS INITIAL,

     
LOOP AT attachments INTO f_attachment.


        w_attachment_subject = f_attachment-subject.
        w_filesize = f_attachment-docsize.

· This Method will have the option to take input as method subject, filesize and
        w_document->add_attachment(
       
EXPORTING
        i_attachment_type    = f_attachment-doc_type
        i_attachment_subject = w_attachment_subject
        i_attachment_size    = w_filesize
        i_att_content_text   = f_attachment-cont_text[] ).

      ENDLOOP.

    iii) For Sending Email to multiple recipients like To, BCC and CC,

· The below Logic can applied to provide cc bcc and to as like multiple receivers. The method

add_recipient   has the option to give blind_copy, Copy and recipient.

w_recipient      TYPE REF TO if_recipient_bcs VALUE IS INITIAL,

· Loop at the multiple receivers

LOOP AT receivers INTO f_receivers.

          w_recipient_mail = f_receivers-receiver .

· The below method sets them mail ID of the Receiver.
          w_recipient = cl_
cam_address_bcs=>create_internet_address(
                         w_recipient_mail).

        w_send_request->add_recipient(
           
EXPORTING
            i_recipient = w_recipient
            i_express =
'X'
            i_copy = f_receivers-copy
            i_blind_copy = f_receivers-blind_copy).
ENDLOOP.

How to Create Endpoints for Multiple ABAP Webservices using Soamanger

$
0
0

Using this document you can create multiple services definition endpoints via single button press in soamanager transaction.

View Document

How to create Trust/Trusted RFC relationship

$
0
0

1.Create a RFC destination to the system you want to trust(for example Y57->Y58)

RFC2 - Copy.png

RFC3.png

 

 

2. Create a trusted system in Y57 using the RFC destination you just created.

rfc4.png

rfc6.png

 

rfc7.png

rfc8.png

3. Go to SMT2, you will see trusting system is here.

rfc9.png

 

4. Create a RFC destination without user and password but using "Trust Relationshiop" and "Current user" instaed.

rfc10.png

Now you can use this RFC destination logon to Y57 without enter user and password

Viewing all 63 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>