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

Issue with sorting in TMG

sriram_ramesh
Participant
0 Likes
1,525

Hi,

I have a TMG and tcode for it.

I'm sorting the table based on material by adding code in PBO.

gt_table[] = extract[].

sort gt_table by matnr.

extract[]  = gt_table[].

Sorting works fine.

But, when I try to add new entry to the table, it all goes to display mode.

I tried using check before the sorting code. (if sy-ucomm <> 'NEWL').

But during save sy-ucomm goes initial.

Is there anyother way to sort?

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,450

Hi,

if     sy-ucomm NE 'NEWL' AND

             sy-ucomm NE 'SAVE' AND

             sy-ucomm NE 'DELE'.

gt_table[] = extract[].

sort gt_table by matnr.

extract[]  = gt_table[].

endif.

try using above code. It may be helpful. In case of these OK codes, MATNRS in Extract[]  are displayed as "L'.

So if sorted, there is an inconsistency and everything goes blank. So I just made a workaround by excluding these OK codes. This is just a guidance and I sincerely suggest you to test all kind of scenarios in your requirement before really using this workaround.

Regards

Pallavi

Hi,

if     sy-ucomm NE 'NEWL' AND

             sy-ucomm NE 'SAVE' AND

             sy-ucomm NE 'DELE'.

gt_table[] = extract[].

sort gt_table by matnr.

extract[]  = gt_table[].

endif.

try using above code. It may be helpful. In case of these OK codes, MATNRS in Extract[]  are displayed as "L'.

So if sorted, there is an inconsistency and everything goes blank. So I just made a workaround by excluding these OK codes. This is just a guidance and I sincerely suggest you to test all kind of scenarios in your requirement before really using this workaround.

Regards

Pallavi

7 REPLIES 7
Read only

sriram_ramesh
Participant
0 Likes
1,450

.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,450

By sorting itab EXTRACT you may trigger some unconsistencies with itab TOTAL?

Could you consider creation of a maintenance view on your table, defining MANDT and MATNR as the first keys (if required add MARA as first table then your table)

Regards,

Raymond

Read only

0 Likes
1,450

Thanks for your reply.

My case is little different so it didn't work.

Read only

Former Member
0 Likes
1,451

Hi,

if     sy-ucomm NE 'NEWL' AND

             sy-ucomm NE 'SAVE' AND

             sy-ucomm NE 'DELE'.

gt_table[] = extract[].

sort gt_table by matnr.

extract[]  = gt_table[].

endif.

try using above code. It may be helpful. In case of these OK codes, MATNRS in Extract[]  are displayed as "L'.

So if sorted, there is an inconsistency and everything goes blank. So I just made a workaround by excluding these OK codes. This is just a guidance and I sincerely suggest you to test all kind of scenarios in your requirement before really using this workaround.

Regards

Pallavi

Read only

0 Likes
1,450

Hi pallavi,

What If I enter a new entry and click on enter? ok code will be space.

And when I run the tcode, ok code will be space.

so cant really use it

Read only

0 Likes
1,450

Hi sriram,

gt_ztest_pal1[] = extract[].

   DELETE gt_ztest_pal1[] WHERE matnr EQ space. "MATNR will be space for any action other than display

   SORT gt_ztest_pal1[] BY matnr.  "sort the remaining

   LOOP AT gt_ztest_pal1.

     LOOP AT extract.

       lv_temp = extract.

       IF lv_temp+3(18) EQ gt_ztest_pal1-matnr.

         DELETE extract. "Delete records which are being manipulated(add or del)

       ENDIF.

     ENDLOOP.

   ENDLOOP.

   INSERT LINES OF gt_ztest_pal1 INTO extract[] INDEX 1."insert sorted lines from index 1 .

Hope this code will help you, this code doesn't require to check on any UCOMM .

Code is not in pro with the performance(loop with in the loop), couldn't spend much time on this.

Please take care of this in case if you are using.

Regards

Pallavi

Read only

0 Likes
1,450

Thanks Pallavi,

This is exactly what I did.