Currently Being Moderated
Robert. Eijpe

Using BAPI Extensions in SAP NetWeaver 7.0

Posted by Robert. Eijpe in r.eijpe on Dec 11, 2009 10:29:38 AM

Short Info.


 

How to  populate and read data into and from a BAPI extension.  BAPI’s  sometimes give you the options of EXTENSIONIN and/or EXTENSIONOUT. In the  releases before SAP NetWeaver 7.0 you would use the MOVE or MOVE-CORRESPONDING  statement to fill or read the EXTENTIONxx structures to your own structure.  (See SAP Help Netweaver '04 ). In SAP  NetWeaver 7.0 this move is no longer accepted. This blog will give a  description how it is done today using FIELD-SYMBOLS.


In SAP NetWeaver 7.0


In this blog I will use the BAPI’s for PROJECTS to show you how to read/write data from/to the extension part of the BAPI.

First let us have a look at the interface of the BAPI BAPI_BUS2001_GETDATA:



CALL FUNCTION 'BAPI_BUS2001_GETDATA'     EXPORTING       I_PROJECT_DEFINITION       =         
  •     I_LANGUAGE                 =
    IMPORTING       E_PROJECT_DEFINITION       =            TABLES
  •     ET_RETURN                  =
  •     EXTENSIONIN                =
  •     EXTENSIONOUT               = .
 


Code Example 1


You can see that there are two table definitions for extensions.


  • one for input (EXTENSIONIN)

  • one for output (EXTENSIONOUT).


To be able to read the data in table EXTENSIONOUT after the BAPI call we need to take care of a few steps.


Definition


Define a type for the content of the data in the table. Do this by creating a type that contains the field STRUCTURE of type TE_STRUC and include the structure that is described in the documentation for that BAPI. In our case the structure BAPI_TE_PROJECT_DEFINITION.


So we declare:



  1. an internal table for the table EXTENSIONOUT parameter

  2. a work area for that internal table

  3. a work area of the defined type

  4. and a Field-symbol with the defined type.


See the example below.



----
TYPES: BEGIN OF ty_cust,          structure TYPE te_struc.         INCLUDE STRUCTURE bapi_te_project_definition. TYPES: END OF ty_cust.

 

DATA: lt_bapiparex TYPE STANDARD TABLE OF bapiparex,       ls_bapiparex TYPE bapiparex,       ls_cust TYPE ty_cust.

 

FIELD-SYMBOLS: TYPE ty_cust. ----
  TYPE ty_cust.

 

PARAMETERS: pa_def LIKE bapi_bus2001_detail-project_definition.

 

START-OF-SELECTION.

 

  CALL FUNCTION 'BAPI_BUS2001_GETDATA'     EXPORTING       i_project_definition       =         pa_def
  1.     I_LANGUAGE                 =
    IMPORTING       e_project_definition       =         ls_2001     TABLES
  1.     ET_RETURN                  =
  2.     EXTENSIONIN                =
      extensionout               =           lt_bapiparex.

 

  LOOP AT lt_bapiparex INTO ls_bapiparex.     ASSIGN ls_bapiparex TO = ls_cust.   APPEND ls_bapiparex TO lt_bapiparex.

 

  CALL FUNCTION 'BAPI_BUS2001_GETDATA'     EXPORTING       i_project_definition       =         pa_def
  1.     I_LANGUAGE                 =
    IMPORTING       e_project_definition       =         ls_2001     TABLES
  1.     ET_RETURN                  =
      extensionin                =         lt_bapiparex.
  1.     EXTENSIONOUT               =       
 


Code Example 4


I hope this blog will help you start using the IN and OUT EXTENSIONS of BAPI’s in the new SAP NetWeaver 7.0 environment.

 


 

Special thanks to Leon Boeijen from NL for Business for helping me writing this weblog.</p> </div>

Comments

Filter Blog

By date: