Skip to Content
0
Former Member
Apr 20, 2007 at 06:56 AM

Z data source issue for creating packets

12 Views

Hi I have created a Z data source (function module) .

My issue is I am not able to create data record packets all the data is coming in one packet only.

The is code is as show below is some one can please assist me how can I change the code so that is can create multiple packets for the option given in Tcode RSA3.

FUNCTION ZBW_MATERIAL_GROUP_HIE.

*"----


""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 STRUCTURE ZBW_MAT_GRP_HIER OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


TABLES : /BI0/HMATL_GROUP.

DATA : BEGIN OF t_hmat OCCURS 0,

hieid LIKE /BI0/HMATL_GROUP-hieid,

objvers LIKE /BI0/HMATL_GROUP-objvers,

iobjnm LIKE /BI0/HMATL_GROUP-iobjnm,

nodeid LIKE /BI0/HMATL_GROUP-nodeid,

nodename LIKE /BI0/HMATL_GROUP-nodename,

tlevel LIKE /BI0/HMATL_GROUP-tlevel,

parentid LIKE /BI0/HMATL_GROUP-parentid,

END OF t_hmat.

DATA : BEGIN OF t_flathier,

hieid LIKE /BI0/HMATL_GROUP-hieid,

lv2_id LIKE /BI0/HMATL_GROUP-nodeid,

lv2_name LIKE /BI0/HMATL_GROUP-nodename,

lv3_id LIKE /BI0/HMATL_GROUP-nodeid,

lv3_name LIKE /BI0/HMATL_GROUP-nodename,

lv4_id LIKE /BI0/HMATL_GROUP-nodeid,

lv4_name LIKE /BI0/HMATL_GROUP-nodename,

lv5_id LIKE /BI0/HMATL_GROUP-nodeid,

lv5_name LIKE /BI0/HMATL_GROUP-nodename,

lv6_id LIKE /BI0/HMATL_GROUP-nodeid,

lv6_name LIKE /BI0/HMATL_GROUP-nodename,

lv7_id LIKE /BI0/HMATL_GROUP-nodeid,

lv7_name LIKE /BI0/HMATL_GROUP-nodename,

lv8_id LIKE /BI0/HMATL_GROUP-nodeid,

lv8_name LIKE /BI0/HMATL_GROUP-nodename,

lv9_id LIKE /BI0/HMATL_GROUP-nodeid,

lv9_name LIKE /BI0/HMATL_GROUP-nodename,

lv10_id LIKE /BI0/HMATL_GROUP-nodeid,

lv10_name LIKE /BI0/HMATL_GROUP-nodename,

lv11_id LIKE /BI0/HMATL_GROUP-nodeid,

lv11_name LIKE /BI0/HMATL_GROUP-nodename,

material LIKE /BI0/HMATL_GROUP-nodename,

END OF t_flathier.

FIELD-SYMBOLS: <f> LIKE LINE OF t_hmat,

<Level> TYPE ANY.

data : count(2) type c,

lv_level(20) type c.

DATA : lv_count TYPE n.

DATA : lv_id LIKE /BI0/HMATL_GROUP-nodeid,

lv_hieid LIKE /BI0/HMATL_GROUP-hieid.

  • 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_nodename FOR /BI0/HMATL_GROUP-nodename,

l_r_hieid FOR /BI0/HMATL_GROUP-hieid.

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

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.

  • Fill range tables BW will only pass down simple selection criteria

  • of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = '0MATERIAL'.

MOVE-CORRESPONDING l_s_select TO l_r_nodename.

APPEND l_r_nodename.

ENDLOOP.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'HIEID'.

MOVE-CORRESPONDING l_s_select TO l_r_hieid.

APPEND l_r_hieid.

ENDLOOP.

  • Get the data from Hierarchy table

SELECT * FROM /BI0/HMATL_GROUP INTO CORRESPONDING FIELDS OF

TABLE t_hmat

WHERE hieid IN l_r_hieid

AND objvers = 'A' .

ENDIF.

  • loop through all the 0MATERIAL entries to get all the hirarchy levels.

  • Start of change.

  • LOOP AT t_hmat ASSIGNING <f>

  • WHERE iobjnm = '0MATL_GROUP'

  • AND nodename IN l_r_nodename.

LOOP AT t_hmat ASSIGNING <f>

