93
Luc Vanrobays SAP Brasil Ltda InfoDay São Paulo, Maio 2010 [email protected] ABAP OO for BW

Abap Objects for BW

Embed Size (px)

Citation preview

Page 1: Abap Objects for BW

Luc VanrobaysSAP Brasil LtdaInfoDay São Paulo, Maio 2010

[email protected]

ABAP OO for BW

Page 2: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Agenda

Page 3: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Agenda

Page 4: Abap Objects for BW

What Are Objects

SAP AG 1999

What Are Objects?

Tree

House

Crane

Objects are an abstraction of the real world

Objects are units made up of data and of the functions belonging to that data

Real worldModel

DataMethodMethodMethod

DataMethodMethodMethod

DataMethodMethodMethod

Boat

DataMethodMethodMethod

Page 5: Abap Objects for BW

Classes

Classes are the central element of object-orientation.

A Class is an abstract description of an object.

Classes are templates for objects.

The attributes of objects are defined by the components of the class, which describe the state and behavior of objects.

You define global classes and interfaces in the Class Builder (Transaction SE24) in the ABAP Workbench.

They are stored centrally in class pools in the class library in the R/3 Repository.

All of the ABAP programs in an R/3 System can access the global classes.

Page 6: Abap Objects for BW

An ABAP OO Class – Transaction SE24

Page 7: Abap Objects for BW

ABAP Objects - Class Components

Visibility Sections: Public ProtectedPrivate

AttributesMethodsTypesEventsInterfaces Friends

Page 8: Abap Objects for BW

Class Visibility Sections

These sections define the external visibility of the class components and therefore the interfaces of the class for their users. Each component of a class must be explicitly assigned to one of the visibility sections.

Public visibility section

All components declared in the public visibility section defined with PUBLIC SECTION are accessible to all users as well as in the methods of all heirs and the class itself. The public components are the interface of the class to each user.

Protected visibility section

All components declared in the protected visibility section defined with PROTECTED SECTION are accessible in the methods of all heirs and in the class itself. The protected components form a specific interface between the class and its subclasses.

Private visibility section

All components declared in the private visibility section defined with PRIVATE SECTION are only accessible in the class itself, and are also not visible to the heirs. The private components therefore do not form an interface to the users of the class.

Page 9: Abap Objects for BW

Class Visibility Sections

Visibility Sections

Page 10: Abap Objects for BW

Class Attributes

Attributes Attributes are internal data objects of any ABAP data type within a class. The content of the attributes specifies the status of the object. You can also define reference variables, which you can then use to create and address objects. This allows objects to be accessed within classes.

Attributes are defined in the declaration part of a class. Public attributes are completely visible from outside the class and as such are part of the interface between objects and their user. To encapsulate the status of the object, you need to use protected or private attributes. You can also limit the changeability of attributes using the READ-ONLY addition during the declaration.

Instance Attributes

The content of instance attributes forms the instance-specific status of the object. Instance attributes are declared using the DATA statement.

Static Attributes The content of static attributes forms the instance-independent status of the object, which is valid for all instances of the class. Static attributes are available once for each class. They are declared using the CLASS-DATA statement and are retained throughout the entire runtime. All the objects within a class can access its static attributes. Changes to a static attribute in an object are visible to all other objects within that class.

Page 11: Abap Objects for BW

Class Attributes - Types

The Attribute “Type” definition can be maintained in the “Types” section of the Class – More on Types follows.

Page 12: Abap Objects for BW

Class Methods

Methods

Methods are internal procedures of a class that determine the behavior of an object. They can access all the attributes of their class and can thus change the object status. Methods have a parameter interface, through which the system passes values to them when they are called, and through which they can return values to the caller. The private attributes of a class can only be changed using methods, of the class owning the method.

You can declare local data types and data objects in methods, just as in all procedures. Methods are called using the CALL METHOD statement or one of its abbreviated forms. You can also call the method dynamically (dynamic invoke).

Page 13: Abap Objects for BW

Methods

Instance methods:

Instance methods are declared using the METHODS statement. They can access all the attributes of a class and can trigger all its events.

Require Instantiation of the Class – CREATE OBJECT

Static methods:

Static methods are declared using the CLASS-METHODS statement. They can access static attributes of a class and are allowed only to trigger static events.

Do not require instantiation

Can be used / Called w/o instantiation or reference to an instance

Do not rely on the state of an instance

Page 14: Abap Objects for BW

Class Methods

Method Parameters:

Importing

Exporting

Changing

Page 15: Abap Objects for BW

Constructor Methods

Constructors are special methods that produce a defined initial state for objects and classes. The state of an object is determined by its instance attributes and static attributes. You can assign contents to attributes using the VALUE addition in the DATA statement. Constructors are necessary when you want to set the initial state of an object dynamically.

Like normal methods, there are two types of constructor - instance constructors and static constructors.

Instance Constructors

Each class has one instance constructor. It is a predefined instance method of the constructor class. If you want to use the instance constructor, the constructor method must be declared in the declaration part of the class using the METHODS statement. Unless it is explicitly declared, the instance constructor is an implicit method, which inherits and accesses the interface from the instance constructor in the upper class.

Static Constructors

Each class has a single static constructor. This is a predefined, public, static method of the class named constructor. If you want to use the static constructor, you must declare the static method class_constructor in the public section of the declaration part of the class using the CLASS-METHODS statement, and implement it in the implementation part. The static constructor has no interface parameters and cannot trigger exceptions. Unless you implement it explicitly it is merely an empty method. The static constructor is executed once in each program. It is called automatically for the class before the class is accessed for the first time

Page 16: Abap Objects for BW

Constructor Methods

method CONSTRUCTOR.

select * from /BIC/PZCITY into CORRESPONDING FIELDS OF TABLE IT_CITY_SIZ where objvers = 'A'.

SORT IT_CITY_SIZ by /BIC/ZCITY.endmethod. method CONSTRUCTOR.

select * from /BIC/PZCITY into CORRESPONDING FIELDS OF TABLE IT_CITY_SIZ where objvers = 'A'.

SORT IT_CITY_SIZ by /BIC/ZCITY.endmethod.

Page 17: Abap Objects for BW

Data Types and Constants

Data types

Independent types The TYPES statement can be used to define any number of your own ABAP data types within a class. Types are not instance-specific and are only available once for all the objects in the class.

As of release 6.40, it is possible to define data types in the public visibility section.

Bound data types Bound data types that occur as properties of instance or static attributes also belong to the static attributes of a class. After a LIKE addition, the class name can be used to access the properties of instance attributes (exceptions to this rule are the statements ASSIGN ... CASTING and SELECT-OPTIONS ... FOR). In addition, a reference variable can be used with an object component selector without the object having previously been generated.

Constants Constants are special static attributes, whose values are specified when they are declared and which cannot be changed later. Use the CONSTANTS statement to declare constants. Constants are not instance-specific - they only once for all the objects in the class.

As of release 6.40, it is possible to define constants in the public visibility section of global classes.

Page 18: Abap Objects for BW

Data Types and Constants – Support All ABAP Types

Page 19: Abap Objects for BW

Events

In ABAP Objects, events are declared as components of classes. SAP makes a distinction between instance events and static events. Triggers and handlers can be objects and classes, depending on whether they are instance events, static events, or event handler methods.

Instance events

Instance events are declared using the EVENTS statement. They can only be triggered in instance methods.

Static events

Static events are declared using the CLASS-EVENTS statement. All methods (instance or static) can trigger them, but only static events can be triggered by static methods.

Page 20: Abap Objects for BW

Interfaces

The components of a class are divided into visibility sections, and this forms the external point of contact between the class and its users. For example, the components of the public section form the public interface of the class, since all attributes and method parameters can be accessed by any user.

The protected components form an interface between the class and those classes that inherit from it (subclasses).

Interfaces are independent structures that allow you to enhance the class-specific public points of contact by implementing them in classes. Different classes that implement the same interface can all be addressed in the same way. Interfaces are the basis for polymorpism in classes because they allow a single interface method to behave differently in different classes. Interface reference variables Interface references allow users to address different classes in the same manner. Interfaces can also be nested.

Page 21: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 22: Abap Objects for BW

The Motivation

For BW Consultants I see three motivating factors:ReusabilityOrganization / Consistency especially in transformations

Modern Approach to ABAP

Page 23: Abap Objects for BW

Note: Regarding the Location of the Scenario Samples

The samples of the scenarios that follow can be found in the BW7 Sandbox, with the exception of the Scenario BADI for BW Loading which is located in the corresponding ECC source system E60 client 001.

Page 24: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 25: Abap Objects for BW

Calling Class Methods in BW Routines

Once a class / class method has been created & activated, the easiest way to call the class method is through the ABAP editor “Patterns” pushbutton.

Enter or F4 for a list of the class methods

Page 26: Abap Objects for BW

Scenario – Class Methods in Transformations

We will be working with the transformation from Infocube 0D_SD_C03 (source) to InfoCube Z0DSD_C03 (target).

In the target InfoCube we have added the City Size (ZCITSIZ), which is determined using the city of the sold to and looking up the city size which is an attribute of the InfoObject ZCITY.

We have defined a class named ZCL_BW_TRAN_FKOM09, which contains the Methods:

FILL_IT_CIT_SIZ - Fills the internal table IT_CITY_SIZ of the class

GET_CITY_SIZ_VIA_SOLDTO – Using sold to, determines sold to city, then looks up city size in the internal table IT_CITY_SIZ .

Lets review the class & methods.

Page 27: Abap Objects for BW

Scenario – Class Methods in Transformations

In the Start Routine of the transformation from Infocube 0D_SD_C03 to InfoCube Z0DSD_C03, we will call the method FILL_IT_CIT_SIZ .

Page 28: Abap Objects for BW

Scenario – Class Methods in Transformations

In the transformation rule for the characteristic ZCITSIZ we will use

The source field 0D_ SOLD_TO and rule type routine where we will call the GET_CITY_SIZ_VIA_SOLDTO.

Page 29: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 30: Abap Objects for BW

Scenario – The Class Constructor

The purpose of this scenario is to demonstrate how the class constructor behaves in terms of producing a defined initial state for class objects, once the class is instantiated.

We will use the ABAP program ZSHOW_CONSTRUCTOR, which instantiates the ZCL_BW_TRAN_FKOM09 class, and then calls the GET_CITY_SIZ_VIA_SOLDTO method.

In our prior example we filled the internal table IT_CITY_SIZ by calling the method FILL_IT_CIT_SIZ in our start routine. In this example the internal table is filled through the CONSTUCTOR method once the class is instantiated.

Let’s take a look at this through the ABAP Editor & then use the debugger to show how the constructor fills the internal table.

Page 31: Abap Objects for BW

Scenario – The Class Constructor

REPORT ZSHOW_CONSTRUCTOR.

data: Xobject type ref to ZCL_BW_TRAN_FKOM09.

data: zout type c length 1.

*************************************************************************  S E L E C T I O N  S C R E E N************************************************************************parameters: p_soldto TYPE /BI0/OID_SOLD_TO obligatory.

*************************************************************************  Process by Instantiating a class implementation which has the effect*  of setting the initial state of class objects such as class attributes*  by executing the CLASS CONSTRUCTOR.*  In this example the class attribute 'IT_CITY_SIZ' an internal table*  is filled by the CLASS CONSTRUCTOR, then the method*  'GET_CITY_SIZ_VIA_SOLDTO' is executed.************************************************************************

create object xobject.

CALL METHOD ZCL_BW_TRAN_FKOM09=>GET_CITY_SIZ_VIA_SOLDTO EXPORTING IN_SOLD_TO = p_soldto IMPORTING OUT_CIT_SIZ = zout.

write: /01 text-001, sy-repid, 40 text-002 INTENSIFIED ON, 100 text-003, sy-datum, space.

write: /01 text-004, sy-uname, 40 text-005, 60 text-006, sy-uzeit, space.write: /.

write: /01 text-007, p_soldto, 40 text-008, zout.

Page 32: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 33: Abap Objects for BW

Scenario – Class Methods in the Userexit for Variables

