This article demonstrates in a step-by-step process to write ABAP Reports that use BAPI function modules.



Similar documents
Step by Step Guide for Language Translation Tool

SAP BI Generic Extraction Using a Function Module

Step by Step Guide How to Copy Flat File from Other Application Server to BI and Load through Info Package

Reverse Transport Mechanism in SAP BI

Scenario... 3 Step-by-Step Solution Virtual Infocube... 4 Function Module (Virtual InfoCube)... 5 Infocube Data Display... 7

Creating Content Using SO10 Objects and Text Symbols

Display Options in Transaction SE16

Restricting Search Operators in any Search View

Creating Transaction and Screen Variants

Deleting the User Personalization done on Enterprise Portal

Exposing RFC as Web Service and Consuming Web Service in Interactive Forms in ABAP

SAP BW - Excel Pivot Chart and Pivot Table report (Excel)

Web Dynpro ABAP: ALV and Table in Popup Window

Embedding Crystal Reports inside ECC ALV Reports

Release Strategy Enhancement in Purchase Order

ALE Settings, for Communication between a BW System and an SAP System

SAP FI - Automatic Payment Program (Configuration and Run)

How to Modify, Create and Delete Table Entries from SE16

Guidelines for Effective Data Migration

Step by Step Procedure to Block and Debug a CIF Queue Flowing from R/3 to APO System

SAP MM: Purchase Requisition with Classification and Workflow Approval

Compounding in Infoobject and Analyzing the Infoobject in a Query

Multi Provider Creation Based on Sales and Planning Info Cubes

Step by Step Guide to Extract Batch Master Data via Generic and Classification Datasource to BW

Web Dynpro: Multiple ALV Grids and Layouts in ALV

Table of Contents. Passing Data across Components through Component Controller between Two Value Nodes

Creating Web Service from Function Modules/BAPIs & Integrating with SAP Interactive Forms

BW Performance Monitoring

Quick Viewer: SAP Report Generating Tool

ABAP How To on SQL Trace Analysis

How to Assign Transport Request for Language Translation?

First step to Understand a Payroll Schema

Deploying Crystal Reports on Top of a SAP BI Query

Process Controlled Workflow SRM 7.0 (Using BRF)

SPDD & SPAU Adjustments Handbook

How to Integrate CRM 2007 WebClient UI with SAP NetWeaver Portal

Mandatory Field Check in Web Dynpro- ABAP

Workflow Troubleshooting and Monitoring in SAP ECC 6.0

SAP CRM 7.0 E2C Setup: CRM via Toolset

Creating New Unit of Measure in SAP BW

Deleting the Requests from the PSA and Change Log Tables in Business Intelligence

Converting and Exporting Data in XML Format

Working with SAP BI 7.0 Data Transfer Process (DTP)

Understanding BW Non Cumulative Concept as Applicable in Inventory Management Data Model

Currency Conversion using Variables in SAP BI -Reporting

How to Get Work Items from Workflow in your Outlook Inbox

Sales Commission Calculation & Settlement Handling through Order Processing

Standard SAP Configuration of SMS through HTTP with Third Party SMS Gateway

Table of Content. SAP Query creation and transport Procedure in ECC6

Customer Exit Variables in SAP BW/BI Reports First day of the Current/Previous Month

Step By Step Procedure to Create Logical File Path and Logical File Name

Creating Mobile Applications on Top of SAP, Part 1

ABAP Proxy Interfacing

SAP CRM System 6.0/7.0. For more information, visit the Customer Relationship Management homepage

Create Automatic Mail Notification/ Alert for Process Chain Monitoring

SAP CRM Campaign Automation

SDN Community Contribution

SAP CRM 7.0 for Newbies: (Part 1) Simple BOL Object Creation for CRM Webclient UI

Creating and Scheduling Publications for Dynamic Recipients on SAP Business Objects Enterprise

Salesforce Integration Using PI: How to Perform Query and Other DML Operations Using the Enterprise WSDL

LSMW: Upload Master Data using Batch Input Recording

Different Types of Alerts for Process Chains. Table of Content

Inventory Management (0IC_C03) Part - 3

Merge PDF files in ABAP

Connecting to SAP BW with Microsoft Excel PivotTables and ODBO

Splitting the Custom Container & Display more than one ALV

SAP Workflow in Plain English

ABAP Debugging Tips and Tricks

Extractor in R/3 and Delta Queue

SAP NetWeaver Developer Studio 7.30 Installation Guide

How to Develop Programs for SAP Mobile RF

Integration of SAP R/3 with BO Universe Using Data Federator Connector

Step by Step guide of Report-to- Report Interface in BW Reporting

How to Generate Stack Xml for Ehp4 and Above Upgrade

SAP CRM Middleware Configurations

