Application Development and Automation 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: 
Read only

Sorting data

Former Member
0 Likes
649

Hello, my question is how to sort data? I have a text file and read it into an internal table with 'GUI_UPLOAD'. I want to sort it by asset number. Is there any function to do it? Thanks in advance!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
628

sort itab by asset. "itab is the internal table name and the field name for asset number is asset

6 REPLIES 6
Read only

Former Member
0 Likes
629

sort itab by asset. "itab is the internal table name and the field name for asset number is asset

Read only

Former Member
0 Likes
628

hi

use:

sort <internal table name> by <field name>.

ex: sort itab by asset_no.

regards,

madhu

Read only

Former Member
0 Likes
628

Hi,

Use the SORT <INT TABLE NAME> BY <ASSET FIELD NAME> Command.

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

Former Member
0 Likes
628

Hi,

After the using GUI_UPload you will get the data into internal table.

Sort that Int table by Asset number field.

SORT ITAB BY ANLNR.

then Loop that Itab and do upload into SAP.

reward if useful

regards,

Anji.

Read only

Former Member
0 Likes
628

Hi...

use the statement,

SORT ITAB BY ASSET_NUMBER.

Hope it helps you...

Let me know if u have any more doubt...

Reward points if useful......

Suresh.......

Read only

Former Member
0 Likes
628

Hi,

try the following code n let me know.

*" Data declarations...................................................

"----


  • Work variables *

"----


data:

w_title(2) type c,

w_name(5) type c,

w_cntcod(2) type c,

w_lang(2) type c.

"----


  • Type declaration of the structure to hold file data *

"----


data:

begin of fs_table,

title(2) type c,

name(5) type c,

cntcod(2) type c,

lang(2) type c,

end of fs_table.

"----


  • Internal table to hold file data *

"----


data:

t_table like standard table

of fs_table.

call function 'GUI_UPLOAD'

exporting

filename = 'C:\ASSIGN\YH645_050201.TXT'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = t_table

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

sort table t_table by title.

reward if helpful.

regards,

kiran kumar k