cancel
Showing results for 
Search instead for 
Did you mean: 

can anybody explain me creating Generic Datasource using Function module?

Former Member
0 Kudos

Hi,

can anybody explain me creating Generic Datasource using Function module?

Thax in advance,

Ravi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (3)

Answers (3)

former_member228339
Contributor
0 Kudos

Generic Extraction via Function Module

/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module

1. Create s structure with the fields that you need from the 4 tables . Activate.

2. Goto SE 80 Select The Function Group , Copy , Select the Function module

" RSAX_BIW_GET_DATA_SIMPLE " and Give a New name starting With

Y or Z .

3. SE37 ->Your Function module name -> Change , In table tab give your structure

name by deleting the associated type given in " E_T_DATA " .

4. Now select source code and Do the coding . Give Data source name in Coding .

In your case you have to take data from more that 1 table .

5. Activate the Function Group .

6. In RSO2 Create the Data source , Give the Function Module Name , And Save.

7. RSA3 -> Give data source name and Check for the Records .

Creation of custom datasource. (Using function module)

<b>is an example</b>

1.Create a function group .

2. Structure ZTEST123

ZMATNR MATNR CHAR 18 0 Material Number

ZMTART MTART CHAR 4 0 Material type

ZMBRSH MBRSH CHAR 1 0 Industry sector

ZMATKL MATKL CHAR 9 0 Material group

ZBISMT BISMT CHAR 18 0 Old material number

ZMAKTX MAKTX CHAR 40 0 Material description

3. Create function module (i.e. ZTEST….) .

FM - YMARA_DATA_TRNS

FUNCTION YMARA_DATA_TRNS.

*"----


""Local Interface:

*" 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 ZTEST123 OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


data : ZTEST123 type ZTEST123 occurs 0 with header line.

  • Maximum number of lines for DB table

STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,

S_COUNTER_DATAPAKID LIKE SY-TABIX.

DATA: begin of t_mara occurs 0,

ZMATNR type MATNR,

ZMTART type MTART,

ZMBRSH type MBRSH,

ZMATKL type MATKL,

ZBISMT type BISMT,

end of t_mara.

DATA: begin of t_makt occurs 0,

ZMATNR type MATNR,

ZMAKTX type MAKTX,

end of t_makt.

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

  • (following calls) ?

IF I_INITFLAG = SBIWA_C_FLAG_ON.

  • Check DataSource validity

CASE I_DSOURCE.

WHEN 'ZZMARA_DATA'.

WHEN OTHERS.

IF 1 = 2. MESSAGE E009(R3). ENDIF.

  • this is a typical log call. Please write every error message like this

LOG_WRITE 'E' "message type

'R3' "message class

'009' "message number

I_DSOURCE "message variable 1

' '. "message variable 2

RAISE ERROR_PASSED_TO_MESS_HANDLER.

ENDCASE.

  • Fill parameter buffer for data extraction calls

S_S_IF-REQUNR = I_REQUNR.

S_S_IF-DSOURCE = I_DSOURCE.

S_S_IF-MAXSIZE = I_MAXSIZE.

ELSE. "Initialization mode or data extraction ?

************************************************************************

  • Data transfer: First Call OPEN CURSOR + FETCH

  • Following Calls FETCH only

************************************************************************

  • First data package -> OPEN CURSOR

IF S_COUNTER_DATAPAKID = 0.

  • Determine number of database records to be read per FETCH statement

  • from input parameter I_MAXSIZE. If there is a one to one relation

  • between DataSource table lines and database entries, this is trivial.

  • In other cases, it may be impossible and some estimated value has to

  • be determined.

select MATNR

MTART

MBRSH

MATKL

BISMT

from mara up to 10 rows

into table t_mara.

if not t_mara[] is initial.

select MATNR

maktx

from makt

into table t_makt

for all entries in t_mara

where matnr = t_mara-zmatnr.

endif.

loop at t_mara.

read table t_makt with key zmatnr = t_mara-zmatnr.

ZTEST123-zmatnr = t_mara-zmatnr.

ZTEST123-ZMTART = t_mara-ZMTART.

ZTEST123-ZBISMT = t_mara-ZBISMT.

ZTEST123-ZMBRSH = t_mara-ZMBRSH.

ZTEST123-ZMATKL = t_mara-ZMATKL.

ZTEST123-zmaktx = t_makt-zmaktx.

append ZTEST123.

clear ZTEST123.

endloop.

clear E_T_DATA.

refresh E_T_DATA.

E_T_DATA[] = ZTEST123[].

ENDIF.

S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

ENDIF. "Initialization mode or data extractio

ENDFUNCTION.

3. Create the data source using transaction (RSO2).

4. If structure exists for the table parameter of your function module then ok else create a structure for the table parameter ‘E_T_DATA’.

5. Test the datasource in R/3 using transaction RSA3.

6. Transfer the data source to BW –System and replicate it in the BW-System.

Former Member
0 Kudos

Hai ravi..

go through this link.

Generic extraction using Function module

/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module

RSAX_BIW_GET_DATA_SIMPLE

Don't asign ponints if helpfull

regards

KP

Former Member
0 Kudos

Hi pankaj,

Thanks for your reply , but u have not sent the required documents.

Please send the GDS with FM

Thanx in advance,

Ravi.