Dynamic Authorization Concept and Role Assignment in BI

Introduction to COPA and COPA Realignment

Forgot or Lock "Administrator or J2EE_ADMIN" Password

Order Split Usage in Production Orders

Organizational Management- Organizational Structure Creation

Understanding OLAP Processor and RSRT

Inventory Management in SAP BW

Understanding BEx Query Designer: Part-2 Structures, Selections and Formulas

Step by Step Guide to Create a Generic Datasource Based on Infoset Query Populated Via External Program

Data Flow from LBWQ/SMQ1 to RSA7 in ECC and Delta Extraction in BI

ALV List with Radio Buttons

Step by Step Procedures to Load Master Data (Attribute and Text) from FlatFile in BI 7.0

Direct Subcontracting Process (SAP SD & MM)

Salesforce.com Integration Using SAP PI: A Case Study

Tutorial - Creating Pop Up Window Using New Features in WebDynpro Java CE 7.1 Ehp1

Automating Invoice Processing in SAP Accounts Payable

SAP BW - Generic Datasource Function Module (Multiple Delta Fields)

Configuration of Enterprise Services using SICF and SOA Manager

How to Load Data from Flat Files into BW PSA

Case Study of a Segregation of Duties Project

Configuring HTTPs Connection in SAP PI 7.10

SAP CRM-BW Adapter an Overview

Sending an Image File Through XI in a File-to-Mail Scenario

Transfer of GL Master from Source SAP System to a Target SAP System through IDOCS

Step by Step Guide to Archiving and Deleting of XML Messages in SAP NetWeaver PI

Transcription:

BAPI Step-by-Step BAPI Step-by-Step Applies to: SAP ABAP Summary: This article demonstrates in a step-by-step process to write ABAP Reports that use BAPI function modules. Author(s): Renjith Kumar. P Company: Pricol Software Soutions. Created on: 26 January 2007 Author Bio P. Renjith Kumar is SAP BI Consultant with Pricol Software solutions. He has extensive crossfunctional experience and has been with end-to-end SAP implementations as ABAP Consultant. 2007 SAP AG 1

Table of Contents Business Object Repository... 3 BOR Definition... 3 BAPI programming... 3 Some Standard BAPI S... 4 GetList... 4 GetDetail... 4 CreateFromData... 4 Selecting the BAPI... 7 Frequently used BAPI:... 9 Sales and Distribution... 9 Material Management... 9 Production and Planning... 10 Finance... 10 ABAP Report using BAPI... 10 Testing the Report:... 13 Disclaimer and Liability Notice... 15 2007 SAP AG 2

Business Object Repository BOR Definition All SAP Business Object types and SAP Interface Types and their methods are defined and described in the R/3 Business Object Repository (BOR). The Business Object Repository was introduced in R/3 Release 3.0, at the same as time as SAP Business Objects and SAP Business Workflow. Presently, the BOR is mainly used by SAP Business Workflow. The BOR has two essential functions: It defines and describes SAP Business Objects and SAP Interface Types and their BAPIs. It creates instances of SAP Business Objects BAPI programming BAPIs are defined in the Business Object Repository (BOR) as methods of SAP Business Objects or SAP Interface Types and are implemented as function modules. The separation of a BAPI definition from its actual implementation enables you to access a BAPI in two ways: You can call the BAPI in the BOR through object-oriented method calls You can make RFC calls to the function module on which the BAPI is based 2007 SAP AG 3

Some Standard BAPI S GetList Delivers a list of key fields objects that satisfies certain selection Criteria GetDetail Delivers detailed information of an object, whose complete key has been Specified CreateFromData Generates new objects in R3 from key fields and returns information. 2007 SAP AG 4

2007 SAP AG 5

