04-07-2010 12:24 PM
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?
04-07-2010 12:28 PM
well since type is same for a b c so cant use corresponding fields either so i dont think u hv any option
04-07-2010 12:30 PM
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
04-07-2010 12:31 PM
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
04-07-2010 12:31 PM
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?
04-07-2010 12:34 PM
my problem is because the a and b fields have the same name in their originating tables
but have diferent meanings.
04-07-2010 12:37 PM
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
04-07-2010 1:00 PM
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)".
04-07-2010 12:35 PM
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