WHERE nodename IN l_r_nodename.

  • End of change

lv_count = <f>-tlevel.

"refresh t_flathier.

CLEAR: t_flathier. ", lv_level, count.

MOVE :

<f>-hieid TO lv_hieid ,

  • <f>-nodename TO t_flathier-material,

<f>-parentid TO lv_id.

if <f>-iobjnm <> '0MATL_GROUP' .

move <f>-nodename+3 to t_flathier-material .

else.

move <f>-nodename to t_flathier-material .

endif.

  • Added for Last level.

if lv_count = '1' .

*t_flathier-lv1_name = t_flathier-material .

elseif lv_count = '2' .

t_flathier-lv2_name = t_flathier-material .

elseif lv_count = '3' .

t_flathier-lv3_name = t_flathier-material .

elseif lv_count = '4' .

t_flathier-lv4_name = t_flathier-material .

elseif lv_count = '5' .

t_flathier-lv5_name = t_flathier-material .

elseif lv_count = '6' .

t_flathier-lv6_name = t_flathier-material .

elseif lv_count = '7' .

t_flathier-lv7_name = t_flathier-material .

elseif lv_count = '8' .

t_flathier-lv8_name = t_flathier-material .

elseif lv_count = '9' .

t_flathier-lv9_name = t_flathier-material .

elseif lv_count = '10' .

t_flathier-lv10_name = t_flathier-material .

endif.

DO lv_count TIMES .

lv_count = lv_count - 1.

IF lv_count = 1.

EXIT.

ENDIF.

READ TABLE t_hmat WITH KEY

hieid = lv_hieid

nodeid = lv_id.

IF sy-subrc = 0.

CLEAR lv_id.

CASE lv_count.

WHEN '11' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv11_name,

t_hmat-parentid TO lv_id.

WHEN '10' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv10_name,

t_hmat-parentid TO lv_id.

WHEN '9' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv9_name,

t_hmat-parentid TO lv_id.

WHEN '8' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv8_name,

t_hmat-parentid TO lv_id.

WHEN '7' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv7_name,

t_hmat-parentid TO lv_id.

WHEN '6' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv6_name,

t_hmat-parentid TO lv_id.

WHEN '5' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv5_name,

t_hmat-parentid TO lv_id.

WHEN '4' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv4_name,

t_hmat-parentid TO lv_id.

WHEN '3' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv3_name,

t_hmat-parentid TO lv_id.

WHEN '2' .

MOVE : t_hmat-nodename+3 TO t_flathier-lv2_name.

ENDCASE.

ENDIF.

ENDDO.

  • Populate data for level 1 (Class Type)

READ TABLE t_hmat WITH KEY

hieid = lv_hieid

tlevel = 1.

IF sy-subrc = 0.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = t_hmat-nodename

IMPORTING

output = e_t_data-0class_type.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = e_t_data-0class_type

IMPORTING

output = e_t_data-0class_type.

ENDIF.

  • populate data to extraction structure ( removing prefixe 'class type')

MOVE : lv_hieid TO e_t_data-hieid,

t_flathier-lv2_name TO e_t_data-xhier_lv1,

t_flathier-lv3_name TO e_t_data-xhier_lv2,

t_flathier-lv4_name TO e_t_data-xhier_lv3,

t_flathier-lv5_name TO e_t_data-xhier_lv4,

t_flathier-lv6_name TO e_t_data-xhier_lv5,

t_flathier-lv7_name TO e_t_data-xhier_lv6,

t_flathier-lv8_name TO e_t_data-xhier_lv7,

t_flathier-lv9_name TO e_t_data-xhier_lv8,

t_flathier-lv10_name TO e_t_data-xhier_lv9,

t_flathier-lv11_name TO e_t_data-xhie_lv10,

t_flathier-material TO e_t_data-0MATL_GROUP.

APPEND e_t_data.

CLEAR e_t_data.

ENDLOOP.

s_counter_datapakid = s_counter_datapakid + 1.

IF s_counter_datapakid > 1 .

RAISE no_more_data.

ENDIF.

ENDIF. "Initialization mode or data extraction ?

ENDFUNCTION.

As now when I run it in Tcode RSA3 it give only one data packet of some 5k to 6k records.

Thanks in advance for your help.

Pawan.