Skip to Content
0
Former Member
Jan 20, 2015 at 07:33 AM

Generic datasource based on function module giving 0 records in BW

763 Views

Hi Team,

We have created a generic datasource using function module in ECC for one requirement and it's giving records in RSA3 by giving selection conditions and extract. After replicating the datasource in BW side, when i try to do full update in infopackage(by same selection in rsa3) it's giving 0 records. Kindly give some idea about why it's not giving data in BW.

My function module code as follows.

FUNCTION zpm_fm_bi_expired_reports.
*"----------------------------------------------------------------------
*"*"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
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" 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 TYPE ZPM_BI_EXPIRED_PERMIT_TT OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------

DATA: it_wcahe TYPE TABLE OF wcahe,
wa_wcahe TYPE wcahe,

it_wcagns TYPE TABLE OF wcagns,
wa_wcagns TYPE wcagns,

it_jest TYPE TABLE OF jest,
wa_jest TYPE jest,

it_wcala_ap TYPE TABLE OF wcala,
wa_wcala_ap TYPE wcala,

it_wcala_or TYPE TABLE OF wcala,
wa_wcala_or TYPE wcala,

it_aufk TYPE TABLE OF aufk,
wa_aufk TYPE aufk,

it_v_usr_name TYPE TABLE OF v_usr_name,
wa_v_usr_name TYPE v_usr_name,

it_final TYPE TABLE OF zpm_bi_expired_permit_st,
wa_final TYPE zpm_bi_expired_permit_st.

DATA :lv_flag TYPE c,
lv_date TYPE wcedatefr.

* 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_carrid FOR sflight-carrid,
* l_r_connid FOR sflight-connid.
RANGES: l_r_iwerk FOR wcahe-iwerk,
l_r_crdate FOR wcahe-crdate.
* 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 'ZDS_EXPIRDPERMIT'.
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.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'CRDATE'." or fieldnm = 'IWERK'.
IF l_s_select-low IS NOT INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_IDATE_INPUT'
EXPORTING
input = l_s_select-low
IMPORTING
output = l_s_select-low.
ENDIF.

MOVE-CORRESPONDING l_s_select TO l_r_crdate.
APPEND l_r_crdate.
ENDLOOP.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'IWERK'..
MOVE-CORRESPONDING l_s_select TO l_r_iwerk.
APPEND l_r_iwerk.
ENDLOOP.

SELECT * FROM wcahe
INTO CORRESPONDING FIELDS OF TABLE it_wcahe
WHERE iwerk IN l_r_iwerk
AND crdate LE l_r_crdate-low.

IF it_wcahe IS NOT INITIAL.
SELECT * FROM wcagns
INTO CORRESPONDING FIELDS OF TABLE it_wcagns
FOR ALL ENTRIES IN it_wcahe
WHERE objnr = it_wcahe-objnr
AND counter = '2'.

SELECT * FROM jest
INTO CORRESPONDING FIELDS OF TABLE it_jest
FOR ALL ENTRIES IN it_wcahe
WHERE objnr = it_wcahe-objnr
AND inact EQ ' '.

SELECT * FROM wcala INTO CORRESPONDING FIELDS OF TABLE it_wcala_ap
FOR ALL ENTRIES IN it_wcahe
WHERE childobj = it_wcahe-objnr.

IF it_wcala_ap IS NOT INITIAL .

SELECT * FROM wcala INTO CORRESPONDING FIELDS OF TABLE it_wcala_or
FOR ALL ENTRIES IN it_wcala_ap
WHERE childobj = it_wcala_ap-fatherobj.

IF it_wcala_or IS NOT INITIAL .

SELECT * FROM aufk INTO CORRESPONDING FIELDS OF TABLE it_aufk
FOR ALL ENTRIES IN it_wcala_or
WHERE objnr = it_wcala_or-fatherobj.

ENDIF.

ENDIF.

ENDIF.

SELECT * FROM v_usr_name
INTO CORRESPONDING FIELDS OF TABLE it_v_usr_name.


SORT it_wcagns BY objnr gendatum DESCENDING.

LOOP AT it_wcahe INTO wa_wcahe.
READ TABLE it_jest INTO wa_jest WITH KEY objnr = wa_wcahe-objnr
stat = 'I0046'
inact = ' '.
IF sy-subrc NE 0.
CLEAR wa_jest.
READ TABLE it_jest INTO wa_jest WITH KEY objnr = wa_wcahe-objnr
stat = 'I0176'
inact = ' '.
IF sy-subrc NE 0.
CLEAR wa_jest.
READ TABLE it_jest INTO wa_jest WITH KEY objnr = wa_wcahe-objnr
stat = 'I0611'
inact = ' '.
IF sy-subrc EQ 0.
lv_flag = 'X'.
ELSE.
CLEAR wa_jest.
READ TABLE it_jest INTO wa_jest WITH KEY objnr = wa_wcahe-objnr
stat = 'I0406'
inact = ' '.
IF sy-subrc EQ 0.
lv_flag = 'X'.
ENDIF.
ENDIF.

