on 04-12-2006 12:00 AM
Hi,
I am still working on the FM to create a generic extractor. I went through the debugger but I am still unable to determine how the ranges are populated. RSA3 always gives me zero values for the results.
There is a RANGE statement in the sample FM and the following statements for SELECTs
RANGES: L_R_CARRID FOR SFLIGHT-CARRID,
L_R_CONNID FOR SFLIGHT-CONNID.
and...
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CARRID'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_CARRID.
APPEND L_R_CARRID.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CONNID'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_CONNID.
APPEND L_R_CONNID.
ENDLOOP.
My question is how is L_R_CONNID and L_R_CARRID populated with low and high values for the SELECT statements? I tried to find the DS 0SAPI_SFLIGHT_SIMPLE to run and see how it is set up but there is no such DS.
Would someone take the time to say something about this in several sentences? I have my own code and it seems that it is not populating the values for the SELECTs when I debug from RSA3 when I provide the low and high values.
Would I normally populate the low and high values from the InfoPackage 'Data Selection' tab once I have implemented in BW or ready to test in BW? That would mean I have to choose those fields as selections from RSO2. Anyway, I think I have asked about this but I am hoping to get an answer to get this going...
Appreciate any replies.
Hi
In our generic extractors we use 2 ways:
1. get the parameters for the load via a code that reads
a control table such as TVARV and populates the
selections for the load.
2. thru the infopckage you you can send ranges and
values as selections. Depending on how the extractor
was built.
Reg's
Edan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the quick response. I wanted to ask you how you did the code for the TVARV using this FM template. I actually understand how, but the placement of the code in this FM module is not the same to what I have been working with the ABAP programming. I would suppose you you would place it after the the statement
IF S_COUNTER_DATAPAKID = 0.
Thanks again
Hi,
The below statement in the FM is the Key part of the answer to your question.
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
i.e in Initialization mode (first call by SAPI) or data transfer mode (First call of full load) the values for S_S_IF-T_SELECT will be filled and then in later (dleta laods for Dela and second onwards calls of Full upload) will use this values of S_S_IF-T_SELECT .
With rgds,
Anil Kumar Sharma .P
Hi Anil Kumar Sharma,
Thanks for your reply. Per your suggestion:
<i>i.e in Initialization mode (first call by SAPI) or data transfer mode (First call of full load) the values for S_S_IF-T_SELECT will be filled...</i>
May I ask how would this be filled? We are looking to load only a year or so of data for full load and not the complete data from the table because if I understand it the full load retrieves all from the table.
Here is what I know
1. Either by TVARV
2. The "Data Selection" tab from the InfoPackage, where I have selected accordingly from RSO2, replicate, create the DS and then IPack.
3. Hard code in the FM to perform the historical full load for a year or so.
Thanks again for the reply and let me know if what I understanding is correct or if there is any other way to fill the parameters.
Hi
Here is an example of an extractor that uses
both method's, if the InfoPackage selection exist's
it overrides the TVARV selection (which is the default).
-
FUNCTION ZBW_TC_FORECAST_SO_EXTRACTOR.
*"----
""Local interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SBIWA_S_INTERFACE-REQUNR
*" VALUE(I_DSOURCE) TYPE SBIWA_S_INTERFACE-ISOURCE OPTIONAL
*" VALUE(I_CHABASNM) TYPE SBIWA_S_INTERFACE-CHABASNM OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SBIWA_S_INTERFACE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SBIWA_S_INTERFACE-INITFLAG OPTIONAL
*" VALUE(I_UPDMODE) TYPE SBIWA_S_INTERFACE-UPDMODE OPTIONAL
*" VALUE(I_DATAPAKID) TYPE SBIWA_S_INTERFACE-DATAPAKID OPTIONAL
*" VALUE(I_PRIVATE_MODE) OPTIONAL
*" VALUE(I_CALLMODE) TYPE ROARCHD200-CALLMODE OPTIONAL
*" TABLES
*" I_T_SELECT TYPE SBIWA_T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SBIWA_T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZBW_TC_FORECASTING_EXT_STR OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*" HIERARCHY_NOT_FOUND
*"----
----
Change History *
----
Mod. # | Date | Developer | Description *
----
*RD3K915762|06/21/2005| SRangaraj | Change selection of open SO *
| | | data to include deleted matls *
| | | and obsolete items too *
RD3K915888|06/29/2005| SRANGARAJ | Add ext matl grp and lab offce
| | | filters for data-selection *
----
The input parameter I_DATAPAKID is not supported yet !
Auxiliary Selection criteria structure
DATA: L_S_SELECT TYPE SBIWA_S_SELECT.
Maximum number of lines for DB table
STATICS L_MAXSIZE TYPE SBIWA_S_INTERFACE-MAXSIZE.
Parameter I_PRIVATE_MODE:
Some applications might want to use this function module for other
purposes as well (e.g. data supply for OLTP reporting tools). If the
processing logic has to be different in this case, use the optional
parameter I_PRIVATE_MODE (not supplied by BIW !) to distinguish
between BIW calls (I_PRIVATE_MODE = SPACE) and other calls
(I_PRIVATE_MODE = X).
If the message handling has to be different as well, define Your own
messaging macro which interprets parameter I_PRIVATE_MODE. When
called by BIW, it should use the LOG_WRITE macro, otherwise do what
You want.
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
************************************************************************
The input parameter I_DATAPAKID is not supported yet !
Invalid second initialization call -> error exit
IF NOT G_FLAG_INTERFACE_INITIALIZED IS INITIAL.
IF 1 = 2. MESSAGE E008(R3). ENDIF.
LOG_WRITE 'E' "message type
'R3' "message class
'008' "message number
' ' "message variable 1
' '. "message variable 2
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDIF.
Check InfoSource validity
CASE I_DSOURCE.
WHEN 'ZBW_TC_SO_EXTRACT'.
WHEN OTHERS.
IF 1 = 2. MESSAGE E009(R3). ENDIF.
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.
Check for supported update mode
CASE I_UPDMODE.
WHEN 'F'.
WHEN OTHERS.
IF 1 = 2. MESSAGE E011(R3). ENDIF.
LOG_WRITE 'E' "message type
'R3' "message class
'011' "message number
I_UPDMODE "message variable 1
' '. "message variable 2
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.
Check for obligatory selection criteria
READ TABLE I_T_SELECT INTO L_S_SELECT WITH KEY FIELDNM = 'PGMID'.
IF SY-SUBRC <> 0.
IF 1 = 2. MESSAGE E010(R3). ENDIF.
LOG_WRITE 'E' "message type
'R3' "message class
'010' "message number
'PGMID' "message variable 1
' '. "message variable 2
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDIF.
APPEND LINES OF I_T_SELECT TO G_T_SELECT.
Fill parameter buffer for data extraction calls
G_S_INTERFACE-REQUNR = I_REQUNR.
G_S_INTERFACE-ISOURCE = I_DSOURCE.
G_S_INTERFACE-MAXSIZE = I_MAXSIZE.
G_S_INTERFACE-INITFLAG = I_INITFLAG.
G_S_INTERFACE-UPDMODE = I_UPDMODE.
G_S_INTERFACE-DATAPAKID = I_DATAPAKID.
G_FLAG_INTERFACE_INITIALIZED = SBIWA_C_FLAG_ON.
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 G_T_FIELDS.
Fill range tables for fixed InfoSources. In the case of generated
InfoSources, the usage of a dynamical SELECT statement might be
more reasonable. BIW will only pass down simple selection criteria
of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
LOOP AT G_T_SELECT INTO L_S_SELECT.
CASE L_S_SELECT-FIELDNM.
WHEN 'PRDHA'.
WGF_PRDHA_LENGTH = STRLEN( L_S_SELECT-LOW ).
IF WGF_PRDHA_LENGTH = 6. "PARTIAL PRDHA
WGF_PRDHA = L_S_SELECT-LOW.
CONCATENATE WGF_PRDHA '%' INTO WGF_PRDHA.
ELSEIF WGF_PRDHA_LENGTH = 12. "FULL PRDHA
MOVE-CORRESPONDING L_S_SELECT TO L_R_PRDHA.
APPEND L_R_PRDHA.
ENDIF.
WHEN 'MATKL'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_MATKL.
APPEND L_R_MATKL.
ENDCASE.
ENDLOOP.
reset the index of where we are in the gt_header table
g_tabix = 0.
perform populate_default_variables.
perform get_data.
perform build_detail.
EXIT.
ENDIF. "Initialization mode or data extraction ?
************************************************************************
Data transfer: First Call OPEN CURSOR + FETCH
Following Calls FETCH only
************************************************************************
First data package -> OPEN CURSOR
IF G_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 InfoSource table lines and database entries, this is trivial.
In other cases, it may be impossible and some estimated value has to
be determined.
DESCRIBE TABLE LT_DATA LINES l_count.
IF g_tabix GE l_count.
RAISE no_more_data.
ENDIF.
*CLEAN UP THE OUTPUT TABLE
refresh E_T_DATA.
LOOP AT LT_DATA FROM G_TABIX INTO LS_DATA.
APPEND LS_DATA TO E_T_DATA.
Set global counter
g_tabix = g_tabix + 1.
ENDLOOP.
G_COUNTER_DATAPAKID = G_COUNTER_DATAPAKID + 1.
ENDIF. "Initialization mode or data extraction ?
ENDFUNCTION.
-
Forms
-
----
***INCLUDE LZBW_TC_FORECAST_SO_EXTF01 .
----
&----
*& Form populate_default_variables
&----
text
----
--> p1 text
<-- p2 text
----
FORM populate_default_variables.
data: wlf_name like tvarv-name.
clear: R_prdh3[], wlf_name.
*get the exclusion range from tvarv for the product hierarchy in
*question
concatenate 'ZBW_EXL_' WGF_PRDHA(6) INTO WLF_NAME.
SELECT LOW FROM TVARV INTO R_prdh3-low WHERE
NAME = WLF_NAME.
move: 'I' to R_prdh3-sign,
'EQ' to R_prdh3-option.
append R_prdh3.
clear R_prdh3.
ENDSELECT.
{Start of insert by SRangaraj on June 29, 2005 >>RD3K915888
CLEAR L_R_LABOR[].
SELECT LOW FROM TVARV INTO L_R_LABOR-Low WHERE
NAME = 'ZBW_TC_FORECAST_LAB_OFF'.
move: 'I' to L_R_LABOR-sign,
'EQ' to L_R_LABOR-option.
append L_R_LABOR.
clear L_R_LABOR.
ENDSELECT.
}End of insert by SRangaraj on June 29, 2005 >>RD3K915888
ENDFORM. " populate_default_variables
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_data.
data: wlf_lmeng like vbep-lmeng.
*get all deliveries for date range for either a range of product hrchy
*or a like value
refresh int_records1.
if wgf_prdha ne space.
select ivbeln iposnr iKLMENG jvkorg i~werks
imatnr imeins mprdha mmatkl
from vbap as i
INNER JOIN VBAK AS j
ON ( jvbeln = ivbeln
and j~vbtyp = 'C' )
INNER JOIN vbuk AS k
ON ( kvbeln = ivbeln
and k~lfgsk <> 'C'
and k~gbstk <> 'C' )
INNER JOIN vbup AS l
ON ( lvbeln = ivbeln and
lposnr = iposnr
and l~lfgsa <> 'C'
and l~gbsta <> 'C' )
INNER JOIN mara AS m
ON ( mmatnr = imatnr
{Start of insert by SRangaraj on June 21, 2005 >>RD3K915762
and m~lvorm eq ' '
and m~mstae ne '99'
{Start of insert by SRangaraj on June 29, 2005 >>RD3K915888
and m~extwg = '080' )
}End of insert by SRangaraj on June 29, 2005 >>RD3K915888
INNER JOIN marc AS n
ON ( nmatnr = imatnr
and nwerks = iwerks
and n~lvorm eq ' ' )
}End of insert by SRangaraj on June 21, 2005 >>RD3K915762
into table int_records1 where ( i~abgru = ' '
and i~klmeng > 0
and m~prdha like wgf_prdha
and m~matkl in l_r_matkl
{Start of insert by SRangaraj on June 29, 2005 >>RD3K915888
and m~labor in l_r_labor ).
}End of insert by SRangaraj on June 29, 2005 >>RD3K915888
elseif not l_r_prdha[] is initial and wgf_prdha = space.
select ivbeln iposnr iKLMENG jvkorg i~werks
imatnr imeins mprdha mmatkl
from vbap as i
INNER JOIN VBAK AS j
ON ( jvbeln = ivbeln
and j~vbtyp = 'C' )
INNER JOIN vbuk AS k
ON ( kvbeln = ivbeln
and k~lfgsk <> 'C'
and k~gbstk <> 'C' )
INNER JOIN vbup AS l
ON ( lvbeln = ivbeln and
lposnr = iposnr
and l~lfgsa <> 'C'
and l~gbsta <> 'C' )
INNER JOIN mara AS m
ON ( mmatnr = imatnr
{Start of insert by SRangaraj on June 21, 2005 >>RD3K915762
and m~lvorm eq ' '
and m~mstae ne '99'
{Start of insert by SRangaraj on June 29, 2005 >>RD3K915888
and m~extwg = '080' )
}End of insert by SRangaraj on June 29, 2005 >>RD3K915888
INNER JOIN marc AS n
ON ( nmatnr = imatnr
and nwerks = iwerks
and n~lvorm eq ' ' )
}End of insert by SRangaraj on June 21, 2005 >>RD3K915762
into table int_records1 where ( i~abgru = ' '
and i~klmeng > 0
and m~prdha in l_r_prdha
and m~matkl in l_r_matkl
{Start of insert by SRangaraj on June 29, 2005 >>RD3K915888
and m~labor in l_r_labor ).
}End of insert by SRangaraj on June 29, 2005 >>RD3K915888
endif.
sort int_records1 by vbeln posnr.
delete adjacent duplicates from int_records1 comparing
vbeln posnr.
*remove unnecessary records
if not r_prdh3[] is initial.
DELETE INT_RECORDS1 WHERE PRDHA+6(3) IN r_prdh3.
endif.
*get the schedule lines for all of the above records and
*get the lowest schedule line date per so line item
if not int_records1[] is initial.
refresh int_records3.
select vbeln posnr etenr mbdat into table int_records3
from vbep for all entries in int_records1
where vbeln = int_records1-vbeln and
posnr = int_records1-posnr and
lmeng > 0.
sort int_records3 by vbeln posnr etenr mbdat ascending.
loop at int_Records1.
loop at int_records3 where vbeln = int_records1-vbeln
and posnr = int_records1-posnr.
int_records1-mbdat = int_records3-mbdat.
modify int_records1.
exit.
endloop.
endloop.
refresh int_records3. free int_records3.
refresh int_records2.
*get the deliveries and calculate the open quantities
select vbelv posnv vbeln posnn rfmng plmin
from vbfa into table int_records2
for all entries in int_Records1
where vbelv = int_records1-vbeln
and posnv = int_records1-posnr
and VBTYP_N = 'J'. "Dels
*calculate open quantities next
loop at int_records1.
clear wlf_lmeng.
clear int_records2.
loop at int_records2 where vbelv = int_records1-vbeln
and posnv = int_records1-posnr.
case int_records2-plmin.
when '-'.
wlf_lmeng = wlf_lmeng - int_records2-rfmng.
when others. "just add
wlf_lmeng = wlf_lmeng + int_records2-rfmng.
endcase.
endloop.
int_records1-klmeng = int_records1-klmeng - wlf_lmeng.
int_records1-vbeln_dl = int_records2-vbeln.
int_records1-posnr_dl = int_records2-posnn.
modify int_records1.
endloop.
endif.
delete int_records1 where klmeng le 0.
refresh int_records2. free int_Records2.
ENDFORM. " get_data
&----
*& Form build_detail
&----
text
----
--> p1 text
<-- p2 text
----
FORM build_detail.
LOOP AT int_records1.
*DO INDIVIDUAL MOVES - ITS FASTER THAN MOVE-CORRESPONDING
move: int_records1-vkorg to LS_DATA-VKORG,
int_records1-werks to LS_DATA-WERKS,
int_records1-matnr to LS_DATA-MATNR,
int_records1-klmeng to LS_DATA-KLMENG,
int_records1-mbdat(6) to LS_DATA-YEARMONTH,
int_records1-meins TO LS_DATA-MEINS,
int_records1-vbeln TO LS_DATA-VGBEL,
int_records1-posnr TO LS_DATA-VGPOS,
int_records1-vbeln_dl TO LS_DATA-VBELN,
int_records1-posnr_dl TO LS_DATA-POSNR,
int_records1-mbdat to LS_DATA-WADAT_IST,
int_records1-PRDHA to LS_DATA-PRDHA,
int_records1-matkl to LS_DATA-MATKL.
APPEND LS_DATA TO LT_DATA.
clear: LS_DATA.
ENDLOOP.
ENDFORM. " build_detail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.