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
Similar Messages
-
MDMP : Language assignmet Table RFDT Field Position 0
Hello Team,
During the Language assignmet we have notice that there are few Tables are identified in Field Position 0.
For example : In SPUM4 Vocabulary Table RFDT have words.
For the words in Table RFDT are identified in Filed 0 .
I would like to know how to proceed with the words having Filed 0 in Hint Management.
Regards,
SantoshHi Santosh,
RFDT is an INDX type table. I assume the words you are referring to are caused by the content of the CLUSTD field.
Looking at the structure of the table, I am unable to find an appropriate field for a hint (however maybe someone with more application knowledge might have a different opinion).
If there is no hint possible (and all other automatic assignment do not work), it is necessary to do a manual assignment.
Best regards,
Nils Buerckel
SAP AG -
What is needed for sorting on two fields in a table control
Hi Everybody
I am going to certification in a couple of days. I need some help and was hopeing that you guys could help.
What is needed for sorting on two fields in a table control?
One sorted table and two processing blocks
Two standard tables and one processing blocks
Two standard tables and two processing
Which one is corret??
//ScriptHi Kimallan
I am not sure what is meant by a "processing block". However, it seems the question wants the original table order to be preserved. If so; as far as I understood the problem we need:
itab_proxy[] = itab_main[] .
"two standard tables"
SORT itab_proxy BY field1 field2 .
If we have a sorted table, then it is always sorted by its keys. So, the question seems to become obsolete for that option.
Hope I've understood correct...
Regards
*--Serdar
[email protected] -
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. -
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( ). -
Dynamic Creation of Data Tables and Fields
Hello all. I am currently working with a system that contains a bunch of windows. These windows are divided into two groups that represent their presentation style: Columns (such as a table) and Free (such as in a form). I created two tables in database to describe each and every window. These tables describe the type of presentation style, the fields of each window (title of the field, size of the field, position in window, and many more...)
I did this to make the creation of the windows more effective. In this way that I have, I only have to make one window to display all the thousands of windows that I have in my database because the values of presentation are taken from the description in the tables.
I was able to do this through TextFields and JTables in Swing. But now I run into JSC. Is this possible with JSC? Say in case the presentation style of the window is Column, can I tell the data table to go read the description of the window that needs to be opened to obtain the amount of columns, the column names, the size of each column... then create the tables and present the values?
Or say the presentation style is Free... I need to go find how many fields need to be created and their positions in the form, and then the titles of each field. Any ideas how this can be performed?
Thank you.
Franklin Angulo>
I was able to do this through TextFields and JTables
in Swing. But now I run into JSC. Is this possible
with JSC? Say in case the presentation style of the
window is Column, can I tell the data table to go
read the description of the window that needs to be
opened to obtain the amount of columns, the column
names, the size of each column... then create the
tables and present the values?
Or say the presentation style is Free... I need to go
find how many fields need to be created and their
positions in the form, and then the titles of each
field. Any ideas how this can be performed?
Creator won't help you with the graphical design, but it's definitely possible to dynamically compose the set of components that are children of a particular component. Doing so leverages the basic component APIs of JSF (javax.faces.component.UIComponent), so you'll want to grab yourself a copy of the JSF Javadocs (or use Creator's lookup facilities as you type your code) to understand what's possible.
The most important detail is that all components have a getChildren() method that returns a java.util.List of the child components for that component (as well as a getParent() to get the parent component). Any manipulation you do on this returned list is reflected in the structure of the overal component tree.
As a simple example, assume you want to add an input text component as a child of the form. You'd do something like this:
HtmlInputText input = new HtmlInputText();
input.setXxx(..); // Set properties as needed
form1.getChildren().add(input); // add new childCraig McClanahan -
I want to change the infotype 0002 field position(first name & lasname)
Dear Freinds,
I have requirement where i have to change the positions of the first name and last name , as pe standard we will see is
the lastname under that field we will se the first name . As per the user he wanted first name and then last name . I have read in sap help that it says the table T522N is the place. But before using i wanted to can i change or is there any method where i can do.
i have changed the name2 as middle name by going to cmod and changing the text label. Here it dint asked me any access key.
similary for chaning the position of the two fields can i do so please let me know if any body has done this.
regards
divya.Hi Divya,
You can't change the position of the fields in standard SAP screens - PA30/20.
This would be repair and you need to get access key to change the 2000 screen of module pool MP000200.
T522N is used to change the name format in reports, etc. (Firstname Lastname or Lastname Firstname) It has nothing to do with the field positions in the screen of PA20/30.
Regards,
Dilek -
Collections.sort() - sort on multiple fields?
I have a collection of objects in a List that I need to be able to sort on each field individually. For example, the data in the List is eventually displayed on a table in a web page. The user is able to click on a column header and the table is to be refreshed with the list contents sorted by that column (asc/desc).
I would rather not re-query the DB for this list (it's pretty static and already saved in memory). So if I use the Collections.sort(myList, new Comparator() { ...} ) method, is it possible for me to pass the field/direction of the sort into the Comparator? Or, do I have to define individual Comparators for every field that the user can sort by and surround it all by an ugly switch statement?Honestly I think that a re-query to the DB is the best approach. Remember that any decent DB engine will cache queries so it will really only have to re-perform the sort algorithm.
Commercial databases are very fast and almost never the source of a performance bottleneck.
I realize this isn't the answer you want, but in my experience it is the best solution, if you really can't stand to re-query then as mentioned creating your own comparator is the way to go. -
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. -
Table Names & Field Names in FS for ABAP
What is the easiest option to find out Table & Field Names normally asked by ABAP Consultant through Functional Specs?
Any specific tips to find specific table names & field names?T000 Clients
T001 Company Codes
T001E Company code-dependent address data
T001P Personnel Areas/Subareas
T500L Personnel Country Grouping
T500P Personnel Areas
T500T Personnel Country Groupings
T501 Employee Group
T501T Employee Group Names
T502T Marital Status Designators
T503 Employee Groups / Subgroups
T503K Employee subgroup
T503T Employee Subgroup Names
T504A Benefits - Default Values (NA)
T504B Benefit Option Texts (North America)
T504C Benefit Type (NA)
T504D Benefit Credit Group Amount
T504E Benefit Amount
T504F Benefit Costs
T508A Work Schedule Rules
T508T Texts for Employee Subgroup Groupings for Work Schedules
T510 Pay Scale Groups
T510A Pay Scale Types
T510F Assign Pay Scale > Time Unit, Currency
T510G Pay Scale Areas
T510H Payroll Constants with Regard to Time Unit
T510I Standard Working Hours
T510J Constant Valuations
T510L Levels
T510M Valuation of pay scale groups acc. to hiring date
T510N Pay Scales for Annual Salaries (NA)
T510S Time Wage Type Selection Rule
T510U Pay Scale Groups
T510Y Special Rules for Wage Type Generation
T511 Wage Types
T512R Cumulation Wage Types in Forms
T512S Texts for Cumulation Wage Types in Forms
T512T Wage Type Texts
T512W Wage Type Valuation
T512Z Permissibility of Wage Types per Infotype
T513 Jobs
T514S Table Name Texts
T514T Field Name Texts
T51D2 Wage Type Classes
T51D3 Reduction Rules
T51D4 Cumulation Rules
T527X Organizational Units
T528B Positions - Work Centers
T528C Wage Type Catalog
T528T Position Texts
T529A Personnel Event
T529F Fast Data Entry for Events
T529T Personnel Event Texts
T52BT Texts For HR Objects
T52C0 Payroll Schemas
T52C1 Payroll Schemas
T52C2 Texts for Personnel Calculation Schemas
T52C3 Texts for Personnel Calculation Schemas
T52C5 Personnel Calculation Rules
T52CC Schema Directory
T52CD Schema Directory
T52CE Directory of Personnel Calculation Rules
T52CT Text Elements
T52CX Cross References via Generated Schemas
T52D1 Valid Processing Classes
T52D2 Valid Values for Processing Classes
T52D3 Valid Evaluation Classes
T52D4 Permitted Values for Evaluation Classes
T52D5 Wage Type Groups
T52D6 Wage Type Group Texts
T52D7 Assign Wage Types to Wage Type Groups
T52D8 Valid Processing Classes - Texts
T52D9 Valid Values for Processing Classes - Texts
T530 Reasons for Events
T530E Reasons for Changes
T530F Reasons for Changes
T530L Wage Types for Special Payments
T530T Event Reason Texts
T531 Deadline Types
T531S Deadline Type Texts
T533 Leave Types
T533T Leave Type Texts
T539A Default Wage Types for Basic Pay
T539J Base Wage Type Valuation
T539R Events for Standard Wage Maintenance
T539S Wage Types for Standard Wage Maintenance
T548 Date Types
T548S Date Conversion
T548T Date Types
T548Y Date Types
T549A Payroll Areas
T549B Company Features
T549C Decision Trees for Features (Customers)
T549D Feature Directory
T549L Date modifiers
T549M Monthly Assignment: Payroll Period
T549N Period Modifiers
T549O Text for date modifier
T549P Valid Time Units for Payroll Accounting
T549Q Payroll Periods
T549R Period Parameters
T549S Payroll date types
T549T Payroll Areas
T549M Monthly Assignment: Payroll Period
T549N Period Modifiers
T549O Text for date modifier
T549P Valid Time Units for Payroll Accounting
T549Q Payroll Periods
T549R Period Parameters
T549S Payroll date types
T549T Payroll Areas
T554S Absence and Attendance Types
T554T Absence and Attendance Texts
T554V Defaults for Absence Types
T554Y Time Constraints in HR TIME
T555A Time Types
T555B Time Type Designations
T559A Working Weeks
T559B Name of Working Week
T572F Event Texts
T572G Allowed Values for Events
T572H Event Value Texts
T582A Infotypes
T582B Infotypes Which Are Created Automatically
T582S Infotype Texts
T582V Assignment of Infotypes to Views
T582W Assigns Infotype View to Primary Infotype
T582Z Control Table for PA Time Management
T584A Checking Procedures - Infotype Assignment
T588A Transaction Codes
T588B Infotype Menus
T588C Infotype Menus/Info Groups
T588D Infogroups for Events
T588J Screen Header Definition
T588M Infotype Screen Control
T588N Screen Modification for Account Assignment Block
T588O Screen Modification for Assignment Data
T588Q Screen types for fast entry
T588R Selection Reports for Fast Data Entry
T588S Screen Types for Fast Entry
T588T Menu and Infogroup Designations
T588V Business object type
T588W Event types for infotype operations
T588X Cust. composite definition of event types for IT operations
T588Z Dynamic Events
T591A Subtype Characteristics
T591B Time Constraints for Wage Types
T591S Subtype Texts
T596F HR Subroutines
T596G Cumulation wage types
T596H _Cumulation wage type texts
T596I Calculation rule for cumulation wage types
T596U Conversion Table
T599B Report Classes
T599C Report Classes
T599D Report Categories
T599F Report Classes - Select Options
T777A Building Addresses
T777T Infotypes
T777Z Infotype Time Constraints
T778T Infotypes
T778U Subtypes
CATSCO Cross-Application Time Sheet (CATS)- Transfer to CO
CATSDB CATS- Database Table for Time Sheet
CATSHR Cross-Application Time Sheet (CATS)- Transfer to HR
CATSMM Cross-Application Time Sheet (CATS)- Transfer to MM
CATSPM Cross-Application Time Sheet (CATS)- Transfer to PM/CS
CATSPS Cross-Application Time Sheet (CATS)- Transfer to PS -
Sorting a varchar2 field in Report 10g
Dear all,
i have a table of salaries, which have a field RANK_NO VARACHAR2.
I create a report and order it by RANK_NO. but it is not ordering what i want to be. it is ordered like
1
10
11
2
3
4
5
6
7
8
9
then i use the order by cluase like this,
ORDER BY TO_NUMBER(REGEXP_SUBSTR(RANK_NO,'[0-9]+')),
REGEXP_SUBSTR(UPPER(RANK_NO),'[A-Z]+').
but the result is same .
how to sort a varchar2 field in reports?
Thanks & RegardsHi Muhammad,
Use the following Order By clause hope it helps you,
ORDER BY TO_NUMBER (REPLACE (RANK_NO, LTRIM (RANK_NO, '0123456789'))), RANK_NO
Best Regards
Arif Khadas -
Text data source for the field Position(PLANS)
Hi Experts,
I have an infoobject ZPOSITION which i am using in a cube for this i can able to display key values but i want to display text for this ZPOSITION. The source for this field is Position(PLANS) which i have tacken from pa0001 table.
I have an another infoobject 0HRPOSITION for this i have already loaded data using data source 0HRPOSITION_TEXT.
Is there any other text datasources for this field Position(PLANS)?
And
Is it possible to load data from one info object to another info object?
Regards,
Sridhar.KHi Sridhar,
Check out in the infotype PA0001 for the check table for this field. In this table you will have the description for the field PLANS (Position).
I request you to catch hold of functional HR team member to know where the text value for the Position (PLANS) is stored. You can get the info from them immeadiatly.
After knowing the table where the text values for Position (PLANS) are stored, you have to create a text datasource using RSO2 transaction and replicate in BW and load data from the R/3 table.
Hope this helps you.
Regards,
Saravanan. -
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
Maybe you are looking for
-
I downloaded a program several times and from different download sites. It never showed up in the download box but it said all downloads have completed. I searched for it anywhere on my computer but the search produced no results.
-
Hi, I am wanting to block text messaging that I sometimes receive from clients after hours, and I want to know is there an app like there is for android phones that has lists that you can create so certain people can be sent an auto reply when they s
-
Automatic Refresh of a Merged Power Query giving 'Table Not Registered' error
Scenario: I have 5 tables in my Azure VM SQL database associated with my ERP system. I have loaded all 5 tables into a 'Build Excel' workbook, merged the tables together and created a dataset that my users will be using. From that 'Build Excel' work
-
Hi, We are currently sending faxes from a standard program. However we would also like to have the ability to download the fax into a PDF document. Does sending a fax (viewed in transaction SCOT) create a temporary spool? If so, I'm unable to see the
-
Imp tip to successful without warnings
I am doing full imp of one full exported dmp file, To finish full exp i used direct=y & statistics=none and full exp was successful without warnings.... I am looking for tips to do full imp of this dmp file without warnings also i already used ignore