Can sorting facilty in internal tables can be used on char fields?
Can sorting facilty in internal tables can be used on char fields?
there is no restriction to sort by any TYPE. u ve the freedom to sort on any TYPE of fields.
sort itab by ascending / descending F1 F2 F2.
abap doubts, i request you to try and practise your doubts befor posting here in forums. I can understand you are a buddy.Please remember, PRACTISE MAKES MAN PERFECT. Try to master on own and approch forum in worst case.
Also award points to all helpful answers.
All the Best
Thanks & Best Regards
Kiran
Similar Messages
-
Declare the internal table with only one 10 character field and use
Hi,
I want to declare the internal table with only one 10 character field and use.
JayaHi,
Go ahead. U can declare IT with only one field
Example:
data: begin of zcustlist occurs 1000,
custmer(10) type c,
end of zcustlist.
Narendra Reddy.
Edited by: Narendra Reddy C on Aug 8, 2008 11:39 AM -
How can I use a subsummary field in a calcultaion field in a database ???
how can I use a subsummary field in a calcultaion field in a database???? I need to use the average I get in my sorted records to make another calculation. Can this be done???
powerbook G4 Mac OS X (10.4.8)Calculation fields work with data that is contained in a single record.
Summary fields use data from the same field(s) in a range of records.
Summary field results can't be used in further calculations.
You may be able to define a summary field to include the average AND the further calculation that you need, but only if you do not want the results to be placed into a particular record or records.
A detailed description of the data you want to use and the result you want to achieve might lead to some ideas on whether it can be done, and how to do it.
Regards,
Barry -
How to populate one internal table from another using field symbols
Hi Gurus,
I have a problem. I have to populate one internal table (sructure t_otput) from another internal table (sructure t_from) using field symbol.
Structure for from table.
types: begin of t_from,
year(4) type c,
ww(2) type c,
site type marc-werks,
demand type i,
end of t_from.
Structure for output table.
types: begin of t_display,
title(30),
WW1(10),
WW2(10),
WW3(10),
end of t_display.
The from table looks like this:
Year | WW | Site | Demand
2005 | 1 | OR1 | 12.00
2005 | 2 | OR1 | 13.00
2005 | 3 | OR1 | 14.00
The display table which has to be populated should look like this:
Title | WW1 | WW2 | WW3
OR1 | | |
Demand | 12.00 | 13.00 | 14.00
How to populate display table using field symbol?
Please give code snippets
Thanks,
GopalGopal,
Here is the code, however I am not vary clear about the ORG1 and Demand display that you have shown in the display. I am sure with this code it should not be a big deal to tweak in whatever manner you want.
TABLES : marc.
TYPES: BEGIN OF type_display,
title(30),
ww1(10),
ww2(10),
ww3(10),
END OF type_display.
TYPES: BEGIN OF type_from,
year(4) TYPE c,
ww(2) TYPE c,
site TYPE marc-werks,
demand TYPE i,
END OF type_from.
data : t_from type table of type_from,
t_display type table of type_display.
field-symbols : <fs_from> type type_from,
<fs_display> type type_display.
data : wa_from type type_From,
wa_display type type_display.
wa_from-year = '2005'.
wa_from-ww = '1'.
wa_from-site = 'OR1'.
wa_from-demand = '12.00'.
insert wa_from into table t_from.
wa_from-year = '2005'.
wa_from-ww = '2'.
wa_from-site = 'OR1'.
wa_from-demand = '13.00'.
insert wa_from into table t_from.
wa_from-year = '2005'.
wa_from-ww = '3'.
wa_from-site = 'OR1'.
wa_from-demand = '14.00'.
insert wa_from into table t_from.
data : variable(3) type c.
field-symbols : <fs_any> type any.
break-point.
Loop at t_from assigning <fs_from>.
variable = 'WW'.
wa_display-title = <fs_from>-site.
concatenate variable <fs_from>-ww into variable.
assign component variable of structure wa_display to <fs_any>.
<fs_any> = <fs_from>-demand.
endloop.
append wa_display to t_display.
clear wa_display.
loop at t_display assigning <Fs_display>.
write :/ <fs_display>.
endloop.
Note : Please award points if this helps you.
Regards,
Ravi -
Hello, I can not use my text field in PS cc. I can drag a text box, but when I write something in, I can't see the letters!
Opacity at 100?
Does the cursor move as you type?
Reset the tool by right clicking here to see if that is the remedy. -
TOP OF PAGE printing according to SORT - ALV main internal table
Hi guys
I manage to solve my previous issues but 1 minor problem here
Lets say I have an itab which has 3 records
Sales Order | Purchase No, | Distributor
1 | 123 | abc
1 | 123 | abc
2 | 456 | TGIF
I'm using FM REUSE_ALV_BLOCK_LIST_APPEND to display the ALV
its working for the main INTERNAL TABLE but when it comes to top of page, it doesn't follow the sort
I want it to print
Sales Order: 1
Purchase No: 123
Distributor: abc
TABLE 1
Sales Order: 2
Purchase No: 456
Distributor: TGIF
TABLE 2
But now its printing
Sales Order: 1
Purchase No: 123
Distributor: abc
TABLE 1
Sales Order: 1
Purchase No: 123
Distributor: abc
TABLE 2
Sales Order: 2
Purchase No: 456
Distributor: TGIF
TABLE <empty table>
My codes was working previously but its not longer the same.
READ TABLE it_report INTO l_report INDEX SY-tabix
WRITE: text-003, "Sales Order Number
AT 22 l_report-ebeln.
WRITE: / text-004, "Purchase Order Number
AT 25 l_report-purch_no.
WRITE: / text-005, "Distributor Number
AT 22 l_report-kunnr.
WRITE: / text-006, "Ship to Name
AT 16 l_report-wename1.
WRITE: / text-007, "Order Date
AT 14 l_report-vdate.
WRITE: / text-008, "Delivery Date
AT 17 i_vdatu.
Can anyone help me out here? How do I make it print just like the SORT for ALV?Refresh the work areas then it work fine
-
Sorting of Dyanmic internal table
Hi Gurus,
I am having a dynamic internal table (it_mat) having fields matnr uname field1,field2,field3 and field4.
the field is upto fieldN.
I want my table to sorted by this manner
Sort it_mat by field4 field3 field2 field1.
Sort it_mat by fieldN field(N-1)...field1.
Please help me in to get this in dynamic manner.You can try something like this:
types : begin of ty_comps.
include type abap_compdescr.
types: srl type i.
types : end of ty_comps .
data: lt_comps type standard table of ty_comps,
la_comps type ty_comps.
data: l_sort type standard table of char30 with header line.
loop at lt_tot_comp into la_comp. " LT_TOT_COMP contains all my components
move-corresponding la_comp to la_comps.
la_comps-srl = sy-tabix.
append la_comps to lt_comps.
clear la_comps.
endloop.
sort lt_comps by srl descending.
loop at lt_comps into la_comps.
l_sort = la_comps-name.
append l_sort.
endloop.
sort <f_tab> by (l_sort).
You can find the entire code which I have used to create a dynamic table at: [Dynamic Internal Table Creation|http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html]
Regards,
Naimesh Patel -
Regarding the sorting of the internal table
hi,
this is my requirement
iam having an internal table itab and it consists of the date field s_date.
i have to sort the internal table in the descending order of the s_date.
please provide me the code for this.
thanks in advanceHi Surya,
U can use this code
SORT ITAB BY S_DATE DESCENDING.
itab----internal table
S_date--Field name
By default the sorting is done ascending you dont have to specify.
Thanks
Mohinder Singh Chauhan -
Differences between Standard , sorted and hashed internal tables
Can any body please tell me what are the main Differences between
1) <b>Standard internal table</b>
2) <b>Hashed internal table</b>
3) <b>Sorted internal table</b>
Please give me a clear idea about these Three.
Thanks
Prabhudutta<b></b>Hi,
<b>Standard Internal Tables</b>
Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
the number of table entries.
<b>Sorted Internal Tables</b>
Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
<b>Hashed Internal Tables</b>
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
using internal tables that are similar to database tables.
Regards
Sudheer -
Delete internal table rows without using loop statement
i have an internal table which consists of 100 records.
i need to keep only first 5 records.
without using the loop statement i need to delete the rest of the records. how can we achieve this result.
i.e. delete itab1 where "recordno" > 5.
regards.
ZGHi,
Delete itab [FROM idx1] [TO idx2] {Where (log_exp)]
To delete several lines at once, you have to specify at least one of the additions FROM, TO, or WHERE. You can only use the additions FROM and TO with standard tables and sorted tables.
Delete itab [FROM idx1]
If you specify FROM, all the table rows from the table index idx1 onwards are included.
Delete itab [TO idx2]
If you specify TO, all the table rows from the table index idx2 onwards are included.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid.
DATA: BEGIN OF seats,
fldate TYPE sflight-fldate,
seatsocc TYPE sflight-seatsocc,
seatsmax TYPE sflight-seatsmax,
seatsfree TYPE sflight-seatsocc,
END OF seats.
DATA seats_tab LIKE STANDARD TABLE OF seats.
SELECT fldate seatsocc seatsmax
FROM sflight
INTO TABLE seats_tab
WHERE carrid = p_carrid AND
connid = p_connid.
LOOP AT seats_tab INTO seats.
seats-seatsfree = seats-seatsmax - seats-seatsocc.
MODIFY seats_tab INDEX sy-tabix FROM seats.
ENDLOOP.
ENDLOOP.
SORT seats_tab BY seatsfree DESCENDING.
DELETE seats_tab FROM 5.
Thanks & Regards,
ShreeMohan
Edited by: ShreeMohan Pugalia on Jul 21, 2009 4:28 PM -
Update databse from internal table statement not using index
Hi Guys,
We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
Should not the update statement here be using the table index (for primary key)?
Regards,
Munish... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
Coming to the original question, what is you actually coding for the update?
What is the table, which fields are in the internal table and what are the indexes?
Siegfried -
Regarding the internal table data by using read table it_mard into wa_mard
hi,
i am reading the internal table it_mard with key matnr .
my code is like this.
*loop at it_final into wa_final.*
*wa_second-matnr = wa_final-matnr.*
wa_second-bwart = wa_final-bwart.
wa_second-bwtar = wa_final-bwtar.
*read table it_mard into wa_mard with key matnr = wa_final-matnr*
*binary search.*
*if sy-subrc = 0.*
*wa_second-labst = wa_mard-labst.*
*endif.*
*append wa_second to it_second.*
clear :wa_final.
*endloop.*
final internal table haveing duplicate values because this table it_final having movement types
so that i am not using delete statement .
is there any logic for handling the duplicate values inside the loop statement
by using read table statement.
could u plz explain clearly \[removed by moderator\]
Edited by: Jan Stallkamp on Jul 11, 2008 2:11 PMthis is my code could u plz explain regarding duplicate material number .
LOOP AT IT_MSEG INTO WA_MSEG.
WA_FINAL-MBLNR = WA_MSEG-MBLNR.
WA_FINAL-MATNR = WA_MSEG-MATNR.
WA_FINAL-BWART = WA_MSEG-BWART.
WA_FINAL-BWTAR = WA_MSEG-BWTAR.
WA_FINAL-MENGE = WA_MSEG-MENGE.
WA_FINAL-SOBKZ = WA_MSEG-SOBKZ.
COLLECT WA_FINAL INTO IT_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
LOOP AT IT_FINAL INTO WA_FINAL.
READ TABLE IT_MARD INTO WA_MARD WITH KEY MATNR = WA_FINAL-MATNR
BINARY SEARCH.
this is reading the duplicate records i need to control duplicate records here .
the labst value is repeating the number of times because of the meterial number duplication
how can i restrict plz explain
IF SY-SUBRC = 0.
WA_FINAL-LABST = WA_MARD-LABST.
ENDIF.
READ TABLE IT_MKPF INTO WA_MKPF WITH KEY MBLNR = WA_FINAL-MBLNR
BINARY SEARCH.
IF SY-SUBRC = 0.
WA_FINAL-BUDAT = WA_MKPF-BUDAT.
ENDIF.
MODIFY IT_FINAL FROM WA_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
LOOP AT IT_FINAL INTO WA_FINAL.
WA_SECOND-BWTAR = WA_FINAL-BWTAR.
IF WA_FINAL-BWART = '101' OR WA_FINAL-BWART = '501' OR WA_FINAL-BWART = '561'.
WA_SECOND-MENGE11 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '201'.
WA_SECOND-MENGE12 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '541' AND WA_FINAL-SOBKZ = 'O' .
WA_SECOND-MENGE13 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '601'.
WA_SECOND-MENGE14 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '543'.
WA_SECOND-MENGE15 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '702'.
WA_SECOND-MENGE16 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '313'.
WA_SECOND-MENGE17 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '315'.
WA_SECOND-MENGE18 = WA_FINAL-MENGE.
ENDIF.
IF WA_FINAL-BWART = '122' OR WA_FINAL-BWART = '161'.
WA_SECOND-MENGE19 = WA_FINAL-MENGE.
ENDIF.
COLLECT WA_SECOND INTO IT_SECOND.
CLEAR WA_SECOND.
ENDLOOP. -
Help to work with 2 internal table with tricky use
HI ,
I have 2 internal table one with new data and one with old data (same structure ) and i want to combine the 2 of them to final table .
what i need to do here is little bit tricky
The table is build like this :
mandt
User
user_data
valid
if there is no different from the user data from table old to table new the user data in the final table should look like this
000
user1
userdata1
X
000
user1
userdata2
X
IF there is difference between of them the table entries in final table should like this
000
user1
userdata3
X
000
user1
userdata4
X
000
user1
userdata1
"Valid field is empty -abap false since the user dont have this data (userdata1) any more
000
user1
userdata2
"Valid field is empty -abap false since the user dont have this data (userdata2) any more
1. alwayes table new is coming with data that is valid field = abap_true
and should be change the user entries just if there is new entries are diffrent than the old one .
2. table new can have new users with data so it enter the new users to final table with valid entry = abap_true
3. if in the new table there is no user which exist in the old table the user in the final table
should stay with the same entries but the valid entry should be abap false
What is the best way to do that ?
Regards
Chris
Edited by: Chris Teb on Nov 15, 2009 10:39 AMHI
I have table with entries like that that i read from DB (i call it itab_old)
old_itab
mandt User user data timestemp valid
0 usr1 User_data1 X TRUE
0 usr1 User_data2 X TRUE
0 usr1 User_data3 X TRUE
0 usr2 User_data1 X TRUE
0 usr2 User_data2 X TRUE
0 usr2 User_data3 X TRUE
0 usr2 User_data4 X TRUE
0 usr3 User_data1 X TRUE
0 usr3 User_data2 X TRUE
0 usr3 User_data3 X TRUE
assume the user entry for usr 1 is changing i.e. (new entries in table itab_new) the table should look like this
new_itab
mandt User user data timestemp valid
0 usr1 User_data4 Y TRUE
0 usr1 User_data2 Y TRUE
0 usr1 User_data6 Y TRUE
0 usr2 User_data1 Y TRUE
0 usr2 User_data2 Y TRUE
0 usr2 User_data3 Y TRUE
0 usr2 User_data4 Y TRUE
and the final_itab should look like that
usr1 old entries are mark as false and new recoreds is enter to the table for him ,
usr2 have the same entries so it not change
final_itab
mandt User user data timestemp valid
0 usr1 User_data1 X FALSE
0 usr1 User_data2 X FALSE
0 usr1 User_data3 X FALSE
0 usr2 User_data1 X TRUE
0 usr2 User_data2 X TRUE
0 usr2 User_data3 X TRUE
0 usr2 User_data4 X TRUE
0 usr3 User_data1 X TRUE
0 usr3 User_data2 X TRUE
0 usr3 User_data3 X TRUE
0 usr1 User_data4 Y TRUE
0 usr1 User_data2 Y TRUE
0 usr1 User_data6 Y TRUE
0 usr7 User_data1 X TRUE
0 usr7 User_data2 X TRUE
0 usr7 User_data3 X TRUE
last thing there is option that new user will come in table new_itab that is not exist in old table for this user we need to create new entry in final table (like user 7 )
Thanks in advance
Chris
Edited by: Chris Teb on Nov 15, 2009 10:50 PM -
Can You Use A Report Field Value In A Hyperlink?
<p>I have a report field that I would like to be a link to another application. Making a report field a hyperlink to a web page was nice and simple. However, I was expecting to be able to use the value of the field in the hyperlink something like...</p><p><a href="http://mywebsite/controller?action=servlets.ReportAlertDetailListAction&key={AlertSearch.ALERT_KEY">http://mywebsite/controller?action=servlets.ReportAlertDetailListAction&key={AlertSearch.ALERT_KEY</a>}</p><p>...where AlertSearch is the table name and ALERT_KEY is the field name. Is there a way to use a report field in a hyperlink? Would using a formula allow it to be dynamic? The goal is to have each row of the report link to a URL with a different parameter. I can see eventually redoing it as a drill down feature but the detail I need already exists in a separate application.</p><p>Thanks,</p><p>Ed</p>
Hi Ed.
I believe the conditional formula that you would use (don't just type in the text box - press the button for the formula first).
"[http://mywebsite/controller?action=servlets.ReportAlertDetailListAction&key | http://mywebsite/controller?action=servlets.ReportAlertDetailListAction&key]=" + {AlertSearch.ALERT_KEY}
The key is to use the conditional formula feature of the hyperlink feature.Â
Enjoy!Â
    - Kathryn Webster (Report Design Consultant)
          Kat's News: http://diamond.businessobjects.com/blog/279 -
What type of internal table should I use based from my scenario...
Hello Experts,
I am currently having a dillema here because I am trying to optimize a certain
part of a report where in the internal table contains around 300,000 lines of
records. The original internal table is of type standard table. So what the original
programmer did was to delete certain records in a given condition then sort it
by fields 1 and 2 in ascending order. Now, it then loops through that internal table
but gives run time error because it exceeded the limit in our prod server which is only 10 mins.
Now what I did was to try modifying the internal table to make it of type sorted. This is to eliminate
the sort statement. I dont know if what I am doing is right. Help would be greatly appreciated and
rewarded. Thanks a lot guys and take care!Hi,
types: begin of t_itab,
field1 like pa0001-pernr,
field2 like pa0001-ename,
end of t_itab.
data: ls_itab type t_itab,
lt_itab type hashed table of t_itab with unique key field1 field2.
select pernr ename into table lt_itab from pa0001.
loop at lt_itab.
<<<<< your logic
endloop.
aRs
Maybe you are looking for
-
Has the Address Book software changed? Or has Mail changed? For purposes of email, Address Book no longer allows me to find an addressee or several addressees who are members of one of my Groups (or Smart Groups). What happens is this: I open Mail, i
-
I have a HP 6 core desktop, with Win 8.1. I have the latest version of Firefox. An example of the problem that I am having: I am looking at Drudge and click on one of the articles and I end up on the start page or the library page. This occurs 90% of
-
Error: ORA-12008: error in materialized view refresh path
Hello Dba' s We are on 12.0.6 EBS with 10.2.0.5 DB on Sun solaris SPARC 64 bit. We are getting below error while Refreshing Materialized View. Start of log messages from FND_FILE Error: ORA-12008: error in materialized view refresh path ORA-00600: in
-
My sleep/power button on my iphone 4 has stuck in the down position and now will no longer work. I called apple and they quoted me $149 to fix it. Does anyone have a less expensive way of fixing this problem? Thanks!
-
Double trouble: email design and re Captcha
Hi, I usually can do anything I need in Muse and now I hit a point where I don't know what to do. I got two problems and both are connected with Muse's email forms. 1) The design of the email I receive from my form. I found the templates for the auto