In this scenario we will use the class ZCL_BW_TRAN_FKOM09 method ZVAR_GET12MOS_FRM_LASTCL in the SAP provided userexit for variables EXIT_SAPLRRS0_001.

We need a Bex Variable that will determine an interval for the time characteristic 0CALMONTH ending with the last closed month as determined in TVARVC and beginning with the month 11 months before the last closed month.

The TVARV variable Z_LAST_CLOSED_MONTH will hold the last closed month (transaction STVARV).

Let’s take a look at the method & run it through in the test mode.

We can also use Query ZJPL_ABAPOO_METH_VAR_USEREXIT to verify our results, then re-run the query after changing the value of the TVARVC variable Z_LAST_CLOSED_MONTH via STVARV.

Page 34: Abap Objects for BW

Scenario – Class Methods in the Userexit for Variables

CASE I_VNAM.

WHEN 'ZVAR_CALMON_INTVL_TVARVC_LST12'. IF i_step EQ 2. CALL METHOD ZCL_BW_TRAN_FKOM09=>ZVAR_GET12MOS_FRM_LASTCL IMPORTING L_S_RANGE = L_S_RANGE.endif. APPEND L_S_RANGE TO E_T_RANGE.

ENDCASE.

Page 35: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 36: Abap Objects for BW

Scenario - Custom Functions in the Formula Builder

BAdI: Customer-defined Functions in Formula BuilderUseThis Business Add-In (BAdI) is used in the formula builder

transformation library. You use this BAdI to integrate user-defined functions into the transformation library of the formula builder. In this way, you can make special functions that are not contained in the standard delivery available for Transfer Rules, Update Rules, Transformations, Process Chain Process Types, APD’s etc.

RequirementsThe technical name of a user-defined functionMust be specifiedMust be uniqueMust begin with 'C_'Can contain only alphanumeric characters

( ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_) (lower-case letters, empty spaces and special characters are not allowed)

Can be a maximum of 61 characters long.Standard settingsThe BAdI can be used repeatedly. Is it not filter-dependent.ActivitiesAfter you have called up the IMG activity, a dialog box appears in

which you enter a name for implementation.If implementations have already been created for this BAdI, a dialog

box appears in which the existing implementations are displayed. In this dialog box, choose Create and proceed as follows:

Continued on next Slide

Page 37: Abap Objects for BW

Custom Functions in the Formula Builder

Steps Continued from prior Slide:

1. In the Implementation field, enter a name for the implementation of the BAdIs and choose Create.

2. The initial screen for creating BAdI implementations appears.

3. In the initial screen, in the Short Text for Implementation field, enter a short text for the implementation.

4. Choose the Interface tab index.

5. On the tab page, the field Name of Implemented Class is filled automatically, since the system assigns a class name based on the name of your implementation.

6. Save your entries and assign the implementation to a development class.

7. Position the cursor on the method and double-click on it to reach the method editing screen.

8. Between the statements method <Interface Name>~<Name of Method>. and endmethod. the coding for your implementation.

9. Save and activate your coding and return to the Change Implementation screen.

10. Save your entries on the Change Implementation screen.

Note: You can create an implementation for a BAdI and activate it later. If this is the case, close the editing screen now.

11. Choose Activate.

When you execute the application program, the coding you defined in the method is executed

Page 38: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision Process Type (0) Scenario I – when to condense ?

In order to decide when is the rigth time to operate some Process Type(Condense InfoProvider, Delete Change Log, Delete PSA etc..) that might have a negative impact on Perfromance at the wrong moment:

We set up the Alternate Decision Step in our Process Chain along with a Z Custom Fox Formula with Multiple Alternatives (IF-ELSEIF-ELSEIF-ENDIF) and a Z custom decision table that have criterias such as InfoProvider, Process Type and Rule Type (Odd-Even Days, Daily, Weekly, Monthly, Other)

D Daily between 0600 PM and 0900 AM.

M > will happen only the last day of the month (18:00 till 12:00 next day)

M Mês = 7 and Valor Livre = 23 wil happen only on 23 July YYYY (Any Year)

A and Valor Livre = 1 > Process Type will happen on Even Days: Tuesday(2)-Thursday(4)-Saturday(6)

A and Valor Livre = ‘’ > Process Type will happen onOdd Days : Monday(1)-Wened(3)-Friday(5)-Sunday(7)

M and Valor Livre = ‘20090725’ – Selected day – anytime.

S and WeekDay1 = 5 > Will Process Weekly On Friday

Page 39: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision (5) – When to Condense ? - ZTABLE

Page 40: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision Process Type (1) Scenario I – when to condense ?

Page 41: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision Process Type (2) Scenario I – when to condense ?

Page 42: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision Process Type (3) Scenario I – when to condense ?

To merge this result with the decision process step development we will go through the steps quickly here:

Activate the BADI RSAR_CONNECTOR

Integration of self-defined functions in the transformation library of the formula builder(See document: Enhancements in SAP BW by Gary Nolan Know - How Network Call March 31, 2004) In SE18 create new implementation: And here are the two screens after clicking Display/Change: And the Interface tab:

Create new class ZCL_IM_CL_BW_FORM_BUILDER.

For this class implement interface: IF_EX_RSAR_CONNECTOR. For this interface implement one method: IF_EX_RSAR_CONNECTOR~GET. Here is the code under the method IF_EX_RSAR_CONNECTOR~GET.

Read the comments in the code. These are largely transparent and useful. Most of this code is provided by SAP.

Page 43: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision Process Type (3)

Custom = User-Defined FunctionsWe created a boolean custom formula function C_COMP_CUBO with two parameters : InfoProvider and Process Type

Page 44: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision Process Type (4)

Custom = User-Defined Functions

We have created a boolean custom formula function C_COMP_CUBO with two parameters : InfoProvider and Process Type

We created a Z decision Table to define the specific processing

Page 45: Abap Objects for BW

Custom Formula (Fox) in Alternate Decision (5) – When to Condense or Delete Chge Log ?

METHOD check_compression_rule.

* Methodo precisa de um parametro a providenciar na FOX Formula*  Infoprovider* Methodo precisa de um parametro a providenciar na FOX Formula*  Infoprovider* Retorna um Booleano 'X' se for o momento de processar*Compressão - Deleção Chge Log - Deleção PSA Etc*ABAP  Programa ABAP*AGGRFILL  Preenchimento inicial de novos agregados*ARCHIVE  Arquivar dados de um InfoProvider*ATTRIBCHAN  Execução de modificação de atributo*BIAINDEX  Ativação inicial e preenchimento de índices BI accelerator*CHAIN  Cadeia de processos local*CHGLOGDEL  Eliminação de requisições do log de modificação*CLEARTODS  Elimina conteúdo total do ODS transacional acoplado*COMMAND  Comando do sistema operacional*COMPRESS  Comprimir InfoCubo*CPS_EVENT  Evento em CPS SAP (Redwood)*CPS_JOB  Job em CPS SAP (Redwood)*DATACHANGE  Acionar evento modificação de dados (p/BEx Broadcaster)*DBSTAT  Estruturar estatística do banco de dados*DROPCUBE  Eliminação completa do conteúdo do destino de dados*DROPINDEX  Eliminar índice*DTP_LOAD  Processo de transferência de dados*INDEX  Estruturar índice*LOADING  Executar InfoPackage*LPI  InfoPackages particionados lógicos*MAIL  Enviar mensagem*MDREORG  Reorganizar atributos e textos dados mestre*MDUPDATEGK  Atualização de dados mestre com chaves globais*ODSACTIVAT  Ativar dados do objeto DataStore*ODSPROCESS  Atualizar dados objeto DataStore (continuação atualização)*OPENHUB  Exportação de dados para sistemas externos (obsoleto)*PC_ACTIVE  A execução anterior da cadeia ainda está ativa?*PLSEQ  Executar seqüência de planejamento*PLSWITCHL  Comutar InfoCubo tempo real para o modo de carregamento*PLSWITCHP  Comutar InfoCubo tempo real para o modo de planejamento*PSADELETE  Eliminação de requisições do PSA*PSAPROCESS  Ler PSA e atualizar destino de dados*RDA_CLOSE  Encerrar requisição de um InfoPackage (RDA/Push)*RDA_RESET  Suspender proc.cargmto.obtenção de dados em tempo real (RDA)*RDA_START  Iniciar proc.cargmto.obtenção de dados em tempo real (RDA)*REMOTE  Cadeia de processos remota*REPA_BB  Cálculo prévio de conjuntos de valores*REPA_BC  Cálculo prévio de modelos Web*REPA_BP  Imprimir em background*REPA_ER  Exception reporting*REQUDEL  Eliminar requisições sobrepostas do InfoCubo*ROLLUP  Efetuar roll-up agregados/índices BI accelerator preenchidos*R_SALES2XI  Enviar dados de vendas POS para sistema XI*TIMCHNGRUN  Ajustar agregados dependentes do tempo*WORKFLOW  Workflow (também remoto)*Z_ABAP_RES  Programa ABAP com Retorno G ou R

TYPE-POOLS: rs.

TYPES: l_rspcvariant TYPE rspcvariant,

t_rspcvariant TYPE STANDARD TABLE OF l_rspcvariant,

l_datastate TYPE v_rsmdatastate,

t_datastate TYPE STANDARD TABLE OF l_datastate,

l_regras TYPE zbc_glregcompr,

t_regras TYPE STANDARD TABLE OF l_regras,

BEGIN OF g_y_data, requid TYPE /bi0/oirequid, calmonth TYPE /bi0/oicalmonth, END OF g_y_data.

DATA: cubo LIKE i_infoprov, l_regra_mths TYPE /bi0/oifc_count.

DATA: dt_regras TYPE t_regras, s_regras TYPE l_regras, dt_datastate TYPE t_datastate, s_datastate TYPE l_datastate.

DATA: g_s_sfc TYPE rsdri_s_sfc, g_th_sfc TYPE rsdri_th_sfc, s_t_data TYPE g_y_data,* G_S_SFK  = description of a key figure that is requested by a query g_s_sfk TYPE rsdri_s_sfk, g_th_sfk TYPE rsdri_th_sfk,

* G_S_RANGE = description of a restriction on a characteristic or*             navigational attribute g_s_range TYPE rsdri_s_range, g_t_range TYPE rsdri_t_range.

DATA: g_end_of_data TYPE rs_bool, g_first_call TYPE rs_bool.

DATA: g_t_data TYPE STANDARD TABLE OF g_y_data.

DATA: min_mth TYPE /bi0/oicalmonth, max_mth TYPE /bi0/oicalmonth, dt_min TYPE sy-datum, dt_max TYPE sy-datum, ct_mes TYPE /bi0/oifc_count, wkday TYPE cind, andy TYPE n LENGTH 8.

DATA: to_day TYPE sy-datum, my_day TYPE sy-datum, hhss TYPE sy-uzeit, zcor TYPE c LENGTH 1, zcormes TYPE /bi0/oicalmonth2, comp_tmstp TYPE ad_tstamp, comp_date TYPE sy-datum, hoje TYPE sy-datum, diff TYPE p. DATA : par TYPE float.

DATA: dt_rspcvariant TYPE t_rspcvariant, l_variante TYPE rspc_variant.

DATA: l_reg_mths TYPE num2.

CONSTANTS: c_yrs TYPE num2 VALUE 0, c_dys TYPE num2 VALUE 0.

*  ZCRGAD10 cubo = i_infoprov.

SELECT * INTO CORRESPONDING FIELDS OF TABLE dt_regras FROM zbc_glregcompr WHERE infocube = i_infoprov.

IF sy-subrc = 0.

CLEAR s_regras.

READ TABLE dt_regras INTO s_regras WITH KEY type = i_type.

CASE s_regras-regra.

WHEN 'D'. "daily - diario IF sy-uzeit BETWEEN '180000' AND '235959' OR sy-uzeit BETWEEN '000000' AND '090000'. return = 'X'. ELSE. return = ''. ENDIF.

WHEN 'S'. "semanal - weekly

* zbc_glregcompr tem o dia para comprimir CALL FUNCTION 'DATE_COMPUTE_DAY' EXPORTING date = sy-datum IMPORTING day = wkday. diff = wkday - s_regras-weekday1.

