User Exits - ABAP

11
© SAP AG 2003, Title of Presentation, Speaker Name 1 User Exits User Exits - - ABAP ABAP

Transcript of User Exits - ABAP

Page 1: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 1

User Exits User Exits -- ABAPABAP

Page 2: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 2

Chapter Overview

This chapter outlines:This chapter outlines:

ABAP Enhancement ConceptABAP Exit SummaryExample Implementation of CATS0002Analysis of CATS0002

Page 3: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 3

Content

Unit 7: Offline Database AccessUnit 7: Offline Database Access

Unit 9: UI EnhancementUnit 9: UI Enhancement

Unit 8: User Exits Unit 8: User Exits -- ABAPABAP

Unit 10 : Additional TechniquesUnit 10 : Additional Techniques

Page 4: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 4

ABAP Enhancement Concept

In conjunction with programming java enhancements on the Mobile Time and Travel application, it is also possible program enhancements in R/3

The exits provide by SAP provide “hooks” into the server-side synchronisation processAlthough linked to CATS, the exits provide enhancement capabilities for Travel Expense management too

The enhancements provide specific functionality which complement the offline exits, for example

Download of additional data to offline databaseSupplement pick listsAdditional server-side validation

The skills required to implement these exits are ABAP (preferably ABAP Objects)

Page 5: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 5

ABAP Enhancement Concept – Exit Summary

The following extract from the “CATS Notebook” documentation provides a summary of the exits:

Page 6: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 6

Example Implementation of CATS0002

The “CATS Notebook” developer documentation provides a list of ABAP exits available for enhancing the synchronisation process

A fully functional example of CATS0002 provides the basis for performing customer table downloads from R/3

Page 7: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 7

Example Implementation of CATS0002

An example implementation of CATS0002 is show below: This example performs the download of R/3 customer table ZMAXHOURS to offline customer table Z_MAXHOURS.xml

*----------------------------------------------------------------------

* INCLUDE ZXMYCU05

*----------------------------------------------------------------------

*"----------------------------------------------------------------------

*"*"Lokale Schnittstelle:

*" IMPORTING

*" REFERENCE(SAP_PERNR) TYPE P_PERNR

*" REFERENCE(SAP_PROFILE) TYPE TCATS-VARIANT

*" REFERENCE(SAP_LANGU) TYPE LANGU

*" TABLES

*" REFERENCE_TABLE TYPE TABLE

*"---------------------------------------------------------------------

**&-------------------------------------------------------------------

**& INCLUDE Name : ZXMYCU05

**& Module Name : T&E

**& Sub-Module : MYCATS

**& Author : R Chengappa

**& Program Type : User Exit

**& SAP Release : 4.6C

**& Transport no. :

**& Description : Download table ZMAXHOURS

**&

**&-------------------------------------------------------------------

Page 8: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 8

Example Implementation of CATS0002

tables: zmaxhours.

types: begin of zty_zmaxhours,

country type zmaxhours-country,

hoursmax type zmaxhours-hoursmax,

end of zty_zmaxhours.

types: ty_zmaxhours_tab type standard table of zty_zmaxhours

with default key.

data: zmaxhours_tab type ty_zmaxhours_tab.

data reference_zmaxhours type ref to data.

field-symbols: <zmaxhours> type any table.

create data reference_zmaxhours type ty_zmaxhours_tab.

assign reference_zmaxhours->* to <zmaxhours>.

select country hoursmax into table zmaxhours_tab

from zmaxhours.

<zmaxhours> = zmaxhours_tab.

assign component 1 of structure reference_table to <field>.

<field> = 'Z_MAXHOURS'.

assign component 2 of structure reference_table to <field>.

<field> = reference_zmaxhours.

append reference_table.

This ABAP code is executed during the synchronisation process by the synchronisation framework

Page 9: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 9

tables: zmaxhours.

types: begin of zty_zmaxhours,

country type zmaxhours-country,

hoursmax type zmaxhours-hoursmax,

end of zty_zmaxhours.

types: ty_zmaxhours_tab type standard table of zty_zmaxhours

with default key.

data: zmaxhours_tab type ty_zmaxhours_tab.

data reference_zmaxhours type ref to data.

field-symbols: <zmaxhours> type any table.

create data reference_zmaxhours type ty_zmaxhours_tab.

assign reference_zmaxhours->* to <zmaxhours>.

select country hoursmax into table zmaxhours_tab

from zmaxhours.

<zmaxhours> = zmaxhours_tab.

assign component 1 of structure reference_table to <field>.

<field> = 'Z_MAXHOURS'.

assign component 2 of structure reference_table to <field>.

<field> = reference_zmaxhours.

append reference_table.

Tables and types definitions

Data declarations

Reference declarations

Selection logic – can combine data from multiple tables based on business requirements

Assign and attach the results to the export parameter “reference_table”

Analysis of CATS0002

Page 10: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 10

Optimisation of ABAP Exits

The ABAP exits are invoked during the synchronisation process –hence when implementing ABAP exits, optimise the code to ensure swift and efficient data exchange

It is advisable to thus:Check whether the required data is already in the offline database! Either in one table or spread across multiple tables

Minimize the number of records/tables to be downloadedOnly send essential data to the offline database – avoid redundant fields.Minimise the number of records with efficient SQL queries – e.g. select data only relevant to that user, region, cost centre, etc

Implement Validation ChecksWhen implementing validation checks in the offline application, it is advisable to implement the same validation checks in ABAP to prevent inconsistencies

Page 11: User Exits - ABAP

© SAP AG 2003, Title of Presentation, Speaker Name 11

Chapter Overview

This chapter outlines:This chapter outlines:

ABAP Enhancement ConceptABAP Exit SummaryExample Implementation of CATS0002Analysis of CATS0002