Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

field sorting problem

Former Member
0 Kudos

I create a one vendor field in z table but this vendor field is data sort wrongly pls help me

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

If you want to sort the values while inserting into the z-table means, you want to

to create a TMG for the table and you can use the events to sort the values before

inserting into the table.

Utilities -> Table Maintenance Generator

and then Environment -> Modification -> Events.

OR

Bofore inserting and while accessing the values use

SORT itab ASCENDING BY field_name.

SORT itab DESCENDING BY field_name.

8 REPLIES 8

Former Member
0 Kudos
SORT itab BY lifnr -- > if you want to sort ascending

If you want to sort by dscending

SORT itab DSCENDING BY lifnr.

In case of Z tables it will get stored in the order how and when the tables gets updated.

satsrockford
Active Participant
0 Kudos

HI,

you have to put your fields in an i_tab then use

sort tablename by ( i_tab ).

Here is an example:

PARAMETERS dbtab TYPE c LENGTH 30.

SELECT-OPTIONS columns FOR dbtab NO INTERVALS.

DATA: otab TYPE abap_sortorder_tab,

oline TYPE abap_sortorder,

dref TYPE REF TO data.

FIELD-SYMBOLS: <column> LIKE LINE OF columns,

<itab> TYPE STANDARD TABLE.

TRY.

CREATE DATA dref TYPE STANDARD TABLE OF (dbtab).

ASSIGN dref->* TO <itab>.

CATCH cx_sy_create_data_error.

MESSAGE 'Wrong data type!' TYPE 'I' DISPLAY LIKE 'E'.

LEAVE PROGRAM.

ENDTRY.

TRY.

SELECT *

FROM (dbtab)

INTO TABLE <itab>.

CATCH cx_sy_dynamic_osql_semantics.

MESSAGE 'Wrong database table!' TYPE 'I' DISPLAY LIKE 'E'.

LEAVE PROGRAM.

ENDTRY.

LOOP AT columns ASSIGNING <column>.

oline-name = <column>-low.

APPEND oline TO otab.

ENDLOOP.

TRY.

SORT <itab> BY (otab).

CATCH cx_sy_dyn_table_ill_comp_val.

MESSAGE 'Wrong column name!' TYPE 'I' DISPLAY LIKE 'E'.

LEAVE PROGRAM.

ENDTRY.

Regards,

Satish

Former Member
0 Kudos

Thank u sir,

z table updated Correctly , but vender field showing worng.

pls help me sir.,

Edited by: siva kumar on Sep 20, 2008 7:12 AM

0 Kudos

hi,

what do u mean by vendor field showing wrong?

if u r updating data correctly in to the ztable then u will not be having any problem with sorting the ztable.

Former Member
0 Kudos

Suppose xxxx vendor update in 15 records in z table.

I give the same vendor in selection screen it showing 10 records.

Whatu2019s the problem?

0 Kudos

hi,

u just look for the other conditions tht u have mentioned in ur program.

if u r retriving data only from tht table using only vendor condition thn u shd get all the records.

check ur code properly or post it here.

Former Member
0 Kudos

Hi,

If you want to sort the values while inserting into the z-table means, you want to

to create a TMG for the table and you can use the events to sort the values before

inserting into the table.

Utilities -> Table Maintenance Generator

and then Environment -> Modification -> Events.

OR

Bofore inserting and while accessing the values use

SORT itab ASCENDING BY field_name.

SORT itab DESCENDING BY field_name.

Former Member
0 Kudos

Many records update in z table itu2019s not new table, itu2019s already created table I insert a vendor filed.

that vendor filed is problem.