Is therr any way to drag one line in ALV to a new postion in the ALV list?

Dear All,
Is there any way to drag one line of ALV and drop it to  a new position ?
Woud you please show me some simple code?

Hi Edwards,
Drag and drop can be achived using the events in the class.
TABLES:
  SSCRFIELDS.
PARAMETERS:
  P_TABLE TYPE DD02L-TABNAME OBLIGATORY.
DATA:
  W_DYNTABLE TYPE REF TO DATA,
  W_DYSTABLE TYPE REF TO DATA,
  W_STRUC    TYPE REF TO DATA.
FIELD-SYMBOLS:
  <T_TABLE>  TYPE STANDARD TABLE,
  <FS_TABLE> TYPE ANY,
  <T_STABLE> TYPE STANDARD TABLE,
  <FS_STABLE> TYPE ANY.
DATA:
  EFFECT TYPE I,
  HANDLE_ALV TYPE I.
DATA:
  GRID TYPE REF TO CL_GUI_ALV_GRID,
  CONT TYPE REF TO CL_GUI_DOCKING_CONTAINER,
  C_DRAGDROPALV TYPE REF TO CL_DRAGDROP,
  T_STBL TYPE LVC_S_STBL,
  T_LAYO TYPE LVC_S_LAYO.
AT SELECTION-SCREEN.
  SELECT TABNAME
    FROM DD02L
   UP TO 1 ROWS
    INTO P_TABLE
   WHERE TABNAME = P_TABLE AND TABCLASS = 'TRANSP'.
  ENDSELECT.
  IF SY-SUBRC NE 0.
    CLEAR SSCRFIELDS-UCOMM.
    MESSAGE 'Invalid Table Name'(001) TYPE 'E'.
  ENDIF.
START-OF-SELECTION.
  CREATE DATA W_DYNTABLE TYPE STANDARD TABLE OF (P_TABLE)
                                      WITH NON-UNIQUE DEFAULT KEY.
  CREATE DATA W_DYSTABLE TYPE STANDARD TABLE OF (P_TABLE)
                                      WITH NON-UNIQUE DEFAULT KEY.
  CREATE DATA W_STRUC TYPE (P_TABLE).
  ASSIGN W_DYNTABLE->* TO <T_TABLE>.
  ASSIGN W_DYSTABLE->* TO <T_STABLE>.
  ASSIGN W_STRUC->* TO <FS_TABLE>.
  ASSIGN W_STRUC->* TO <FS_STABLE>.
  SELECT * FROM (P_TABLE) INTO CORRESPONDING FIELDS OF TABLE
  <T_TABLE>.
  CALL SCREEN 100.
      CLASS lcl_dataobject DEFINITION
CLASS LCL_DATAOBJECT DEFINITION.
  PUBLIC SECTION.
    DATA:
        INDEX TYPE I.
ENDCLASS.                    "lcl_dataobject DEFINITION
DATA:
  L_OBJ TYPE REF TO LCL_DATAOBJECT.
      CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
          DRAG FOR EVENT
                       ONDRAG OF CL_GUI_ALV_GRID
                       IMPORTING ES_ROW_NO E_DRAGDROPOBJ E_ROW,
          DROP FOR EVENT
                       ONDROP OF CL_GUI_ALV_GRID
                       IMPORTING ES_ROW_NO E_DRAGDROPOBJ E_ROW.
ENDCLASS.                    "lcl_event_handler DEFINITION
      CLASS lcl_event_handler  IMPLEMENTAION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
  METHOD DRAG .
    CREATE OBJECT L_OBJ.
    READ TABLE <T_TABLE> INDEX ES_ROW_NO-ROW_ID ASSIGNING <FS_TABLE> .
    IF SY-SUBRC EQ 0.
      L_OBJ->INDEX = E_ROW-INDEX.
      ASSIGN <FS_TABLE> TO <FS_STABLE>.
      APPEND <FS_STABLE> TO <T_STABLE>.
      E_DRAGDROPOBJ->OBJECT = L_OBJ.
    ENDIF.
  ENDMETHOD.                    "lcl_event_handler
  METHOD DROP.
    DELETE <T_TABLE> INDEX L_OBJ->INDEX.
    LOOP AT <T_STABLE> ASSIGNING <FS_STABLE>.
      INSERT <FS_STABLE> INTO <T_TABLE> INDEX E_ROW-INDEX.
    ENDLOOP.
    PERFORM REFRESH_TABLE.
    CLEAR <FS_STABLE>.
    REFRESH <T_STABLE>.
  ENDMETHOD.                    "drop
