on ‎2007 Jun 18 4:21 PM
Hi,
we created 10 custom tables in ECC for FI/CO process. I need to create a generic extractor using function module. I found many posts to create a function module for single table.
Can I use one function module to extract data from more than one table? All the tables have relationships. or do I need to create 10 different function modules?
Please advise.
Thanks&Regards,
Hans.
Request clarification before answering.
Hi Hans,
You can build a single extract structure with all the required fields from those 10 different tables. In the function module you can fill in this extract structure by using select statements from 10 different tables.
The other option would be to create a view on those 10 tables with all the possible relationships and create a generic extraction from view.
Regards, Uday
Assign points for helpful answers and get one point for yourself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dash,
I have seen RSAX_BIW_GET_DATA_SIMPLE and blogs on that but it pulls data from only SFLIGHT table. I need to pull data from multiple tables.
Cursors are used in that function module. For example, Could you please advise how to write the code for SFIGHT, SBOOK and if one more table is there.
Thanks.
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 'ZDMS_TYP_CON'.
WHEN OTHERS.
IF 1 = 2. MESSAGE e009(r3). ENDIF.
this is a typical log call. Please write every error message like
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.
*Use table DRAW and read everything for document type(DOKAR) = DIS
select dokar doknr dokvr doktl
into table it_draw
from DRAW
where dokar = 'CON'.
sort it_draw by doknr.
clear it_zdmsstruct.
clear g_first.
if s_counter_datapakid = 0.
g_first = 'X'.
loop at it_draw INTO wa_draw.
clear wa_zdmsstruct.
wa_zdmsstruct-ZSAPKEY = wa_draw-doknr.
wa_zdmsstruct-ZSAPDOCNO = wa_draw-DOKVR.
CONCATENATE wa_draw-dokar wa_draw-doknr wa_draw-dokvr
wa_draw-doktl INTO wa_zdmsstruct-Z_SAP_DOKNR.
select single dktxt_uc into wa_zdmsstruct-Z_CONSENT_NO
from drat
where dokar = 'CON'
and doknr = wa_draW-doknr
and dokvr = wa_draW-dokvr.
clear it_drad.
clear l_cuobj.
select single cuobj from INOB
into l_cuobj
where objek = wa_zdmsstruct-Z_SAP_DOKNR
and klart = '017'
and obtab = 'DRAW'.
if sy-subrc = 0.
select objek atinn atzhl atwrt atflv
into table it_ausp
from AUSP
where objek = l_cuobj.
sort it_ausp by atzhl ASCENDING.
select mandt dokar doknr dokvr doktl dokob obzae objky into
table it_drad
from DRAD
where dokar = 'CON'
and dokvr = wa_draw-DOKVR
and doktl = wa_draw-doktl
and doknr = wa_draw-doknr
and dokob = 'IFLOT'.
if sy-subrc <> 0.
clear wa_zdmsstruct-Z_FUNCT_LOC_1.
append wa_zdmsstruct to E_T_DATA.
else.
loop at it_drad INTO wa_drad.
clear wa_zdmsstruct-Z_FUNCT_LOC_1.
wa_zdmsstruct-Z_FUNCT_LOC_1 = wa_drad-objky.
append wa_zdmsstruct to E_T_DATA.
endloop.
endif.
endif.
endloop.
endif.
s_counter_datapakid = s_counter_datapakid + 1.
IF g_first EQ 'X'.
CLEAR g_first.
ELSE.
RAISE no_more_data.
ENDIF.
ENDIF. "Initialization mode or data extraction ?
SORT E_T_DATA ASCENDING BY Z_CONSENT_NO.
ENDFUNCTION.
| User | Count |
|---|---|
| 13 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.