function zpsb_w4_zds_accdtfr.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" 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 STRUCTURE ZACCDTFR OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
* Auxiliary Selection criteria structure
data:
wa_data like line of e_t_data.
* 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,
a(1).
* 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_ACCDTFR'.
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.
a = 'X'.
EXEC SQL.
open with hold s for
select c.TB_CAEXT,
CASE WHEN ( select substr("/BIC/ZWPRODTXT",9,1)
from SAPSR3."/BIC/AZCONTRCT00" z
where z.TB_CAEXT = c.TB_CAEXT ) IN ('S', 'B') AND c."/BIC/OPENUPIS" = ' '
THEN c.TB_CAVALFR
ELSE nvl(
( select min("/BIC/CRDGVDT")
from SAPSR3."/BIC/AMCRDFACT00" m
where m."/BIC/TBACAEXT" = c.TB_CAEXT
and m."/BIC/ZCA_REGM" NOT IN ('009','010')
and m."/BIC/CRDGVDT" <> '00000000' ),
( select min(cc.TB_CAVALFR)
from SAPSR3."/BIC/AZCONTRCT00" cc
where cc."/BIC/ZCONTROID" = c.TB_CAEXT
and cc."/BIC/ZCONTCAT" in ('C')
and cc."/BIC/ZPRODCAT" = 'C'
and cc."/BIC/ZWBPCAT" = 'P') )
END as "/BIC/ACCDTFR"
from SAPSR3."/BIC/ATBCAEXTD00" c
where c."/BIC/ZCONTCAT" in ('A')
and c."/BIC/ZPRODCAT" = 'C'
and c."/BIC/ZWBPCAT" = 'P'
and c."/BIC/ACCDTFR" <> CASE WHEN ( select substr("/BIC/ZWPRODTXT",9,1)
from SAPSR3."/BIC/AZCONTRCT00" z
where z.TB_CAEXT = c.TB_CAEXT ) IN ('S', 'B') AND c."/BIC/OPENUPIS" = ' '
THEN c.TB_CAVALFR
ELSE nvl(
( select min("/BIC/CRDGVDT")
from SAPSR3."/BIC/AMCRDFACT00" m
where m."/BIC/TBACAEXT" = c.TB_CAEXT
and m."/BIC/ZCA_REGM" NOT IN ('009','010')
and m."/BIC/CRDGVDT" <> '00000000' ),
( select min(cc.TB_CAVALFR)
from SAPSR3."/BIC/AZCONTRCT00" cc
where cc."/BIC/ZCONTROID" = c.TB_CAEXT
and cc."/BIC/ZCONTCAT" in ('C')
and cc."/BIC/ZPRODCAT" = 'C'
and cc."/BIC/ZWBPCAT" = 'P') )
END
ENDEXEC.
endif. "First data package ?
refresh e_t_data.
if a is initial.
raise no_more_data.
endif.
s_counter_datapakid = s_counter_datapakid + 1.
do s_s_if-maxsize times.
clear wa_data.
EXEC SQL.
fetch next s into :wa_data
ENDEXEC.
if ( wa_data is initial ) or sy-subrc <> 0.
EXEC SQL.
close s
ENDEXEC.
clear a.
exit.
endif.
append wa_data to e_t_data.
enddo.
endif. "Initialization mode or data extraction ?
endfunction.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" 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 STRUCTURE ZACCDTFR OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
* Auxiliary Selection criteria structure
data:
wa_data like line of e_t_data.
* 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,
a(1).
* 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_ACCDTFR'.
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.
a = 'X'.
EXEC SQL.
open with hold s for
select c.TB_CAEXT,
CASE WHEN ( select substr("/BIC/ZWPRODTXT",9,1)
from SAPSR3."/BIC/AZCONTRCT00" z
where z.TB_CAEXT = c.TB_CAEXT ) IN ('S', 'B') AND c."/BIC/OPENUPIS" = ' '
THEN c.TB_CAVALFR
ELSE nvl(
( select min("/BIC/CRDGVDT")
from SAPSR3."/BIC/AMCRDFACT00" m
where m."/BIC/TBACAEXT" = c.TB_CAEXT
and m."/BIC/ZCA_REGM" NOT IN ('009','010')
and m."/BIC/CRDGVDT" <> '00000000' ),
( select min(cc.TB_CAVALFR)
from SAPSR3."/BIC/AZCONTRCT00" cc
where cc."/BIC/ZCONTROID" = c.TB_CAEXT
and cc."/BIC/ZCONTCAT" in ('C')
and cc."/BIC/ZPRODCAT" = 'C'
and cc."/BIC/ZWBPCAT" = 'P') )
END as "/BIC/ACCDTFR"
from SAPSR3."/BIC/ATBCAEXTD00" c
where c."/BIC/ZCONTCAT" in ('A')
and c."/BIC/ZPRODCAT" = 'C'
and c."/BIC/ZWBPCAT" = 'P'
and c."/BIC/ACCDTFR" <> CASE WHEN ( select substr("/BIC/ZWPRODTXT",9,1)
from SAPSR3."/BIC/AZCONTRCT00" z
where z.TB_CAEXT = c.TB_CAEXT ) IN ('S', 'B') AND c."/BIC/OPENUPIS" = ' '
THEN c.TB_CAVALFR
ELSE nvl(
( select min("/BIC/CRDGVDT")
from SAPSR3."/BIC/AMCRDFACT00" m
where m."/BIC/TBACAEXT" = c.TB_CAEXT
and m."/BIC/ZCA_REGM" NOT IN ('009','010')
and m."/BIC/CRDGVDT" <> '00000000' ),
( select min(cc.TB_CAVALFR)
from SAPSR3."/BIC/AZCONTRCT00" cc
where cc."/BIC/ZCONTROID" = c.TB_CAEXT
and cc."/BIC/ZCONTCAT" in ('C')
and cc."/BIC/ZPRODCAT" = 'C'
and cc."/BIC/ZWBPCAT" = 'P') )
END
ENDEXEC.
endif. "First data package ?
refresh e_t_data.
if a is initial.
raise no_more_data.
endif.
s_counter_datapakid = s_counter_datapakid + 1.
do s_s_if-maxsize times.
clear wa_data.
EXEC SQL.
fetch next s into :wa_data
ENDEXEC.
if ( wa_data is initial ) or sy-subrc <> 0.
EXEC SQL.
close s
ENDEXEC.
clear a.
exit.
endif.
append wa_data to e_t_data.
enddo.
endif. "Initialization mode or data extraction ?
endfunction.
Комментариев нет:
Отправить комментарий