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

Question about a Select

Former Member
0 Likes
889

Lets supose I have an internal table (itab) with this structure

a Type c

b Type c

c Type c

and then I want to make this select

SELECT d e FROM example
           INTO table itab.

but supose the a field corresponds to d and c corresponds to e...

is there anyway to do something like this

SELECT d blank e FROM example
           INTO table itab.

so that my internal table stays correctly filled?

8 REPLIES 8
Read only

Former Member
0 Likes
818

well since type is same for a b c so cant use corresponding fields either so i dont think u hv any option

Read only

Former Member
0 Likes
818

No, Why dont you define the type columns as d & e, and use the keyword "MOVE CORRESPONDING FIELDS OT <ITAB> in select statment.

Regards

Vinod

Read only

Former Member
0 Likes
818

hi ,

i think we cant give black in between,

but use corresponing field and i think that should work if both a and d (and c and e) have same data element.

SELECT d e FROM example

INTO corresponding field of table itab.

thanks,

tanmaya

Read only

Former Member
0 Likes
818

An array fetch (into table itab) will fill the first two rows. Why build an internal table that doesn't match what you're selecting?

Read only

Former Member
0 Likes
818

my problem is because the a and b fields have the same name in their originating tables

but have diferent meanings.

Read only

0 Likes
818

Hi,

One option is to use a work area. Something like;


SELECT d e FROM example
             INTO (wa_itab-a, wa_itab-c).
append wa_itab to itab.
ENDSELECT.

Regards,

Nick

Read only

0 Likes
818

this last answer solves it, but is not very optimized.

i tryed to make 2 different internal tables so that i could use the TO CORRESPONDENT FIELDS thingy

but then I cant dinamicaly change the table of my Control table, or can I ?

ive made this

PROCESS BEFORE OUTPUT.
  MODULE status_0200.
*
  MODULE select_tabelas.

  LOOP AT (tab) INTO (wa_tab) WITH CONTROL tcon.
    MODULE actualiza_tc.
  ENDLOOP.

PROCESS AFTER INPUT.

  LOOP AT (tab).
    MODULE actualiza_tabi.
  ENDLOOP.
  MODULE user_command_0200.

MODULE select_tabelas OUTPUT.

  IF r1 = 'X'.
    tab = 'tabi'.
    wa_tab = 'wa_tabi'.
  ELSEIF r2 = 'X'.
    tab = 'tabi2'.
    wa_tab = 'wa_tabi2'.
  ENDIF.

ENDMODULE.

and got this:

Error analysis

Program "ZSL_EX_3" was terminated.

The following error occurred: (short text of error cause)

"FX097: Internal table undefined."

Affected:

Screen name..............."ZSL_EX_3"

Screen number.............0200

This is an error that occurred during processing of an internal table in

conjunction with field or variable "(WA_TAB)".

Read only

Former Member
0 Likes
818

Hi,

What vinod says is correct, create a proper internal table with the fields you are selecting, that would be simple.

Anothe solution is given by Kartik here you need to be little intelligent, here you wont get any error as data field type and size is same but problem occur for b as e will be stored in b. So you need to handel it properly