Application Development 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: 

Class Builder - Internal types

Former Member
0 Kudos

Hi,

I'm inside class Builder in SE80.

Is it possible to pass/declare internal types between methods inside my class.

(I don't want to put it into my data dictionary)

I would like to pass this structure between methods in my class.

types: begin of t_PriceStruct,

X_A004_MATNR type A004-MATNR,

X_A004_VTWEG type A004-VTWEG,

end of t_PriceStruct.

Any pointers ? Howto document ?

//Martin

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I hope I address the question correclty. Yes you can declare internal types and use them as interface parameters. When inside class builder, press Ctrl+F5 to declare any local type declarations.

Regards

8 REPLIES 8

Former Member
0 Kudos

Hi,

I hope I address the question correclty. Yes you can declare internal types and use them as interface parameters. When inside class builder, press Ctrl+F5 to declare any local type declarations.

Regards

0 Kudos

Hi,

Thx for that. But I still have problem ...

Tells me that "I_PRICETAB" is not type-compatible with formal parameter "PRICE_INOUT"

I want to pass a internal table and fill it and then return it to the caller.

method GETPRICEZERO .

data: i_PriceTab type table of t_PriceStruct.

call method me->getpricecondition

exporting

vkorg_in = '3100'

date_in = sy-datum

changing

price_inout = i_PriceTab

.

endmethod.

****

LOCAL TYPE

types: begin of t_PriceStruct,

X_A004_MATNR type A004-MATNR,

X_A004_VTWEG type A004-VTWEG,

end of t_PriceStruct.

//MA

0 Kudos

Hi,

Could you please specify type of PRICE_INOUT?

Regards

0 Kudos

Hi,

The parameter looks like this class Builder.

Parameter,type,typinging method,associated type

PRICE_INOUT,Changing,Type,T_PRICESTRUCT

//MA

0 Kudos

Hi,

From the definitions, it seems that PRICE_INOUT is typed as a structure (single line only) while you are passing it a table type, i_PriceTab, as parameter. You will have to change the definition of formal parameter PRICE_INOUT as TYPE TABLE.

See if it helps.

Regards

Message was edited by: Shehryar Khan

Otherwise, declare another local table type like

TYPES: tab_t_PriceStruct TYPE TABLE OF t_PriceStruct and then mention it as data type for PRICE_INOUT.

0 Kudos

Hi,

Thx! It seems to work.

Soo... it's a common task to create methods that have fetch funtionality. Like

GetPrice,GetMaterialDetails,GetStatus etc.

The way I do it is to pass in a empty table and then fill it and then return it to the caller.

Is this Best Practice?

It seems a little bit overkill having to create:

2 diffrent types...

types: begin of t_PriceStruct,

X_A004_MATNR type A004-MATNR,

X_A004_VTWEG type A004-VTWEG,

end of t_PriceStruct.

TYPES: tab_t_PriceStruct TYPE TABLE OF t_PriceStruct.

//Martin

0 Kudos

Hi Martin,

Good to know that the problem is resolved. I would appreciate if you please mark the post as answered so that other members know that the problem has been addressed.

Talking about fetch methods, this is the idea behind OO programming. No need to expose data that is not relevant. Just provide a set of GET and SET methods to the user to use them, since the developer knows what conditions to check and what validations to carry out. Hence the methods encapsulate functionality and keep the interface clean for the user of that method.

Talking about overkilling, the other way of declaring a table type is through Data Dictionary but that was something you did not wish to use. You are in a better position to tell how to best implement your class.

Regards

Former Member
0 Kudos

Hi Martin,

In am trying to add an internal type to a standard class. I have created a type with Ctrl + F5, But am not sure what to do next. Could you plz explain me what are all the steps involved?

Regards,

Rajesh.