‎2011 Feb 03 6:22 AM
Hi all,
I need to sort table before it display it,
I used the following code, But In ECC 6.0 I got dumb.
Assigning extract[] = gt_ztest[] ( OBJECTS_TABLES_NOT_COMPATIBLE ) it says... Is it possible help me,...
Line: -
Step 1:
Insert a module line after the module "LISTE_INITIALISIEREN" .
e.g.
PROCESS BEFORE OUTPUT.
MODULE LISTE_INITIALISIEREN.
MODULE sort .
LOOP AT EXTRACT ...
...
Step 2:
In your new module (in my example "sort"), do the sorting as follows. I will sort my table by the field "f3" .Thank God because ABAP gives assignment regardless of structures of both sides. Here what I mean:
e.g.
MODULE sort OUTPUT.
DATA gt_ztest LIKE ztest OCCURS 1 WITH HEADER LINE .
*--Getting the content of extract in an internal table
*-having the structure of my table.
gt_ztest] = extract[ .
*--Sorting it
SORT gt_ztest BY f3 .
*--Restoring extract from my sorted table
extract[] = gt_ztest[] .
ENDMODULE. " sort OUTPUT
Line: -
‎2011 Feb 03 10:32 AM
Hi Florian,
You got that dump because of incorrect data type of table which you have declared "LIKE ztest".If you want to sort the final table why dont you sort extract directly? I think you can do it.
Equal assigment operator you can use only when both the tables have same structure and fields in it.Please check the fields in both the tables gt_ztest and extract.That should be same to use "=" Operator to copy data.
Regards,
Saurabh
‎2011 Feb 03 10:32 AM
Hi Florian,
You got that dump because of incorrect data type of table which you have declared "LIKE ztest".If you want to sort the final table why dont you sort extract directly? I think you can do it.
Equal assigment operator you can use only when both the tables have same structure and fields in it.Please check the fields in both the tables gt_ztest and extract.That should be same to use "=" Operator to copy data.
Regards,
Saurabh
‎2011 Feb 03 11:30 AM
‎2011 Feb 03 9:42 PM
Dear Florian,
If once you have created the table maintenance generator follow the below steps for the needful:
Step 1: Choose the menu path Environment -> Modification -> Maintenance Screens, you will get a popup with screen number and description. Double click on screen number, with that you can see the flow logic of the screen.
Step 2: Now define one PBO module (MODULE sort_before_save) under PROCEE BEFORE OUTPUT statement as below
PROCESS BEFORE OUTPUT.
MODULE sort_before_display.
MODULE LISTE_INITIALISIEREN.
LOOP AT EXTRACT WITH CONTROL
TCTRL_ZZTEST CURSOR NEXTLINE.
MODULE LISTE_SHOW_LISTE.
ENDLOOP.
Step 3: Now create the module SORT_BEFORE_SAVE. With in the module define one internal table with the reference of the table name. For example the table name is: ZZTEST then you have to define one internal table as below:
DATA: ta_zztest TYPE STANDARD TABLE OF ZZTEST.
Then copy the data from the table TOTAL TO TA_ZZTEST as below:
TA_ZZTEST[ ] = TOTAL[ ].
Now sort the table TA_ZZTEST[ ] as for your requirement. For example table ZZTEST have 3 fields like Field1, field2, and field3, and if you want sort the data based on third field then you can sort the table data as below:
SORT ta_zztest[ ] by field3.
Now copy the data from TA_ZZTEST[ ] to TOTAL[ ] as below:
TOTAL[ ] = TA_ZZTEST[ ].
At last copy the data from TOTAL[ ] to EXTRACT[ ] as below:
EXTRACT[ ] = TOTAL[ ].
_______________________________________________________________________________________________
module sort_before_display output.
DATA: ta_test TYPE TABLE OF zztest.
ta_test[ ] = total[ ].
SORT ta_test[ ] by field3.
total[ ] = ta_test[ ].
extract[ ] = total[ ].
endmodule. " sort_before_display OUTPUT
_______________________________________________________________________________________________
Save and activate. Goto transaction code SM30 and see the table entries, you can find all the entries in sorting order based on the table field FIELD3.
I hope this will solve your problem.
Edited by: Mallik_M on Feb 3, 2011 10:44 PM
‎2011 Feb 07 12:27 PM
Hi Mallik,
As per your Suggestion I inserted the following code, for ZSPFLI which is replica of SPFLI table.
DATA: TA_TEST TYPE TABLE OF ZSPFLI.
TA_TEST[ ] = TOTAL[ ].
SORT TA_TEST[ ] BY DISTANCE.
TOTAL[ ] = TA_TEST[ ].
EXTRACT[ ] = TOTAL[ ].
TA_TEST[ ] = TOTAL[ ]. -----> Dump ( OBJECTS_TABLES_NOT_COMPATIBLE )
For minimum fields and char fields its working i think. But in my table DATS, NUMC, QUAN types may come.
Suggest me if you have any idea.
‎2011 Jul 13 1:48 PM
Hi Florian!
I would like to know if you have found any solution for this problem. I have the same error message and I cannot find any solution around. Can you help me?
Betty