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

Move data to Export Parameter type TABLE

Former Member
0 Likes
4,591

Hi All,

I have a method with Exporting parameter declared as

EX_ITABExportingTypeTABLE

Now i want to move some records into EX_ITAB...How do i do that ...

Say i want to move some records from MARA Table to EX_ITAB ...How should i do that...

Do i need to create a structure for EX_ITAB first and then move the data...

I would appreciate if someone can throw some light on this

And also is there any difference between

EX_ITABExportingTypeSTANDARD TABLE

and above statement

Thanks in advance

6 REPLIES 6
Read only

custodio_deoliveira
Active Contributor
0 Likes
2,081

Hi Satyam,

I'll start from the end. TYPE TABLE means you can export any type of internal table. TYPE STANDARD TABLE does not allow hasehd or idexed tables to be exported.

The actual type of the table is defined by the parameter passed to the method. So, if in your caller program you call:

object->method( IMPORTING ex_itab = lt_mara )

in your method ex_itab will have the same structure as lt_mara. Not sure it's clear enough

As for assigning values to ex_itab, there are a few ways to do it. If you are sure the table is MARA, then you can declare:

data lt_mara type table of mara.

move all the record to this internal table, than do:

ex_itab = lt_mara.

Again, be aware of type mismatch. If the calling program is like this:

object->method( IMPORTING ex_itab = lt_marc )

and you move mara to ex_itab, you will have a short dump.

Cheers,

Custodio

Read only

0 Likes
2,081

Thanks Custodio ..

I was just giving an example of Mara...

I will know the structure of the EX_ITAB at run time in the method...

Then i don't think this will work

data lt_mara type table of mara.

move all the record to this internal table, than do:

ex_itab = lt_mara.

I wanted to move the values so that it wold for any scenario

I hope you understood my question

Thanks

Read only

0 Likes
2,081

Yes, I did understand it.

Thing is, it may be very complex. probably best way is by using RTTS.  Here is a very simple code that may help you:

REPORT zcust01.

DATA lt_mara TYPE TABLE OF mara.

*----------------------------------------------------------------------*

*       CLASS lcl_class DEFINITION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS lcl_class DEFINITION.

   PUBLIC SECTION.

     CLASS-METHODS    get EXPORTING ex_tab TYPE table.

ENDCLASS.                    "lcl_class DEFINITION

*----------------------------------------------------------------------*

*       CLASS lcl_class IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS lcl_class IMPLEMENTATION.

   METHOD get.

     DATA p_descr_ref TYPE REF TO cl_abap_typedescr.

     p_descr_ref = cl_abap_datadescr=>describe_by_data( ex_tab ).

     BREAK-POINT.

   ENDMETHOD.                    "get

ENDCLASS.                    "lcl_class IMPLEMENTATION

START-OF-SELECTION.

   lcl_class=>get(

     IMPORTING

       ex_tab = lt_mara

).

On this break-point, have a look at p_descr_ref. There's an attribute with all components from the table.

Hope this helps.

Read only

Former Member
0 Likes
2,081

Hi satyam ,

As per my understanding you need to move data to internal table parameter which is exporting

1. Create structure in  SE11.

use this structure in exporting parameter.

hope it will work. If it not working means create type table of and try..

thanks & regards

meena

Read only

Former Member
0 Likes
2,081

Hi

data: ex_tab type table of table (internal tabel)

         lx_tab type table. (work area for your table)

         lx_workarea type mara. (work area for mara).

loop at it_mara into lx_workarea.

move corresponding lx_workarea into lx_tab.

append lx_tab to ex_tab.

endloop.

With regards

Suneesh

Read only

Former Member
0 Likes
2,081

Hello ,

If you have global table or structure(visible in SE11 not internal) of type you want to export, then make a table type of those using se11 and passing that table and structure  name. 

and if you don't have a table/structure then firstly create a structure(when you don't want to store data in DB) or table(when you want to store data in DB) and then create table type using se11 of those.