cancel
Showing results for 
Search instead for 
Did you mean: 

Using Function Module for extrcting data to BW

Former Member
0 Kudos

Hi,

This is just my opinion but I could be wrong. Using a FM as an extractor, I can't see the data right away similar to the R3 transparent table format. I used RSA3 but the data always come out to 0. I am an ABAPer and have been used to another method using the regular way of extracting data, instead of using the FM, and the transparent table as a datasource. I usually check the data directly in the table to see anything got extracted. Using the structure, I can't see the data right away before I actually send it to BW.

May be I am not used to using the FM but what would be the best way to check the data before going through BW to start loading? Please advise.

Thank you

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Siggi,

I think my problem has to do with the data package issue. If I am running for a date range from 01/01/2006 to 03/31/2006, what would the values for S_S_IF-T_FIELDS should be?

Should all the SELECT statements be placed before the "<i>ENDIF. "First data package ?</i>" to limit only to one time and then perform other processing after the statement "<i>RAISE NO_MORE_DATA. ENDIF.</i>"?

I am now just getting the problem that I am retrieving too many records transferring to BW, but it gets updated less number of records. I think this is just about the IC set up but the number of records transferred should not be so many.

Any other suggestions about my questions. I am debugging it but thought I get some answer from you to make sure my observation is correct.

Thank you

Former Member
0 Kudos

Hi Everyone,

Here is my code for the FM and I am not getting any data. I created a regular ABAP to see whether the SELECTs will extract data and it did produce 12 records, but I am getting 0 record from loading using the InfoPackage and RSA3.

FUNCTION ZBW_TEST.

*"----


""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 ZBW_PORELSTRAT OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


  • Example: DataSource for PO Release Strategies

TABLES: AGR_1251, AGR_USERS.

DATA: BEGIN OF S_PORELSTRAT,

ATWRT LIKE AUSP-ATWRT,

AGR_NAME LIKE AGR_1251-AGR_NAME,

UNAME LIKE AGR_USERS-UNAME,

CLASS LIKE USR02-CLASS,

NAME1 LIKE USR03-NAME1,

NAME2 LIKE USR03-NAME2,

END OF S_PORELSTRAT.

DATA: T_AGR_1251 LIKE AGR_1251 OCCURS 0 WITH HEADER LINE,

T_AGR_USERS LIKE AGR_USERS OCCURS 0 WITH HEADER LINE,

T_AUSP LIKE AUSP OCCURS 0 WITH HEADER LINE,

T_PO_REL LIKE S_PORELSTRAT OCCURS 0 WITH HEADER LINE.

DATA: L_USR02 LIKE USER02,

L_USR03 LIKE USER03.

  • 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.

  • Select ranges

RANGES: L_R_OBJECT FOR AGR_1251-OBJECT,

L_R_FIELD FOR AGR_1251-FIELD.

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

  • (following calls) ?

IF I_INITFLAG = SBIWA_C_FLAG_ON.

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

  • Initialization: check input parameters

  • buffer input parameters

  • prepare data selection

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

  • Check DataSource validity

CASE I_DSOURCE.

WHEN 'ZPORELSTRAT'.

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.

APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.

  • 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.

  • Fill field list table for an optimized select statement

  • (in case that there is no 1:1 relation between InfoSource fields

  • and database table fields this may be far from beeing trivial)

APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.

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.

  • Fill range tables BW will only pass down simple selection criteria

  • of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'OBJECT'.

MOVE-CORRESPONDING L_S_SELECT TO L_R_OBJECT.

APPEND L_R_OBJECT.

ENDLOOP.

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'FIELD'.

MOVE-CORRESPONDING L_S_SELECT TO L_R_FIELD.

APPEND L_R_FIELD.

ENDLOOP.

  • 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.

OPEN CURSOR WITH HOLD S_CURSOR FOR

SELECT (S_S_IF-T_FIELDS) FROM AGR_1251

WHERE OBJECT = 'M_EINK_FRG' AND

FIELD = 'FRGGR' AND

LOW >< '''''' AND

LOW >< SPACE.

ENDIF. "First data package ?

  • Fetch records into interface table.

  • named E_T_'Name of extract structure'.

FETCH NEXT CURSOR S_CURSOR

APPENDING CORRESPONDING FIELDS

OF TABLE T_AGR_1251

PACKAGE SIZE S_S_IF-MAXSIZE.

IF SY-SUBRC <> 0.

CLOSE CURSOR S_CURSOR.

RAISE NO_MORE_DATA.

ENDIF.

SELECT OBJEK ATWRT ATINN KLART

INTO CORRESPONDING FIELDS OF TABLE T_AUSP

FROM AUSP

WHERE ATINN = '811'

AND KLART = '032'.

SELECT UNAME AGR_NAME

INTO CORRESPONDING FIELDS OF TABLE T_AGR_USERS

FROM AGR_USERS

FOR ALL ENTRIES IN T_AGR_1251

WHERE AGR_NAME = T_AGR_1251-AGR_NAME.

SORT: T_AGR_1251 BY AGR_NAME,

T_AGR_USERS BY AGR_NAME.

LOOP AT T_AGR_1251.

READ TABLE T_AGR_USERS WITH KEY AGR_NAME = T_AGR_1251-AGR_NAME

BINARY SEARCH.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING T_AGR_1251 TO T_PO_REL.

MOVE-CORRESPONDING T_AGR_USERS TO T_PO_REL.

SELECT SINGLE CLASS BNAME

INTO CORRESPONDING FIELDS OF L_USR02

FROM USR02

WHERE BNAME = T_AGR_USERS-UNAME.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING L_USR02 TO T_PO_REL.

ENDIF.

SELECT SINGLE NAME1 NAME2 BNAME

INTO CORRESPONDING FIELDS OF L_USR03

FROM USR03

WHERE BNAME = T_AGR_USERS-UNAME.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING L_USR03 TO T_PO_REL.

ENDIF.

APPEND T_PO_REL.

ENDIF.

ENDLOOP.

SORT: T_AUSP BY OBJEK,

T_AGR_1251 BY LOW.

LOOP AT T_PO_REL.

MOVE-CORRESPONDING T_PO_REL TO E_T_DATA.

APPEND E_T_DATA.

ENDLOOP.

S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

ENDIF. "Initialization mode or data extraction ?

ENDFUNCTION.

Former Member
0 Kudos

Hi Crystal,

so far so good, couldn't find a error in there, so did you already do a debug in rsa3? Check if there are entries in table S_S_IF-T_FIELDS. Check if there are entries in T_PO_REL and in e_t_data. Remember that you do the selects at AUSP and agr_users for each data package. In case of agr_users it might be ok because it is depending on the data package, but the other one can be limited to only one time, be declaring the internal table as static or global.

You can debug the code in rsa3 by setting the debug flag.

Keep us updated.

Siggi

Former Member
0 Kudos

Hi Dinesh,

Thank you for your suggestion. Actually, the other option is the approach that I have been working for along time and I am very proficient in setting it up to do the transferring data of the data from R3 to BW, but I am on this project that has a requirement to prove that I can learn something new instead of doing something efficient and simple. I try to keep things simple and efficient but there is always someone else who wants some other approach just to prove something unimportant and and not necessary.

I will keep my head banging at this until it gets loaded. I hope I am still alive after this....

Thanks again

Former Member
0 Kudos

Hi Crystal,

Probably something is wrong with the FM extractor or there is no data hence you see 0 records. But RSA3 is the place to check whether you have data for your datasource or not.

The other option would be to use a staging table in R/3 to populate all the data and then use that table to create the datasource.

Bye

Dinesh