IF diff = 0. return = 'X'.

ELSE.

* se for previsto comprimir tal dia da semana* mas que a compressão anterior aconteceu amais de 7 dias* > não deixa mais de 7 dias sem compressão

CLEAR: comp_tmstp,diff.

SELECT SINGLE * INTO CORRESPONDING FIELDS OF s_datastate FROM v_rsmdatastate WHERE dta_type = 'CUBE' AND bwobject = i_infoprov AND NOT ts_comp_changed IS NULL.

IF sy-subrc = 0. CLEAR: comp_tmstp.

MOVE s_datastate-ts_comp_changed TO comp_tmstp.

IF comp_tmstp = 0. MOVE '19000101000000' TO comp_tmstp. ENDIF.

CALL FUNCTION 'ADDR_CONVERT_TIMESTAMP_TO_DATE' EXPORTING iv_timestamp = comp_tmstp IMPORTING ev_date = comp_date.

CALL FUNCTION 'Z_CIGE_SD_DATETIME_DIFFERENCE' EXPORTING date1 = sy-datum date2 = comp_date IMPORTING datediff = diff.

IF diff GE 7 AND ( sy-uzeit BETWEEN '180000' AND '235959' OR sy-uzeit BETWEEN '000000' AND '090000' ).

return = 'X'.

ELSE.

return = ''.

ENDIF.

ENDIF. ENDIF.

WHEN 'M'.

* compressão mensal* se valor livre = empty > final do mês - cenario snapshot* ultimo dia do mes ate o primeiro dia do mes seguinte hora 120000.

IF s_regras-valorlivre IS INITIAL AND s_regras-mes IS INITIAL.

IF sy-datum+6(2) = '01' AND sy-uzeit BETWEEN '000000' AND '120000'. my_day = sy-datum - 1. zcor = 'X'. ELSE. my_day = sy-datum. ENDIF.

CALL FUNCTION 'Z_GET_MONTH_LASTDAY' EXPORTING i_date = my_day IMPORTING e_date = to_day.

IF zcor NE 'X' AND sy-datum = to_day AND sy-uzeit BETWEEN '180000' AND '235959'. return = 'X'. ELSEIF zcor EQ 'X' AND my_day = to_day. return = 'X'. ELSE. return = ''. ENDIF.

ELSEIF NOT s_regras-valorlivre IS INITIAL AND s_regras-mes IS INITIAL.* s_regras-VALORLIVRE NOT INITIAL > determina o dia do mes para comprimir

CLEAR: diff, andy.

andy = sy-datum. diff = andy - s_regras-valorlivre. IF diff = 0. return = 'X'. ELSE. return = ''. ENDIF.* o mes fixo é determinado nas regras - a compressão acontece no ultimo dia /primeiro dia ELSEIF s_regras-valorlivre IS INITIAL AND NOT s_regras-mes IS INITIAL.

IF sy-datum+6(2) = '01' AND sy-uzeit BETWEEN '000000' AND '120000'. my_day = sy-datum - 1. zcor = 'X'. zcormes = sy-datum+4(2). ELSE. my_day = sy-datum. ENDIF.

CALL FUNCTION 'Z_GET_MONTH_LASTDAY' EXPORTING i_date = my_day IMPORTING e_date = to_day.

IF zcor NE 'X' AND sy-datum = to_day AND sy-uzeit BETWEEN '180000' AND '235959' AND sy-datum+4(2) = s_regras-mes. return = 'X'. ELSEIF zcor EQ 'X' AND my_day = to_day AND sy-datum+4(2) = zcormes. return = 'X'. ELSE. return = ''. ENDIF.* o mes fixo é determinado nas regras - a valor livre indica o dia do mes ELSEIF NOT s_regras-valorlivre IS INITIAL AND NOT s_regras-mes IS INITIAL. IF sy-datum+4(2) = s_regras-mes AND sy-datum+6(2) = s_regras-valorlivre. return = 'X'. ELSE. return = ''. ENDIF. ENDIF.

WHEN 'A'.

* compressão dia da semana impar > regra A e valor livre inicial* impares : segunda(1) - quarta(3) - sexta(5) - domingo(7)* compressão dia da semana par > regra A e valor livre not inicial* pares : terça(2) - quinta(4) - sabado(6)

CLEAR: par.

CALL FUNCTION 'DATE_COMPUTE_DAY' EXPORTING date = sy-datum IMPORTING day = wkday.

COMPUTE par = wkday mod 2.

IF NOT s_regras-valorlivre IS INITIAL. "par escolhido IF par = 0 AND ( sy-uzeit BETWEEN '180000' AND '235959' OR sy-uzeit BETWEEN '000000' AND '090000'). . return = 'X'. ENDIF. ELSEIF s_regras-valorlivre IS INITIAL. "impar escolhido IF par <> 0 AND ( sy-uzeit BETWEEN '180000' AND '235959' OR sy-uzeit BETWEEN '000000' AND '090000'). return = 'X'. ENDIF. ENDIF.

WHEN 'O'.

* espera-se aqui ZCRGAD10 com regra O e valorlivre de 13 (meses)

IF NOT s_regras-valorlivre IS INITIAL.

MOVE s_regras-valorlivre TO l_regra_mths.* verificar o conteúdo do cubo IF i_infoprov+3(5) = 'GAD10'. "'ZCRGAD10' Non-Cumulative para Stock CLEAR g_s_sfc. g_s_sfc-chanm = '0REQUID'.* --- name of corresponding column in G_T_DATA g_s_sfc-chaalias = 'REQUID'.* --- no ORDER-BY g_s_sfc-orderby = 0.* --- include into list of characteristics INSERT g_s_sfc INTO TABLE g_th_sfc.* 0CALMONTH CLEAR g_s_sfc. g_s_sfc-chanm = '0CALMONTH'.* --- name of corresponding column in G_T_DATA g_s_sfc-chaalias = 'CALMONTH'.* --- no ORDER-BY g_s_sfc-orderby = 0.* --- include into list of characteristics INSERT g_s_sfc INTO TABLE g_th_sfc.

WHILE g_end_of_data = rs_c_false.

CALL FUNCTION 'RSDRI_INFOPROV_READ' EXPORTING i_infoprov = cubo i_th_sfc = g_th_sfc i_th_sfk = g_th_sfk i_t_range = g_t_range i_reference_date = sy-datum i_save_in_table = rs_c_false i_save_in_file = rs_c_false i_packagesize = 500 IMPORTING e_t_data = g_t_data e_end_of_data = g_end_of_data CHANGING c_first_call = g_first_call EXCEPTIONS illegal_input = 1 illegal_input_sfc = 2 illegal_input_sfk = 3 illegal_input_range = 4 illegal_input_tablesel = 5 no_authorization = 6 illegal_download = 8 illegal_tablename = 9 OTHERS = 11.

IF sy-subrc <> 0. IF sy-uname(3) = 'FF_' OR sy-uname(3) = 'SAP'. BREAK-POINT. ENDIF. EXIT. ENDIF. ENDWHILE.

IF NOT g_t_data IS INITIAL.

* desconsiderar info já comprimida DELETE g_t_data WHERE requid IS INITIAL.* determinar o primeiro mes do request não comprimido SORT g_t_data BY calmonth ASCENDING. READ TABLE g_t_data INTO s_t_data INDEX 1. MOVE s_t_data-calmonth TO min_mth.* determinar   o ultimo mes do request não comprimido SORT g_t_data BY calmonth DESCENDING. READ TABLE g_t_data INTO s_t_data INDEX 1. MOVE s_t_data-calmonth TO max_mth.

CONCATENATE min_mth '01' INTO dt_min. CONCATENATE max_mth '01' INTO dt_max.

l_regra_mths = l_regra_mths - 1.

CALL FUNCTION 'Z_CIGE_MTH_BTW_TWODTES' EXPORTING i_date_to = dt_max i_date_from = dt_min IMPORTING e_month = ct_mes.

DATA : last_day TYPE sy-datum, day_past TYPE sy-datum, l_days TYPE p.

IF ct_mes = l_regra_mths.

CALL FUNCTION 'Z_GET_MONTH_LASTDAY' EXPORTING i_date = sy-datum IMPORTING e_date = last_day.

l_reg_mths = l_regra_mths.

CALL FUNCTION 'Z_CIGE_CALC_DATE_IN_INTERVAL' EXPORTING days = '00' date = last_day months = l_reg_mths signum = '-' years = '00' IMPORTING calc_date = day_past.

CALL FUNCTION 'Z_CIGE_SD_DATETIME_DIFFERENCE' EXPORTING date1 = sy-datum date2 = day_past IMPORTING datediff = l_days EXCEPTIONS invalid_datetime = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.

SELECT SINGLE variante INTO l_variante FROM rspcvariant WHERE type = i_type AND fnam = 'DTA_CUBE' AND low = 'ZCRGAD10'.

IF sy-subrc = 0.

UPDATE rspcvariant SET low = l_days WHERE variante = l_variante AND type = i_type AND fnam = 'DAYS_RNR_NOT_PROC'.

IF sy-subrc = 0. COMMIT WORK. return = 'X'. ENDIF. ELSE. return = ''. RAISE no_variant_for_cube. ENDIF.

ENDIF. ENDIF. ENDIF. ENDIF. WHEN OTHERS. ENDCASE. ENDIF.

ENDMETHOD.

Page 46: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (1) – Set the Semaphore

Use Decision Process Type and a Custom Formula to Control Process Chain Flow

Scenario:

This is a simple test scenario designed to illustrate the technique.

You have a task to execute different branches of a Process Chain depending on conditions in the System.

These conditions can be determined via ABAP code.

The conditions could be :

state of data, date, time, factory calendar or other settings changed by the user, etc.,

This Scenario can also set a semaphore (in TVARVC) as STOP or CONTINUE if some conditions are or are not met.

Page 47: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (2) – Set the Semaphore

Here is the final chain you have to deliver:

The Start step of the chain is triggered by an event.

The second step, the decision process type, directs the flow and either:

1) runs the ABAP process step - wait one minute - and subsequently the ABAP process step - continue(trigger event), or

2) runs the ABAP process step - wait two minute- and terminates, or

3) errors out, in case the state could not be defined, and terminates.

4) In addition, in our example, the event triggered is the same event which starts the chain.

Page 48: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (3) – Set the Semaphore

Consequently, in case 1) the chain will restart and continue executing (will loop) until conditions change and the decision process type directs it to 2) or 3).

For the purpose of our example we created a record in TVARV table with key:

NAME = ZDW_CONTROL. We control the flow by changing the value of field LOW.

Possible values are ‘STOP’ or 'CONTINUE'.

Any other value will cause Decision to error out.

Here is how this entry looks: Or: Creating the elements: To achieve the above result, the most complicated part is creating a custom formula. This is very well documented by SAP (see references at the end).

Page 49: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (4) - IF_EX_RSAR_CONNECTOR~GET Code

All this method does is to append a formula to the list of available formulas METHOD if_ex_rsar_connector~get. DATA: l_function TYPE sfbeoprnd.* Structure with the description of the function CASE i_key.*      importing parameter: key with the function category WHEN 'CUSTOM'.* The BAdI implementation is always accessed with the ‘CUSTOM’ key. CLEAR l_function. l_function-tech_name = 'C_COMP_CUBO'.* Aparece mais tarde no nome tecnico da coluna e preciso ser unico l_function-descriptn = 'Determina Se For Hora de Comprimir'.* Aparece mais tarde na coluna Dexcrição. l_function-class = 'Z_CL_FORMULAS'.* Nome da Classe que implementa o methodo que implementa a formula l_function-method = 'CHECK_COMPRESSION_RULE'.* Nome do Methodo que implementa a formula APPEND l_function TO c_operands.* Changing parameter: Table with descriptions of the function l_function-tech_name = 'C_CHECK_LOAD'. l_function-descriptn = 'Check Load'. l_function-class = 'Z_CL_FORMULAS'. l_function-method = 'CHECK_LOAD'. APPEND l_function TO c_operands. ENDCASE.ENDMETHOD. "IF_EX_RSAR_CONNECTOR~GET