ENDCLASS.                    "lcl_event_handler  IMPLEMENTAION
*&      Module  STATUS_0100  OUTPUT
      text
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'ALV'.
  SET TITLEBAR 'TITLE' WITH P_TABLE.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
      text
MODULE USER_COMMAND_0100 INPUT.
  CASE SY-UCOMM.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Module  display  OUTPUT
      text
MODULE DISPLAY OUTPUT.
  CREATE OBJECT CONT
     EXPORTING
       DYNNR             = '100'
       SIDE              = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_TOP
       EXTENSION         = 350.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CREATE OBJECT GRID
    EXPORTING
      I_PARENT          = CONT.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CREATE OBJECT C_DRAGDROPALV.
  EFFECT = CL_DRAGDROP=>MOVE + CL_DRAGDROP=>COPY.
  CALL METHOD C_DRAGDROPALV->ADD
    EXPORTING
      FLAVOR     = 'Line'(002)
      DRAGSRC    = 'X'
      DROPTARGET = 'X'
      EFFECT     = EFFECT.
  CALL METHOD C_DRAGDROPALV->GET_HANDLE
    IMPORTING
      HANDLE = HANDLE_ALV.
  T_LAYO-S_DRAGDROP-ROW_DDID = HANDLE_ALV.
  CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      I_STRUCTURE_NAME = P_TABLE
      IS_LAYOUT        = T_LAYO
    CHANGING
      IT_OUTTAB        = <T_TABLE>.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  SET HANDLER LCL_EVENT_HANDLER=>DRAG FOR GRID.
  SET HANDLER LCL_EVENT_HANDLER=>DROP FOR GRID.
ENDMODULE.                 " display  OUTPUT
*&      Form  refresh_table
      text
-->  p1        text
<--  p2        text
FORM REFRESH_TABLE .
  CALL METHOD GRID->REFRESH_TABLE_DISPLAY
    EXPORTING
      IS_STABLE      = T_STBL
      I_SOFT_REFRESH = 'X'
    EXCEPTIONS
      FINISHED       = 1
      OTHERS         = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " refresh_table
Edited by: Kumar M on Jun 29, 2009 8:02 AM

