2012 Mar 07 11:10 AM
Hi All,
I have a requirement to extract data from 7 tables, for which i have written the code as below :
My approach:
1. Created a FM.
2. Defined a structure with all the fields from all the tables ZZXXXX and assigned it to E_T_DATA in the FM.
3. Created a structure (for each table)
Example:
Table A code :
TYPES: BEGIN OF t_aXX,
kschl TYPE AX-ksXXl,
knumXX TYPE AXX-knumXX,
vkorgXX TYPE AXX-vkorg,
END OF t_aXX.
DATA: wa_aXX1 TYPE t_aXX,
it_aXX TYPE STANDARD TABLE OF t_aXX.
SELECT * FROM aXX1 (Actual Table) INTO CORRESPONDING FIELDS OF TABLE it_aXX.
LOOP AT it_aXX INTO wa_aXX1.
ENDLOOP.
Similarly for rest of the Tables...
in the End
MOVE-CORRESPONDING wa_Tab A TO e_t_data.
MOVE-CORRESPONDING wa_Tab B TO e_t_data.
lly .....like above for all the tables...
APPEND e_t_data TO i_t_data.
Where E_T_DATA is like the Main Structure 'ZZXXXX.
' which i created with all the fields...
Is the above approach is correct or is there any better way of writing the code...
I need all the data from all the tables...into my final structure, because the users can post transactions in any table...of which i am not able to append based on some key field...
All help is appreciated..
Thanks,
Hi All,
I have a requirement to extract data from 7 tables, for which i have written the code as below :
My approach:
1. Created a FM.
2. Defined a structure with all the fields from all the tables ZZXXXX and assigned it to E_T_DATA in the FM.
3. Created a structure (for each table)
Example:
Table A code :
TYPES: BEGIN OF t_aXX,
kschl TYPE AX-ksXXl,
knumXX TYPE AXX-knumXX,
vkorgXX TYPE AXX-vkorg,
END OF t_aXX.
DATA: wa_aXX1 TYPE t_aXX,
it_aXX TYPE STANDARD TABLE OF t_aXX.
SELECT * FROM aXX1 (Actual Table) INTO CORRESPONDING FIELDS OF TABLE it_aXX.
LOOP AT it_aXX INTO wa_aXX1.
ENDLOOP.
Similarly for rest of the Tables...
in the End
MOVE-CORRESPONDING wa_Tab A TO e_t_data.
MOVE-CORRESPONDING wa_Tab B TO e_t_data.
lly .....like above for all the tables...
APPEND e_t_data TO i_t_data.
Where E_T_DATA is like the Main Structure 'ZZXXXX.
' which i created with all the fields...
Is the above approach is correct or is there any better way of writing the code...
I need all the data from all the tables...into my final structure, because the users can post transactions in any table...of which i am not able to append based on some key field...
All help is appreciated..
Thanks,
2012 Mar 07 11:21 AM
Hi,
Check if there is a common link between all the tables. If yes, then you can go for JOINS.
Regards,
Danish.
2012 Mar 07 11:25 AM
Hi Danish,
There are some key fields but as these are client specific tables and client specific fields ...un able to do jon condition...
i tried it in creating a view but was not possible...
Thanks,
2012 Mar 07 11:42 AM
Hi,
For those tables which are having common keys, you can then use FOR ALL ENTRIES IN. For the rest of the tables you will have to fetch the data individually.
Regards,
Danish.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |