Skip to Content
Former Member
Oct 13, 2006 at 08:22 PM

Help me to understand the code


function z_get_data.

  • DataSource for table ZBOOK

tables: zbook.

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

if i_initflag = sbiwa_c_flag_on.

  • Check DataSource validity

case i_dsource.

when 'ZZBOOK'.

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.


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 fieldsand 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 ?

if s_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 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 * from zbook.


"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 e_t_data

package size s_s_if-maxsize.

if sy-subrc <> 0.

close cursor s_cursor.

raise no_more_data.


s_counter_datapakid = s_counter_datapakid + 1.


"Initialization mode or data extraction ?