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

Need help in OO programming

Former Member
0 Likes
1,266

Dear experts,

I am looking a way out by which i provide a single value as a parameter to a method .Assume single value is N.

and which could return me an internal table.I read it is not possible with returning.Any other way ?.

Also,What is returning then used for ?.It will be great if ii could get some examples.I could not see any example where

any internal table is returned.To pass though looks possible using parameter-tab.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,233

Hi,

Please refer to the below link.

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/20b50a75-0330-2c10-bf86-a2e4b7ab64ba&override...

Hope this will be useful.

Regards,

Dhanalakshmi L

11 REPLIES 11
Read only

Former Member
0 Likes
1,233

Dear experts,

If i compare with java, if i use

Vector x;

public Vector method(int x)

{

return(Vector)

}

main()

{

x = method(1);

// I will expect x getting values in Vector

Isn;t this concept applicable in java using method and returning internal table.If no what is OO abap made for ?

Read only

Former Member
0 Likes
1,234

Hi,

Please refer to the below link.

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/20b50a75-0330-2c10-bf86-a2e4b7ab64ba&override...

Hope this will be useful.

Regards,

Dhanalakshmi L

Read only

0 Likes
1,233

I dont know gentleman dhanlakshmi what u mean by asking me to visit this link.

However,i tried to find forums of same issue.I got solution saying one.

Hi urjose,

Here is the solution.

Just follow these steps.

1)In the main program, you have defined your internal table as:

data: begin of itab occurs 0.

include structure kna1.

data: end of itab.

2) After creating and initializing the object , call the method of the class as:

call emp->get_table exporting int_table = itab.

3) Go to se11, create a table type of kna1 say ztabtype.

3) In se24, in the methods section, define the method get_table . In the parameters section,give

int_table importing type ztabtype.Give some description.

4) In the implementation, for accessing the values,

do as follows.

method get_table.

data: wa_itab type kna1.

loop at int_table into wa_itab.

now u can access the contents using wa_itab.

endmethod.

This co-mensurates to many view i got to my current problem.

All i need to say that if programming in OO- abap is that bit ugly that every type has to be defined in your dictionary.

I was much-much happy using traditional approach.I am surprised that if i want to return an internal table of structure mseg,that

means i goto dictionary and create some ZMSEG and give each and every entry creating duplicate mseg !!!!!!.Ins't this creating

junk in your dictionary.Further what is the guarantee that tomorrow , i migrate from SAP 4.7 to ECC 6.0 ,all Z Objects will be

taken care of !!! .This is complete **** !!.

Read only

0 Likes
1,233

Plz plz plz experts, i am desperately waiting for your views as today may become a significant day in my life which will be

rolling back to my original approach which has been tradiitonal so long.Also ,as i have not worked on netweaver,do they use same principles !! ??

Read only

0 Likes
1,233

Cant even i define table types in global subroutines ?

Read only

0 Likes
1,233

Hi!

As i understand u need to get something like this:

program zjdtest.

types: begin of ty_s_vector,
         a type c,
         b type c,
*        ....
       end of ty_s_vector,
       ty_t_vector type standard table of ty_s_vector
         with default key.

data: lt_vector type ty_t_vector.

class lcl_report definition.
  public section.
    class-methods: method1 importing id_parameter type i
                           returning value(rt_vector) type ty_t_vector.
endclass.

class lcl_report implementation.
  method method1.
*    rt_vector = " something that have been calculated.
  endmethod.
endclass.

start-of-selection.

  lt_vector = lcl_report=>method1( 1 ).

Edited by: Petr.Plenkov on Nov 18, 2009 7:36 AM

Read only

0 Likes
1,233

no petr,i quoted Vector just as an example from Java - OO perspective. I simply want to return an internal table from

a method.Moreover opinions say that for every internal table you return make a Z table in your dictionary.This is not

acceptable to us.

Read only

0 Likes
1,233

>

> I simply want to return an internal table from a method.Moreover opinions say that for every internal table you return make a Z table in your dictionary.

Where do u see any Ztype declaration in the code above? Here is local table type ty_t_vector and a method returning internal table of this type. i haven't expected u are even not able to read the simpliest abap code

Read only

0 Likes
1,233

i correct myself Z tabletype not z table

Read only

0 Likes
1,233

Sorry petr, i give it a try .Believe me i got a little disturbed.

Read only

0 Likes
1,233

Thanx petr your techniqe has worked.This means lot of misconception is there between consultants who have been guiding each other in a way like creating Z objects on SE11.

I am sorry for my comments which were dipped in ignorance.

Petr you deserve full marks here.