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

internal table with an internal table

Former Member
0 Likes
1,327

Hi,

I have following definition:


TYPES:  BEGIN OF ty_pos,
             numbertype(29)            TYPE c,
             number(29)                TYPE c,
             END OF ty_pos.

DATA: gt_pos TYPE STANDARD TABLE OF ty_pos,
      gs_pos LIKE LINE OF gt_pos.

TYPES: BEGIN OF ty_struc,
        city(29)                  TYPE c,
        country(29)               TYPE c,
        name(29)                  TYPE c,

        pos LIKE gt_pos,
END OF ty_struc.

DATA: gt_tab TYPE STANDARD TABLE OF ty_struc,
      gs_tab LIKE LINE OF gt_tab.

The problem is that the system don't know the fields when I say


  gs_tab-pos-number                = 'test'.

How should I write the syntax therefore?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,247

Hi,

Check the code

TYPES : BEGIN OF t_gr,
          wrbtr TYPE ekbe-wrbtr,
          menge TYPE ekbe-menge,
          bwart TYPE ekbe-bwart,
         END OF t_gr.
 
  DATA :  i_gr    TYPE TABLE OF t_gr.
*
  TYPES : BEGIN OF t_ekbe,
           ebeln TYPE ekbe-ebeln,
           ebelp TYPE ekbe-ebelp,
           *llggr LIKE i_gr,*
          END OF t_ekbe.
 
   DATA : i_ekbe      TYPE TABLE OF t_ekbe.
 
   SELECT ebeln
          ebelp
          wrbtr
          FROM ekbe
          INTO TABLE i_ekbe1
          FOR ALL ENTRIES IN i_data1
          WHERE ebeln = i_data1-ebeln   AND
                ebelp = i_data1-ebelp   AND
                  bewtp = c_e          AND
                ( bwart = c_101        OR
                  bwart = c_102        OR
                  bwart = c_103        OR
                  bwart = c_104 ).
 
loop at i_ekbe1 into wa_ekbe1.
wa_ekbe = wa_ekbe1.
wa_gr-wrbtr = wa_ekbe-wrbtr
append wa_gr to i_gr.
on change of  wa_ekbe1-ebeln.
       INSERT LINES OF i_gr INTO wa_ekbe-llggr INDEX 1.
       APPEND wa_ekbe TO i_ekbe.
endon.
edloop.

the above code the ekbe table is having one move itab l_gr

l_gr is updated in each loop and and each change the i_ekbe is updated with one set of l_gr data as internal table line for i_ekbe.

Here u need to refer each table seperately.

parent table(EKKO) line has the child tables(EKPO).

regards,

Nandha

Hi,

I have following definition:


TYPES:  BEGIN OF ty_pos,
             numbertype(29)            TYPE c,
             number(29)                TYPE c,
             END OF ty_pos.

DATA: gt_pos TYPE STANDARD TABLE OF ty_pos,
      gs_pos LIKE LINE OF gt_pos.

TYPES: BEGIN OF ty_struc,
        city(29)                  TYPE c,
        country(29)               TYPE c,
        name(29)                  TYPE c,

        pos LIKE gt_pos,
END OF ty_struc.

DATA: gt_tab TYPE STANDARD TABLE OF ty_struc,
      gs_tab LIKE LINE OF gt_tab.

The problem is that the system don't know the fields when I say


  gs_tab-pos-number                = 'test'.

How should I write the syntax therefore?

10 REPLIES 10
Read only

Former Member
0 Likes
1,247

hi,

check the spelling.

gs_pos-number = 'test'.

Read only

Former Member
0 Likes
1,248

Hi,

Check the code

TYPES : BEGIN OF t_gr,
          wrbtr TYPE ekbe-wrbtr,
          menge TYPE ekbe-menge,
          bwart TYPE ekbe-bwart,
         END OF t_gr.
 
  DATA :  i_gr    TYPE TABLE OF t_gr.
