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

Importing table from one method to another method

former_member210674
Participant
0 Likes
3,046

Hello Experts,

I am a BW consultant and an ABAP learner

Currently I am creating a class in which two methods

Method 1: Reading a master data and Exporting in a Table.

Table RD_DETVERS is declared in Parameter as EXPORTING, Typing method is TYPE and Associated with ZDETVERSION (Master infoObject)

In the method I have given SELECT statement which reads data from master data and exporting to table RD_DETVERS

Method 2:

I am trying to IMPORT the values of table TB_DETVERS (from method 2) into LT_DETVERS (in method 1)

Below are the codes

********************************************************

LT_DETVERS = ZCL_IM_DECISION_CUSTOM=>READ_EDETVERS( 'RD_DETVERS' ).

   IF SY-SUBRC EQ 0.

     READ TABLE LT_DETVERS INTO LS_DETVERS WITH TABLE KEY

     ZDETVERS = '10' ZBWVERS = 'I'.

    IF SY-SUBRC EQ 0.

     E_STATUS = 'X'.

     RETURN.

     ENDIF.

   ENDIF.

*********************************************************************

Table RD_DETVERS is declared in Parameter as IMPORTING, Typing method is TYPE and Associated with ZDETVERSION (Master infoObject)

But I am getting below error

Class ZCL_IM_DECISION_CUSTOM,Method C_DETVERS_FUNC

You can only omit the parameter name if the method only has a

non-optional parameter or an optional IMPORTING parameter that is

identified by "PREFERRED PARAMETER". by "PREFERRED PARAMETER".

Can anyone please correct me.

Thanks in advance,

Gopi R

4 REPLIES 4
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,698

Hi,

what error says. Your method call C_DETVERS_FUNC is wrong.

I guess it is first method? Which parameters you have in that method? Only one?

try call it like:

...C_DETVERS_FUNC( nameOfParameter = RD_DETVERS ).

-- Tomas --
Read only

matt
Active Contributor
0 Likes
1,698

Class ZCL_IM_DECISION_CUSTOM,Method C_DETVERS_FUNC has more then one parameter. You've only supplied one. Look at the signature (parameters) of c_detvers_func.

Read only

Former Member
0 Likes
1,698

Hello Gopi,

to make work of above method call. you need to make the parameter of method READ_EDETVERS as MANDATORY or PREFFERED.

when you open the class in se 24, place the cursor on method name and press on parameters.

check there you willl get the corresponding settings.

Other way around is in method calling should be as follow

Call Method ZCL_IM_DECISION_CUSTOM=>READ_EDETVERS importing RD_DETVERS = LT_DETVERS .

Regards,

Bhaskar

Read only

amadeusgrabmayer
Participant
0 Likes
1,698

Hi,

you have to set the Option "Preferred" for the parameter.

(the prerequisites are that you only have optional importing parameters (or maximum one not optional one) and your result comes as a returning parameter)

Regards,

Amadeus