As a result you should see two formulas C_COMP_CUBO, C_ZDW_CHECK_LOAD in the formula screen:

Page 50: Abap Objects for BW

Custom Formula with Alternate Decision – Custom Formulas Availables (6)

Page 51: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (6) - new method CHECK_LOAD

In the newly created new class Z_CL_FORMULAS Implement another method: CHECK_LOAD

Create this method with two parameters: CONTROL and RETURN

Page 52: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (7) - new method CHECK_LOAD

method CHECK_LOAD.* The control parameter allows multiple checks to be implemented:* We may have if,...elseif,...elseif,...else,...endif. statement* We created a record in table TVARV with name Z_PC_CONTROL* We can control the flow by changing*  the value of field LOW in the record:*  NAME = 'Z_PC_CONTROL' of table TVARV* ************************************************************************ data f_low like control. select single LOW into f_low from TVARV where NAME = 'Z_PC_CONTROL' and TYPE = 'P' and NUMB = '0000'. if f_low = control. return = 'X'. else. return = ''. endif.endmethod.

Page 53: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (8) - new method CHECK_LOAD

FUNCTION ZWRITE_TVARVC.*"----------------------------------------------------------------------*"*"Interface local:*"  TABLES*"      T_VALUES STRUCTURE  TVARVC*"  EXCEPTIONS*"      UPDATE_FAILED*"      OTHERS*"---------------------------------------------------------------------- TYPES: l_values type tvarvc. DATA: s_values TYPE l_values.

MOVE t_values to s_values. MODIFY tvarvc FROM s_values.

IF SY-SUBRC = 0. COMMIT WORK. ELSE. RAISE UPDATE_FAILED. ENDIF.

ENDFUNCTION.

Page 54: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (9) – Decision Step

Create the Decision step as follows:

Customize the formulas:

C_CHECK_LOAD( 'CONTINUE' ) And: C_CHECK_LOAD( 'STOP' )

ABAP code: In this example ABAP process steps

wait one minute wait two minutes and after error just exit- Use the following report Z_CIGE_TIME_WAIT with different parameter

settings:

Page 55: Abap Objects for BW

Custom Formula with Alternate Decision – Scenario II (8) - Z_CIGE_TIME_WAIT

REPORT Z_CIGE_TIME_WAIT.

PARAMETER: P_WAIT TYPE I,*           p_server LIKE MSXXLIST-NAME, P_event TYPE btceventid.START-OF-SELECTION.WAIT UP TO P_WAIT SECONDS.* The ABAP process step continue(trigger event)* uses metodo cl_batch_event=>raise to trigger event.

CALL METHOD cl_batch_event=>raise EXPORTING i_eventid = p_event EXCEPTIONS excpt_raise_failed = 1 excpt_raise_forbidden = 3 excpt_unknown_event = 4 excpt_no_authority = 5 OTHERS = 6.

CASE sy-subrc. WHEN 0. EXIT. WHEN 1 OR 3. RAISE raise_failed. WHEN 4. RAISE eventid_does_not_exist. WHEN OTHERS. RAISE raise_failed. ENDCASE.

Page 56: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 57: Abap Objects for BW

Scenario: - BADI for BW Loading - RSU5_SAPI_BADI

Scenario: Need to Enhance 2LIS_03_BF with MBEW-VPRSV Price Control (MAC or Standard). Since this can change month to month customer wants the value of VPRSV at the time of Material Doc Creation.

Note:Normally this should be handled via SMOD MCB10001 in a CMOD implementation, but due to

constraints on suitable datasources of the sandbox application tables with data in the I chose 2LIS_03_ITM to

demonstrate the load BADI.

Steps Taken in

month to month customer wants the value of VPRSV at the time of Material Doc Creation.

VIA SE11 added the field VPRSV to structure MCMSEGUSR.

VIA LBWE Maintained the 2LIS_03_BF STRUCTURE - Transferred VPRSV from right to left

VIA LBWE Un Hide VPRSV and generated the 2LIS_03_BF DataSource, and activated the update.

IN BW7 Replicated 2LIS_03_BF

Created a classic Implementation of the RSU5_SAPI_BADI named Z_FKOM_2009_LOADDATA

Using the DATA_TRANSFORM method of the RSU5_SAPI_BADI implemented the code to acquire the VPRSV value of each MATERIAL movement doc line item that contains a valid material.

Page 58: Abap Objects for BW

BADI for BW Loading - RSU5_SAPI_BADI

Use SE19

This Business Add-In (BAdI) is used in the SAP Business Information Warehouse Extractors (BC-BW) component. Using this BAdI you are able to either fill fields with data, or change the content of the DataSource fields that you added to the extract structure of a DataSource as an append structure.

Requirements

If you want to fill the fields of an append structure, create an append structure for the DataSource.You can find more information on append structures in the Web Application Server documentation in the SAP Library at ABAP Workbench -> ABAP Dictionary, in the section Tables.

Standard settings

Business Add-In is active in the standard system.

Business Add-In can be used more than once. All active implementations are called up and executed.

Business Add-In is not dependent on a filter.

Page 59: Abap Objects for BW

BADI for BW Loading - RSU5_SAPI_BADI

Activities: Via Transaction SE19 if creating a new BADI implementation, Enter the BADI name RSU5_SAPI_BADI in the Classic BADI, BADI name input field of the Create Implementation section, then select Create.

Or, If you are editing an existing implementation of the BADI, enter the implementation name in the classic BADI implementation name field of the Edit Implementation section.

Page 60: Abap Objects for BW

BADI for BW Loading - RSU5_SAPI_BADI

You then reach the initial screen for creating BAdI implementations. In the field implementation Short text , enter a short text for the implementation.

Page 61: Abap Objects for BW

- BADI for BW Loading - RSU5_SAPI_BADI

Select the Interface tab. The Name of implementing class field on the interface tab page is filled automatically. The system allocates a class name based on the name of your implementation.Here:ZCL_IM_ZRSU5_SAPI_BADI and has two methods.

Save your entries and assign a package for transport.

Page 62: Abap Objects for BW

Add four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (1).

Besides methods inherited from the BADi

IF_EX_RSU5_SAPI_BADI~DATA_TRANSFORMIF_EX_RSU5_SAPI_BADI~HIER_TRANSFORM We create now 4 new methods (in case they do not already exist)

_CALL_DATASOURCE_CHECK_BW_SYSTEM_TEMPLATE_DATASOURCE _CHECK_METHOD_EXISTS

Page 63: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (1).

_CHECK_METHOD_EXISTS Description “Check if the implementation of datasource is done” Level Static Visibility PublicParametersIV_CMPNAME Importing Type SEOCMPNAME “Component name”RV_EXISTSReturning (Value Transfer) Type CHAR01 “Method Exists”Exceptions None

With the following code:METHOD _check_method_exists.

DATA: lv_clsname TYPE seoclskey.*  FIELD-SYMBOLS: "<ls_method>      TYPE seoo_method_r,*                 <ls_method_ex>   TYPE seoo_method_r. CLEAR rv_exists. IF ct_methods IS INITIAL. lv_clsname-clsname = 'ZCL_IM_RSU5_SAPI_BADI'. CALL FUNCTION 'SEO_METHOD_READ_ALL' EXPORTING cifkey = lv_clsname version = seoc_version_active IMPORTING methods = ct_methods EXCEPTIONS clif_not_existing = 1 OTHERS = 2. IF sy-subrc <> 0. ENDIF. DELETE ct_methods WHERE cmpname(1) = '_'. ENDIF.* check existence READ TABLE ct_methods TRANSPORTING NO FIELDS WITH KEY cmpname = iv_cmpname. IF sy-subrc EQ 0. rv_exists = 'X'. ENDIF.ENDMETHOD.

Page 64: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (2).

_CHECK_BW_SYSTEM Description “Checks what system is doing the request”(could be BOBJ not BW) Level Static Visibility Public

Parameters RV_IS_EDWH Returning (Value Transfer) Type CHAR01 “Request is a EDWH Request”Exceptions None

With the following code:METHOD _check_bw_system.

rv_is_edwh = 'X'.

* FIELD-SYMBOLS: <ls_request> TYPE rosrequest.* CLEAR rv_is_edwh.** in online mode (extraction checker) just do it* IF sy-batch IS INITIAL.* rv_is_edwh = 'X'.* EXIT.* ENDIF.** IF cv_bwsystem IS INITIAL.** get request parameters* ASSIGN ('(SBIE0001)REQUEST') TO <ls_request>.** finally* cv_bwsystem = <ls_request>-rcvprn.* ENDIF.*** check* IF cv_bwsystem(3) = 'DED'* OR cv_bwsystem(3) = 'QED'* OR cv_bwsystem(3) = 'PED'.* rv_is_edwh = 'X'.* ENDIF.

ENDMETHOD.

Page 65: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (3.1).

_CALL_DATASOURCE Description “Call Individual Method for Each DataSource” Level Static Visibility Public

Parameters

I_DATASOURCE Importing (Value Transfer) Type RSAOT_OLTPSOURCE I_UPDMODE Importing (Value Transfer) Type SBIWA_S_INTERFACE-UPDMODE I_T_SELECT Importing (Value Transfer) Type SBIWA_T_SELECT I_T_FIELDS Importing (Value Transfer) Type SBIWA_T_FIELDS C_T_DATA Changing Type ANY TABLE C_T_MESSAGES Changing Type RSU5_T_MESSAGES

Exceptions None

Page 66: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (3.2).

With the following code:

METHOD _call_datasource.

DATA: ls_oltpsource TYPE rsaot_s_osource, lv_data TYPE REF TO data, lv_method TYPE seocmpname.

FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.

* check if any data is extracted CHECK c_t_data IS NOT INITIAL.

CALL FUNCTION 'RSA1_SINGLE_OLTPSOURCE_GET' EXPORTING i_oltpsource = i_datasource i_objvers = 'A' IMPORTING e_s_oltpsource = ls_oltpsource EXCEPTIONS no_authority = 1 not_exist = 2 inconsistent = 3 OTHERS = 4.

IF sy-subrc <> 0. EXIT. ENDIF.

Page 67: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (3.3) c’td.

Continuing with the following code:

* create data for Extract Structure CREATE DATA lv_data TYPE TABLE OF (ls_oltpsource-exstruct). ASSIGN lv_data->* TO <lt_data>. ASSIGN c_t_data TO <lt_data>.* get method name for datasource lv_method = i_datasource. IF lv_method(1) = '0' or lv_method(1) = '2'. "for instance 2LIS_11** shift by one character as methods can't start with a number SHIFT lv_method. ENDIF.* check method is implemented CHECK _check_method_exists( lv_method ) = 'X'.

CALL METHOD (lv_method) EXPORTING i_updmode = i_updmode i_t_select = i_t_select i_t_fields = i_t_fields CHANGING c_t_data = <lt_data> c_t_messages = c_t_messages.

ENDMETHOD.

Page 68: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (4.1).

_TEMPLATE_DATASOURCE Description “Template You Can Use To Copying Enhancement Method of your DataSource” Level Static Visibility Public

Parameters

I_DATASOURCE Importing (Value Transfer) Type RSAOT_OLTPSOURCE I_UPDMODE Importing (Value Transfer) Type SBIWA_S_INTERFACE-UPDMODE I_T_SELECT Importing (Value Transfer) Type SBIWA_T_SELECT I_T_FIELDS Importing (Value Transfer) Type SBIWA_T_FIELDS C_T_DATA Changing Type ANY TABLE C_T_MESSAGES Changing Type RSU5_T_MESSAGES

Exceptions None

Page 69: Abap Objects for BW

Adding four new Methods in your implementation ZCL_IM_ZRSU5_SAPI_BADI (4.2).

Append the following code to Your Method _template_datasource:

METHOD _template_datasource.

* Data Definition* DATA: lth_vbak type hashed table of vbak with unique key vbeln,* ls_vbak type vbak .

* FIELD-SYMBOLS: <L_S_DATA> TYPE <Extract structure name>.* Init* Perform always a mass select into an internal table* SELECT * FROM VBAK INTO TABLE lth_vbak* FOR ALL ENTRIES IN C_T_DATA* WHERE VBELN = C_T_DATA_VBELN.