Similar Messages

  • Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?

    Hi, Im not a frequent forum poster, as most of my questions can be found already answered on them!
    This is a question Ive had for a long time and it amazes me that no-one else seems to ask it. I check at each OS upgrade but its never there...
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    I was able to do this years ago in MS Outlook, and utilized it all the time when I needed to push things back, now I have to open the event and select an new date in the drop-down calendar for each & every event I want to move to a new month at the end of the month.
    If its definitely not possible, how to you ask apple to consider including it - it doesnt seem like a particularly difficult task.
    Thankyou
    Andrew.

    Andrew,
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    No, but you can use cut/paste. Cut (⌘X) the event, then click on the week where you want to move the event, and Paste (⌘V).
    If you have a suggestion for Apple to change that method use: Apple - Mac OS X - Feedback.

  • I just got a new macbook. Is there any way I can transfer pictures or music to this new mac from my old one?

    I just got a new macbook. Is there any way I can transfer pictures or music to this new mac from my old one?

    Welcome to Apple Support Communities
    There are different ways to transfer your data from another Mac, but as you just want to transfer pictures and music, the best way is to use an external drive. You can also connect them with a Thunderbolt or FireWire cable, but you need specific Macs to do it, so I prefer the external drive method.
    You just have to get an external drive and plug it to the old Mac. Then, open Finder, navigate to the folders with your pictures and music, and drag them to the external drive in the Finder sidebar, under "Devices".
    Then, connect the external drive to the new Mac and you will see the external drive in the Finder sidebar after opening a Finder window, so choose it. Then, just copy the pictures and music to the folder you want, for example, Music or Pictures

  • In Pages 5.0.1. is there any way to link one pages document to another pages document.  If so, How?

    Is Pages 5.0.1 is there any way to link one Pages document to another Pages document?  If so, Please, How?

    Well, you could trade it in for a white one! 
    First, try a system reset.  It cures many ills and it's quick, easy and harmless...
    Hold down the on/off switch and the Home button simultaneously until the screen blacks out or you see the Apple logo.  Ignore the "Slide to power off" text if it appears.  You will not lose any apps, data, music, movies, settings, etc.
    If the Reset doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."

  • I Have Signed In With 3  icloud account is there any way to Delete one of them

    i brought a New Iphone today and i signed in with three different but i dont know any of there password is there a way to delete one and sign in with a new account i created

    do u have facebook so tht i can talk to you

  • All I want for Christmas is a mute Icon, a mute icon, a mute icon. Is there any way to haver one? Iphone 4S

    All I want for Christmas is a mute Icon, a mute icon, a mute icon. Is there any way to have one? Iphone 4S And no the tiny metal slide on the side with the tiny orange liver is not the same. I just want to know is there a way to have an icon?

    Succinct and clear. Oh well.

  • Is there any way to do a mass copy and paste of song titles from the "name" column to the "sort name" column? I know it can be done with individual titles but I have over 6,000 titles in my library.

    In iTunes, is there any way to do a mass copy and paste of song titles from the "name" column to the "sort name" column? I know it can be done with individual titles but I have over 6,000 titles in my library.

    Thank you. I have heard of Logic Pro 7, but I have never personally used it. I'm still growing in the world of Composition, and I know that it is something I will be studying in one of my Computer Music classes coming up for my degree. I think it is something I will look into getting once I can justify the price of it. I guess for the time being, I will continue to play and grow in my ability to use and take advantage of GB, and then see what I can do about or with Logic Pro when I'm ready. The thought of spending $1000 for a program is hard to bite, because I've already spent a lot to produce my music, not only electronic music, but also chamber music and so on. I had no idea it would be so expensive to dive deep into the world of composition! lol.
    Finale 2007: $500
    Sibelius 4: $500
    Jam Packs: $400
    Midi Keyboard Interface: $100
    PowerBook: $1700
    Printer for printing scores and analysis: $150
    Logic Pro 7: Oy!
    As you can see it adds up very quickly...that doesn't even include my personal instruments and study materials.
    Thank you for your input, as I haven't really worked much with LP, and therefore didn't know which features are available. I will talk with some of my Composition buddies, and professors and see what they have to say as well, and who knows, I may be able to get the express version through one of them.

  • Hi am having problems with iTunes,I have all my music on my 4s but I bought the iPhone 5 today.us there any way that I can transfer music over to my new phone without using the library?as it doesn't seem to be on my PCM anymore.

    Hi am having problems with iTunes,I have all my music on my 4s but I bought the iPhone 5 today.is there any way that I can transfer music over to my new phone without using the library?as it doesn't seem to be on my PC anymore.i reset my pc and save my iTunes to a hard drive but can't access it.Need help please

    " When I did this, my library showed all the music I have "purchased" from itunes but did not have the music that I downloaded a long time ago through itunes from my old CDs."
    Correct.
    " How can I get that music to show up in my library now on my new computer?  "
    Copy it from your old computer or your backup copy of your old computer.
    The sync is one way - computer to ipod.

  • Is there any way I can use continuity between an iDevice and a Lumia? (The iDevice being an iPad or iMac)

    Is there any way I can use continuity between an iDevice and a Lumia? (The iDevice being an iPad or iMac)

    Continuity requires OS X and iOS. At least one of the devices you mention is lacking those... So no.

  • HT1918 I have 2 Apple ID's, how do I delete the old one as its interferring with my new account and the music I have already purchased through ITunes does not want to play.  Any suggestions?

    I have 2 Apple ID's, how do I delete the old one as its interferring with my new account and the music I have already purchased through ITunes does not want to play.  Any suggestions?

    Why would you create a new account?
    All purchases will be tied to the account from which they were purchased.
    You will have to authorize your computer for all the accounts from which music is purchased.

  • On iTunes 11, how can I access home sharing if the music is from a CD? Is there any way I can download these songs if (A) I no longer have the CD, or (B) I do not want to pay $25 a year for iTunes Match?

    On iTunes 11, how can I access home sharing if the music is from a CD on a different computer using Home Sharing? Is there any way I can download these songs if (A) I no longer have the CD, or (B) I do not want to pay $25 a year for iTunes Match?

    Yes, you can copy songs that you ripped from a CD to your Home Sharing computer.
    Turn on Home Sharing first on both computers.  To do that, go to File > Home Sharing > Turn on Home Sharing.  Enter your Apple ID and password.
    Now go to your computer that you want to copy the songs to and connect to your Home Share.  You can do that by clicking on the popover button located at the left top corner right below the play control buttons.  Click on it and scroll to the bottom until you see your Home Share and select it.
    Go to Music in your Home Share.  Select the songs that you want to copy in your Home Share and click Import at the bottom right corner.

  • Is there any way that I can have songs in an iTunes Playlist without having the songs play in my regular music list.  For instance: can I have a Playlist of Christmas songs without having them play in the routine shuffle of my music library?  Thanks -Rog

    Is there any way that I can have songs in an iTunes Playlist without having the songs play in my regular music list.  For instance: can I have a Playlist of Christmas songs without having them play in the routine shuffle of my music library?  Thanks -Rog

    Select the songs, press CTRL+I to Get Info, on the Options tab set Skip when shuffling to Yes.
    If you want to the hide the songs from your main music view you could consider changing the media kind to audiobooks or podcasts if you don't mind the side effect of them showing up there instead.
    tt2

  • Is there a way to delete one of several checkboxes from a pdf form without the leftover checkboxes automatically renumbering themselves?

    Is there a way to delete one of several checkboxes from a pdf form without the leftover checkboxes automatically renumbering themselves?
    I used LiveCycle Designer to make a pdf form with many checkboxes. When I deleted a few of the checkboxes the rest left on the form renumbered themselves. This made my JavaScript out of sync since the JavaScript checkbox numbers did NOT update automatically. I am hoping there is a preference option to not auto update. I just cannot find it,

    I believe you're using the same name for each checkbox, right?!
    If so, each checkbox has an index number which represents its position relative to the other copies in the XML tree and when you add, delete or reorder the copies the index will always be recreated because thats the way how XML works.
    There is no way to stop Designer from doing this, I'm afraid.
    To address individual objects through JavaScript you should use unique names.

  • I recently changed jobs and no longer have access to the computer that contained my Firefox bookmarks. I don't have a Firefox profile. Is there any way to find and transfer my bookmarks to my new computer?

    I recently changed jobs and no longer have access to the computer that contained my Firefox bookmarks. I don't have a Firefox profile. Is there any way to find and transfer my bookmarks to my new computer?

    If you don't have access to the old computer any longer, '''no'''. Unless you were using something like the Google Toolbar & Google Bookmarks or Xmarks, which would have your bookmarks in an online account that you could access. Firefox doesn't include an online storage feature for personal data, yet. That is coming in a future version.
    If you have a friend at your old job maybe they have access to that old PC and they could export your bookmarks to a file and email that file to you.

  • My on/off button does not appear to be working on my iphone 3.....is there any way around this....anyway around this?...the phone also periodically just switches off.

    my on/off button does not appear to be working on my iphone 3.....is there any way around this....anyway around this?...the phone also periodically just switches off.

    Likely a hardware issue... no way around that except to get it repaired or don't use it (the button).
    Try restoring to solve the switching off problem.

Maybe you are looking for

  • Highlighting Text in pdf Documents using Preview

    Am using Snow Leopard (10.6.3) with Preview version 5.0.2. Tried highlighting text using the instructions in Preview help. No success. I click Annotate; chose the Highlight Colour but then appear to be unable to select the text. Anyone any ideas? Tha

  • Is it possible to remotely start an exectutable/application on Real-Time target?

    Hi All, Apologies if this is an obvious question - I could not get an applicable answer using any search terms I could think of - and I am quite new to Real-Time programming. Is it possible to launch a headless real-time .exe (or uncompiled applicati

  • How to hide. textInput in UIX file....

    Hi, I need to hide.. textInput in the UIX file... is their any way to do it! following is the part of UIX file, in which i just need to hide the textInput <cellFormat> <contents> <textInput name="${uix.data.constants.RESPONSIBILITY_PARAM}" columns="4

  • How to set user InitialContext in Weblogic ?

    Hi , Below 2 questions : 1). We have an MDB which received an XML message with userId and SiteMinder token. We need to process that message to set the Initial Context in Weblogic.What is the best way to do that ? 2). Since,we have userId in the JMS x

  • Completed Project Doesn't work When Deployed FilePermission Error

    Hello all, I have been slaving away over an applet for the past several weeks, and I have finally gotten it finished. When I tried to upload it to MY web server, it suddenly stopped working. The applet itself reads files from the directory in which i