How to select data from an internal table
material norm date last modified
B2-SP HEAT 50.000 20090420
BF COKE 575.000 20090419
GROSS COKE 200.000 20090419
B2-SP HEAT 100.000 20090419
TWT 33.000 20090330
B7-SP HEAT 2.000 20090310
B1-SP HEAT 1.000 20090309
B7-SP HEAT 615.000 20090308
B2-SP HEAT 585.000 20090308
B1-SP HEAT 100.000 20090308
B3-SP HEAT 610.000 20090308
BF COKE 68.500 20090308
GROSS COKE 72.600 20090308
B8-SP HEAT 600.000 20090308
B9-SP HEAT 625.000 20090308
BX-SP HEAT 615.000 20090308
B9-SP HEAT 58.000 20090307
B1-SP HEAT 100.000 20090307
B6-SP HEAT 350.000 20090306
B2-SP HEAT 888.000 20090306
Like above there r numerous data in a table :
how will i select data into another internal table where material above is not repeated with latest modified date.please help.
Hi Sonu,
The main task is to move the contents of the one internal table to another with some condition.
First sort and delete the duplicate entries from the First Internal table like below :
sort it_tab by material ascending date_modified descending.
delete adjacent duplicates from it_tab.
Then move that Internal table contents to another internal table.
Define another internal table with the same structure as you have first internal table and then
Second Step :
it_itab1 = it_itab.
If you are using seperate Header line and Body then you can do like below :
it_itab1[] = it_itab[].
This will fix the issue.
Please let me know if you need any further explonation.
Regards,
Kittu
Edited by: Kittu on Apr 24, 2009 12:21 PM
Similar Messages
-
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. -
Select Data from 2 intern tables
Hi Experts,
how I can select Data from 2 intern Tables into another intern table?
For Example:
My Result Table has the fields: mandt, user, ID, ID_Name.
My select table no. 1 has the fields mandt, XYZ (like A_Name), ID, ID_Name, ...
My select table no. 2 has the fields mandt, A_Name, User, ...
I want to search for all entries in select table no. 1 and 2. where are a_name have the same worth.
How I can select my Dates?
Regards,
Mikehii
you can do it by using for all entries and with READ statement ..do like follow code
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
wa_output-lgort = wa_mard-lgort.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0
regards
twinkal -
How to read data from an internal table into a real table?
Hello experts,
I'm relatively new to ABAP and I'm trying to figure out how to read data from an internal table into a table that I created. I'm trying to use the RRW3_GET_QUERY_VIEW_DATA function module to read data from a multiprovider. I'm trying to read data from the e_cell_data and e_axis_data tables into a table that I've already created. Please see code below.
TABLES MULTITAB.
DATA:
query_name TYPE RSZCOMPID,
s_cubename TYPE RSINFOPROV,
t_cell_data TYPE RRWS_T_CELL,
t_axis_data TYPE RRWS_THX_AXIS_DATA,
t_axis_info TYPE RRWS_THX_AXIS_INFO,
wa_t_cell_data like line of t_cell_data,
wa_t_axis_data like line of t_axis_data,
w_corp_tab like line of t_cell_data.
s_cubename = 'CORP_MPO1'.
query_name = 'Z_corp_test'.
CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA'
EXPORTING
i_infoprovider = s_cubename
i_query = query_name
i_t_parameter = query_string_tab
IMPORTING
e_cell_data = t_cell_data
e_axis_data = t_axis_data
e_axis_info = t_axis_info.
If anyone has any information to help me, I would greatly appreciate it. Thanks.Hi,
<li>Once you call the function module RRW3_GET_QUERY_VIEW_DATA, lets say data is available in the corresponding tables e_cell_data e_axis_data which you have mentioned.
<li>Modify your internal table defined for other purpose, with data from e_cell_data e_axis_data like below.
LOOP AT t_cell_data INTO wa_t_cell_data.
"Get the required data from t_cell_data.
MOVE-CORRESPONDING wa_t_cell_data TO it_ur_tab.
"Modify your internal table wih data
MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
ENDLOOP.
LOOP AT t_axis_data INTO wa_t_axis_data.
"Get the required data from t_cell_data.
MOVE-CORRESPONDING wa_t_axis_data TO it_ur_tab.
"Modify your internal table wih data
MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
ENDLOOP.
Thanks
Venkat.O -
How to get data from an internal table in some other program
I would like to get data from the internal table in the other program. When I using FM "LIST_FROM_MEMORY" to get the data, it doesn't work and the exception is not fount.
If any special code need in the other program, like write data to memory .
Many thx .
From Ross WangHi
<li>You need to have interaction if you want to use EXPORT/IMPORT statments.
<li>The internal tables in both programs must be same
<li>Program one ..Calling program
REPORT ZTEST_NOTEPAD.
DATA: BEGIN OF it_t001 OCCURS 0,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_t001.
START-OF-SELECTION.
SUBMIT ztest_notepad1 AND RETURN.
IMPORT it_t001 FROM MEMORY ID 'ZTEST_T100'.
LOOP AT it_t001.
WRITE:/ it_t001.
ENDLOOP.
<li>Program two ...Called program
REPORT ztest_notepad1.
DATA: BEGIN OF it_t001 OCCURS 0,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_t001.
START-OF-SELECTION.
SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_t001 UP TO 10 ROWS.
IF sy-dbcnt > 1.
EXPORT it_t001 TO MEMORY ID 'ZTEST_T100'.
ENDIF.
I hope that it gets you some idea.
Thanks
Venkat.O -
How to insert data from different internal table into a data base table
hi all,
I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
in short i want to do something like the foll:
INSERT INTO ZMIS_CODES-CODE VALUE '1'.
*INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)REPORT ZINSERT.
tables kna1.
data: itab LIKE KNA1.
data lv_kUNAG LIKE KNA1-KUNNR.
lv_kuNAG = '0000010223'.
ITAB-kuNNR = lv_kuNAG.
ITAB-name1 = 'XYZ'.
INSERT INTO KNA1 VALUES ITAB.
IF SY-SUBRC = 0.
WRITE:/ 'SUCCESS'.
ELSE.
WRITE:/ 'FAILED'.
ENDIF.
Here lv_kunag is ref to kna1 kunnr passed in different name
In internal table .
Try and let me know if this logic dint work. -
How to scan data from one internal table to another
Hi All,
let me know how to scan all from one internal table to another internal table. Pls provide me the syntax and code.
i am very thankful to you all in advance.
Thanks & Regards,
Nagarjuna.if u want to copy data from itab1 to itab2 then use
itab2[] = itab1[].
if u want to compare whether both itab1 and itab2 are same or not,use
if itab1[] = itab2[].
*--same
else.
*--not same
endif.
if u want to compare itabs based on primary key....
loop at itab1.
read table itab2 with key f1 = itab1-f1.
if sy-subrc <> 0.
*--not same....
endif.
endloop.
if u want to copy only few lines(say from 1 to 3) of itab1 to itab2 then use...
append lines of itab1 from 1 to 3 to itab2.
if internal tables don't have same structure,
say only fields f1 and f2 are common,then
loop at itab1.
itab2-f1 = itab1-f1.
itab2-f2 = itab1-f2.
append itab2.
clear itab2.
endloop.
if there are many common fields then...
loop at itab1.
move-corresponding itab1 to itab2.
append itab2.
clear itab2.
endloop.
Please don't forget to reward points....!!!
Regards
vasu -
How to download data from an internal table to a text
Hi All,
I want to download data from an internal table to a text file.
The fields should be pipe(|) separated. I have tried GUI_DOWNLOAD but it is not taking the field separator.
The sample of the desired data that i require should be this way:-
13456TR|M|COUP|MATERIAL|KGS
Thanks in advance.
Regards
Satish.Hi,
Try this..
REPORT zc1download message-id zc1dwnmsg.
*& Declaration Section for the Tables *
TABLES: makt.
*& Declaration Section for the Internal Tables
DATA: intab TYPE TABLE OF makt,
wa_intab LIKE LINE OF intab,
no_of_rec TYPE i,
count TYPE i.
DATA: BEGIN OF f_intab,
str(255) TYPE c,
END OF f_intab.
DATA: t_intab LIKE TABLE OF f_intab,
w_intab LIKE LINE OF t_intab,
temp(255) TYPE c.
FIELD-SYMBOLS: <f> TYPE ANY.
*& Selection ScreenSection for the file download
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: file TYPE rlgrap-filename MEMORY ID file,
tab RADIOBUTTON GROUP rad1 DEFAULT 'X',
others RADIOBUTTON GROUP rad1,
delimit TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
IF file IS INITIAL. " check to ensure file.
MESSAGE i001.
EXIT.
ENDIF.
IF others = 'X'. " check to ensure delimiter.
IF delimit = ' '.
MESSAGE i002.
EXIT.
ENDIF.
ENDIF.
SELECT * FROM makt INTO TABLE intab.
IF tab = 'X'. " default delimiter tab is used
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = file
filetype = 'DAT'
mode = 'A'
TABLES
data_tab = intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE. " If user defind delimiter is to be used
Counts the number of fields *
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
IF sy-subrc <> 0.
EXIT.
ELSE.
count = count + 1.
ENDIF.
ENDDO.
LOOP AT intab INTO wa_intab.
DO count TIMES. " Adding the delimiter in required places
ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
CONCATENATE temp delimit <f> INTO temp.
ENDDO.
SHIFT temp.
APPEND temp TO t_intab.
CLEAR temp.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = file
filetype = 'ASC'
mode = 'A'
TABLES
data_tab = t_intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
WRITE:/ 'The Data has been tranfered to :', file.
Cheers
Kathir!~ -
How to copy data from one internal table to another
i am using some function module to get some data for my function module
and the retrieved data is not getting populated in mu fumctional module
i am sucessful in getting the data to an internal table in my function module but dont know how to pass it to my table parameter
thanks in advanceHi Naval,
Declare an internal table of type table parameter structure and pass it the table parameters of the Function module.
Check the code for this function module.
DATA IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
SELECT * FROM MARA UP TO 10 ROWS INTO TABLE IT_MARA.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\TEST.TXT'. FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
<b> TABLES
DATA_TAB = IT_MARA</b>
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Vinay -
How to select data from one nested table and into another nested table
create or replace
TYPE ctxt_code_rec as object
ctxt_header varchar2(10),
header_description varchar2(300),
status varchar2(30),
adjacent_code varchar2(300),
adjacent_desc Varchar2(400),
adjacent_flag varchar2(4000),
adjacent_text_href varchar2(4000)
create or replace
type ctxt_code_table as table of CTXT_CODE_REC
d_table ctxt_code_table ;
v_tab ctxt_code_table ;
Iam trying to select data from d_table to v_tab
using and bulk collect into
select m.*
bulk collect into p_code_result
from table(l_loop_diag_code_table1)m
order by 1;
Receiving error:
ora 94007 : not enoughvalues
Could you please let me know how to solve it?
Thanks,
in advance>
create or replace
TYPE ctxt_code_rec as object
ctxt_header varchar2(10),
header_description varchar2(300),
status varchar2(30),
adjacent_code varchar2(300),
adjacent_desc Varchar2(400),
adjacent_flag varchar2(4000),
adjacent_text_href varchar2(4000)
create or replace
type ctxt_code_table as table of CTXT_CODE_REC
d_table ctxt_code_table ;
v_tab ctxt_code_table ;
Iam trying to select data from d_table to v_tab
using and bulk collect into
select m.*
bulk collect into p_code_result
from table(l_loop_diag_code_table1)m
order by 1;
Receiving error:
ora 94007 : not enoughvalues
Could you please let me know how to solve it?
>
Not unless you provide the code you are actually using.
There is no definition of 'p_code_result' in your post and you say you 'trying to select data from d_table' but there is no code that loads 'd_table' in what you posted.
And the SELECT query you posted actuall selects from an object named 'l_loop_idag_code_table1' which isn't mentioned in your code.
Post the actual code you are using and all of the structures being used.
Also explain why you even need to use nested tables and PL/SQL for whatever it is you are really doing. -
How to delete data from dynamic internal table
Hi,
I have dynamic internal table and I have some slection screen fields , using these selection screen fields
(select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,
and also delete will not work for dynamic table..
as we cannot use assigning with delete..
So how to do this?
and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),
so now after selection of data, I need to filter the data from dynamic table.
Is there any way to do this?
Regards,
MrunalHi matt,
I tried with below code as you said. But I am getting dump. can you help?
here is my piece of code.
FIELD-SYMBOLS: <LS_DATA> type any,
<LT_DATA> TYPE table,
<L_FIELD> type any.
ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.
ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.
LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
IF <L_FIELD> NOT IN SO_BUKRS.
DELETE <LT_DATA>.
ENDIF.
UNASSIGN <L_FIELD>.
ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
IF <L_FIELD> NOT IN SO_BELNR.
DELETE <LT_DATA>.
ENDIF.
UNASSIGN <L_FIELD>.
ENDLOOP.
and here is the description of my dump:->>>
You attempted to access an unassigned field symbol
(data segment 32772).
This error may occur for any of the following reasons:
- You address a typed field symbol before it is set using ASSIGN
- You address a field symbol that points to a line in an internal table
that has been deleted
- You address a field symbol that had previously been reset using
UNASSIGN, or that pointed to a local field that no longer exists
- You address a global function interface parameter, even
though the relevant function module is not active,
that is it is not in the list of active calls. You can get the list
of active calls from the this short dump. -
How to append data from an internal table to an external table.
HI everyone,
I am trying to update an DB table type 'c'from the data captured in my internal table. can any one tell me as to how to do this.the contents of the DB table needs to be erased completly before i send in new data.
Regards,
VjAssuming that you table has 1 character field(?) besides the MANDT field
MANDT
FIELD
you need to update this db table with values from ITAB which I assume has one field of type c.
To first delete all of the data from DB table.
* Yes there are other ways of doing this.
tables: ztable.
select * from ztable.
delete ztable.
endselect.
Then simply LOOP your internal table and update the table.
loop at itab.
ztable-field = itab-field.
insert ztable.
endloop.
Regards,
Rich Heilman -
HOW TO TRANSFER DATA FROM ONE INTERNAL TABLE TO ANOTHER
FOR PERTICULAR OBJECT ID ONE INT TABLE JTAB CONTAINS ONE RECORD(ROW) AND ANOTHER INT TABLE KTAB CONTAINS 3 RECORDS(ROWS). THEN HOW I SHOULD TRANSFER DATA FROM KTAB TO JTAB? WHAT R THE VARIOUS WAYS TO DO THAT. PLS HELP ME OUT. THANKS IN ADVANCE
Try something like
If you want one record per ktab :
LOOP AT jtab.
MOVE-CORRESPONDING jtab TO itab.
LOOP AT ktab WHERE id = jtab-id.
MOVE-CORRESPONDING ktab TO itab.
APPEND itab.
ENDLOOP.
ENDLOOP.
or
LOOP AT ktab.
READ TABLE jtab WITH KEY id = ktab-id. " binary implicit if sorted type
MOVE-CORRESPONDING jtab TO itab.
MOVE-CORRESPONDING ktab TO itab.
APPEND itab.
ENDLOOP.
If you want to sum ktab ratio into itab for each jtab
LOOP AT jtab.
MOVE-CORRESPONDING jtab TO itab.
LOOP AT ktab WHERE id = jtab-id.
ADD-CORRESPONDING ktab TO itab.
APPEND itab.
ENDLOOP.
ENDLOOP.
Use sorted type table when LOOP AT WHERE, else SORT table is enough.
Regards -
How to fetch data from nested internal table
Hi,
Im using FM CRM_PRODUCT_GETDETAIL_API which is returning me work area (ES_PRODUCT_DATA) of type
COMT_PRODUCT_MAINTAIN_API. This work area contains a table SHORT_TEXTS of type COMT_PR_SHTEXT_MAINTAIN_TAB
whcih in turn contain a line type DATA of type COMT_PRSHTEXT_X. I need to fetch fields lying inside DATA. Can anybody please
let me know how to achieve this. I would like to do this by not using nested loop structure.
Rgds
Sudhanshu SharmaHi,
Use field ES_PRODUCT_DATA-short_texts like any other internal table (without header line).
E.g.:
field-symbols: <text> type COMT_PRSHTEXT_X.
loop at ES_PRODUCT_DATA-short_texts assigning <text>.
write: <text>-short_text
endloop.
Regards, Gerd Rother -
How to pass data from dynamic internal table to standard internal table
hi experts,
below is the piece of code which i have used in my requirement but the data is not moved.
LOOP AT <tab> ASSIGNING <tab1>.
MOVE-CORRESPONDING <tab1> TO wa.
append wa TO gt_outtab.
ENDLOOP.
here
<tab> - dynamic internal table.
<tab1>-dynamic internal table work area.
gt_outtab - standard internal table.
wa- standard internal table work area.
i am not getting what additional thing i have to write.
pls help me in this regard.
thankx in advance.
soham.p.Hello soham p ,
I am also using the same logic but in my program it is working fine so you declare the fieldsymols like this and try and also check the dynamic internal contain the data or not.
FIELD-SYMBOLS : <y_i_table> TYPE STANDARD TABLE,
<y_wa_table> TYPE ANY.
LOOP AT <y_i_table> ASSIGNING <y_wa_table>.
MOVE-CORRESPONDING <y_wa_table> TO y_wa_vfscaid.
APPEND y_wa_vfscaid TO y_i_vfscaid.
CLEAR y_wa_vfscaid.
ENDLOOP.
Maybe you are looking for
-
I'm trying to do a "complete" uninstall of Firefox.
But, it is leaving add-ons, etc, and it's reloading them on reinstall and I don't want that. I went into all folders (some are not allowing access even though I have admin. rights) and removed all FF folders I could find and when I reinstall FF all t
-
Producer Consumer simultaneous operations at different frequencies
My goal is to do two operations simultaneously. The desired end result is: 1) Produce an output signal which oscillates at a specified frequency (1 to 10 hz)(using DIO NI-9403). This signal will cause a solenoid to vibrate at different frequenci
-
Dear Experts, We have a 10MB Data-link between our company and an external DATA-CENTER where our mail-server is hosted aswell, this 10MB link has been provided for us through an ISP. so our issue is while we open outlook it takes 1 to 2 minutes to
-
Encryption Method algorithm for WS security
Hi there, We enabled WS security for one of our interface which acts as a consumer to use one web service provided by our partner. The connectivity is in place and we verified our request was received and processed, but the following is the returned
-
Indesign keeps crashing when opening documents
i recently intalled indesign cs5.5. it won't open documents created on other computers. the program crashes before the document ever shows on my screen. have called adobe tech twice but the problem remains unsolved. i'm running mac lion. have checked