Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

funciton module error

Former Member
0 Likes
314

Hi SAP-ABAP Exerts,

Here are the steps that we have performed to create a funciton module and to extract data from data source.

please look into this

1. Identified the master data table -- MARA

2. Identified the columns -- MATNR (Material Number),

MTART (Material Type),

MATKL (Material Group),

MEINS (Base Unit Of Measure)

3. Created the Extract Structure via /nse11 --> DataType --> Create (ZJCMATSTRUCT1). Added the above fields in the structure components. Made sure that the structure cannot be extended.

4. Executed the Transaction Code /nse80. Created the Function Group (ZJCRSAX) and based the Function Group on the template RSAX. Activated the Function Group.

5. Created the function module (ZJCFMMATMSTR) with the following code:

FUNCTION ZJCFMMATMSTR.

*"----


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

*" 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 MARA OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


TABLES: MARA.

DATA: l_s_select TYPE srsc_s_select.

STATICS: s_s_if TYPE srsc_s_if_simple,

s_counter_datapakid LIKE sy-tabix,

s_cursor TYPE cursor.

RANGES: l_r_matnr FOR MARA-matnr,

l_r_mtart FOR MARA-mtart,

l_r_matkl FOR MARA-matkl,

l_r_meins FOR MARA-meins.

IF i_initflag = sbiwa_c_flag_on.

"----


"Initialization: check input parameters & prepare data selection

"----


APPEND LINES OF i_t_select TO s_s_if-t_select.

s_s_if-requnr = i_requnr.

s_s_if-dsource = i_dsource.

s_s_if-maxsize = i_maxsize.

APPEND LINES OF i_t_fields TO s_s_if-t_fields.

ELSE.

"----


"Second Call by SAPI

"----


IF s_counter_datapakid = 0.

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

MOVE-CORRESPONDING l_s_select TO l_r_matnr.

APPEND l_r_matnr.

ENDLOOP.

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

MOVE-CORRESPONDING l_s_select TO l_r_mtart.

APPEND l_r_mtart.

ENDLOOP.

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

MOVE-CORRESPONDING l_s_select TO l_r_matkl.

APPEND l_r_matkl.

ENDLOOP.

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

MOVE-CORRESPONDING l_s_select TO l_r_meins.

APPEND l_r_meins.

ENDLOOP.

OPEN CURSOR WITH HOLD s_cursor FOR

SELECT (s_s_if-t_fields)

FROM MARA

WHERE matnr IN l_r_matnr

AND mtart IN l_r_mtart

AND matkl IN l_r_matkl

AND meins IN l_r_meins.

ENDIF.

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.

ENDIF.

s_counter_datapakid = s_counter_datapakid + 1.

ENDIF.

ENDFUNCTION.

6. Created the Data Source using the Transaction Code /nrso2. (DS Name -- ZJCDSMATMSTR) using the above named Function Module and extract Structure. The data source was saved successfully.

7. Used the Transaction Code /nrsa3 to extract the data from data source. Upon trying to extract, we are getting the following run time error:

"E_T_DATA" is the correct type, its length is incorrect.

2 REPLIES 2
Read only

Former Member
0 Likes
280

>

> E_T_DATA STRUCTURE MARA OPTIONAL

quote}

You have to use this Structure ZJCMATSTRUCT1 instead of mara.

Change the Red line with this code( I mean the declaration)

E_T_DATA STRUCTURE ZJCMATSTRUCT1

Rhea.

Edited by: rhea on Nov 25, 2008 11:03 AM

Read only

Former Member
0 Likes
280

thanku rhea.