‎2011 Dec 25 2:04 PM
Hi Gurus,
I have this problem, I am trying to sort a internal table with the syntax after endselect statement and before read table statement
SORT ITAB_SBOOK BY NAMEname is a field in the table of type CHAR length 25 in actual table and here is how i am declaring name
in internal table
name LIKE stravelag-namebut the sort statement is not executing properly, names are being printed on the screen but they are not
being formated.
can some one tell me whare am i wrong ?
thanks.
Moderator Message: Please use more descriptive subject line in future post.
Edited by: Suhas Saha on Dec 25, 2011 7:55 PM
‎2011 Dec 25 5:30 PM
Hi hisheeraz,
Please use " As text " addition of sort statement for sorting character strings.
Pls see this
http://help.sap.com/saphelp_470/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm
Thanks
Jitendra soni
‎2011 Dec 25 5:30 PM
Hi hisheeraz,
Please use " As text " addition of sort statement for sorting character strings.
Pls see this
http://help.sap.com/saphelp_470/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm
Thanks
Jitendra soni
‎2011 Dec 25 9:01 PM
‎2011 Dec 26 4:47 AM
@ jitu188 thank man, your comment did not solve the problem but it definately lead me to the solution,
all i had to do was declare a string variable, transfer the value accross and then sort SOLVED
@ AnupamPratapSingh as of my understanding there is no difference between LIKE and TYPE there are 100% same.
i think one is newer version and other one is classic i am not sure which one though.
correct me if i am wrong
Cheers
‎2011 Dec 26 5:05 AM
Hi
as per my knowledge there is slight diff between type and like keywords
type key refer the data type of a field where as like key refer the reference of existing internal table in this just refer the data types not content(data)
example:
types:BEGIN OF ty_itab,
matnr type mara-matnr,
matkl type mara-matkl,
mbrsh type mara-mbrsh,
ersda type mara-ersda,
END OF ty_itab.
data:itab type STANDARD TABLE OF ty_itab.
data:wa_itab type ty_itab.
we want to create one more internal table with the existing structure at this time we will go through the like keyword.
jtab like itab occurs 10.
-
and also check the following code.
REPORT sort.
types:BEGIN OF ty_itab,
matnr type mara-matnr,
matkl type mara-matkl,
mbrsh type mara-mbrsh,
ersda type mara-ersda,
END OF ty_itab.
data:itab type STANDARD TABLE OF ty_itab.
data:wa_itab type ty_itab.
select matnr matkl mbrsh ersda from mara into wa_itab.
APPEND wa_itab to itab.
ENDSELECT.
SORT itab by mbrsh.
write:/ 'matno',' mat group','industry sector','created on'.
loop at itab into wa_itab.
write:/ wa_itab-matnr,wa_itab-matkl,wa_itab-mbrsh,wa_itab-ersda.
endloop.best regards
sreenivas p
‎2011 Dec 26 5:06 AM
Hi
as per my knowledge there is slight diff between type and like keywords
type key refer the data type of a field where as like key refer the reference of existing internal table in this just refer the data types not content(data)
example:
types:BEGIN OF ty_itab,
matnr type mara-matnr,
matkl type mara-matkl,
mbrsh type mara-mbrsh,
ersda type mara-ersda,
END OF ty_itab.
data:itab type STANDARD TABLE OF ty_itab.
data:wa_itab type ty_itab.
we want to create one more internal table with the existing structure at this time we will go through the like keyword.
jtab like itab occurs 10.
-
and also check the following code.
REPORT sort.
types:BEGIN OF ty_itab,
matnr type mara-matnr,
matkl type mara-matkl,
mbrsh type mara-mbrsh,
ersda type mara-ersda,
END OF ty_itab.
data:itab type STANDARD TABLE OF ty_itab.
data:wa_itab type ty_itab.
select matnr matkl mbrsh ersda from mara into wa_itab.
APPEND wa_itab to itab.
ENDSELECT.
SORT itab by mbrsh.
write:/ 'matno',' mat group','industry sector','created on'.
loop at itab into wa_itab.
write:/ wa_itab-matnr,wa_itab-matkl,wa_itab-mbrsh,wa_itab-ersda.
endloop.best regards
sreenivas p