* map the data* LOOP AT C_T_DATA ASSIGNING <L_S_DATA>.

* READ TABLE lth_vbak into ls_vbak* with table key vbeln = <L_S_DATA>-vbeln.* if sy-subrc eq 0.* <L_S_DATA>-VKORG = ls_vbak-vkorg.* !!! No MODIFY necessary as the field is changed immediatly in the* internal table by using Field Symbols* endif.* ENDLOOP.

ENDMETHOD.

Page 70: Abap Objects for BW

Modify now the Method DATA_TRANSFORM in your implementation of IF_EX_RSU5_SAPI_BADI

Do not forget to modify the original method DATA_TRANSFORM with the following code !!

METHOD if_ex_rsu5_sapi_badi~data_transform.

CALL METHOD zcl_im_rsu5_sapi_badi=>_call_datasource EXPORTING i_datasource = i_datasource i_updmode = i_updmode i_t_select = i_t_select i_t_fields = i_t_fields CHANGING c_t_data = c_t_data c_t_messages = c_t_messages.

ENDMETHOD.

Page 71: Abap Objects for BW

Summary

In the methods tab of the class ZCL_IM_ZRSU5_SAPI_BADI, ( inheriting from the Interface IF_EX_RSU5_SAPI_BADI) we have created 4 new methods.

Enriching a datasource, will consist of extending its structure (SE11 and RSA6) and then creating your own method using _TEMPLATE_DATASOURCE as a model and rename it to the almost exact name of your datasource:

In case you enhance a Business Content datasource skip the 0 or the 2 at the beginning (e.g. Datasource 0UC_MTR_DOC -> Method UC_MTR_DOC or 2LIS_03_BF -> Method LIS_03_BF), the Z datasource Z_DS_G_TR_ZV_EGER giving its exact name to the enrichment method.

The method is then called by the Exit Framework

Page 72: Abap Objects for BW

Creating an enhancement of a DataSource(1)

I will assume that you have enhanced the structure of the data source, and need to code to populate the enhanced fields of the structure.

Copy the method _TEMPLATE_DATASOURCE and rename it, with the same name of the datasource you want to enhance. In case of standard datasource, omit the first character of the name (‘0’ or ‘2’).

ie. DataSource 2LIS_18_IOTASK Method name: LIS_18_IOTASK

Page 73: Abap Objects for BW

Creating an enhancement of a DataSource(2)

Declare on the code the structure to populate.

On the code, you have to declare the structure <L_S_DATA> of the type of the enhancement sctructure of your data source, ie: Tcode RSA6As you see in the picture, the Extract Structure of the data source 2LIS_18_I0TASK is MC18I00TSK.

Page 74: Abap Objects for BW

Creating an enhancement of a DataSource(3)

Declare:

FIELD-SYMBOLS: <l_s_data> TYPE MC18I00TSK .

During the execution of the extraction process, when this method is called, the structure C_T_DATA will be populated with packages of 100 records each time. So a loop must be declared to process these data packages, as you see on the code examples bellow.

Here is a simple way to populate the fields of the structure straight from the select:

LOOP AT C_T_DATA ASSIGNING <L_S_DATA>.

SELECT SINGLE BETRH BETRW INTO (<L_S_DATA>-BETRH, <L_S_DATA>-BETRW) FROM DFKKOP WHERE OPBEL = <L_S_DATA>-OPBEL AND OPUPW = <L_S_DATA>-OPUPW AND OPUPK = <L_S_DATA>-OPUPK AND OPUPZ = <L_S_DATA>-OPUPZ.

ENDLOOP.

Go testing your DataSource in Tx RSA3.

Page 75: Abap Objects for BW

- BADI for BW Loading - RSU5_SAPI_BADIAlternate Non-Modular Way (Not Recommended)

Double click on the appropriate method, DATA_TRANSFORM, for Transaction, Master Data, and Texts datasources, or HIER_TRANSFORM for hierarchy datasource.

Between the instructions Method <Interface Name>~<Method name>. and endmethod., enter the code that you require for the implementation.

Save and activate your code and navigate back to the Change implementation screen, then be sure to activate the BADI implementation. method IF_EX_RSU5_SAPI_BADI~DATA_TRANSFORM.

CASE I_DATASOURCE. WHEN '2LIS_03_BF'. data: wa_vprsv TYPE mbew-vprsv.

FIELD-SYMBOLS: <c_t_data> TYPE TY_MC03BF0.

loop at c_t_data ASSIGNING <c_t_data>. if not <c_t_data>-matnr is INITIAL. select vprsv from mbew into wa_vprsv where matnr = <c_t_data>-matnr and BWKEY = <c_t_data>-werks. ENDSELECT. if sy-subrc = 0. <c_t_data>-vprsv = wa_vprsv. endif. endif. endloop. ENDCASE.endmethod.

Note the use of

FIELD-SYMBOLS

Launch Internet Explorer Browser.lnk

Page 76: Abap Objects for BW

References

Note 691154 - SAPI with BADI: User exits in SAPI with BADI-interfaces

Page 77: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 78: Abap Objects for BW

Other Areas Where ABAP OO Classes Are Used

Other areas where Classes / Methods Can be used.

XI Integration to BI using ABAP Proxy Services

BADI for :

Virtual Characteristics & Key Figures

Own Report Type as Jump Target Recipient

InfoSpoke with Transformation (BW 3.5 only)

>> Custom Process Type

Formula in Alternate Decision Process Type

Page 79: Abap Objects for BW

Custom Process Type using Pass-Through technique (1)

- Creation of Class ZCL_ABAP_PT_RESULT with no methods, types, attributes etc.- Go To > Public Section and Paste the following Lines- interfaces if_rspc_call_monitor .

interfaces if_rspc_check .interfaces if_rspc_execute .interfaces if_rspc_get_status .interfaces if_rspc_get_variant .interfaces if_rspc_maintain .interfaces if_rspc_transport .interfaces if_rspv_transport .

constants failed type rspc_state value 'R'. "#EC NOTEXTconstants status_mem_id type char20 value 'PC_ABAP_STATUS'. "#EC NOTEXTconstants success type rspc_state value 'G'. "#EC NOTEXT

Page 80: Abap Objects for BW

Custom Process Type using Pass-Through technique (2)

- The protected and public section contain nothing. - Now we need to implement the methods of the interface. - They all must be implemented - though most are empty. - Those that are not empty are:

-

if_rspv_transport~get_additional_objects. - if_rspc_transport~get_tlogo. - if_rspc_maintain~maintain. - if_rspc_maintain~get_header. - if_rspc_get_variant~get_variant. - if_rspc_get_variant~wildcard_enabled. - if_rspc_get_variant~exists. - if_rspc_get_status~get_status. - if_rspc_execute~give_chain. - if_rspc_check~check. - if_rspc_check~give_all - if_rspc_call_monitor~call_monitor. - if_rspc_execute~execute.

Page 81: Abap Objects for BW

Custom Process Type using Pass-Through technique (3)

You'll notice, that with the exception of the last method, all I've done is pass and retrieve identical parameters to CL_RSPC_ABAP static methods.

This is known as passing through, because we execute the methods of Class CL_RSPC_ABAP

In the last method (if_rspc_execute~execute), I also do this, but I have an additional statement.

“IMPORT e_state TO e_state FROM MEMORY ID zcl_abap_pt_result=>status_mem_id. “

This method executes the ABAP program in the Process Type variant, and then sets the state of the Process Type according to that stored in the memory id.

Page 82: Abap Objects for BW

Custom Process Type using Pass-Through technique (4) – Abap Program

The ABAP program that the process type will actually call, needs to set its status - whether it succeeded or failed - and report that to the process type handling class. This I've done simply using memory ids. You could follow the example in Jürgen Noe's blog, where he addresses the same issue, and use a table to store the result of the called program.

* Set the flag for the process chain to read

if ... " The ABAP program failed

l_flag = zcl_abap_pt_decision =>failed.

else. " The ABAP program was successful

l_flag = zcl_abap_pt_decision =>success.

endif. export e_state from l_flag to memory id zcl_abap_pt_decision=>status_mem_id.

Page 83: Abap Objects for BW

Custom Process Type using Pass-Through technique (4) – Abap Program

The ABAP program that the process type will actually call, needs to set its status - whether it succeeded or failed - and report that to the process type handling class. This I've done simply using memory ids. You could follow the example in Jürgen Noe's blog, where he addresses the same issue, and use a table to store the result of the called program.

* Set the flag for the process chain to read

if ... " The ABAP program failed

l_flag = zcl_abap_pt_decision =>failed.

else. " The ABAP program was successful

l_flag = zcl_abap_pt_decision =>success.

endif. export e_state from l_flag to memory id zcl_abap_pt_decision=>status_mem_id.

Page 84: Abap Objects for BW

Custom Process Type using Pass-Through technique (5) – Create New Process Type

The final bit of work is setting up the process type for use within a process chain.

From transaction RSPC, go to Settings->Maintain Process types. ( You might have to select a process chain first to activate this menu option ). Create a new process type: Z_ABAP_RES

Page 85: Abap Objects for BW

Custom Process Type using Pass-Through technique (6) – Sample Program

REPORT Z_TEST_GREEN_OR_RED.

DATA:e_state type RSPC_STATE,zcl_abap_pt_result TYPE REF TO zcl_abap_pt_result,l_flag TYPE rspc_state.

SELECTION-SCREEN BEGIN OF BLOCK eins WITH FRAME.

PARAMETERS:red RADIOBUTTON GROUP radi,green RADIOBUTTON GROUP radi.

SELECTION-SCREEN END OF BLOCK eins.

START-OF-SELECTION.

CREATE OBJECT zcl_abap_pt_result.

IF NOT green IS INITIAL.

l_flag = zcl_abap_pt_result=>success.

ELSE.

l_flag = zcl_abap_pt_result=>failed.

ENDIF.

EXPORT e_state FROM l_flag TO MEMORY ID zcl_abap_pt_result=>status_mem_id.

Page 86: Abap Objects for BW

Custom Process Type using Pass-Through technique (7) – Methods Copied from Class

Passing Through CL_RSPC_ABAP static meth

Page 87: Abap Objects for BW

Overview – ABAP OO Classes & Methods

Motivation For Using ABAP OO In BW

Scenario: Using Classes & Methods in Transformations

Scenario: The Class Constructor

Scenario: Class Methods in the Userexit for Variables

Scenario: Custom Functions for The Formula Builder

Scenario: BADI for BW Loading

Other Areas in BW using ABAP OO Classes & Methods

Page 88: Abap Objects for BW

Custom Class To Use in Transformation : generic programming (1)

Will fill internal tables in the START ROUTINE to derive from in the END ROUTINEObject Types : InfoObjects, ODSO . The method allows up to 5 filters with a FOR ALL ENTRIES type of conditions

Page 89: Abap Objects for BW

Custom Class To Use in Transformation : generic programming (2)

Handle several logical partitions based on Naming Conventions and Source SystemThe Object can be local or global.Up to 5 Filters as Distinct Values working as FOR ALL ENTRIESTime Dependency for InfoObjects

Page 90: Abap Objects for BW

Custom Class To Use in Transformation : generic programming (3)

Page 91: Abap Objects for BW

Custom Class To Use in Transformation : generic programming (4) – START Routine

Page 92: Abap Objects for BW

Appendix 1 – Passing Through CL_RSPC_ABAP static methods.

method IF_RSPV_TRANSPORT~AFTER_IMPORT.

endmethod.

method IF_RSPV_TRANSPORT~GET_ADDITIONAL_OBJECTS.

cl_rspc_abap=>if_rspv_transport~get_additional_objects(

EXPORTING i_variant = i_variant

i_cto_mode = i_cto_mode

i_is_content_system = i_is_content_system

IMPORTING e_t_cto_object = e_t_cto_object

e_t_cto_key = e_t_cto_key ).

endmethod.

method IF_RSPC_TRANSPORT~GET_TLOGO.

cl_rspc_abap=>if_rspc_transport~get_tlogo( EXPORTING i_variant = i_variant

i_objvers = i_objvers

IMPORTING e_tlogo = e_tlogo

e_objnm = e_objnm ).

