Consulting

Results 1 to 1 of 1

Thread: Copy & Paste SAP Transaction Cell Content

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Copy & Paste SAP Transaction Cell Content

    Hi

    I am not a programmer and am very new to scripting (this is actually my first attempt) and would really appreciate some guidance. In SAP, I have got to copy a value from one field and paste it into another (repeatedly across in excess of 5000 documents) - usually I would create an LSMW for this, but in this instance, there is no table join relationship; therefore, I have recorded a script which automates my mouse clicks. The problem that I have is that the value of the cell that I copied (9300000027) in my recording is obviously stuck in the code - I need to be able to copy whatever the cell content is. Here is my script:

    If Not IsObject(application) Then
        Set SapGuiAuto  = GetObject("SAPGUI")
        Set application = SapGuiAuto.GetScriptingEngine
    End If
    If Not IsObject(connection) Then
        Set connection = application.Children(0)
    End If
    If Not IsObject(session) Then
        Set session    = connection.Children(0)
    End If
    If IsObject(WScript) Then
        WScript.ConnectObject session,     "on"
        WScript.ConnectObject application, "on"
    End If
        session.findById("wnd[0]").resizeWorkingPane 163,52,false
        session.findById("wnd[0]").sendVKey 2
        session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
        session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_SRELATIONS"
        session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell/shellcont[3]/shell").currentCellColumn = "PARTNER"
        session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell/shellcont[3]/shell").selectedRows = "0"
        session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell/shellcont[3]/shell").doubleClickCurrentCell
        session.findById("wnd[0]/shellcont/shell").selectItem "Control","Spalte1"
        session.findById("wnd[0]/shellcont/shell").ensureVisibleHorizontalItem "Control","Spalte1"
        session.findById("wnd[0]/shellcont/shell").doubleClickItem "Control","Spalte1"
        session.findById("wnd[0]/usr/tabsTABSTRIP_SHOW_EDIDC/tabpSADR").select
        session.findById("wnd[0]/usr/tabsTABSTRIP_SHOW_EDIDC/tabpSADR/ssub/1/2/txt[0]").setFocus
        session.findById("wnd[0]/usr/tabsTABSTRIP_SHOW_EDIDC/tabpSADR/ssub/1/2/txt[0]").caretPosition = 0
        session.findById("wnd[0]/tbar[0]/btn[3]").press
        session.findById("wnd[0]/tbar[0]/btn[3]").press
        session.findById("wnd[1]").close
        session.findById("wnd[0]/tbar[1]/btn[13]").press
        session.findById("wnd[0]/tbar[1]/btn[5]").press
        session.findById("wnd[1]/usr/txt[2]").text = "9300000027"
        session.findById("wnd[1]/usr/txt[2]").setFocus
        session.findById("wnd[1]/usr/txt[2]").caretPosition = 10
        session.findById("wnd[1]/tbar[0]/btn[0]").press
        session.findById("wnd[2]/tbar[0]/btn[0]").press
        session.findById("wnd[0]/tbar[0]/btn[11]").press
    I would be ever so grateful if someone could help me.

    Kind Regards


    Simon
    Last edited by Aussiebear; Yesterday at 03:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •