Delete spaces in internal table
Hi this question is to improve my performance...
what is the performance oriented way of delete entires in internal table where any of the field is empty.
1 2 3 4 5 6 7
A B C D E F G "<< ok
A B C E F G "<< delete
A B C E G "<< delete
or
loop at itab.
if itab-f1 eq space or itab-f2 eq space.....
delete itab.
endif.
endloop. " how to eliminate this loop...?
Try this way
delete itab where f1 eq space
or f2 eq space
or f7 eq space.
a®
Similar Messages
-
How to choose in Delete Duplicates from internal table?
Now I need to delete Duplicates from internal table,
So at first I sort
than I delete duplicate
Sort itab1 BY Company_Code Asset_No Capital_Date.
DELETE ADJACENT DUPLICATES FROM itab1 COMPARING Company_Code Asset_No Capital_Date
Company_Code
Asset_No
Capital_Date
Remark
BC35
1515593
20021225
Helen
BC35
1515593
20021225
Common Asset
BC35
1515594
20030109
Judy
BC35
1515594
20030109
Common Asset
But here comes my problem~If I want to delete the Common Asset in Remark Column,how I let it choose the right one to do it?Hi Jack
Try the below coding..
Report zsamp.
types: begin of t_tab,
comp_code(4) type c,
***_no(7) type n,
cap_date type d,
remark type string,
end of t_tab.
data: i_tab type TABLE OF t_tab,
w_tab type t_tab.
w_tab-comp_code = 'BC35'.
w_tab-***_no = '1515593'.
w_tab-cap_date = '20021225'.
w_tab-remark = 'Helen'.
append w_tab to i_tab.
w_tab-comp_code = 'BC35'.
w_tab-***_no = '1515593'.
w_tab-cap_date = '20021225'.
w_tab-remark = 'Common Asset'.
append w_tab to i_tab.
w_tab-comp_code = 'BC35'.
w_tab-***_no = '1515594'.
w_tab-cap_date = '20030109'.
w_tab-remark = 'Judy'.
append w_tab to i_tab.
w_tab-comp_code = 'BC35'.
w_tab-***_no = '1515594'.
w_tab-cap_date = '20030109'.
w_tab-remark = 'Common Asset'.
append w_tab to i_tab.
sort i_tab by remark.
delete ADJACENT DUPLICATES FROM i_tab COMPARING remark. -
Delete Command in Internal table
Hi Friends,
Currently i am using DELETE command in internal table. My main requirement is delete the records in internal table based on the select -options given in Selection screen.
Synatx is given below.
DELETE i_list WHERElifsk NOT in S_lifsk[].
It is working fine if we give positive values ie EQ 24 etc.
if we give negetive values if NE 23(in select options) here
sy-subrc is failing.
Can any one kindly suggest.
Regards,
DVNS.Hi DV
Its so simple... u r requirement is to delete all the entries which are not in the select options.
Ur sintax is working correct. Because, even if u hit a database table with select querry using this select option, it will fetch all the positive entries and excludes all negative entries....
if still u feel problem is persisting... then fetch the lifsk from db table using this select option into an internal table and then filter how ever u want.
Venkata Raju Duggirala -
Deleting blank spaces in internal table
Hi Gurus,
I want to delete the empty spaces of a particular field in internal table.I used condense and shift statements but didnt work because the work area value is already condensed.I am not sure why the internal table field is having so much of empty spaces to its left.It's a character field with length 60.
Please suggest.Hi,
This is the rellevant code
LOOP AT IT_HIER INTO WFL_HIER.
WFL_FINAL-NODEID = WFL_HIER-NID.
WFL_FINAL-IOBJNM = WFL_HIER-IOBJ.
WFL_FINAL-NODENAME = WFL_HIER-NNAME.
WFL_FINAL-PID = WFL_HIER-PID.
condense wfl_hier-desc.
WFL_FINAL-DESCRIPTION = WFL_HIER-DESC.
SHIFT WFL_FINAL-DESCRIPTION LEFT DELETING LEADING SPACE.
APPEND WFL_FINAL TO E_T_DATA.
CLEAR WFL_FINAL.
CLEAR: WFL_HIER,OUT.
ENDLOOP.
The problem is not with the work area.
Say if I have a value apple in the work area wa, (wa - 'apple').
It doesnt have any leading sapces to the left.
But when I am appending it to the internal table it gets posted at the last say like this (it - ' apple'.
It occupies the last five characters.
Not sure how to resolve this. -
Delete Duplicates from internal table with object references
Hi
How can I delete duplicates from an internal table in ABAP OO based on the value of one of the attributes?
I have created a method, with the following code:
LOOP AT me->business_document_lines INTO l_add_line.
CREATE OBJECT ot_line_owner
EXPORTING
i_user = l_add_line->add_line_data-line_owner
i_busdoc = me->business_document_id.
APPEND ot_line_owner TO e_line_owners.
ENDLOOP.
e_line_owners are defined as a table containing only object references.
One of the attribute of the object in the table is called USER. And I would like to do a "delete ADJACENT DUPLICATES FROM e_line_owners", based on that attribute.
How can do this?
Regards,
Morten NielsenHello Morten
Assuming that the instance attribute is <b>public </b>you could try to use the following coding:
SORT e_line_owners BY table_line->user.
DELETE ADJACENT DUPLICATES FROM e_line_owners
COMPARING table_line->user.
However, I am not really sure (cannot test myself) whether <b>TABLE_LINE</b> can be used together with SORT and DELETE.
Alternative solution:
DATA:
ld_idx TYPE sy-tabix.
LOOP AT e_line_owners INTO ls_line.
ld_idx = syst-tabix + 1.
LOOP AT e_line_owners TRANSPORTING NO FIELDS FROM ld_idx
WHERE ( table_line->user = ls_line->user ).
DELETE e_line_owners INDEX syst-tabix.
ENDLOOP.
ENDLOOP.
Regards
Uwe -
Problem in deleting entries from internal table
i am selecting
vrgar
perio
paobjnr
belnr
gjahr
perde
budat
kndnr
artnr
frwae
kursf
rec_waers
kaufn
kdpos
bukrs
kokrs
werks
gsber
vkorg
vtweg
spart
rbeln
rposn
prctr
pprctr
kunnr
land1
regio
kunwe
kvgr1
wwpmg
zterm
wwcst
wwrst
mvgr3
wwseg
wwcls
wwesa
prdha
wwbun
wwexd
wwph1
wwph2
wwph3
wwph4
prat1
prat2
vrprs
vv510
vv508
vv509
vvqt2
vv515
INTO TABLE ct_ce11000 FROM ce11000
WHERE paledger EQ gv_ledbo AND
vrgar EQ lc_vrgar AND
belnr GT uv_belnr AND
gjahr EQ pa_gjahr AND
perde EQ pa_perd AND
bukrs EQ pa_bukrs.
now i awant to delete all those entries from my internal table ct_ce11000 where my plant (WEKRS) and company code (BUKRS)
i am writting
loop at ct_ce11000 into wa_ce11000.
if wa_ce11000-werks ne wa_ce11000-bukrs.
now how can i delete all the entries from nmy internal table (ct_ce11000) when plant and company code is not same
pls help me with logic.
thank you for helping meHello Guys,
It is not advisable to delete the entries from the internal table you are looping upon. See this thread: [Sy-tabix in loop : Doubt|Sy-tabix in loop : Doubt]
And to answer the OP's question select data into some local internal table & based on the condition populate your final table. Creating a local table of the same type as the final table will not create too much performance overhead
Cheers,
Suhas -
DELETED rows from internal table
Hi Experts,
If I delete row/s from an internal table
using the command DELETE ADJACENT DUPLICATES,
is there a way to get these deleted rows.
Thanks in advance.
RoseHi roselie,
1. ofcourse not.
2.hence, before that,
u can declare another internal table,
similar to original,
and use like this.
3. ITAB1[] = ORIGINALITAB[].
regards,
amit m. -
Deleting entry from internal table
Hi Experts,
i have the following internal table:
data : it_result1 TYPE crmt_object_guid_tab
and work area
data : wa_result1 type crmt_object_guid.
i have to delete a guid from internal table based on some condition.
loop at it_resul1 into wa_result1
if lv_priority eq priority.
delete this entry from internal table.
endif.
endloop..
i tried using delete table it_result with table key CRMT_OBJECT_GUID = wa_result. but this is giving syntax error.
what should be done to delete the entry?
Thanks and regards
ShilpiHi
Check Syntax for DELETE operator on pressing F1
1. DELETE itab.
2. DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
3. DELETE TABLE itab [FROM wa].
4. DELETE itab INDEX idx.
5. DELETE itab FROM idx1 TO idx2.
6. DELETE itab WHERE logexp.
7. DELETE ADJACENT DUPLICATES FROM itab.
delete table it_result with table key CRMT_OBJECT_GUID = wa_result
this is wrong
delete it_result where CRMT_OBJECT_GUID = wa_result
Edited by: Lavanya K on Apr 22, 2009 10:20 AM -
Delete records in internal table
Hi,
I have two internal tables itab1 and itab2.
I need to delete records from itab1 comparing the data from itab2. I tried to use the read statement within the main table.
My problem is itab2 and itab1 has multiple records and all the records need to be checked from itab2 with itab1 before deleting the records from itab1.
itab1 and itab2 have a common field 'runid' between them.
How can this be accomplished?
Thanks,
VG>
Venkat.O wrote:
> Hi VG,
> Try this way.
>
> data: tabix type sy-tabix.
> loop at itab1.
> tabix = sy-tabix.
> _LOOP at itab2 where runid = itab1-runid._
_> if sy-subrc NE 0._
> delete itab1 index tabix.
> endif.
> endloop.
>
> Thanks
> Venkat.O
Venkat, inside a loop a IF SY-SUBRC NE 0 doesn't make sense because you are in the loop only after the condition in WHERE clause is satisfied (which means SY-SUBRC is always 0). Also you are missing another ENDLOOP. -
Deleting block from internal table with AT / ENDAT
Hi.
I have the following code:
sort itab by pred_doc.
loop at itab into wa_cust.
At end of pred_doc.
sum.
write :/ wa_cust-pred_doc, wa_cust-amount.
if wa_cust-amount = 0.
Delete entire block of this pred_doc
endif.
endat.
endloop.
Within that "IF" statement, I want to delete the entire block (all entries with that pred_doc). How do I do this? I'm not sure of the syntax. In other words, I just need to do subtotals of the internal table by pred_doc on amount. If the subtotal equals zero, the records for that pred_doc need to be removed from the internal table.
Thanks,
ClayHi,
I agree with Rob. Use two internal tables for this purpose.
data: itab1 like itab. New internal table which will hold the required entries
sort itab by pred_doc.
loop at itab into wa_cust.
At end of pred_doc.
sum.
write :/ wa_cust-pred_doc, wa_cust-amount.
if wa_cust-amount ne 0. " If the workarea has the subtotal entry with amount not equal to zero, then transfer it to a new internal table
append wa_cust to itab1
endif.
endat.
endloop.
Now itab1 will contain your required entries. But please note that this will be the 'summed up' entries and not the the individual entries before summing up.
Hope this helps!
Cheers,
Mahesh -
Delete row from internal table using field symbol.
Hi friends,
I created dynamic internal table using field symbol. I want to delete some data using where clause.
for example. i want to use like,
DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
Like the above statment it won't work. How i can use delete with where clause in field symbols.
Hope any one can help me.
Thanks and regards
Srikanth. Shi Srikanth,
I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
LOOP at <itab> INTO <wa>.
ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
CHECK <field> IS ASSIGNED.
IF <field> EQ WA_KNA1-KUNNR.
DELETE ...
ENDIF.
UNASSIGN <field>.
ENDLOOP.
hope this helps
ec -
Delete duplicate from internal table
HI Abapers,
I have a query on how to remove the duplicates from an internal table
My internal table data is as follows :
Cno Catg1 Catg2
01 0 1000
01 2000 0
I want to get only one record as
01 2000 1000
How to get the result.
I tried sorted by cno and used delete duplicates but it was not helpful.
Is there any other alternative to get this done
Please help me.
Regards,
Priyacheck it out with delete adjacent duplicate records
Deleting Adjacent Duplicate Entries
To delete adjacent duplicate entries use the following statement:
DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
[COMPARING <f1> <f 2> ...
|ALL FIELDS].
The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are duplicate if they fulfill one of the following compare criteria:
Without the COMPARING addition, the contents of the key fields of the table must be identical in both lines.
If you use the addition COMPARING <f1> <f 2> ... the contents of the specified fields <f 1 > <f 2 > ... must be identical in both lines. You can also specify a field <f i > dynamically as the contents of a field <n i > in the form (<n i >). If <n i > is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.
If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines must be identical.
You can use this statement to delete all duplicate entries from an internal table if the table is sorted by the specified compare criterion.
If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4. -
Delete records from internal table
hi all,
i want to delete records from intenal table which are starting with a particular starting number .
eg internal table
10000
20000
90000
91000
92000
88880
i want delete the records starting with 9 i.e. 90000 91000 92000.
Thanks in Adv
RAJYou can test this piece of code.
DATA:
i_tab TYPE STANDARD TABLE OF mara,
wa_tab TYPE mara.
wa_tab-matnr = '1000'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '1001'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '1002'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '1003'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '2001'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '3001'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '4010'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Aug 8, 2008 4:49 PM -
Deleting from Dynamic Internal table
Hi,
How can we delete data from dynamic internal table...
I have a dynamic internal table <fs_dyn_table> which is of type any and can have any fields...
I want to delete all those records which have a value of '10' in a field named field1
I have written my delete statement in the following manner..
DELETE <fs_dyn_table> WHERE field1 = '10'.....but it is not working...it gives me an error...stating that the line type of table must be statically defined.Hi,
Loop on the internal table into a field-symbol of line type same as the internal table.
Use assign component statement and then delete the corresponding record.
Regards,
Ankur Parab -
Deleting records from internal table.
Hello Friends,
I have done F1 on delete and also went through the forum . I want to do a delete effectively as it involves huge amount of data ..
Lets cosider I have two internal tables ITAB 1 and ITAB 2 .
ITAB 1 has 10000 records having two key fields
ITAB2 has 1000 records having the same two key fields in it .
THe other fields are different .
Now I want to perform an operation where for corresponding 1000 records in ITAB2 I must delete the records in ITAB1 and result in ITAB 1 must be 10000 - 1000 = 9000 records.
Which could be the most effecient way to do this.?
Comradely,
K.SibiAre you sure that the keys are all unique? That is non trivial with internal tables.
If yes, then you should define itab1 as a hashed table or copy into a hashed table.
LOOP AT itab2
READ TABLE itab1 WITH TABLE KEY ...
IF ( sy-subrc = 0 ).
DELETE itab1 WITH TABLE KEY ...
ENDIF
ENDLOOP.
You can also use sorted tables and delete with index, will be somewhat slower. Or standard table with REAB BINARY SEARCH and DELETE with index.
If the uniqueness is unclear, then you must change the order and LOOP itab1first and comletely, because the same key can appear several times.
A READ without BINARY SEARCH will kill you, i.e. the above recommendation is incorrect.
Siegfried
Maybe you are looking for
-
How to configure ebz 12.1.3 after upgrade db 11.2.0.2
Hello all, currently i have upgraded database 11.1.0.7 to 11.2.0.2 my application version = 12.1.3 My Question: 1. How to configure the application post upgrade ... like creating db context file from new db home 2. I tried to run AD_TOP/bin perl admk
-
Setting Error on Mac OS X 10.6.2 for flash internet plugin
Hi all Since I bought my new iMac (27" 3.06 GHz) every so often when I open a page with Flash content it asks for me to confirm my settings as the image below shows: When I click settings it open a new page and gives me this message: I have never com
-
Faild to save sequence file. Out of memory
I need to write several arrays to my report file. This works fine for a couple of times, but when I add to many steps I get the message "Failed to save sequence file xxx.seq. Out of memory" from the Sequence Editor. I found the "CustomActionStep" on
-
Keep getting error 1611on itunes help!!
keep getting error 1611on itunes help!!
-
I'm trying to add "masking actions" to Illustrator but it won't copy. I'm using the 30-day trial version of illustrator. Could that me why I'm not able to add actions?