Sorted tables
eg. is this way of doing correct for building sorted table?
will this lose the binary properties for quick access?
sort standard_itab by a b c.
sorteditab[] = standard_itab[]
or should it be this way? using insert?
loop at standard_itab into wa.
insert wa into sorteditab.
endloop.
Hi Charles,
sorteditab[] = standard_itab[]
is correct but will cause a dump if you have duplicate keys in the standard_itab.
loop at standard_itab into wa.
insert wa into sorteditab.
endloop.
is comparably very slow because for all loops the table line is copied to the work area. And it is syntacticalkly not correct because you must use into table ... when inserting into sorted itabs.
Do it using field-symbols, optional remember duplicates:
field-symbols:
<itab> like standard_itab.
data:
lt_itab_dup like sorteditab.
loop at standard_itab assigning <itab>.
insert <itab> into table sorteditab. "Note: must use TABLE otherwise syntax error
check sy-subrc <> 0. "Record akready exists
insert <itab> into table lt_itab_dup.
endloop.
Now it won't fail under any circumstances. And you have the duplicate key records in table lt_itab_dup for evaulation purposes.
Regards,
Clemens
Similar Messages
-
All,
I have the following code While executing system is pointing to sy-tabix, but the data I am getting in the READ statement is from last record in the internal table
report z_9699_30.
tables : eket.
types : begin of ty_eket.
include structure eket.
types: end of ty_eket.
data: wa_eket type ty_eket.
data: it_eket like sorted table of wa_eket
with unique key primary_key
components ebeln ebelp etenr
with non-unique sorted key secondary_key
components ebeln ebelp.
parameters: p_ebeln like eket-ebeln.
parameters: p_ebelp like eket-ebelp.
select * from eket into table it_eket
where ebeln eq p_ebeln.
read table it_eket into wa_eket with table key secondary_key
components ebeln = p_ebeln
ebelp = p_ebelp.
Please copy and execute this by giving EBELN and EBELP from EKET
Please make sure while selecting from EKET please select data of multiple records available for same EBELP ie llike
Here below PO # 4500000003 and for Item # 00030 is have multiple records
Here in selection screen by giving PO # as 4500000003 (EBELN) Item # as 00030 (EBELP) , then in the above READ statement system giving SY-TABIX as 3 but if you see the WA_EKET-ETENR is showing 2 instead of 1. This is where is the issue is
EBELN
EBELP
ETENR
Header 4
4500000003
00010
1
4500000003
00020
1
4500000003
00030
1
4500000003
00030
2Now execute some
MOVE sy_tabix TO lv_index.
READ TABLE it_eket INTO wa_eket
INDEX lv_index USING KEY secondary_key.
BREAK-POINT.
READ TABLE it_eket INTO wa_eket
INDEX lv_index USING KEY primary_key.
BREAK-POINT.
and conclude yourself on the meaning of life index with two different keys defined...
Regards,
Raymond
PS: Reference in online help for sy-tabix now
Note that the sy-tabix system field is populated by the assigned secondary index, if sorted secondary keys are used. If this value is used for the subsequent index access to the internal table, the same table index must be explicitly used here. If used implicitly, the value would be interpreted as a primary index. -
Error when inserting or changing in a sorted table
Hi Experts,
When i am executing a webdynpro application it says Error when inserting or changing in a sorted table. Can any one help for this.
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: GET_CATEGORY_LIST of program /1BCWDY/F9XHYWN4WKNMG4CDUGA8==CP
Method: IF_COMPONENTCONTROLLER~GET_CATEGORY_LIST of program /1BCWDY/F9XHYWN4WKNMG4CDUGA8==CP
Method: WDDOMODIFYVIEW of program /1BCWDY/F9XHYWN4WKNMG4CDUGA8==CP
Method: IF_WDR_VIEW_DELEGATE~WD_DO_MODIFY_VIEW of program /1BCWDY/F9XHYWN4WKNMG4CDUGA8==CP
Method: DO_MODIFY_VIEW of program CL_WDR_DELEGATING_VIEW========CP
Method: MODIFY_VIEW of program CL_WDR_VIEW===================CP
Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP
Method: DO_MODIFY_VIEW of program CL_WDR_WINDOW_PHASE_MODEL=====CP
Method: PROCESS_REQUEST of program CL_WDR_WINDOW_PHASE_MODEL=====CP
Method: PROCESS_REQUEST of program CL_WDR_WINDOW=================CP
in ST22
Object Definition
DATA: lo_node TYPE REF TO if_wd_context_node,
lo_node_info TYPE REF TO if_wd_context_node_info,
lo_element TYPE REF TO if_wd_context_element.
Additional Data declarations
DATA: lv_key TYPE string.
Get context node.
lo_node = wd_context->get_child_node( name = 'DROPDOWNLISTS' ).
lo_node_info = lo_node->get_node_info( ).
Call method to fetch the categories.
CALL METHOD cl_hap_wd_start_page_ui=>category_get_list
EXPORTING
add_on_application = add_on_application
IMPORTING
t_categories = lt_categories.
Append Default selection entry 'All'.
lw_category-category_id = '00000000'.
lw_category-category_name = 'All'.
APPEND lw_category TO lt_categories.
Sort table after appending the new entry.
SORT lt_categories ASCENDING.
Loop through the category list and populate key(category_id) value(category_name) pair for
LOOP AT lt_categories INTO lw_category.
lw_key_value-key = lw_category-category_id.
625 lw_key_value-value = lw_category-category_name.
>>>>> APPEND lw_key_value TO lt_key_values.------>Here it throws an error
627 CLEAR: lw_key_value, lw_category.
628 ENDLOOP.
629
630 * Bind the category key-value pair to the context attribute.
631 CALL METHOD lo_node_info->set_attribute_value_set
632 EXPORTING
633 name = 'CATEGORY_LIST'
634 value_set = lt_key_values.
635
636 * Make the entry 'All' as default selected.
637 CALL METHOD lo_node->set_attribute
638 EXPORTING
639 value = '00000000'
640 name = 'CATEGORY_LIST'.
641
642 ENDMETHOD.
643
644 method GET_EMPLOYEES.
645Hello Durga,
from the error what I understood is lt_key_values is a sorted table and you are trying append a new line to it. Incase of sorted table you need to use the INSERT statement and not the APPEND statement.
INSERT lw_key_value INTO table lt_key_values.
BR, Saravanan -
Short Dump While Changing Non-KeyField of Sorted Table
Hello,
A short dump occurs while trying to change a field of a sorted table item passed as CHANGING parameter. Are non-key fields in a sorted structure protected? The error message does not explicitely say so. Can anyone link to documentation explaining this behavior?
best regards,
JNNYou are passing by reference with CHANGING.
It looks like read-only stuff can't be passed to method CHANGING.
When I pass a literal or constant, there is a syntax error.
System could have given you a syntax error instead of dump.
Have a look at this snippet. Both method calls throw syntax error.
CLASS mainclass DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
PRIVATE SECTION.
CLASS-METHODS passref CHANGING cv_test TYPE i.
ENDCLASS. "mainclass DEFINITION
CLASS mainclass IMPLEMENTATION.
METHOD main.
"pass literal by ref
passref(
CHANGING
cv_test = '2'
"pass constant by ref
CONSTANTS lc_test TYPE i VALUE 1.
passref(
CHANGING
cv_test = lc_test
ENDMETHOD. "main
METHOD passref.
"nothing
ENDMETHOD. "passref
ENDCLASS. "mainclass IMPLEMENTATION
START-OF-SELECTION.
mainclass=>main( ). -
How to read the data from a sorted table
Hi all,
How to read data from the sorted tables. Please provide some examples.
Thanks and regards,
LisaYou can read like this :
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
INSERT LINE INTO TABLE ITAB.
ENDDO.
CLEAR LINE.
READ TABLE ITAB WITH TABLE KEY COL1 = 3
INTO LINE TRANSPORTING COL2.
WRITE: 'SY-SUBRC =', SY-SUBRC,
/ 'SY-TABIX =', SY-TABIX.
SKIP.
WRITE: / LINE-COL1, LINE-COL2. -
Hi all
I have created an advance table and using multiple selection.I set Sort Allowed property 'Yes' for every column in property inspector.
But when I clicked on cloumn it throws a warning "The table cannot be sorted because it has pending changes which would be lost." and I am not able to sort table.
Can somebody give me some suggestions.
Thanks
BhupendraI have createed sortable header.I have done this thing many times and it works.But this time only I m facing problem.I am using PPR in this table where I am enabling and disabling the checkbox.
Please give suggestions if anybody has faced this problem.
Thanks
Bhupendra -
Possible Sequential Read Access for a Sorted Table
Hi All,
I have the following warnings in Code inspector check.
'Possible Sequential Read Access for a Sorted Table'
Kindly provide me the solution to overcome this warning message.
This is my code in BAdi : CRM_ORDER_FIELDCHECK , Method : FIELDCHECK
I am getting the above warning at
READ TABLE lt_status INTO ls_status WITH KEY status = 'E0001'
user_stat_proc = 'ZITRHDQT'
object_type = 'BUS2000114'.
and at
MODIFY ct_input_field_names FROM ls_input_field_names
TRANSPORTING changeable
WHERE fieldname NE lv_field.
Please see the below code .
DATA : lt_header_guid TYPE crmt_object_guid_tab,
lt_item_guid TYPE crmt_object_guid_tab,
lt_order_i TYPE crmt_orderadm_i_wrkt,
ls_order_i LIKE LINE OF lt_order_i,
lt_status TYPE crmt_status_wrkt,
ls_status LIKE LINE OF lt_status,
ls_input_field_names TYPE crmt_input_field_names.
DATA : lv_header_guid TYPE crmt_fieldcheck_com-guid,
lv_chng_no TYPE c VALUE 'A',
lv_field(10) TYPE c VALUE 'ACT_STATUS'.
DATA: lv_status_completed TYPE crmt_boolean.
To Get GUID
IF is_fieldcheck_com-guid IS NOT INITIAL.
lv_header_guid = is_fieldcheck_com-guid.
ELSE.
lv_header_guid = is_fieldcheck_com-ref_guid.
ENDIF.
IF is_fieldcheck_com-ref_kind EQ 'A'.
INSERT lv_header_guid INTO TABLE lt_header_guid.
ELSE.
SELECT SINGLE header FROM crmd_orderadm_i INTO lv_header_guid
WHERE guid = is_fieldcheck_com-ref_guid.
INSERT lv_header_guid INTO TABLE lt_header_guid.
ENDIF.
*To Get the required details
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_header_guid
IMPORTING
et_status = lt_status
EXCEPTIONS
document_not_found = 1
error_occurred = 2
document_locked = 3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE lt_status INTO ls_status WITH KEY status = 'E0001'
user_stat_proc = 'ZITRHDQT'
object_type = 'BUS2000114'.
IF sy-subrc = 0.
ls_input_field_names-changeable = lv_chng_no.
MODIFY ct_input_field_names FROM ls_input_field_names
TRANSPORTING changeable
WHERE fieldname NE lv_field.
ENDIF.
ENDMETHOD.
Regards
VenkatHello Blake,
Try this:
READ TABLE lt_action_fld WITH KEY STATUS = '0' BINARY SEARCH.
wf_index = sy-tabix.
loop at lt_action_fld from wf_index.
if lt_action_fld-status ne '0'.
exit.
endif.
delete lt_action_fld index wf_index.
endloop.
Let us know, if this helps.
Rgds,
Raghu. -
Sort table of objects by object attribute
Hi all,
I would like to write method for sorting table of objects. Sorting will be according selected attribute of object.
My problem is that when I have dynamic data, I'm not able to access attributes of object. Here is example in code. Problematic lines are commented.
If you have any idea how to solve it, I will be very happy.
CLASS lcl_reflection DEFINITION CREATE PUBLIC.
PUBLIC SECTION.
CLASS-METHODS: sort_object_table_by_field IMPORTING field_name TYPE char72
direction TYPE c DEFAULT 'A'
CHANGING object_table TYPE table.
ENDCLASS. "lcl_reflection DEFINITION
CLASS lcl_reflection IMPLEMENTATION.
METHOD sort_object_table_by_field.
DATA: obj_type_desc TYPE REF TO cl_abap_refdescr,
cls_type_desc TYPE REF TO cl_abap_classdescr,
tab_type_desc TYPE REF TO cl_abap_tabledescr,
elm_type_desc TYPE REF TO cl_abap_elemdescr,
struc_type_desc TYPE REF TO cl_abap_structdescr,
line TYPE REF TO data,
tab TYPE REF TO data,
object TYPE REF TO data,
lt_component TYPE cl_abap_structdescr=>component_table,
ls_component LIKE LINE OF lt_component.
FIELD-SYMBOLS: <object> TYPE any,
<tab> TYPE table,
<line> TYPE any,
<value> TYPE any.
READ TABLE object_table INDEX 1 ASSIGNING <object>.
cls_type_desc ?= cl_abap_classdescr=>describe_by_object_ref( <object> ).
elm_type_desc ?= cls_type_desc->get_attribute_type( field_name ).
obj_type_desc ?= cl_abap_refdescr=>create( cls_type_desc ).
UNASSIGN <object>.
ls_component-name = 'key'.
ls_component-type = elm_type_desc.
APPEND ls_component TO lt_component.
ls_component-name = 'object'.
ls_component-type ?= obj_type_desc.
APPEND ls_component TO lt_component.
struc_type_desc ?= cl_abap_structdescr=>create( lt_component ).
tab_type_desc ?= cl_abap_tabledescr=>create( p_line_type = struc_type_desc
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
REFRESH lt_component.
CLEAR ls_component.
CREATE DATA line TYPE HANDLE struc_type_desc.
CREATE DATA tab TYPE HANDLE tab_type_desc.
CREATE DATA object TYPE HANDLE obj_type_desc.
ASSIGN tab->* TO <tab>.
ASSIGN line->* TO <line>.
ASSIGN object->* TO <object>.
LOOP AT object_table REFERENCE INTO object.
APPEND INITIAL LINE TO <tab> REFERENCE INTO line.
ASSIGN object->* TO <value>.
ASSIGN line->* TO <line>.
* <line>-key = <value>->(field_name).
* <line>-object = object.
ENDLOOP.
* SORT <tab> BY key.
* LOOP AT <tab> REFERENCE INTO line.
* APPEND INITIAL LINE TO object_table REFERENCE INTO object.
* object = line-object.
* ENDLOOP.
ENDMETHOD. "sort_object_table_by_field
ENDCLASS. "lcl_reflection IMPLEMENTATIONOk guys, it's solved. It was little bit more complicated then I expected. Thanks for you help.
METHOD sort_object_table_by_field.
TYPES: t_object TYPE REF TO object.
DATA: obj_type_desc TYPE REF TO cl_abap_refdescr,
cls_type_desc TYPE REF TO cl_abap_classdescr,
tab_type_desc TYPE REF TO cl_abap_tabledescr,
elm_type_desc TYPE REF TO cl_abap_elemdescr,
struc_type_desc TYPE REF TO cl_abap_structdescr,
r_line TYPE REF TO data,
r_tab TYPE REF TO data,
r_object TYPE REF TO data,
r_obj TYPE REF TO data,
lt_component TYPE cl_abap_structdescr=>component_table,
ls_component LIKE LINE OF lt_component.
FIELD-SYMBOLS: <object> TYPE any,
<obj> TYPE REF TO object,
<tab> TYPE table,
<line> TYPE any,
<key> TYPE any,
<fs_key> TYPE any,
<fs_object> TYPE any.
READ TABLE object_table INDEX 1 ASSIGNING <object>.
cls_type_desc ?= cl_abap_classdescr=>describe_by_object_ref( <object> ).
elm_type_desc ?= cls_type_desc->get_attribute_type( field_name ).
obj_type_desc ?= cl_abap_refdescr=>create( cls_type_desc ).
UNASSIGN <object>.
ls_component-name = 'key'.
ls_component-type = elm_type_desc.
APPEND ls_component TO lt_component.
ls_component-name = 'object'.
ls_component-type ?= obj_type_desc.
APPEND ls_component TO lt_component.
struc_type_desc ?= cl_abap_structdescr=>create( lt_component ).
tab_type_desc ?= cl_abap_tabledescr=>create( p_line_type = struc_type_desc
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
REFRESH lt_component.
CLEAR ls_component.
CREATE DATA r_line TYPE HANDLE struc_type_desc.
CREATE DATA r_tab TYPE HANDLE tab_type_desc.
CREATE DATA r_object TYPE HANDLE obj_type_desc.
CREATE DATA r_obj TYPE REF TO object.
ASSIGN r_tab->* TO <tab>.
LOOP AT object_table REFERENCE INTO r_object.
APPEND INITIAL LINE TO <tab> REFERENCE INTO r_line.
ASSIGN r_object->* TO <object>.
ASSIGN r_obj->* TO <obj>.
MOVE <object> TO <obj>.
ASSIGN <obj>->(field_name) TO <key>.
ASSIGN r_line->* TO <line>.
ASSIGN COMPONENT 'KEY' OF STRUCTURE <line> TO <fs_key>.
ASSIGN COMPONENT 'OBJECT' OF STRUCTURE <line> TO <fs_object>.
<fs_object> = <object>.
<fs_key> = <key>.
ENDLOOP.
DATA: sort_field TYPE fieldname.
sort_field = 'KEY'.
SORT <tab> BY (sort_field).
REFRESH object_table.
LOOP AT <tab> REFERENCE INTO r_line.
APPEND INITIAL LINE TO object_table REFERENCE INTO r_object.
ASSIGN r_line->* TO <line>.
ASSIGN r_object->* TO <object>.
ASSIGN COMPONENT 'OBJECT' OF STRUCTURE <line> TO <fs_object>.
<object> = <fs_object>.
ENDLOOP.
ENDMETHOD. -
Hi,
in SE30 (abap runtime analysis) i have tried to possible solutions for a DB access, and according to the performance tuning rules you should use sorted(or hashed) tables in stead of standard table, but in my case the runtime is almost equal. How is that possible ? Any explanations ?
Situation : table RSSELDONE, more than 80000 records
Code 1 with standard table - runtime 6.710.000 ms
data: i_tab type table of rsseldone,
lwa like line of i_tab.
select * from rsseldone into table i_tab.
read table i_tab into lwa
with key rnr = 'REQU_3N57ZUZODOJ53FHTMO97BKDTH'.
Code 2 with sorted table - runtime 7.051.939 ms
data: i_stab type sorted table of rsseldone
with non-unique key
rnr
initial size 0,
lwa like line of i_stab.
select * from rsseldone into table i_stab.
read table i_stab into lwa
with table key rnr = 'REQU_3N57ZUZODOJ53FHTMO97BKDTH'.
Strange !hi,
<u>Standard Table</u> - the most commonly used type of table. You can sort and resort this table anytime. You can have duplicate records in them. Recommend that when accessing these tables, you sort them by a key and then READ via a BINARY SEARCH - better performance. When you write to this table the record is "appended" to the end of the table. In order to maintain the sort sequence (if any) you must use the SORT command again.
<u>Sorted table</u> - this table has a defined sort sequence. You cannot resort. You can have duplicates. When you READ these tables, SAP automatically tries to use a BINARY SEARCH. Because you use a Binary Search, the retrieval time isexpodential to the number of records. When you write a record to this table the table is resorted.
<u>Hashed Table</u> - this table has a defined key. When you write to the table it uses a hashing algorithm to identify where the record is stored (think if this as writing the location of a page in an index of a book). When you READ this table the system looks up this "index" and retrieves the record. Because of this the retrieval time is constant. Writing to this type of table takes the most time as it needs to calculate the hashing algorithm.
Just go thorugh this link
http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb35de358411d1829f0000e829fbfe/frameset.htm
Regard
anver -
Currency Format in Spry Sort Table
Any ideas on how to format all numbers in a spry sort table
into US currency? Currently on my site, Spry is not displaying the
".00" that is included in my XML file.
My
Spry Sort Table ExampleHi,
yes, I`ve had the same behavior. As a workaround, you have to change the format of the cells.
Go into the properties of the cells:
-> Right mouse click
-> format cells
-> category
-> number
-> change something, e.g. the number of decimal places to show
Then you will have to map the component again to the same cells under "Display Data".
And now, the currency information will be shown correctly.
Regards
Victor -
Internal error - insert in sorted tabl ZADRU with
Hello Experts,
While i open BP transaction for one of the business partner. We are getting the following error:
*Internal error - insert in sorted tabl ZADRU with*.
Request your help to resolve this issue. Do we have some SAP note to handle such scenarios. It seems the data has become inconsistent.
Thanks,
RohitHi, Rohit
Table ZADRU - it's your own development, please ask abap-team about this table.
Denis -
Can't we use Binary SEARCH for TYPE SORTED TABLE?(Performance Improvement)
Hi Expert!
I have declare a sorted type table with NON -UNIQUE, and want to use Binary search in read statement. But while using bunary search in read statement I'm facing an error. The ERROR is
"Table LI_MARC is a SORTED TABLE or INDEX TABLE. The BINARY SEARCH
addition is only allowed for these tables if the key specified is an
initial part of the table key."
Please find detail
TYES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr,werks.
DATA: li_marc type tt_marc.
READ TABLE li_marc INTO marc WITH KEY matnr = i_mbew-matnr
werks = i_mbew-bwkey BINARY SEARCH .
To my understanding , there is no need to mention Bianry Search for sorted table TYPE. Please let me know can i use ?Hello,
there is no need to mention Bianry Search for sorted table TYPE.
Yes, this is because for SORTED TABLEs binary search algorithm is used by default for READ TABLE. Although you can use BINARY SEARCH addition but it's use is redundant.
As for your case you've defined the KEY fields incorrectly There shouldn't be any "comma(s)" between the fields.
TYPES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr werks.
When you define it with commas
TYPES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr, werks.
the result is something like this:
TYPES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr.
TYPES: werks.
Hence you were getting the syntax error!
BR,
Suhas
PS: As for MARC you can use UNIQUE KEY addition because MATNR & WERKS are the key fields in the table. -
Memory and performance when copying a sorted table to a standard table
Hello,
As you all probably know, it's not possible to use a sorted table as a tables parameter of a function module, but sometimes you want to use a sorted table in your function module for performance reasons, and at the end of the function module, you just copy it to a standard table to return to the calling program.
The problem with this is that at that moment, the contents of the table is in memory twice, which could result in the well known STORAGE_PARAMETERS_WRONG_SET runtime exception.
I've been looking for ways to do this without using an excessive amount of memory and still being performant. I tried four methods, all have their advantages and disadvantages, so I was hoping someone here could help me come up with the best way to do this. Both memory and performance are an issue.
Requirements :
- Memory usage must be as low as possible
- Performance must be as high as possible
- Method must work on all SAP versions from 4.6c and up
So far I have tried 3 methods.
I included a test report to this message, the output of this on my dev system is :
Test report for memory usage of copying tables
table1[] = table2[]
Memory : 192,751 Kb
Runtime: 436,842
Loop using workarea (with delete from original table)
Memory : 196,797 Kb
Runtime: 1,312,839
Loop using field symbol (with delete from original table)
Memory : 196,766 Kb
Runtime: 1,295,009
The code of the program :
I had some problems pasting the code here, so it can be found at [http://pastebin.com/f5e2848b5|http://pastebin.com/f5e2848b5]
Thanks in advance for the help.
Edited by: Dries Horions on Jun 19, 2009 1:23 PM
Edited by: Dries Horions on Jun 19, 2009 1:39 PM
Edited by: Dries Horions on Jun 19, 2009 1:40 PM
Edited by: Dries Horions on Jun 19, 2009 1:40 PMI've had another idea:
Create a RFC function like this (replace SOLI_TAB with your table types):
FUNCTION Z_COPY_TABLE .
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(IT_IN) TYPE SOLI_TAB
*" EXPORTING
*" VALUE(ET_OUT) TYPE SOLI_TAB
et_out[] = it_in[].
ENDFUNCTION.
and then try something like this in your program:
DATA: gd_copy_done TYPE c LENGTH 1.
DATA: gt_one TYPE soli_tab.
DATA: gt_two TYPE soli_tab.
PERFORM move_tables.
FORM move_tables.
CLEAR gd_copy_done.
CALL FUNCTION 'Z_COPY_TABLE'
STARTING NEW TASK 'ztest'
PERFORMING copy_done ON END OF TASK
EXPORTING
it_in = gt_one[].
CLEAR gt_one[].
WAIT UNTIL gd_copy_done IS NOT INITIAL.
ENDFORM.
FORM copy_done USING ld_task TYPE clike.
RECEIVE RESULTS FROM FUNCTION 'Z_COPY_TABLE'
IMPORTING
et_out = gt_two[].
gd_copy_done = 'X'.
ENDFORM.
Maybe this is a little bit faster than the Memory-Export?
Edited by: Carsten Grafflage on Jul 20, 2009 11:06 AM -
Reading a sorted table in Sequence
Hi,
I have a sorted table and want to read it in a sequence.
Say for example:
Table: sort by secondary key field2, non unique
Field1 Field2
10 100
20 100
30 100
Now, when i read the table with the secondray key, field2, I wnat that it should always return the data in same sequence i. e. 100, 200, 300
But currently when the sequence is not maintained liek it can be 100, 200, 300 or 200, 100, 300
Is it posisble that I get the same sequence every time.
Thanks & Regards,
Rupali RayHi,
When you sort the table sort that table using the two fields that to in ascending order..
this will make the internal table records in sequence like
field1 field2
10 100
20 100
30 100
10 200
20 200
30 200
Now whilw reading the table using the key 2 as 100 or 200 the value of field1 will be in sequence as desired.
ie.... field1 field2
10 100
20 100
30 100
Hope this will help.
Regards,
Rohan.
Edited by: Rohan on Dec 4, 2008 1:02 PM -
Sort table by field position?
Hello,
Is it possible to sort a table by field position? For example, I have table ITAB with a 4 character field F1. I want to sort the table first by the 3rd position ( itab-f12(1) ) ascending then the 4th position ( itab-f13(1) ) descending.
data: begin of itab occurs 0,
f1(4),
end of itab.
itab-f1 = '01AC'.
append itab.
itab-f1 = '02AB'.
append itab.
itab-f1 = '01CD'.
append itab.
itab-f1 = '02CA'.
append itab.
sort itab...
I thought about using TRANSLATE with a rule and converting each position to a numeric value (then transfer the value to a new 'sort' field), but I wasn't sure if there was an easier way.
The sorted table should read: '01AC' ; '02AB' ; '01CD' ; '02CA'
Any help is appreciated.Hi,
Please try this.
DATA: BEGIN OF ITAB OCCURS 0,
F1(4),
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
F1(1),
F2(1),
F3(4),
END OF ITAB2.
ITAB-F1 = '01AC'.
APPEND ITAB.
ITAB-F1 = '02AB'.
APPEND ITAB.
ITAB-F1 = '01CD'.
APPEND ITAB.
ITAB-F1 = '02CA'.
APPEND ITAB.
LOOP AT ITAB.
ITAB2-F1 = ITAB-F1+2(1).
ITAB2-F2 = ITAB-F1+3(1).
ITAB2-F3 = ITAB-F1.
APPEND ITAB2.
ENDLOOP.
SORT ITAB2 BY F1 ASCENDING
F2 DESCENDING.
LOOP AT ITAB2.
WRITE: / ITAB2-F3.
ENDLOOP.
Regards,
Ferry Lianto -
How to re-sort Table data like A-Z and Z-A
Hello Gurus,
How can i re-sort Table data based on last name or first name, once table filled data from backend(i mean, once executed RFC, Table will be filled with data records, after that i want to re-sort table).
Can you provide me code, how to do?
Thanks
Venkat.Hi Venkat,
For sorting to table columns, you need to pick up the code from here and add into a java file within your development component.
http://wiki.sdn.sap.com/wiki/display/Snippets/TableSorterClassfor+WebDynpro
Then, you can call the constructor of the class and pass the arguments to enable table sorting in your code.
Refer to following blog for execution
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID1078501850DB00490474849923920126End?blog=/pub/wlg/3287
Let me know, if the problem persists.
Regards,
Tushar Sinha
Maybe you are looking for
-
I can't view PDF files on Safari 5.1 for windows 7, how do I fix this?
I like using Safari 5.1 for my web browser at work (I use a windows 7 machine). But the recent update won't let me view PDF files. I have to open up Google Chrome then copy and paste the address into it so I can view the PDF. How do I fix this?
-
I have reinstalled Firefox twice, each time downloading a new installer exe from the website. I have also updated all plug-ins. This is a continual problem, as this makes normal scrolling impossible because the arrow keys move the I bar.
-
3 Different Currencies on 1 Purchase Order
Hi all Is it possible to have 3 different currencies on 1 P.O. Eg Price of Item in Dollars Customs in Pounds Locak freight in Dollars Thanks Vishnu
-
Hi All, i have deleted obsolete machine from SMS collection after that i reinstalled the SMS client and readded the same machine still that machine is showing client status is NO Please help me what to do
-
Different number ranges for same order type
Hi PP Guru's , Can anyone send me the user exit for the differnet number range creation for the same order type. Same order type is used in two different Plants. So our client want to track the production order plantwise. Thanx in advance. Regards, N