endmethod.

method IF_RSPC_TRANSPORT~KEY_CHANGE.

endmethod.

method IF_RSPC_MAINTAIN~MAINTAIN.

cl_rspc_abap=>if_rspc_maintain~maintain( EXPORTING i_variant = i_variant

i_t_chain = i_t_chain

IMPORTING e_variant = e_variant

e_variant_text = e_variant_text ).

endmethod.

method IF_RSPC_MAINTAIN~GET_HEADER.

cl_rspc_abap=>if_rspc_maintain~get_header( EXPORTING i_variant = i_variant

i_objvers = i_objvers

IMPORTING e_variant_text = e_variant_text

e_s_changed = e_s_changed

e_contrel = e_contrel

e_conttimestmp = e_conttimestmp ).

endmethod.

METHOD if_rspc_get_variant~get_variant.

cl_rspc_abap=>if_rspc_get_variant~get_variant( EXPORTING i_variant = i_variant

i_t_chain = i_t_chain

i_t_select = i_t_select

i_objvers = i_objvers

IMPORTING e_variant = e_variant

e_variant_text = e_variant_text

EXCEPTIONS nothing_selected = 1 ).

IF sy-subrc EQ 1.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

RAISING nothing_selected.

ENDIF.

ENDMETHOD.

method IF_RSPC_GET_VARIANT~WILDCARD_ENABLED.

result = c l_rspc_abap=>if_rspc_get_variant~wildcard_enabled( ).

endmethod.

method IF_RSPC_GET_VARIANT~EXISTS.

r_exists = c l_rspc_abap=>if_rspc_get_variant~exists( i_variant = i_variant

i_objvers = i_objvers ).

endmethod.

method IF_RSPC_GET_STATUS~GET_STATUS.

cl_rspc_abap=>if_rspc_get_status~get_status( EXPORTING i_variant = i_variant

i_instance = i_instance

i_dont_update = i_dont_update

IMPORTING e_status = e_status ).

endmethod.

method IF_RSPC_EXECUTE~GIVE_CHAIN.

return = cl_rspc_abap=>if_rspc_execute~give_chain( i_variant ).

endmethod.

method IF_RSPC_CHECK~CHECK.

cl_rspc_abap=>if_rspc_check~check(

EXPORTING

i_s_process = i_s_process

i_t_chain = i_t_chain

i_t_chains = i_t_chains

IMPORTING

e_t_conflicts = e_t_conflicts

).

endmethod.

method IF_RSPC_CALL_MONITOR~CALL_MONITOR.

cl_rspc_abap=>if_rspc_call_monitor~call_monitor(

i_variant = i_variant

i_instance = i_instance ).

endmethod.

method IF_RSPC_CHECK~GIVE_ALL.

return = cl_rspc_abap=>if_rspc_check~give_all( i_variant ).

endmethod.

METHOD if_rspc_execute~execute.

cl_rspc_abap=>if_rspc_execute~execute(

EXPORTING

i_variant = i_variant

i_event_start = i_event_start

i_eventp_start = i_eventp_start

i_t_processlist = i_t_processlist

i_logid = i_logid

i_t_variables = i_t_variables

i_synchronous = i_synchronous

i_simulate = i_simulate

i_repair = i_repair

IMPORTING

e_instance = e_instance

e_state = e_state

e_eventno = e_eventno

e_hold = e_hold

).

IMPORT e_state TO e_state FROM MEMORY ID zcl_abap_pt_result=>status_mem_id.

ENDMETHOD.

Page 93: Abap Objects for BW

Appendix 2 – ZCL_ISU_GET_MASTER_DATA

