Chinaunix首页 | 论坛 | 博客
  • 博客访问: 277984
  • 博文数量: 62
  • 博客积分: 2966
  • 博客等级: 少校
  • 技术积分: 615
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-07 23:16
个人简介

Be a simple man

文章分类

全部博文(62)

文章存档

2012年(6)

2011年(15)

2010年(6)

2009年(3)

2008年(5)

2007年(27)

我的朋友

分类:

2011-04-01 10:45:19

 

How does the extraction api work in case you are extracting data using a self defined function module with generic delta?

Sometimes, if your application or requirement makes it necessary, you have to create your own function module to extract the data from whatever sap system to bw.

Therefore you normally make a copy of the standard fm 'RSAX_BIW_GET_DATA_SIMPLE'. To make this new function work for you, you have to realize the following.

 

1.) the fm gets called by the extraction api for at least 2 times. First time is for initialization and from the 2nd time on it is for data extraction.

2.) right after the last data package (somehow you need to make sure that it is the last one) you have to raise the exception no_more_data.

 

Example with lots of comments

 

 

FUNCTION RSAX_BIW_GET_DATA_SIMPLE.

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

*"*"Lokale Schnittstelle:

*" IMPORTING

*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR

*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL

*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL

*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL

*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL

*" TABLES

*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL

*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL

*" E_T_DATA STRUCTURE SFLIGHT OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

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

 

* Auxiliary Selection criteria structure

DATA: L_S_SELECT TYPE SRSC_S_SELECT.

 

* Maximum number of lines for DB table

STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,

 

* counter

S_COUNTER_DATAPAKID LIKE SY-TABIX,

 

* cursor

S_CURSOR TYPE CURSOR.

 

* Initialization mode (first call by SAPI) or data transfer mode

IF I_INITFLAG = SBIWA_C_FLAG_ON.

* the coding here will be processed the first time the fm gets called.

* it is used to populate static or global variables and to check wether

* it's called by the right datasource or not.

ELSE. "Initialization mode or data extraction ?

* this part will be executed from the 2nd call on

* First data package -> OPEN CURSOR

IF S_COUNTER_DATAPAKID = 0.

* in case it is for the first data package, range tabs gets filled, a cursor will

* be opened or a initial dataset will be read from database into a global internal table

* this has to be done here, with the first data package, to avoid getting the same data with

* each call of the fm.

* additionally you can check wether you get select-options for your 'generic delta'-field or not,

* and, if it is provided, you are able to set a flag in order to do different selections

* based on this flag for delta or full load.

ENDIF. "First data package ?

* from now on records gets fetched from the database or gets read from the internal table

* and the return table e_t_data gets populated with the number of rows given by parameter s_s_if-maxsize.

* if the last record is populated to table e_t_data you need to raise the exeption no_more_data

* and you need to close the cursor, if you opened one.

* with each data package you also have to increase s_counter_datapakid.

ENDIF. "Initialization mode or data extraction ?

 

ENDFUNCTION.

 

 

If you forget to raise no_more_data, the extraction api will call the fm forever

阅读(1188) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~