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

Returning table in classes

former_member184551
Contributor
4,511

Hey Guys

I have created a class with two methods.

In of these methods I am trying to return a table of type VBFAVB, this is a type in se38.

Here is my method code

METHOD get_docflow_vbelv.

  DATA: t_vbfa TYPE TABLE OF vbfavb,
        l_vbfa LIKE LINE  OF t_vbfa .

  CALL FUNCTION 'WB2_VBFA_READ_WITH_VBELV'
    EXPORTING
      i_vbelv          = vbelv
    TABLES
      et_vbfa          = t_vbfa
    EXCEPTIONS
      record_not_found = 1
      OTHERS           = 2.

  IF sy-subrc = 0.
      ret_tab[] = t_vbfa[].
  ENDIF.

  CLEAR: l_vbfa,t_vbfa[].
ENDMETHOD.

And I have defined in parametrs the ret_tab like this

RET_TAB Exporting Type VBFAVB

When I compile it says 'RET_TAB' is not an internal table the specification OCCURS N is missing.

Please give me an Idea on how to "pass" an internal table in classes.

A sample code would be great !

Thanks for reading.

Rgds

Sameer

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
2,424

at the interface you can define,

RET_TAB Exporting Type STANDARD TABLE.

9 REPLIES 9
Read only

Sm1tje
Active Contributor
0 Kudos
2,424

So how have you defined REF_TAB? Should be the same type as your itab!!

And it looks to me that you haven't?

Edited by: Micky Oestreich on May 13, 2008 10:32 PM

RET_TAB Exporting Type VBFAVB, this is not an internal table.

What you can do is find out if this type also has a table type defined in data dictionary via where used list.

If not available create this table type with line type Type VBFAVB .

Edited by: Micky Oestreich on May 13, 2008 10:33 PM

Alternative:

create the type in the class itself. Look at the TYPES button at the top of the screen.

ref_tab type table of VBFAVB.

Edited by: Micky Oestreich on May 13, 2008 10:41 PM

Read only

Former Member
0 Kudos
2,425

at the interface you can define,

RET_TAB Exporting Type STANDARD TABLE.

Read only

uwe_schieferstein
Active Contributor
0 Kudos
2,424

Hello Sameer

On ECC 6.0 you have plenty of table types available having line type VBFAVB:

LEINT_VBFAVB_T                   Reference structures VBFAVB
LESHP_DELIVERY_DOCUMENT_FLOW_T   Delivery's Document Flow
SA_XVBFA                         Document Flow: Sales
SHP_VL10_VBFA_T                  SD Document Flow
VA_VBFAVB_T                      Table for structure VBFAVB
VBFA_SRT_T                       BAdI Interface Type for Structure VBFAVB

I would recommend to use SA_XVBFA because it is part of the rather "generic" package VA.

Your class method should look like this:


CLASS lcl_myclass DEFINITION.

  PUBLIC SECTION.

    METHODS:
      get_docflow_vbelv
        IMPORTING
          VALUE(id_vbelv)    TYPE vbeln
        RETURNING 
          VALUE(rt_data)     TYPE sa_xvbfa.

ENDCLASS.


CLASS lcl_myclass IMPLEMENTATION.

  METHOD get_docflow_vbelv.
  CALL FUNCTION 'WB2_VBFA_READ_WITH_VBELV'
    EXPORTING
      i_vbelv          = id_vbelv
    TABLES
      et_vbfa          = rt_data
    EXCEPTIONS
      record_not_found = 1
      OTHERS           = 2.
 
    IF sy-subrc = 0.
    ENDIF.
  ENDMETHOD.

ENDCLASS.


REPORT zmyreport.


DATA:  gt_vbfa   TYPE  sa_xvbfa.

PARAMETERS:
  p_vbeln            TYPE vbeln.

START-OF-SELECTION.

  CREATE go_myclass.

  gt_vbfa = go_myclass->get_docflow_vbelv( p_vbeln ).  " function call OR:
  CALL METHOD go_myclass->get_docflow
    EXPORTING
      id_vbelv = p_vbeln
    RECEIVING
      rt_data = gt_vbfa.
