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

select (join) into internal table with nested structures

Former Member
0 Likes
2,971

Hello Experts,

i wonder about the correct notation of a select statement.

I have an internal table it_zoll including two structures as defined below.

The select is a join on the two tables zollp and zolls. As coded below the select is syntactically correct, but the fields

in the nested structures are not filled ....

Any ideas how to write the select statement ? (The internal table it_zoll must have the nested structures for other reasons ..)

Declaration:


TYPES: BEGIN OF ty_zollp,
  belnr     TYPE  zollp-belnr,
  werks     TYPE  zollp-werks,
  gebnr     TYPE  zollp-gebnr,
  ...
  ...
       END OF ty_zollp.

TYPES: BEGIN OF ty_zolls,
  grnum     type  zolls-grnum,
  werks     type  zolls-werks,
  name1     TYPE  zolls-name1,
  ...
  ...
       END OF ty_zolls.


DATA: BEGIN OF wa_zoll.
DATA: zollp type ty_zollp.
DATA: zolls type ty_zolls.
DATA: END OF wa_zoll.
DATA: it_zoll LIKE TABLE OF wa_zoll.

Select:


  SELECT
    zollp~belnr   zollp~werks  zollp~gebnr
    zolls~grnum zolls~werks  zolls~name1

      FROM zollp
      JOIN zolls ON   zolls~werks = zollp~werks
                 AND  zolls~grnum = zollp~grnum

      INTO CORRESPONDING FIELDS OF TABLE it_zoll
      WHERE zollp~werks = werks
      AND   zollp~gebnr IN s-gebnr
      AND ...
      .

Thank you !

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,874

No data is copied cause there are no corresponding fields. Actually there are only two fields in the internal table, they are ZOLLP and ZOLLS , SELECT wont care of sub-fields.

Try to remove the CORRESPONDING FIELDS OF option in your SELECT.

Regards,

Raymond

6 REPLIES 6
Read only

andreas_mann3
Active Contributor
0 Likes
1,874

have you tried it without TYPES?

and : i nclude structure...

grx

Andreas

Read only

Former Member
0 Likes
1,874

DATA: BEGIN OF ty_zollp,

belnr TYPE zollp-belnr,

werks TYPE zollp-werks,

gebnr TYPE zollp-gebnr,

...

...

END OF ty_zollp.

DATA: BEGIN OF ty_zolls,

grnum type zolls-grnum,

werks type zolls-werks,

name1 TYPE zolls-name1,

...

...

END OF ty_zolls.

DATA: BEGIN OF wa_zoll.

Include structure ty_zollp.

Include structure ty_zolls.

DATA: END OF wa_zoll.

The above declaration had worked. Please try.

Regards,

Satish Kanteti

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,875

No data is copied cause there are no corresponding fields. Actually there are only two fields in the internal table, they are ZOLLP and ZOLLS , SELECT wont care of sub-fields.

Try to remove the CORRESPONDING FIELDS OF option in your SELECT.

Regards,

Raymond

Read only

0 Likes
1,874

Thanks for your replies

the "include structure"-proposal won't work for me. I need to address the content of table it_zoll (respectivly structure wa_zoll) lateron by using e.g. following syntax "wa_zoll-zollp-werks" or "wa_zoll-zolls-werks" and not e.g. "wa_zoll-werks".

Any more ideas ?

! removal of "into corresponding fields of" works

Edited by: Andreas Milbredt on Apr 29, 2011 1:24 PM

Read only

0 Likes
1,874

My solution works if the list of fields selected map the structure definition, so don't forget to adapt the sequence of fields selected to any change of the structure definition to respect sequence and mapping rules. ([Work Areas in Open SQL Statements |http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_WA.htm])

Regards,

Raymond

Read only

0 Likes
1,874

Thanks Raymond,

it really is a bit unflexible, because when changing the underlying structures also the select statements have to be changed. And even the sequence of the selected fields has to match exactly the definition of the structures.

As an alternative i could define the structures like the (huge) database tables and use select *, that would be more flexible but not have the best performance effect.