How to do a SELECT from different tables into an internal table?
How to do a SELECT from different tables into an internal table?
I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
REPORT zinternal_table.
TABLES:
mara,
marc,
zperson.
TYPES:
BEGIN OF str_table1,
v_name LIKE zperson-zname,
v_matnr LIKE marc-matnr,
v_emarc LIKE marc-emarc,
v_werks_d LIKE marc-werks_d,
v_dstat LIKE marc-dstat,
END OF str_table,
i_table1 TYPE STANDARD TABLE OF str_table1.
DATA:
BEGIN OF str_table2,
v_mandt LIKE mara-mandt,
v_ernam LIKE mara-ernam,
v_laeda LIKE mara-laeda,
END OF str_table2,
itab_final LIKE STANDARD TABLE OF str_table2.
first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
then for all the entries in that internal table retrieve data from zperson into another internal table.
then loop at one internal table
read another internal table where key equals in both the tables.
finally assign fileds if sy-subrc = 0.
gs_finaltable-matnr = gs_table-matnr
etc...
and finally append gs_finaltable to gt_finaltable.
there u go ur final table has all the data u want.
regards
Edited by: BrightSide on Apr 2, 2009 3:49 PM
Similar Messages
-
How to extract data from info cube into an internal table using ABAP code
HI
Can Anyone plz suggest me
How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
Thankx in advance
regds
AJAYHI Dinesh,
Thankq for ur reply
but i ahve already tried to use the function module.
When I try to Use the function module RSDRI_INFOPOV_READ
I get an information message "ERROR GENERATION TEST FRAME".
can U plz tell me what could be the problem
Bye
AJAY -
How can i add two table into one internal table
I WANT TO ADD THIS TWO DIFFERENT TABLE INTO ONE INTERNAL TABLE PLEASE HELP.
TABLES: J_1IEXCHDR, J_1IEXCDTL.
SELECT * FROM J_1IEXCHDR WHERE STATUS = 'P'.
WRITE: / J_1IEXCHDR-LIFNR,
J_1IEXCHDR-DOCNO,
J_1IEXCHDR-EXYEAR,
J_1IEXCHDR-BUDAT.
SELECT * FROM J_1IEXCDTL WHERE TRNTYP = J_1IEXCHDR-TRNTYP
AND DOCYR = J_1IEXCHDR-DOCYR
AND DOCNO = J_1IEXCHDR-DOCNO.
WRITE: / J_1IEXCDTL-EXBAS,
J_1IEXCDTL-EXBED,
J_1IEXCDTL-RDOC1,
J_1IEXCDTL-ECS.
ENDSELECT.
ENDSELECT.
THANKS IN ADVANCED.U have to link these 2 tables like this
<b>SELECT
J_1IEXCHDR~DOCNO
FROM J_1IEXCHDR inner join J_1IEXCDTL
on J_1IEXCHDRDOCYR = J_1IEXCDTLDOCYR
WHERE STATUS = 'P'.</b>
this is sample code only, and u have to check the F.key relationship.
Regards
Prabhu -
Selecting from multiple tables, into one internal table
Hi,
What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
Thanks,
John
Points will be rewarded and all responses will be highly appreciated.I have simple example :
First one - Join 5 tables
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 4 or 5 tables join.
get run time field f2.
f3 = f2 - f1 ( Total time).
Second one - joins 3 table and use for all entries
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 3 tables join and use for all entries
get run time field f2.
f3 = f2 - f1. ( Total time )
Finally you can have time diffrence between the both sql statement. -
How to read data in correct format from EXCEL file into an internal table??
Hi Experts,
My requirement is to upload data from an excel file on presentation server into an internal table on <b>SRM</b> server.
I used 'GUI_UPLOAD' function module to achieve the same but all the the data is getting uploaded in # only.I had set in the 'HAS_FIELD_SEPARATOR' to 'X' to overcome this problem.
But all the efforts are in vain. The function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' doesn't exist on SRM Server and I am not getting any other function module having similar functionality available on SRM server.
I have written the following code:-
TYPES: BEGIN OF ty_addr_loc,
userid TYPE xubname, "User Id
addr_code TYPE char4, "3 Digit Site Location Code/4 Digit
"Alternate Address
loc_id TYPE bbp_location, "Indicator: Address is standard address
END OF ty_addr_loc.
*Retrieving file name
parameters: p_file type rlgrap-filename.
DATA:
Local variable holding file name
l_file TYPE string,
Local Variable holding the file type,
l_type TYPE filetype VALUE 'ASC',
Local Variable holding the field separator
l_sep TYPE char01,
i_tab type standard table of ty_addr_loc.
Clearing local variables
CLEAR:
l_file,
l_sep.
Initializing the local variables
MOVE p_file TO l_file.
l_sep = 'X'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = l_type
has_field_separator = l_sep
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = i_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
Throwing an information message
MESSAGE i003. "Data Upload Failed
LEAVE LIST-PROCESSING.
ENDIF.
Please tell me a way out. I have to make a delivery urgently.
Thanks in advance,
Swati GuptaHi
Try the FM <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b>
Sample:
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
exporting
filename = i_filename
i_begin_col = l_begin_col
i_begin_row = l_begin_row
i_end_col = l_end_col
i_end_row = l_end_row
tables
intern = xt_intern
exceptions
INCONSISTENT_PARAMETERS = 201
UPLOAD_OLE = 201.
if sy-subrc <> 0.
e_subrc = sy-subrc.
exit.
endif.
<b>reward if Helpful.</b> -
Retrive data from two tables into one internal table.
Hi SDN,
I am downloading the Assets data from two tables ANLA,ANLZ.
there is a common field ANL1in both tables and i have to retrive the data by using anl1 into the internal table.
can you please send me the SELECT Syntax for this probl.....
Thank you & Regards,
ManojHi manoj,
Please see the following sample code. But kindly don't use join as it may hamper ur performance. No trouble in using two select query.
data: begin of itab occurs 0,
BUKRS like anla-BUKRS,
ANLN1 like anla-ANLN1,
BDATU like anlz-BDATU,
end of itab.
select anlabukrs anlaANLN1 anlzBDATU into corresponding fields of table itab from anla inner join anlz on anlaanl1 eq anlz~anl1 where (logexp).
Please come back for any clarification.
Thanks and Regards,
saurabh -
Get multiple selection data of Table into an internal table
Hi Guys,
I have a Table in my view layout and selected 'SelectionMode' as 'Multi' in the table properties.How to get the selected data into an internal table when rows selected on the table output.For example,I have a 10 rows in the table and selected only 5 rows,need to get these 5 rows into an internal table?
Regards
NandanaHi,
Here is some sample code. Please try this and let me know if you are still getting any errors.
DATA lo_nd_table_node TYPE REF TO if_wd_context_node.
DATA lo_el_table_node TYPE REF TO if_wd_context_element.
DATA ls_table_node TYPE wd_this->element_table_node.
DATA lt_table_node TYPE wd_this->elements_table_node.
DATA lt_table TYPE wdr_context_element_set.
lo_nd_table_node = wd_context->get_child_node( name = wd_this->wdctx_table_node ).
lt_table = lo_nd_table_node->get_selected_elements( including_lead_selection = abap_true ).
LOOP AT lt_table INTO lo_el_table_node.
lo_el_table_node->get_static_attributes(
IMPORTING
static_attributes = ls_table_node ).
APPEND ls_table_node TO lt_table_node.
CLEAR ls_table_node.
ENDLOOP.
lt_table_node contains the selected rows. -
How to read xml file and place it into an internal table...
hello all,
can any one help me in - how to read xml data file (placed in application server) and placing the same into an internal table (remove the xml tags or say fetching the xml data without xml tags).Hi Murashali,
use this.
TYPES: BEGIN OF day,
name TYPE string,
work(1) TYPE c,
END OF day.
DATA: BEGIN OF week,
day1 TYPE day,
day2 TYPE day,
day3 TYPE day,
day4 TYPE day,
day5 TYPE day,
day6 TYPE day,
day7 TYPE day,
END OF week.
DATA xml_string TYPE string.
DATA result LIKE week.
week-day1-name = 'Monday'. week-day1-work = 'X'.
week-day2-name = 'Tuesday'. week-day2-work = 'X'.
week-day3-name = 'Wednesday'. week-day3-work = 'X'.
week-day4-name = 'Thursday'. week-day4-work = 'X'.
week-day5-name = 'Friday'. week-day5-work = 'X'.
week-day6-name = 'Saturday'. week-day6-work = ' '.
week-day7-name = 'Sunday'. week-day7-work = ' '.
CALL TRANSFORMATION ...
SOURCE root = week
RESULT XML xml_string.
CALL TRANSFORMATION ...
SOURCE XML xml_string
RESULT root = result.
Regards,
Vijay -
Data from field symbol into an internal table or workarea
Hi Experts,
I have field symbol in which i get the data. I want to get this data into an internal table of type any or into an work area. How is this possible.
My declaration for field symbol is as follow:
FIELD-SYMBOLS: <l_t_data> TYPE any.
DATA l_r_data TYPE REF TO data.
CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
ASSIGN l_r_data->* TO <l_t_data>.
I get the data in this field symbol <l_t_data>. by passing into a funtion module. and I get the data into it. Now i have to assign the values of this field symbol to any internal table or to a work are how do i do it. Please help.
Regards,
Prashant.Not exactly sure what you need here, but.....
FIELD-SYMBOLS: <l_t_data> TYPE TABLE. "<<-- Change this
FIELD-SYMBOLS: <l_s_data> TYPE ANY. "<<---Add This
DATA l_r_data TYPE REF TO data.
CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
ASSIGN l_r_data->* TO <l_t_data>.
Loop at <l_t_data> assigning <l_s_data>.
* Do what ever using <l_s_data>
Endloop.
Regards,
Rich Heilman
Edited by: Rich Heilman on Feb 28, 2008 2:42 PM -
Combine Accounts from different Generations into a single Table Prompt
We are on OBIEE 11.1.1.6.2 and using an ASO (11.1.2.1) cube as a datasource.
I wish to make a drop down menu of only ten accounts in OBIEE. These ten accounts do not all belong in the same generation. The desired Accounts are from Gen6, Gen5 and Gen4. How do I make a single drop down list with these ten accounts when the members belong to different generations ? I have tried building this custom list of ten accounts via Selection Steps but it seems that I cannot cross different generations of the Account dimension.
Any help would be appreciated.Thanks for the reply Christian. I literally tried at least 100 possible iterations of the Evaluate statement and none of them will compile in OBIEE. Before posting, I scoured the Internet for days hoping someone else has had this issue resolved. I had no luck. If you know of anyone that has actually been successful with the EVALUATE statement to make a list of dimension members from different generations, please post the exact code snippet so that I can leverage off of somone else's knowledge.
I have tried dozens of possible iterations of: with no luck at all.
EVALUATE('Intersect(%1.dimension.members,{[Account1], [Account2]})',"Account"."Gen1,Account") -
How to Down load Data in Application server into the Internal Table
hi freinds,
iam having a file in the application server.
now i need to send the data in the file to the internal table.
is there any Function Module?
i need with out using the OPEN DATA SET and CLOSE DATA SET Keywords.
is there any possible?
Regard's,
Ranjith.Hi,
There is no other option for uploading the data from the application server to the internal table without using OPEN DATASET and CLOSE DATASET. Even if you find the FM internal logic in FM uses these keywords to read the data from Application server. -
Join 2 internal tables into 1 internal table
itab 1
field 1
1
2
3
5
itab2
field 1
1
2
3
4
6
The result require is
itab3
filed 1
1
2
3
4
5
6
how to achieve this if any one can give the exact code for this it will be of great help to me.
thanks
naveenhi ,
create the new internal table with all required fields and select the data from those tables through inner-join query as example follows.
REPORT Z0292_INT_SELECT.
DATA : BEGIN OF WA,
PONO TYPE Z0292_PURITEM-PONO,
ITEM TYPE Z0292_PURITEM-ITEM,
POD TYPE Z0292_PURHEA-POD,
VENID TYPE Z0292_PURHEA-VENID,
END OF WA.
DATA : ITAB LIKE TABLE OF WA WITH HEADER LINE.
SELECT APONO AITEM BPOD BVENID
INTO TABLE ITAB
FROM Z0292_PURITEM AS A INNER JOIN Z0292_PURHEA AS B
ON APONO = BPONO.
LOOP AT ITAB.
WRITE : / ITAB-PONO,ITAB-ITEM,ITAB-POD,ITAB-VENID.
ENDLOOP.
sagun desai
Posts: 51
Questions: 9
Registered: 2/27/06
Forum points: 48
Re: how to get the data in one internal table? with 3 different tables..
Posted: Jul 31, 2007 10:34 AM in response to: rhymmeanne Reply E-mail this post
DATA : BEGIN OF IT_A005 OCCURS 0,
vkorg TYPE a005-vkorg,
vtweg TYPE a005-vtweg,
kschl TYPE a005-kschl,
matnr TYPE a005-matnr,
kunnr TYPE a005-kunnr,
datab TYPE a005-datab,
end of it_a005.
DATA : begin of IT_MVKE OCCURS 0,
matnr TYPE MVKE-matnr,
vkorg TYPE MVKE-vkorg,
vtweg TYPE MVKE-vtweg,
kondm TYPE mvke-kondm,
end of it_mvke.
DATA : begin of IT_KNVV OCCURS 0,
kunnr TYPE KNVV-kunnr,
vkorg TYPE KNVV-vkorg,
vtweg TYPE KNVV-vtweg,
kdgrp TYPE knvv-kdgrp,
konda TYPE knvv-konda,
end of it_knvv.
DATA : BEGIN OF IT_FINAL OCCURS 0,
vkorg TYPE a005-vkorg,
vtweg TYPE a005-vtweg,
kschl TYPE a005-kschl,
kondm TYPE mvke-kondm,
matnr TYPE a005-matnr,
kdgrp TYPE knvv-kdgrp,
konda TYPE knvv-konda,
kunnr TYPE a005-kunnr,
datab TYPE a005-datab,
END OF IT_FINAL.
SELECT * FROM A005 INTO TABLE IT_A005.
SELECT * FROM MVKE INTO CORRESPONDING FIELDS
OF TABLE IT_MVKE
FOR ALL ENTRIES IN IT_A005
WHERE MATNR = IT_A005-MATNR
AND VKORG = IT_A005-VKORG
AND VTWEG = IT_A005-VTWEG.
SELECT * FROM KNVV INTO CORRESPONDING FIELDS
OF TABLE IT_KNVV
FOR ALL ENTRIES IN IT_A005
WHERE KUNNR = IT_A005-KUNNR
AND VKORG = IT_A005-VKORG
AND VTWEG = IT_A005-VTWEG.
LOOP AT IT_A005.
IT_FINAL-vkorg = IT_a005-vkorg.
IT_FINAL-vtweg = IT_a005-vtweg.
IT_FINAL-kschl = IT_a005-kschl.
IT_FINAL-MATNR = IT_a005-matnr.
IT_FINAL-KUNNR = IT_a005-kunnr.
IT_FINAL-DATAB = IT_a005-datab.
READ TABLE IT_MVKE WITH KEY MATNR = IT_A005-MATNR
AND VKORG = IT_A005-VKORG
AND VTWEG = IT_A005-VTWEG.
IT_FINAL-kondm = IT_mvke-kondm.
READ TABLE IT_KNVV WITH KEY KUNNR = IT_A005-KUNNR
AND VKORG = IT_A005-VKORG
AND VTWEG = IT_A005-VTWEG.
IT_FINAL-kdgrp = IT_knvv-kdgrp.
IT_FINAL-konda = IT_knvv-konda.
APPEND IT_FINAL.
CLEAR : IT_FINAL, IT_MVKE, IT_KNVV.
ENDLOOP.
You can try with this code.
It should work.
if it ok for you then you can close this issue.
Cheers,
Sagun Desai. -
How do I combine selections from various photos into a single picture?
I can't figure out how to open several pictures at once and then select sections from them and put the selections into one complete photo. Can someone tell me how to do this?
Hi T.Bux and welcome to the forum.
This video tutorial should help you with basic photo compositing: -
How to move data from 2 internal table to 1 internal table
Can any body send me code that how to move data from 2 internal table into one internal table.
Moderator message : Read ABAP documentation. Thread locked.
Edited by: Vinod Kumar on Jun 13, 2011 11:45 AMHi Mohdarif92;
I don't know your full needs. But general method should be as below code.
Please check exam below code.
Best regards.
data : begin of gt_result.
... like mkpf-...
... like mkpf-...
... like mseg-...
... like mseg-...
end of gt_result
select *
into table gt_mkpf
from mkpf where ...
select *
into table mseg
from mseg where ...
loop at gt_mkpf.
loop at gt_mseg where ... = mkpf-...
move-corresponding gt_mkpf to gt_result.
move-corresponding gt_mseg to gt_result.
append gt_result
endloop.
endloop. -
Reading long text from excel file to an internal table
Hi
Can any body tell me how to read long text from excel file to an internal table.
When i am using this FM KCD_EXCEL_OLE_TO_INT_CONVERT then it is reading only 32 characters from each cell.
But in my excel sheet in one of the cell has very long text which i need to upload into a internal table.
may i know which FM or what logic i need to use for this problem.
RegardsHi,
Here is an example program. It will upload an Excel file with two columns. You could also assign the Excel structure dynamically, but I wanted to keep the example simple. The main point is that the internal table (it_excel in this example) must match the Excel structure that you want to convert.
Remember, this is just an example to help you figure out how to properly use the technique. It will certainly need to be modified to fit your requirements, and as always there may be a better way to get the Excel converted... this is just one possibility that has worked for me in the past.
*& Report zexcel_upload_test *
REPORT zexcel_upload_test.
TYPE-POOLS: truxs.
TYPES: BEGIN OF ty_excel,
col_a(10) TYPE n,
col_b(35) TYPE c,
END OF ty_excel.
DATA: l_data_tab TYPE TABLE OF string,
l_text_data TYPE truxs_t_text_data,
l_gui_filename TYPE string,
it_excel TYPE TABLE OF ty_excel.
FIELD-SYMBOLS: <wa_excel> TYPE ty_excel.
PARAMETERS: p_file TYPE rlgrap-filename.
* Pass the file name in the correct format
l_gui_filename = p_file.
* Upload data from PC
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_gui_filename
filetype = 'ASC'
has_field_separator = 'X'
CHANGING
data_tab = l_data_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
* MESSAGE ...
EXIT.
ENDIF.
* Convert from Excel into the appropriate itab
l_text_data[] = l_data_tab[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = l_text_data
i_filename = p_file
TABLES
i_tab_converted_data = it_excel
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ...
EXIT.
ENDIF.
LOOP AT it_excel ASSIGNING <wa_excel>.
* Do something here...
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM filename_get CHANGING p_file.
* FORM filename_get *
FORM filename_get CHANGING p_in_file TYPE rlgrap-filename.
DATA: l_in_file TYPE string,
l_filetab TYPE filetable,
wa_filetab TYPE LINE OF filetable,
l_rc TYPE i,
l_action TYPE i,
l_init_dir TYPE string.
* Set the initial directory to whatever you want it to be
l_init_dir = 'C:\'.
* Call the file open dialog without multiselect
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Load file'
default_extension = '.XLS'
default_filename = l_in_file
initial_directory = l_init_dir
multiselection = 'X'
CHANGING
file_table = l_filetab
rc = l_rc
user_action = l_action
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
REFRESH l_filetab.
ENDIF.
* Read the selected filename
READ TABLE l_filetab INTO wa_filetab INDEX 1.
IF sy-subrc = 0.
p_in_file = wa_filetab-filename.
ENDIF.
ENDFORM. " filename_get
Regards,
Jamie
Maybe you are looking for
-
Animated GIF doesn't work against dark backgrounds in HTML
I've created an animated GIF in Photoshop, exported it for web with transparency, and placed it in my HTML code. It doesn't work against the dark background on my page. However, when I open the image in a new browser tab, voila, the animation works p
-
I have restored my iPhone 4 S but iTunes is still trying to restore it. What do I do?
I have upgraded my iPhone 4 to a 4S and have all afternoon been trying to restore it with my old iPhone backup. I connected it to my computer and it did it straight away - I have all my contacts and texts up until monday morning however I have none
-
A friend has sent me some photos that are in a zip file. Can anyone tell me how to open and view them? I have saved the file to the desktop and doubleclicked it. Then I control click and open it with appleworks but I only get the captions that go alo
-
VO - bind variable in where clause problem
Hi I have Jdeveloper 12. I successfully connected to mySQL database which works in Oracle mode (PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, NO_AUTO_CREATE_USER) Next I created EO, VO (screenshot) an
-
Mandatory condition VPRS is missing
Does the total stock of material affects the pricing condition to not to determine the standard cost? when i check on the analysis, the diagnosis in the pricing condition vprs says the minimum amount of free goods condition is not reached that is why