+ Reply to Thread
Results 1 to 3 of 3

Data Upload To SAP

  1. #1
    Registered User
    Join Date
    07-30-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    10

    Post Data Upload To SAP

    Hi All,

    I have 10 text file with following name UploadData_1.txt, UploadData_2.txt & UploadData_3.txt
    These text file has data as below
    UploadData_1.txt
    1389525819
    1000707049
    1390579107

    UploadData_2.txt
    1001568973
    1035826500
    2314936093 and so on...

    I have recorded the macro which works fine below is the recorded macro.
    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 188,19,false
    session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "RAM1978"
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "********"
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 12
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/tbar[0]/okcd").text = "yh3sd033"
    session.findById("wnd[0]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/usr/radP_RAD4").select
    session.findById("wnd[0]/usr/radP_RAD4").setFocus
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[0]/usr/radP_RAD2").setFocus
    session.findById("wnd[0]/usr/radP_RAD2").select
    session.findById("wnd[0]/usr/chkP_CHK1").setFocus
    session.findById("wnd[0]/usr/chkP_CHK1").selected = true
    session.findById("wnd[0]/usr/btn%_S_VBELN_%_APP_%-VALU_PUSH").press
    session.findById("wnd[1]/tbar[0]/btn[23]").press
    session.findById("wnd[2]/usr/ctxtDY_PATH").text = "C:\SAPUploadFiles"
    session.findById("wnd[2]").sendVKey 4
    session.findById("wnd[3]/usr/ctxtDY_FILENAME").text = "UploadData_1.txt"
    session.findById("wnd[3]/usr/ctxtDY_FILENAME").caretPosition = 14
    session.findById("wnd[3]/tbar[0]/btn[0]").press
    session.findById("wnd[2]/tbar[0]/btn[0]").press
    session.findById("wnd[1]/tbar[0]/btn[8]").press
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/tbar[0]/btn[3]").press
    session.findById("wnd[0]/usr/btn%_S_VBELN_%_APP_%-VALU_PUSH").press
    session.findById("wnd[1]/tbar[0]/btn[16]").press
    session.findById("wnd[1]/tbar[0]/btn[23]").press
    session.findById("wnd[2]/usr/ctxtDY_PATH").text = "C:\SAPUploadFiles"
    session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = "UploadData_2.txt"
    session.findById("wnd[2]/usr/ctxtDY_FILENAME").caretPosition = 14
    session.findById("wnd[2]/tbar[0]/btn[0]").press
    session.findById("wnd[1]/tbar[0]/btn[8]").press
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/tbar[0]/btn[3]").press
    session.findById("wnd[0]/usr/btn%_S_VBELN_%_APP_%-VALU_PUSH").press
    session.findById("wnd[1]/tbar[0]/btn[16]").press
    session.findById("wnd[1]/tbar[0]/btn[23]").press
    session.findById("wnd[2]/usr/ctxtDY_PATH").text = "C:\SAPUploadFiles"
    session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = "UploadData_3.txt"
    session.findById("wnd[2]/usr/ctxtDY_FILENAME").caretPosition = 14
    session.findById("wnd[2]/tbar[0]/btn[0]").press
    session.findById("wnd[1]/tbar[0]/btn[8]").press
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/tbar[0]/btn[3]").press
    session.findById("wnd[0]/usr/btn%_S_VBELN_%_APP_%-VALU_PUSH").press
    session.findById("wnd[1]/tbar[0]/btn[16]").press
    session.findById("wnd[1]/tbar[0]/btn[23]").press
    session.findById("wnd[2]/usr/ctxtDY_PATH").text = "C:\SAPUploadFiles"
    session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = "UploadData_4.txt"
    session.findById("wnd[2]/usr/ctxtDY_FILENAME").caretPosition = 14
    session.findById("wnd[2]/tbar[0]/btn[0]").press
    session.findById("wnd[1]/tbar[0]/btn[8]").press
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/tbar[0]/btn[3]").press
    session.findById("wnd[0]/tbar[0]/btn[3]").press
    session.findById("wnd[0]/tbar[0]/btn[3]").press

    I need some help here in validating this like I want a macro to check if text file exist in C:\SAPUploadFiles folder and upload one by one file and delete file in C:\SAPUploadFiles folder post upload to SAP.
    As some times I might place only 5 files or some times it may increase the files. Kindly help me on this.

    TIA

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    1,280

    Re: Data Upload To SAP

    ??? hmm ... try this scheme:
    Please Login or Register  to view this content.
    Ps:
    Apply tags to vba code - the code will be easier to read

  3. #3
    Registered User
    Join Date
    07-30-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    10

    Re: Data Upload To SAP

    Woow that was brilliant thanks a lot with your solution I was able to upload multiple files via VBA. Thanks a lot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1