METHOD zcl_isu_get_data. DATA: struct_type TYPE REF TO cl_abap_structdescr, tab_type TYPE REF TO cl_abap_tabledescr, comp_tab TYPE cl_abap_structdescr=>component_table, comp LIKE LINE OF comp_tab. DATA: t_data TYPE REF TO data. DATA: BEGIN OF ls_rsdchabas, chabasnm TYPE rschabasnm, chatp TYPE rschatp, attrib fl TYPE rsattrib fl, timdepfl TYPE rstimdepfl, END OF ls_rsdchabas. TYPES: BEGIN OF ly_dd03l, tabname TYPE tabname, fieldname TYPE fieldname, domname TYPE domname, position TYPE tabfdpos, datatype TYPE datatype_d, leng TYPE ddleng, END OF ly_dd03l. TYPES: BEGIN OF ly_where, line(100) TYPE c, END OF ly_where. DATA: lt_where TYPE STANDARD TABLE OF ly_where, ls_where TYPE ly_where.* DATA: lt_dd03l TYPE STANDARD TABLE OF ly_dd03l,* ls_dd03l TYPE ly_dd03l. DATA: lv_object_ddic TYPE string, lv_soursystem(3). DATA: dref TYPE REF TO data. FIELD-SYMBOLS: <f_s_table> TYPE ANY, <f_t_tab le> TYPE ANY TABLE. FIELD-SYMBOLS: <f_v_fie ld> TYPE ANY. FIELD-SYMBOLS: <f_t_filter1> TYPE STANDARD TABLE, <f_t_filter2> TYPE STANDARD TABLE, <f_t_filter3> TYPE STANDARD TABLE, <f_t_filter4> TYPE STANDARD TABLE. FIELD-SYMBOLS: <f_s_filter1> TYPE ANY, <f_s_filter2> TYPE ANY, <f_s_filter3> TYPE ANY, <f_s_filter4> TYPE ANY. DATA: lt_is_u_infobjects TYPE RANGE OF rsattrinm. DATA: ls_is_u_infobjects LIKE LINE OF lt_is_u_infobjects. DATA: lt_columns TYPE zcl_ isu_t_filter, ls_columns LIKE LINE OF lt_columns. DATA: lv_field_filter TYPE string. DATA: lv_dynamic_data_table TYPE string. DATA: lv_dynamic_range_table TYPE string. DATA: lv_e_tablnm TYPE tabname. DATA: lv_number(1). DATA: lt_fields_range TYPE TABLE OF lvc_s_fcat, ls_fields_range LIKE LINE OF lt_fields_range. DATA: ls_data_filter TYPE LINE OF zcl_ isu_t_filter. DATA: lv_e_chktab TYPE rsdchkview, lv_e_chntab TYPE rschntab. DATA: lv_chabasnm TYPE rschabasnm. DATA: lv_soursystem_view TYPE string.* begin of insertion by SAP - 25.11.2008 DATA: new_table TYPE REF TO data, new_line TYPE REF TO data. DATA: descr_ref TYPE REF TO cl_abap_structdescr, lt_deta ils TYPE abap_compdescr_tab, ls_details TYPE abap_compdescr.* end of insertion by SAP - 25.11.2008 IF ( i_soursystem NE 'RS' ) AND ( i_soursystem NE 'BS' ) AND ( i_soursystem NE 'PS' ). RAISE source_system_no_good. ENDIF.* begin of modification by SAP - 26.11.2008* source system CONCATENATE 'ZC' i_soursystem INTO lv_soursystem. CASE i_object_type.* infoobjetc WHEN 'IOBJ'.* verifica se o infoobjeto existe SELECT SINGLE chabasnm chatp attribfl timdepfl INTO ls_rsdchabas FROM rsdchabas WHERE chabasnm = i_object_name AND objvers = cv_objvers. IF sy-subrc NE 0. RAISE master_data_doesn_exist. ENDIF.* DSO WHEN 'ODSO'. lv_chabasnm = i_object_name.* BEGIN OF INSERTION BY SAP - 03.12.2008 IF i_global_dso IS INITIAL. REPLACE 'ZCG' WITH lv_soursystem INTO lv_chabasnm. ENDIF.* END OF INSERTION BY SAP - 03.12.2008 clear lv_e_tablnm. CALL METHOD cl_rsd_odso=>get_tablnm EXPORTING i_odsobject = lv_chabasnm* i_tabt = IMPORTING e_tablnm = lv_e_tablnm* e_ttypename =* e_viewnm =* e_chnglognm =* e_infosource =* e_datasource = EXCEPTIONS name_error = 1 input_ invalid = 2 OTHERS = 3 . IF sy-subrc <> 0. RAISE dso_doesn_exist. ENDIF.* begin of insertion by SAP - 24.11.2008* VIEW WHEN 'VIEW'. CONCATENATE '_' i_soursystem(1) '_' INTO lv_soursystem_view. lv_dynamic_data_table = i_object_name. REPLACE '_G_' WITH lv_soursystem_view INTO lv_dynamic_data_table.* to be continued (insert double check over table DDTYPES to insure* that the view really exists* end of insertion by SAP - 24.11.2008 WHEN OTHERS. RAISE object_type_no_good. ENDCASE.* begin of insertion by SAP - 25.11.2008* tab le CREATE DATA new_table LIKE e_t_table. ASSIGN new_table->* TO <f_t_tab le>.* structure CREATE DATA new_line LIKE LINE OF <f_t_table>. ASSIGN new_line->* TO <f_s_table>. descr_ref ?= cl_abap_typedescr=>describe_by_data( <f_s_table> ). lt_details[] = descr_ref->components[].* end of insertion by SAP - 25.11.2008* trata atributos controlados por empresa* atributos controlados por empresa** Somente quando for d iferente de objeto VIEW IF i_object_type = 'IOBJ'. ls_is_u_infobjects-sign = 'I'. ls_is_u_infobjects-option = 'EQ'.* 1) Dados Técnicos* Instalação ls_is_u_infobjects-low = '/BIC/ZCGINSTAL'. APPEND ls_is_u_infobjects TO lt_ is_u_infobjects. ls_is_u_infob jects-low = 'ZCGINSTAL'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.* Local de Consumo ls_is_u_infobjects-low = '/BIC/ZCGPREMIS'. APPEND ls_is_u_infob jects TO lt_is_u_infob jects. ls_is_u_infobjects-low = 'ZCGPREMIS'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects.* Objeto de Ligação ls_is_u_infobjects-low = '/BIC/ZCGCONOBJ'. APPEND ls_ is_u_infobjects TO lt_ is_u_infobjects. ls_is_u_infob jects-low = 'ZCGCONOBJ'. APPEND ls_is_u_infobjects TO lt_ is_u_infobjects.* Device ls_ is_u_infobjects-low = '/BIC/ZCGDEVICE'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects. ls_is_u_infobjects-low = 'ZCGDEVICE'. APPEND ls_is_u_infob jects TO lt_is_u_infobjects.* 2) Dados Comercia is* Parceiro de Negócio ls_is_u_infobjects-low = '/BIC/ZCGBPARTN'. APPEND ls_is_u_infob jects TO lt_is_u_infob jects. ls_is_u_infobjects-low = 'ZCGBPARTN'. APPEND ls_is_u_infobjects TO lt_ is_u_infobjects.* Contrato ls_is_u_infobjects-low = '/BIC/ZCGCONTRA'. APPEND ls_is_u_infobjects TO lt_ is_u_infobjects. ls_is_u_infobjects-low = 'ZCGCONTRA'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects.* Conta-Contrato ls_is_u_infobjects-low = '/BIC/ZCGACCOUN'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects. ls_is_u_infobjects-low = 'ZCGACCOUN'. APPEND ls_is_u_infob jects TO lt_is_u_infobjects.* Conta-Contrato Parceiro ls_is_u_infob jects-low = '/BIC/ZCGACNTBP'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects. ls_ is_u_infobjects-low = 'ZCGACNTBP'. APPEND ls_is_u_infob jects TO lt_is_u_infob jects.* begin of insertion by SAP - 10.01.2009** Conta Contrato Coletiva ls_is_u_infob jects-low = '/BIC/ZCGABWVK'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects. ls_is_u_infobjects-low = 'ZCGABWVK'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects.** Pagador a lternativo - re f. PN ls_is_u_infobjects-low = '/BIC/ZCG_ABWRE'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects. ls_is_u_infobjects-low = 'ZCG_ABWRE'. APPEND ls_is_u_infob jects TO lt_is_u_infobjects.** Empregado responsável - ref. PN ZCRBPEMPL ls_is_u_infobjects-low = '/BIC/ZCGBPEMPL'. APPEND ls_is_u_infobjects TO lt_ is_u_infobjects. ls_is_u_infobjects-low = 'ZCGBPEMPL'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects.*** início alteração SAP040877 - Diogo em 11/08/09*** chamado 8000019681 ls_ is_u_infobjects-low = '/BIC/ZCGUNLEIT'. APPEND ls_ is_u_infobjects TO lt_is_u_infobjects. ls_is_u_infobjects-low = 'ZCGUNLEIT'. APPEND ls_is_u_infobjects TO lt_is_u_infobjects.*** fim alteração SAP040877 - Diogo em 11/08/09**** alteração 21/08/09 - cadeia batch - carga FAT - EBF*** chamado 8000020612 - Diogo Almeida ls_ is_u_infobjects-low = '/BIC/ZCGPORTIO'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects. ls_ is_u_infobjects-low = 'ZCGPORTIO'. APPEND ls_ is_u_infobjects TO lt_is_u_infobjects.**** fim alteração 21/08/09 - cadeia batch - carga FAT - chamado *** chamado 8000020612* end of insertion by SAP - 10.01.2009 ELSE. ls_is_u_infobjects-sign = 'I'. ls_is_u_infobjects-option = 'EQ'.* Registro dummy ls_is_u_infobjects-low = 'DUMMY'. APPEND ls_is_u_infob jects TO lt_is_u_infobjects. ENDIF.* begin of insertion by SAP - 25.11.2008 LOOP AT lt_details INTO ls_deta ils. ls_columns = ls_details-name. IF ls_columns IN lt_is_u_infobjects. REPLACE 'ZCG' WITH lv_soursystem INTO ls_columns. ENDIF. APPEND ls_columns TO lt_columns. ENDLOOP.* end of insertion by SAP - 25.11.2008 IF i_object_type NE 'VIEW'. IF i_ignore_source_system IS INITIAL.* SOURCE SYSTEM CONCATENATE 'SOURSYSTEM = ''' i_soursystem '''' INTO ls_where-line. APPEND ls_where TO lt_where. ENDIF.* in foobject IF i_object_type = 'IOBJ'. IF i_ignore_source_system IS INITIAL.* and ls_where-line = 'AND'. APPEND ls_where TO lt_where. ENDIF.* monta select dinamico CONCATENATE 'OBJVERS = ''' cv_objvers '''' INTO ls_where-line. APPEND ls_where TO lt_where. lv_chabasnm = i_object_name. IF lv_chabasnm IN lt_is_u_infobjects. REPLACE 'ZCG' WITH lv_soursystem INTO lv_chabasnm. ENDIF.* re tornar configuração de dicionário para infoobjet CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS' EXPORTING i_chabasnm = lv_chabasnm* I_NSPACEGEN =* I_S_VIOBJ =* I_T_ATR = IMPORTING e_chktab = lv_e_chktab e_chntab = lv_e_chntab* E_CHTTAB =* E_TXTTAB =* E_SIDTAB =* E_SIDVIEW =* E_ASITAB =* E_ASISTR =* E_ASTTAB =* E_CHKNEW = EXCEPTIONS name_error = 1 OTHERS = 2 . IF sy-subrc <> 0. RAISE erro_dynamic_table. ENDIF.* determina tabela para se lect* de acordo com infoobjet IF i_time_dependent = 'X' AND ls_rsdchabas-timdepfl EQ 'X'.* time-dependent table lv_dynamic_data_table = lv_e_chktab. ELSE.* regular tab le lv_dynamic_data_table = lv_e_chntab. ENDIF.* DSO ELSE. lv_dynamic_data_table = lv_e_tablnm. ENDIF. ENDIF.* time-dependente in formation IF ( i_object_type = 'IOBJ' AND i_time_dependent = 'X' AND ls_rsdchabas-timdepfl EQ 'X' ) OR ( i_object_type = 'ODSO' AND i_time_dependent = 'X' ). IF NOT lt_where[] IS INITIAL.* and ls_where-line = 'AND'. APPEND ls_where TO lt_where. ENDIF.* SOURCE SYSTEM CONCATENATE 'DATETO = ''' cv_datato '''' INTO ls_where-line. APPEND ls_where TO lt_where. ENDIF.* begin of insertion by SAP - 26.11.2008* cria filtros para select* Até 4 filtros de select IF NOT i_filter IS INITIAL. DO 4 TIMES. MOVE sy-index TO lv_number. CONCATENATE 'I_FILTER-ZCL_FILTER' lv_number INTO lv_field_filter. ASSIGN (lv_field_filter) TO <f_v_field>. IF sy-subrc EQ 0. IF NOT <f_v_field> IS INITIAL. READ TABLE lt_deta ils WITH KEY name = <f_v_field> INTO ls_details. IF sy-subrc EQ 0.* FIRST FIELTER - FOR ALL ENTRIES IF lv_number = 1. REFRESH lt_fields_range. CLEAR ls_fie lds_range.* TABELA interna para ser u tilizada como for all entries ls_columns = ls_details-name. IF ls_columns IN lt_is_u_infobjects. REPLACE 'ZCG' WITH lv_soursystem INTO ls_columns. ENDIF. ls_fie lds_range-fie ldname = ls_columns. ls_fie lds_range-ref_table = lv_dynamic_data_table.* ls_fields_range-ref_fie ld = <f_v_field>. ls_fields_range-ref_field = ls_columns. APPEND ls_fields_range TO lt_fields_range.*** Alteração Bobis data: op_len TYPE i, op_out type OUTPUTLEN, op_dec TYPE OUTPUTLEN, w_iob j type RSD_IOBJNM, w_iobj1 type RSD_IOBJNM. LOOP AT lt_fie lds_range INTO ls_fields_range. if ls_fields_range-FIELDNAME(4) eq '/BIC'. w_iobj = ls_fields_range-FIELDNAME+5(10). e lse. concatenate '0' ls_fields_range-FIELDNAME into w_iobj. endif. clear op_len. select sing le CHABASNM from RSDCHA into w_iobj1 where CHANM = w_iobj and objvers = 'A'. select single OUTPUTLEN from RSDCHABAS into op_out where CHABASNM = w_iobj1 and objvers = 'A'. if sy-subrc eq 0. move op_out to op_len. endif. comp-name = ls_fields_range-FIELDNAME.* CASE op_type.* WHEN 'DEC'.* CALL METHOD cl_abap_elemdescr=>get_p* EXPORTING* p_ length = op_len* p_decimals = op_dec* RECEIVING* p_result = comp-type.* WHEN OTHERS. comp-type = cl_abap_elemdescr=>get_c( op_len ).* ENDCASE. APPEND comp TO comp_tab. CLEAR: comp. ENDLOOP. CLEAR struct_type . CALL METHOD cl_abap_structdescr=>create EXPORTING p_components = comp_tab p_strict = cl_abap_structdescr=>fa lse RECEIVING p_result = struct_type. CLEAR tab_type . CALL METHOD cl_abap_tabledescr=>create EXPORTING p_line_type = struct_type p_table_kind = cl_abap_tabledescr=>tablekind_std RECEIVING p_result = tab_type. CLEAR: dref. CREATE DATA dref TYPE HANDLE tab_type. ASSIGN dref->* TO <f_t_filter1>. CREATE DATA dref LIKE LINE OF <f_t_filter1>. ASSIGN dref->* TO <f_s_filter1>.** CREATE DATA t_data LIKE LINE OF <f_t_filter1>.** ASSIGN t_data->* TO <f_s_filter1>.**** Alteração Bobis* CALL METHOD cl_a lv_table_create=>create_dynamic_table* EXPORTING* it_fieldcatalog = lt_fields_range* IMPORTING* ep_table = dref* EXCEPTIONS* generate_subpool_dir_full = 1* OTHERS = 2.** IF sy-subrc NE 0.* RAISE erro_dynamic_table.* ENDIF.** ASSIGN dref->* TO <f_t_filter1>.* CREATE DATA dref LIKE LINE OF <f_t_filter1>.* ASSIGN dref->* TO <f_s_filter1>.**** Alteração Bobis LOOP AT i_ filter-zcl_data_filter1 INTO ls_data_filter. CONCATENATE '<f_s_filter1>' ls_columns INTO lv_field_filter SEPARATED BY '-'. ASSIGN (lv_fie ld_filter) TO <f_v_field>. <f_v_fie ld> = ls_data_filter. APPEND <f_s_filter1> TO <f_t_filter1>. ENDLOOP. ELSE. break sap857850. REFRESH lt_fields_range. CLEAR ls_fields_range.* cria fie ld range para receber valores do filtro ls_fields_range-fieldname = 'SIGN'. ls_fields_range-datatype = 'CHAR'. ls_fields_range-outputlen = 1. APPEND ls_fields_range TO lt_fields_range. ls_fie lds_range-fie ldname = 'OPTION'. ls_fields_range-datatype = 'CHAR'. ls_fields_range-outputlen = 2. APPEND ls_fields_range TO lt_fields_range. ls_fields_range-fieldname = 'LOW'. ls_fields_r

I_SOURSYSTEM Importing Type RSSOURSYSID Source System

I_OBJECT_NAME Importing Type RSIOBJNM InfoObjeto

I_TIME_DEPENDENT Importing Type CHAR1 'X' or ''

I_OBJECT_TYPE Importing Type RSTLOGO 'IOBJ' (InfoObjeto), 'ODSO' (Objeto DataStore), or 'VIEW'

I_IGNORE_SOURCE_SYSTEM Importing Type CHAR1 'X' or '' (default tem sourcesystem)

E_T_MESSAGES Exporting Type RSU5_T_MESSAGES Log de aplicação: interface para Business Add Ins

E_OBJECT_NAME Exporting Type STRING Object Name

METHOD zcl_isu_get_object_name.

DATA: BEGIN OF ls_rsdchabas, chabasnm TYPE rschabasnm, chatp TYPE rschatp, attribfl TYPE rsattribfl, timdepfl TYPE rstimdepfl, END OF ls_rsdchabas.

DATA: lv_soursystem(3).

DATA: lt_is_u_infobjects TYPE RANGE OF rsattrinm. DATA: ls_is_u_infob jects LIKE LINE OF lt_ is_u_infobjects.

DATA: lv_e_tablnm TYPE tabname.

DATA: lv_e_chktab TYPE rsdchkview, lv_e_chntab TYPE rschntab.

DATA: lv_chabasnm TYPE rschabasnm. DATA: lv_soursystem_view TYPE string.

IF ( i_soursystem NE 'RS' ) AND ( i_soursystem NE 'BS' ) AND ( i_soursystem NE 'PS' ).

RAISE source_system_no_good.

ENDIF.

* source system CONCATENATE 'ZC' i_soursystem INTO lv_soursystem.* CASE i_object_type.

* infoobjetc WHEN 'IOBJ'.

* verifica se o infoobjeto existe SELECT SINGLE chabasnm chatp attribfl timdepfl INTO ls_rsdchabas FROM rsdchabas WHERE chabasnm = i_object_name AND objvers = cv_objvers.

IF sy-subrc NE 0.

RAISE master_data_doesn_exist.

ENDIF.

* DSO WHEN 'ODSO'.

lv_chabasnm = i_object_name.

REPLACE 'ZCG' WITH lv_soursystem INTO lv_chabasnm.

CALL METHOD cl_rsd_odso=>get_tablnm EXPORTING i_odsobject = lv_chabasnm*    i_tabt        = IMPORTING e_tablnm = lv_e_tablnm*    e_ttypename   =*    e_viewnm      =*    e_chnglognm   =*    e_infosource  =*    e_datasource  = EXCEPTIONS name_error = 1 input_invalid = 2 OTHERS = 3 . IF sy-subrc <> 0.

RAISE dso_doesn_exist.

ENDIF.

* begin of insertion by SAP - 24.11.2008* VIEW WHEN 'VIEW'.

CONCATENATE '_' i_soursystem(1) '_' INTO lv_soursystem_view. e_object_name = i_object_name.

REPLACE '_G_' WITH lv_soursystem_view INTO e_object_name.

* to be continued  (insert double check over table DDTYPES to insure* that the view really exists* end of insertion by SAP - 24.11.2008

WHEN OTHERS.

RAISE object_type_no_good.

ENDCASE.

* begin of insertion by SAP - 25.11.2008

IF i_object_type = 'IOBJ'.

ls_is_u_infobjects-sign = 'I'. ls_is_u_infobjects-option = 'EQ'.

* 1) Dados Técnicos* Instalação ls_is_u_infobjects-low = '/BIC/ZCGINSTAL'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGINSTAL'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* Local de Consumo ls_is_u_infobjects-low = '/BIC/ZCGPREMIS'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGPREMIS'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* Objeto de Ligação ls_is_u_infobjects-low = '/BIC/ZCGCONOBJ'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGCONOBJ'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* Device ls_is_u_infobjects-low = '/BIC/ZCGDEVICE'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGDEVICE'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* 2) Dados Comerciais

* Parceiro de Negócio ls_is_u_infobjects-low = '/BIC/ZCGBPARTN'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGBPARTN'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* Contrato ls_is_u_infobjects-low = '/BIC/ZCGCONTRA'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGCONTRA'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* Conta-Contrato ls_is_u_infobjects-low = '/BIC/ZCGACCOUN'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGACCOUN'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

* Conta-Contrato Parceiro ls_is_u_infobjects-low = '/BIC/ZCGACNTBP'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ls_is_u_infobjects-low = 'ZCGACNTBP'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ELSE.

ls_is_u_infobjects-sign = 'I'. ls_is_u_infobjects-option = 'EQ'.

* Registro dummy ls_is_u_infobjects-low = 'DUMMY'. APPEND ls_is_u_infobjects TO lt_is_u_infob jects.

ENDIF.

* begin of insertion by SAP - 02.12.2008

e_object_name = i_object_name.

IF e_object_name IN lt_is_u_infobjects.

REPLACE 'ZCG' WITH lv_soursystem INTO e_object_name.

ENDIF.* end of insertion by SAP - 02.12.2008

IF i_object_type = 'IOBJ'.

lv_chabasnm = e_object_name.

* retornar configuração de dicionário para infoobjet CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS' EXPORTING i_chabasnm = lv_chabasnm*   I_NSPACEGEN       =*   I_S_VIOBJ         =*   I_T_ATR           = IMPORTING e_chktab = lv_e_chktab e_chntab = lv_e_chntab*   E_CHTTAB          =*   E_TXTTAB          =*   E_SIDTAB          =*   E_SIDVIEW         =*   E_ASITAB          =*   E_ASISTR          =*   E_ASTTAB          =*   E_CHKNEW          = EXCEPTIONS name_error = 1 OTHERS = 2 . IF sy-subrc <> 0.

RAISE erro_dynamic_table.

ENDIF.

* determina tabela para se lect* de acordo com infoobjet IF i_time_dependent = 'X' AND ls_rsdchabas-timdepfl EQ 'X'.* time-dependent tab le e_object_name = lv_e_chktab.

ELSE.* regular table e_object_name = lv_e_chntab.

ENDIF.

* DSO ELSE.

e_object_name = lv_e_tablnm.

ENDIF.

ENDMETHOD.

nge-ref_table = lv_dynamic_data_table. ls_fie lds_range-ref_field = <f_v_fie ld>. APPEND ls_fields_range TO lt_fields_range. ls_fields_range-fieldname = 'HIGH'. ls_fie lds_range-ref_table = lv_dynamic_data_table. ls_fields_range-ref_field = <f_v_fie ld>. APPEND ls_fields_range TO lt_fields_range.*** Alteração Bobis refresh comp_tab. clear comp_tab. LOOP AT lt_fie lds_range INTO ls_fie lds_range. clear op_len. if ls_fields_range-REF_FIELD(4) eq '/BIC'. w_iobj = ls_fields_range-REF_FIELD+5(10). else. concatenate '0' ls_fields_range-REF_FIELD into w_iobj. endif. select sing le CHABASNM from RSDCHA into w_iobj1 where CHANM = w_iobj and objvers = 'A'. if sy-subrc eq 0. select single OUTPUTLEN from RSDCHABAS into op_out where CHABASNM = w_iobj1 and objvers = 'A'. if sy-subrc eq 0. if sy-subrc eq 0. move op_out to ls_fields_range-outputlen. endif. endif. endif. op_len = ls_fie lds_range-outputlen. comp-name = ls_fields_range-FIELDNAME. comp-type = cl_abap_elemdescr=>get_c( op_len ). APPEND comp TO comp_tab. CLEAR: comp. endloop. CALL METHOD cl_abap_structdescr=>create EXPORTING p_components = comp_tab p_strict = cl_abap_structdescr=>false RECEIVING p_result = struct_type. CLEAR tab_type . CALL METHOD cl_abap_tabledescr=>create EXPORTING p_ line_type = struct_type p_table_kind = cl_abap_tabledescr=>tablekind_std RECEIVING p_result = tab_type.* CLEAR: dref.* CREATE DATA dref TYPE HANDLE tab_type.* ASSIGN dref->* TO <f_t_filter1>.* CREATE DATA t_data LIKE LINE OF <f_t_filter1>.* ASSIGN t_data->* TO <f_s_filter1>.* CALL METHOD cl_alv_table_create=>create_dynamic_table* EXPORTING* it_fie ldcatalog = lt_fie lds_range* IMPORTING* ep_table = dref* EXCEPTIONS* generate_subpool_dir_full = 1* OTHERS = 2.** IF sy-subrc NE 0.* RAISE erro_dynamic_table.* ENDIF.*** Alteração Bobis CASE lv_number.********************************************************************************************* Filtro 2**************************************************************************************** WHEN 2.*** Alteração Bobis CLEAR: dref. CREATE DATA dref TYPE HANDLE tab_type. ASSIGN dref->* TO <f_t_filter2>. CREATE DATA t_data LIKE LINE OF <f_t_filter2>. ASSIGN t_data->* TO <f_s_filter2>.* ASSIGN dref->* TO <f_t_filter2>.* CREATE DATA dref LIKE LINE OF <f_t_filter2>.* ASSIGN dref->* TO <f_s_filter2>.*** Alteração Bobis lv_field_filter = '<f_s_filter2>-sign'. ASSIGN (lv_field_filter) TO <f_v_field>. <f_v_field> = 'I'. lv_field_filter = '<f_s_filter2>-option'. ASSIGN (lv_field_filter) TO <f_v_field>. <f_v_field> = 'EQ'. LOOP AT i_filter-zcl_data_filter2 INTO ls_data_filter. lv_field_filter = '<f_s_filter2>-low'. ASSIGN (lv_fie ld_filter) TO <f_v_field>. <f_v_field> = ls_data_filter. APPEND <f_s_filter2> TO <f_t_filter2>. ENDLOOP.********************************************************************************************* Filtro 3**************************************************************************************** WHEN 3.*** Alteração Bobis CLEAR: dref. CREATE DATA dref TYPE HANDLE tab_type. ASSIGN dref->* TO <f_t_filter3>. CREATE DATA t_data LIKE LINE OF <f_t_filter3>. ASSIGN t_data->* TO <f_s_filter3>.* ASSIGN dref->* TO <f_t_filter3>.* CREATE DATA dref LIKE LINE OF <f_t_filter3>.* ASSIGN dref->* TO <f_s_filter3>.*** Alteração Bobis lv_field_filter = '<f_s_filter3>-sign'. ASSIGN (lv_field_filter) TO <f_v_fie ld>. <f_v_field> = 'I'. lv_field_filter = '<f_s_filter3>-option'. ASSIGN (lv_fie ld_filter) TO <f_v_field>. <f_v_fie ld> = 'EQ'. refresh <f_t_filter3>. LOOP AT i_filter-zcl_data_filter3 INTO ls_data_filter. lv_fie ld_filter = '<f_s_filter3>-low'. ASSIGN (lv_field_filter) TO <f_v_field>. <f_v_fie ld> = ls_data_filter. APPEND <f_s_filter3> TO <f_t_filter3>. ENDLOOP.********************************************************************************************* Filtro 3**************************************************************************************** WHEN 4. CLEAR: dref. CREATE DATA dref TYPE HANDLE tab_type. ASSIGN dref->* TO <f_t_filter4>. CREATE DATA t_data LIKE LINE OF <f_t_filter4>. ASSIGN t_data->* TO <f_s_filter4>.* ASSIGN dref->* TO <f_t_filter4>.* CREATE DATA dref LIKE LINE OF <f_t_filter4>.* ASSIGN dref->* TO <f_s_filter4>.*** Alteração Bobis lv_field_filter = '<f_s_filter4>-sign'. ASSIGN (lv_field_filter) TO <f_v_fie ld>. <f_v_field> = 'I'. lv_field_filter = '<f_s_filter4>-option'. ASSIGN (lv_fie ld_filter) TO <f_v_field>. <f_v_fie ld> = 'EQ'. refresh <f_t_filter4>. LOOP AT i_filter-zcl_data_filter4 INTO ls_data_filter. lv_fie ld_filter = '<f_s_filter4>-low'. ASSIGN (lv_field_filter) TO <f_v_field>. <f_v_field> = ls_data_filter. APPEND <f_s_filter4> TO <f_t_filter4>. ENDLOOP. ENDCASE. ENDIF. ENDIF. ELSE. EXIT. ENDIF. ENDIF. ENDDO. ENDIF.* end of insertion by SAP - 26.11.2008* filtro 1 IF <f_t_filter1> IS ASSIGNED. IF NOT lt_where[] IS INITIAL.* and ls_where-line = 'AND'. APPEND ls_where TO lt_where. ENDIF. ls_columns = i_ filter-zcl_ filter1. IF ls_columns IN lt_is_u_infobjects. REPLACE 'ZCG' WITH lv_soursystem INTO ls_columns. ENDIF.* condição where* condição where CONCATENATE ls_columns ' EQ <f_t_filter1>-' ls_columns INTO ls_where. APPEND ls_where TO lt_where. ENDIF.* filtro 2 IF <f_t_filter2> IS ASSIGNED. IF NOT lt_where[] IS INITIAL.* and ls_where-line = 'AND'. APPEND ls_where TO lt_where. ENDIF. ls_columns = i_ filter-zcl_filter2. IF ls_columns IN lt_ is_u_infobjects. REPLACE 'ZCG' WITH lv_soursystem INTO ls_columns. ENDIF.* condição where CONCATENATE ls_columns ' IN <f_t_filter2>' INTO ls_where. APPEND ls_where TO lt_where. ENDIF.* filtro 3 IF <f_t_filter3> IS ASSIGNED. IF NOT lt_where[] IS INITIAL.* and ls_where-line = 'AND'. APPEND ls_where TO lt_where. ENDIF. ls_columns = i_ filter-zcl_ filter3. IF ls_columns IN lt_is_u_infobjects. REPLACE 'ZCG' WITH lv_soursystem INTO ls_columns. ENDIF.* condição where CONCATENATE ls_columns ' IN <f_t_filter3>' INTO ls_where. APPEND ls_where TO lt_where. ENDIF.* filtro 4 IF <f_t_filter4> IS ASSIGNED. IF NOT lt_where[] IS INITIAL.* and ls_where-line = 'AND'. APPEND ls_where TO lt_where. ENDIF. ls_columns = i_filter-zcl_filter4. IF ls_columns IN lt_is_u_infob jects. REPLACE 'ZCG' WITH lv_soursystem INTO ls_columns. ENDIF.* condição where CONCATENATE ls_columns ' IN <f_t_filter4>' INTO ls_where. APPEND ls_where TO lt_where. ENDIF.* faz se lect infoobject IF <f_t_filter1> IS ASSIGNED. SELECT (lt_columns) FROM (lv_dynamic_data_table) INTO TABLE e_t_table FOR ALL ENTRIES IN <f_t_filter1> WHERE (lt_where). ELSE. SELECT (lt_columns) FROM (lv_dynamic_data_table) INTO TABLE e_t_table WHERE (lt_where). ENDIF.ENDMETHOD.