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 a table draw

Former Member
0 Likes
526

HI Friends,

I need a small help on a logic.

I have a table draw which will have versions for document.The version will start from NC,A,B,C,D,E,F........J,K,L.........Q,R,S,T......X,Y,Z,AA,AB,AC,AD,AE..........AK,AL......AZ,BA,BB,BC.....BZ....so..on.

here the oldest version is NC and the latest version is BZ.Now, how can i write the logic such that i get the laterst version from this table.Sort descending is not working as, it is taking Z as the biggest.Kindly help.

Thanks ,

Sakshi

2 REPLIES 2
Read only

Former Member
0 Likes
481

Hi Sakshi,

You can use DRAW_LAST_CHANGE table and get the created time and date and sort the version based on these values.

For log you can use the table DRAP and the fields DATUM & PZEIT fields will give the date and time the document got changed.

Thanks,

Srinath S

Read only

Former Member
0 Likes
481

hi ..

i have made some code to check if i can assign a rank to these versions . check if this works for you .



TYPES: begin of TY_itab,
         f2 type i,
         f1(2) type c,
        end of TY_itab.

DATA : ITAB TYPE TABLE OF TY_ITAB WITH HEADER LINE,
       WA TYPE TY_ITAB.
field-symbols: <FS> TYPE TY_ITAB.


itab-f1 = 'NC'.  append itab. "Start
itab-f1 = 'A'.  append itab.  "First
itab-f1 = 'B'.  append itab.
itab-f1 = 'Z'.  append itab.   "End of first
itab-f1 = 'AA'.  append itab.
itab-f1 = 'AB'.  append itab.
itab-f1 = 'AZ'.  append itab.
itab-f1 = 'BA'.  append itab.
itab-f1 = 'BB'.  append itab.
itab-f1 = 'BZ'.  append itab.
itab-f1 = 'CA'.  append itab.


DELETE ITAB WHERE F1 IS INITIAL.
clear itab.
loop at itab assigning <FS> ."INTO  WA .
  IF <fs>-F1+1(1) EQ SPACE.

    CASE <fs>-f1.
      when 'A'.
        <FS>-f2 = '1'.
      when 'B'.
        <FS>-f2 = '2'.
      when 'Z'.
        <FS>-f2 = '26'. "WRITE <FS>-F1.
    endcase.
  ELSEIF <fs>-F1+1(1) NE SPACE.
* AA = Z + A = (26) + 1 = 27
    CASE <FS>-F1.
      when 'AA'.
        <FS>-f2 = '27'.
      when 'AB'.
        <FS>-f2 = '28'.

      when 'AZ'.
        <FS>-f2 = '42'.

      when 'BA'.
        <FS>-f2 = '43'.

      when 'BB'.
        <FS>-f2 = '44'.
*BZ = BB + 24
      when 'BZ'.
        <FS>-f2 = '68'.
*CA  = BZ + 1
      when 'CA'.
        <FS>-f2 = '69'.

      WHEN 'NC'.
        <FS>-f2 = '0'.
    ENDCASE.
  ENDIF.
endloop.


SORT ITAB BY F2 DESCENDING.
LOOP AT ITAB ASSIGNING <FS>.
  WRITE:/ 'Latest version is', <FS>-F2 .
  exit. "one time hit.
ENDLOOP.

This can be simplified to assign the rank by assigning ranges .