The code to illustrate the steps involved when the BAPI ActiveX Control is used to access BAPIs. Creating a BAPI ActiveX Control object Set obapictrl = CreateObject( SAP.BAPI.1 ) Creating a logon control object: Set ologonctrl = CreateObject( SAP.Logoncontrol.1") Creating a connection object to the R/3 System: Set obapictrl.connection = ologonctrl.newconnection Logging on to R/3 System by calling the logon method of the connection object: If obapictrl.connection.logon(frmstart.hwnd,false) = FALSE then MsgBox"R/3 Connection failed" End Endif 2007 SAP AG 6

Selecting the BAPI 1. Give Transaction BAPI, You will get the Following Screen Now based on you requirement you have to search for BAPI, Here we are going to search for BAPI related to Purchase Order. Purchase order is in MM so we select that from the list. We have to get purchase order detail, So Double click on the GetDetail. The right frame will show the BAPI name. 2007 SAP AG 7

Now Expand The GetList by pressing >, you will get the screen as below We need Purchase Order Header detail, so double Click Header; you will get Right Frame with the Dictionary Reference. The Dictionary Reference is BAPIEKKO; Note that you have to use that in Report. Double click that BAPIEKKO to see the fields that can be displayed in Report. 1 2 2007 SAP AG 8

Note down the Fields name from the Components Column that you need in the Report output. Frequently used BAPI: Sales and Distribution Customer Material Info Sales order Sales order BAPI_CUSTMATINFO_GETDETAILM BAPI_SALESORDER_GETLIST BAPI_SALESORDER_GETSTATUS Material Management Purchase Req Item Purchase order BAPI_REQUIREMENT_GET_LIST BAPI_PO_GETDETAIL Purchase order BAPI_PO_GETITEMS 2007 SAP AG 9

Purchase order Purchase order Purchasing info BAPI_PO_GETITEMSREL BAPI_PO_GET_LIST BAPI_INFORECORD_GETLIST Production and Planning Planned order Planned order BAPI_PLANNEDORDER_GET_DETAIL BAPI_PLANNEDORDER_GET_DET_LIST Planned Indep Reqmt BAPI_REQUIREMENTS_GETDETAIL Finance AP Account AP Account Debtor Credit Account AR Account AR Account AR Account BAPI_AP_ACC_GETOPENITEMS BAPI_AP_ACC_GETOPENITEMS BAPI_CR_ACC_GETDETAIL BAPI_AR_ACC_GETOPENITEMS BAPI_AR_ACC_GETPERIODBALANCES BAPI_AR_ACC_GETSTATEMENT ABAP Report using BAPI Now in The ABAP editor (SE38) create a new report and write the Code *&---------------------------------------------------------------------* *& Report ZBAPI_1 *& *&---------------------------------------------------------------------* *& *& BAPI TO GET PO ITEM DETAILS *&---------------------------------------------------------------------* REPORT ZBAPI_1. DATA : BEGIN OF I_POITEM OCCURS 0. INCLUDE STRUCTURE BAPIEKPO. Include the Structure of dictionary Ref. 2007 SAP AG 10

DATA : END OF I_POITEM. PARAMETERS P_EBELN LIKE EKKO-EBELN default '4500012164'.. Input. CALL FUNCTION 'BAPI_PO_GETDETAIL' EXPORTING PURCHASEORDER = P_EBELN * ITEMS = 'X' * ACCOUNT_ASSIGNMENT = ' ' * SCHEDULES = ' ' * HISTORY = ' ' * ITEM_TEXTS = ' ' * HEADER_TEXTS = ' ' * SERVICES = ' ' * CONFIRMATIONS = ' ' * SERVICE_TEXTS = ' ' * EXTENSIONS = ' ' * IMPORTING * PO_HEADER = * PO_ADDRESS = TABLES * PO_HEADER_TEXTS = PO_ITEMS = I_POITEM. Assign the Internal Table * PO_ITEM_ACCOUNT_ASSIGNMENT = * PO_ITEM_SCHEDULES = * PO_ITEM_CONFIRMATIONS = * PO_ITEM_TEXTS =. * PO_ITEM_HISTORY = * PO_ITEM_HISTORY_TOTALS = * PO_ITEM_LIMITS = * PO_ITEM_CONTRACT_LIMITS = * PO_ITEM_SERVICES = * PO_ITEM_SRV_ACCASS_VALUES = * RETURN = * PO_SERVICES_TEXTS = * EXTENSIONOUT = LOOP AT I_POITEM. WRITE :/ 'PO NUMBER = ', I_POITEM-PO_NUMBER COLOR COL_HEADING, 2007 SAP AG 11

ULINE. / 'ITEM = ', I_POITEM-PO_ITEM, / 'MATERIAL NAME = ', I_POITEM-MATERIAL, / 'MATERIAL = ', I_POITEM-PUR_MAT, / 'CHANGED ON = ', I_POITEM-CHANGED_ON, / 'SHORT TEXT = ', I_POITEM-SHORT_TEXT, / 'COMPANY CODE = ', I_POITEM-CO_CODE, / 'PLANT = ', I_POITEM-PLANT, / 'MATERIAL GROUP = ', I_POITEM-MAT_GRP, / 'QUANTITY = ', I_POITEM-QUANTITY LEFT-JUSTIFIED, / 'UNIT = ', I_POITEM-UNIT, / 'NET PRICE = ', I_POITEM-NET_PRICE LEFT-JUSTIFIED. ENDLOOP. Note: You can write any no fields from the Dictionary BAPIEKPO in the output, just Note the field and give that in the Write statement within LOOP ENDLOOP Output of the Report 2007 SAP AG 12

Testing the Report: Give transaction ME23 and give the Purchase order no, you can see the details of the report there. 2007 SAP AG 13

. 2007 SAP AG 14

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 2007 SAP AG 15