ENDIF.
ENDIF.

READ TABLE it_wcala_ap INTO wa_wcala_ap WITH KEY childobj = wa_wcahe-objnr.
IF sy-subrc EQ 0.
READ TABLE it_wcala_or INTO wa_wcala_or WITH KEY childobj = wa_wcala_ap-fatherobj.
IF sy-subrc EQ 0.
READ TABLE it_aufk INTO wa_aufk WITH KEY objnr = wa_wcala_or-fatherobj.
IF sy-subrc EQ 0.
wa_final-aufnr = wa_aufk-aufnr.
wa_final-auart = wa_aufk-auart.
ENDIF.
ENDIF.
ENDIF.


IF lv_flag = 'X'.
IF wa_aufk-auart = 'ZM08'.
lv_date = wa_wcahe-datefr + 14.
ELSE.
lv_date = wa_wcahe-datefr + 6.
ENDIF.
IF lv_date LT sy-datum.
wa_final-wcnr = wa_wcahe-wcnr.
wa_final-objnr = wa_wcahe-objnr.
wa_final-wctyp = wa_wcahe-wctyp.
wa_final-stxt = wa_wcahe-stxt.
wa_final-iwerk = wa_wcahe-iwerk.
wa_final-wkcrid = wa_wcahe-wkcrid.
wa_final-crname = wa_wcahe-crname.
READ TABLE it_v_usr_name INTO wa_v_usr_name WITH KEY bname = wa_final-crname .
IF sy-subrc EQ 0.
wa_final-crname_txt = wa_v_usr_name-name_text.
ENDIF.
wa_final-crdate = wa_wcahe-crdate.
wa_final-aufnr = wa_aufk-aufnr.
wa_final-auart = wa_aufk-auart.
wa_final-vaplz = wa_aufk-vaplz.
wa_final-datefr = wa_wcahe-datefr.
wa_final-dateto = wa_wcahe-dateto.
wa_final-zzrdate = wa_wcahe-zzrdate.
wa_final-zzrdate2 = wa_wcahe-zzrdate2.
wa_final-zzrdate3 = wa_wcahe-zzrdate3.
wa_final-zzrdate4 = wa_wcahe-zzrdate4.
wa_final-zzrdate5 = wa_wcahe-zzrdate5.
wa_final-zzrdate6 = wa_wcahe-zzrdate6.
IF wa_final-zzrdate6 IS NOT INITIAL.
wa_final-zzrdate_latest = wa_final-zzrdate6.
ELSEIF wa_final-zzrdate5 IS NOT INITIAL.
wa_final-zzrdate_latest = wa_final-zzrdate5.
ELSEIF wa_final-zzrdate4 IS NOT INITIAL.
wa_final-zzrdate_latest = wa_final-zzrdate4.
ELSEIF wa_final-zzrdate3 IS NOT INITIAL.
wa_final-zzrdate_latest = wa_final-zzrdate3.
ELSEIF wa_final-zzrdate2 IS NOT INITIAL.
wa_final-zzrdate_latest = wa_final-zzrdate2.
ELSEIF wa_final-zzrdate IS NOT INITIAL.
wa_final-zzrdate_latest = wa_final-zzrdate.
ENDIF.

wa_final-zzrdate_expired = lv_date + 1.
READ TABLE it_wcagns INTO wa_wcagns WITH KEY objnr = wa_wcahe-objnr.
IF sy-subrc EQ 0.
wa_final-genname = wa_wcagns-genname.
READ TABLE it_v_usr_name INTO wa_v_usr_name WITH KEY bname = wa_final-genname .
IF sy-subrc EQ 0.
wa_final-genname_txt = wa_v_usr_name-name_text.
ENDIF.

wa_final-gendatum = wa_wcagns-gendatum.
ENDIF.

APPEND wa_final TO it_final.
CLEAR:wa_final, wa_wcahe,wa_wcagns, lv_flag, lv_date,wa_v_usr_name, wa_aufk,wa_wcala_ap,wa_wcala_or.

ENDIF.

ENDIF.


ENDLOOP.

e_t_data[] = it_final[].

ELSE .
RAISE no_more_data.
*-- Custom code
ENDIF.

s_counter_datapakid = s_counter_datapakid + 1.

ENDIF. "Initialization mode or data extraction ?
ENDFUNCTION.

Regards

Harikrishna N

Attachments

Expired.zip (2.6 kB)