END-OF-SELECTION.

Regards

Uwe

Read only

0 Kudos
2,119

Hi!

I have a similar issue working with a method that called a function....I have already put the returning table as you said, but it didn't work 😪, could you help me? Please 

 

 method ZGET_DETALLE.
*    TYPES it_detalle TYPE ty_det.
     DATA: t_det TYPE STANDARD TABLE OF zccdetalle,
        l_detalle LIKE LINE  OF t_det .

    CALL FUNCTION 'ZF_DATOS_CLIENTE_LVAA'
      EXPORTING
        pncliente =  PNCLIENTE                " ELEMENTO DE LOS DATOS DEL CLIENTE
      IMPORTING
        pmensaje  = PMENSAJE                 " ELEMENTO DE DATO PARA MENSAJE*S
      TABLES
        ptcte     =  t_det             " ESTRUCTURA DETALLE CLIENTE
      .
    "PTDET[] = it_detalle[].
     IF sy-subrc = 0.
      ptdet[] = t_det[].
     ENDIF.

  CLEAR: l_detalle,t_det[].

  endmethod.

 

 In the interface

lizvalpi_mx_0-1717707846732.png

When I run the method appears this window

lizvalpi_mx_1-1717707992368.png

 

 

Read only

former_member184551
Contributor
0 Kudos
2,424

thanx guys

Read only

Former Member
0 Kudos
2,424

Dear experts,

I have a similar problem regarding to exporting internal table in a method when I create a global class in SE24. The difference is that I have defined the internal table as Standard table of a structure. For example:

DATA: t_vbfa TYPE Standard TABLE OF vbfavb,
"assume vbfavb is a structure.                                                                                
"t_vbfa is defined in the class attribute section
METHOD get_docflow_vbelv.
    CALL FUNCTION 'WB2_VBFA_READ_WITH_VBELV'
     EXPORTING
          i_vbelv          = vbelv
     TABLES
        et_vbfa          = t_vbfa.
  
  IF sy-subrc = 0.
      ret_tab[] = t_vbfa[].
  ENDIF.
 
ENDMETHOD.

I have defined a table using the fields of vbfavb structure as ZVBFAVB, for example. I then declared an variable as follow:

RET_TAB Exporting Type ZVBFAVB

When I compiled my program, it says 'RET_TAB' is not an internal table the specification OCCURS N is missing.

How can I avoid the above problem. Where and how should I define this exporting variable RET_TAB so that I can pass this internal table out of the method.

Your help is greatly appreciated.

Thanks,

Anna

Read only

Former Member
0 Kudos
2,424

Dear experts,

I have a similar problem regarding to exporting internal table in a method when I create a global class in SE24. The difference is that I have defined the internal table as Standard table of a structure. For example:

DATA: t_vbfa TYPE Standard TABLE OF VBFAVB,
               "assume VBFAVB is a structure here. 
               "t_vbfa is defined in the class attribute section
METHOD get_docflow_vbelv.
    CALL FUNCTION 'WB2_VBFA_READ_WITH_VBELV'
     EXPORTING
          i_vbelv          = vbelv
     TABLES
        et_vbfa          = t_vbfa.
  
  IF sy-subrc = 0.
      ret_tab[] = t_vbfa[].
  ENDIF.
 
ENDMETHOD.

I have defined a table using the fields of VBFAVB structure as ZVBFAVB, for example. I then declared the internal table as follow:

RET_TAB Exporting Type ZVBFAVB

When I compiled my program, it says 'RET_TAB' is not an internal table the specification OCCURS N is missing.

How should I define RET_TAB so that I can pass this internal table out of the method.

Your help is greatly appreciated.

Thanks,

Anna

Read only

0 Kudos
2,424

Hi Anna

This what you need to do

Either look for a table type with line type VBFAVB, or create one. Table types work with classes when you are exporting tables.

I found two which are already existing and could solve your purpose.

VA_VBFAVB_T and

LEINT_VBFAVB_T.

Hope you understand.

Read only

0 Kudos
2,424

Thanks for your help. I understand now. Anna