*
  TYPES : BEGIN OF t_ekbe,
           ebeln TYPE ekbe-ebeln,
           ebelp TYPE ekbe-ebelp,
           *llggr LIKE i_gr,*
          END OF t_ekbe.
 
   DATA : i_ekbe      TYPE TABLE OF t_ekbe.
 
   SELECT ebeln
          ebelp
          wrbtr
          FROM ekbe
          INTO TABLE i_ekbe1
          FOR ALL ENTRIES IN i_data1
          WHERE ebeln = i_data1-ebeln   AND
                ebelp = i_data1-ebelp   AND
                  bewtp = c_e          AND
                ( bwart = c_101        OR
                  bwart = c_102        OR
                  bwart = c_103        OR
                  bwart = c_104 ).
 
loop at i_ekbe1 into wa_ekbe1.
wa_ekbe = wa_ekbe1.
wa_gr-wrbtr = wa_ekbe-wrbtr
append wa_gr to i_gr.
on change of  wa_ekbe1-ebeln.
       INSERT LINES OF i_gr INTO wa_ekbe-llggr INDEX 1.
       APPEND wa_ekbe TO i_ekbe.
endon.
edloop.

the above code the ekbe table is having one move itab l_gr

l_gr is updated in each loop and and each change the i_ekbe is updated with one set of l_gr data as internal table line for i_ekbe.

Here u need to refer each table seperately.

parent table(EKKO) line has the child tables(EKPO).

regards,

Nandha

Read only

former_member632729
Contributor
0 Likes
1,247

Hi Dude,

Use this..




TYPES:  BEGIN OF ty_pos,
             numbertype(29)            TYPE c,
             number(29)                TYPE c,
             END OF ty_pos.

data : gt_pos type ty_pos,
       gs_pos like gt_pos .

TYPES: BEGIN OF ty_struc,
        city(29)                  TYPE c,
        country(29)               TYPE c,
        name(29)                  TYPE c,
        pos  like gs_pos,
END OF ty_struc.


data : gt_tab type ty_struc,
       gs_tab like gt_tab.

break-point.
gs_tab-pos-number = 'test'.

write : gs_tab-pos-number.

Read only

Former Member
0 Likes
1,247

Hi,

I am not understood why ur checking like gs_tab-pos-number = 'test'. Number field should be

gs_pos-number = 'test'.

Regards

Md.MahaboobKhan

Read only

0 Likes
1,247

number field is also in my structure gs_tab as I inlude it in the field pos

Read only

0 Likes
1,247

I cannot use this mentioned statement as I want that field pos in gt_tab is an internal table

TYPES: BEGIN OF ty_struc,

city(29) TYPE c,

country(29) TYPE c,

name(29) TYPE c,

pos like gs_pos,

END OF ty_struc.

with this statement pos is only a structure and not an internal table within an internal table

Read only

former_member222860
Active Contributor
0 Likes
1,247

Hi,

Declare

Pos like gs_pos

TYPES:  BEGIN OF ty_pos,
             numbertype(29)            TYPE c,
             number(29)                TYPE c,
             END OF ty_pos.

DATA: gt_pos TYPE STANDARD TABLE OF ty_pos,
      gs_pos LIKE LINE OF gt_pos.

TYPES: BEGIN OF ty_struc,
        city(29)                  TYPE c,
        country(29)               TYPE c,
        name(29)                  TYPE c,
        
        pos LIKE gs_pos,      "  Change here
END OF ty_struc.

DATA: gt_tab TYPE STANDARD TABLE OF ty_struc,
      gs_tab LIKE LINE OF gt_tab.


gs_tab-pos-number = 'test'.

it works now.

thanks|

Mahesh

Read only

Former Member
0 Likes
1,247

Hi,

Here work area gs_tab corresponds to the table gt_tab, which corresponds to the structure ty_struc and this structure doesnt contain POS_NUMBER.

define POS_NUMBER in strucute ty_struc than only wont get error.

Cheers,

Rudhir

Read only

0 Likes
1,247

your right but it contains pos-number

Read only

0 Likes
1,247

is it not possible that I can define pos as an internal table within an internal table to read the several fields of pos like number?