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: 

DOUBT IN INTERNAL TABLES

Former Member
0 Kudos
101

Hi i have a doubt in internal table

can i transfer the data in one internal table into another internal table and i have to print that in ALV grid format if yes then can u give me an example

1 ACCEPTED SOLUTION

Former Member
0 Kudos
72

yes..if internal table are of same structure then simply do :-

itab[] = itab1[].

otherwise do a loop at itab and write -

move-corresponding itab to itab1.

endloop.

reward points..

and to print Itab via ALV use following code -

data : WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'PERNR'.

WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.

  • WA_FIELDCAT-ddictxt = 'l'.

WA_FIELDCAT-COL_POS = 2.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

  • when 'maktx'.

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'NAME'.

WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.

  • WA_FIELDCAT-ddictxt = 'l'.

WA_FIELDCAT-COL_POS = 3.

WA_FIELDCAT-OUTPUTLEN = 15.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'ORG'.

WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.

WA_FIELDCAT-COL_POS = 4.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'DOB'.

WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.

WA_FIELDCAT-COL_POS = 5.

WA_FIELDCAT-OUTPUTLEN = 12.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'SALARY'.

WA_FIELDCAT-SELTEXT_L = 'SALARY'.

WA_FIELDCAT-COL_POS = 6.

WA_FIELDCAT-OUTPUTLEN = 25.

WA_FIELDCAT-do_sum = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = repid

IT_FIELDCAT = IT_FIELDTAB

TABLES

t_outtab = itab[]

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

reward points

Message was edited by:

Amit Tyagi

Message was edited by:

Amit Tyagi

3 REPLIES 3

Former Member
0 Kudos
73

yes..if internal table are of same structure then simply do :-

itab[] = itab1[].

otherwise do a loop at itab and write -

move-corresponding itab to itab1.

endloop.

reward points..

and to print Itab via ALV use following code -

data : WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'PERNR'.

WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.

  • WA_FIELDCAT-ddictxt = 'l'.

WA_FIELDCAT-COL_POS = 2.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

  • when 'maktx'.

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'NAME'.

WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.

  • WA_FIELDCAT-ddictxt = 'l'.

WA_FIELDCAT-COL_POS = 3.

WA_FIELDCAT-OUTPUTLEN = 15.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'ORG'.

WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.

WA_FIELDCAT-COL_POS = 4.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'DOB'.

WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.

WA_FIELDCAT-COL_POS = 5.

WA_FIELDCAT-OUTPUTLEN = 12.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CLEAR WA_FIELDCAT .

WA_FIELDCAT-TABNAME = 'ITAB'.

WA_FIELDCAT-FIELDNAME = 'SALARY'.

WA_FIELDCAT-SELTEXT_L = 'SALARY'.

WA_FIELDCAT-COL_POS = 6.

WA_FIELDCAT-OUTPUTLEN = 25.

WA_FIELDCAT-do_sum = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDTAB.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = repid

IT_FIELDCAT = IT_FIELDTAB

TABLES

t_outtab = itab[]

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

reward points

Message was edited by:

Amit Tyagi

Message was edited by:

Amit Tyagi

Former Member
0 Kudos
72

Hi Pavan,

Its simple:

i_tab2[] = i_tab1[].

CALL METHOD o_alvgrid->set_table_for_first_display

EXPORTING

is_variant = w_variant

i_save = 'A'

is_layout = p_layout

CHANGING

it_outtab = i_tab2

it_fieldcatalog = p_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

Reward points if this Helps.

Manish

Former Member
0 Kudos
72

Hi Pavan ,

You can transfer the content of one internal table into another in 2 ways

1. If both of them have the same structure

itab2[] = itab1[].

2. If they have different structures then

loop at itab1.

{ move-corresponding itab1 to itab2

or

move it individually }

append itab2

endloop.

Regards

Arun