Quantcast
Channel: SCN : Unanswered Discussions - Scripting Languages
Viewing all 376 articles
Browse latest View live

VBA \ VB.NET error capturing logon manager

$
0
0

I want to make the opening and starting of my SAP Script flawless if thats possible..

 

this will login for me all good, but I want to make sure ever option has a 'error check'

 

so from the beginning,

 

-make sure the SAP program is open - 'on error resume next' has solved this for me but any other ways to do it would be awesome.

-SAPName and SAPClient is actually available for the person when they run it

-ensure scripting is enabled

-load SAP window to continue with the rest of the script

 

did i miss a variable ?

 

do i make sense?

 

i have added 'on error resume next' but when i turn off scripting to 'debug' SAP actually pops up saying its disabled,

can i check without 'hassling' SAP ?

 

 

SAPName = "04. DoH\AHO ECC PRD - PRD"

SAPClient = "400"

PAClient = "wnd[0]/usr/subSUBSCR_HEADER:/1PAPAXX/HDR_40017A:0100/txt$_DG02_400A17_DTX_P0000_STAT2"

 

If Not IsObject(App) Then

 

Set SAP = GetObject("SAPGUI")

Set App = SAP.GetScriptingEngine

 

End If

 

Set SAPConnection = App.OpenConnection(SAPName, True)

Set session    = SAPConnection.Children(0)

 

session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = SAPClient

session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = UserID

session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = Password

session.findById("wnd[0]").sendVKey 0

 

 

 

sorry to pester you all...newbie .... trying to learn as i go ...


Change ME22N confirmation key fail

$
0
0

Hi Dears,

I want to change confirmation key, and input confirmation automatically, but when I tried to run SAP script it always failed on this line.

This is to check if confirmation control is blank, if yes, then choice C001, some times PO line already has confirmation key, some times not.

And I always got problem when I try to choice confirmation label, some times it will failed as well.

Can some body help on this, many thanks in advance.

 

 

If Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").Key = "" Then

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").Key = "C001"

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").SetFocus

Session.findById("wnd[0]").sendVKey 0

End If

 

 

 

 

 

Below is total script

Option Explicit

Public SapGuiAuto As Object, Applicat As Object, Connection As Object, Session As Object

 

 

Function Attach() As Boolean

On Error Resume Next

Set SapGuiAuto = GetObject("SAPGUI")

On Error GoTo 0

 

 

If SapGuiAuto Is Nothing Then

   Attach = False

   Exit Function

   Else

   Set Applicat = SapGuiAuto.GetScriptingEngine

   On Error GoTo 0

End If

 

 

If Applicat Is Nothing Then

   Attach = False

   Exit Function

End If

 

 

If Applicat.Children.Count = 0 Then

  Attach = False

  Exit Function

  Else

  Set Connection = Applicat.Children(0)

  On Error GoTo 0

End If

Set Session = Connection.Children(0)

 

 

If Session.ActiveWindow.Text = "SAP" Then

   Attach = False

   Exit Function

End If

 

 

Attach = True

End Function

 

 

 

Sub addABcon1025()

Dim i, PartNo, joblen, btt

Dim P

Dim Pline

Dim saptab

Dim POline, POnum, POdate, POqty

Application.DisplayAlerts = False

Application.EnableEvents = False

joblen = Sheet1.Cells(55555, 1).End(xlUp).Row

btt = Sheet1.Cells(55555, 4).End(xlUp).Row

If Attach Then

For PartNo = 2 To 10

'Range("d3:d9").ClearContents

 

 

Session.findById("wnd[0]").maximize

Session.findById("wnd[0]/tbar[0]/okcd").Text = "/nme22n"

Session.findById("wnd[0]").sendVKey 0

Session.findById("wnd[0]/tbar[1]/btn[17]").press

Session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").Text = Sheet1.Cells(PartNo, 4)

Session.findById("wnd[1]").sendVKey 0

''以上是改成我想要的PO,不用再做更改了

 

 

POdate = Sheet1.Cells(PartNo, 3)

POqty = Sheet1.Cells(PartNo, 10)

Pline = Sheet1.Cells(PartNo, 5) / 10

 

 

If Pline = 1 Then GoTo 10

If Pline < 10 Then

Sheet1.Cells(PartNo, 2) = "'   " & Pline

Else

If Pline < 100 Then

Sheet1.Cells(PartNo, 2) = "'  " & Pline

Else

If Pline < 1000 Then

Sheet1.Cells(PartNo, 2) = "' " & Pline

End If

End If

End If

 

 

 

 

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").SetFocus

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").Key = Sheet1.Cells(PartNo, 2) ''换成第二行

''以上是根据PO item更改行,如果没问题不要更改。

 

 

 

 

10 Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16").Select

''以上是选择Confirmation label,现在如果本来就是默认的这个label 就会报错.

 

 

 

If Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").Key = "" Then

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").Key = "C001"

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").SetFocus

Session.findById("wnd[0]").sendVKey 0

End If

 

 

 

 

If Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").Key = "" Then

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").Key = "C001"

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO1334-BSTAE").SetFocus

Session.findById("wnd[0]").sendVKey 0

End If

''以上是更改confirmation key,如果为空就增加

 

Next PartNo

End If

Application.DisplayAlerts = True

Application.EnableEvents = True

End Sub

 

 

 

 

''update on1024,增加判断是否已经有AB的地方

If Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/ctxtEKES-EBTYP[0,0]").Text = "" Then

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/ctxtEKES-EBTYP[0,0]").Text = "ab"

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/ctxtRM06E-EEIND[2,0]").Text = POdate

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/txtEKES-MENGE[4,0]").Text = POqty

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/txtEKES-MENGE[4,0]").SetFocus

Session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/txtEKES-MENGE[4,0]").caretPosition = 3

Session.findById("wnd[0]").sendVKey 0

Session.findById("wnd[0]").sendVKey 0

Session.findById("wnd[0]").sendVKey 0

Session.findById("wnd[0]/tbar[0]/btn[11]").press

Session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press

End If ''如果第一个AB code 写过了

SAP GUI scripting interference at the middle is possible ?

$
0
0

Hi SAP GUI scripting experts,

 

When I use SAP GUI scripting for role editing, it sometimes stops with error because it cannot find the authorization object in the right location. It is understandable that script searches for object as per the position , when it cannot find the object in the same position in which it was recorded, it throws error and stops. But is there any way we can interfere at this stage, find the object manually then continue running the script. Instead of terminating the script every time, this shall provide us ability to partially automate the mass role editing activity. Could anyone please let me know a method to do it ?

 

Thanks and Regards,

Syam

How to achieve a set of unix commands in SAP without writing code

$
0
0

Hi All,

 

I want to achieve following set of commands of unix in SAP. I don't have UNIX access so have to achieve these in SAP.

 

  • Cd /usr/sap/data/acd/xyz/
  • Rm acd1000d
  • Approve with Y

  • ./acd1000x

 

 

First three commands are for accessing the directory and deleting the file, which I am able to do from one of the standard FM in SAP, FMCT_DELETE_UNIXFILE. But i am not able to find the solution of the  last command, which is triggering/initiating a script. I dont wish to write any code.

 

So Please let me know if there is some other standard way in SAP to achieve the last command or some other FM.

 

Thanks in advance

 

Ankikt

Message box if sap session is not open

$
0
0

Hi SAP Experts,

 

I am new to SAP Vbscript. I have created a vbscript in SAP. My scripts extract the data from FBL1N and save it into a folder as .xls formate. Before run this VBscript I have to open SAP session.

 

So I would like to edit one message box in to my VBscript. This message box should warn If any user run this Vbscript before opening SAP session.

 

The messaage should be like (Please open SAP Session).

 

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]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "fbl3n"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/ctxtSD_SAKNR-HIGH").setFocus

session.findById("wnd[0]/usr/ctxtSD_SAKNR-HIGH").caretPosition = 0

session.findById("wnd[0]/usr/btn%_SD_SAKNR_%_APP_%-VALU_PUSH").press

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,0]").text = "40305120"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,1]").text = "40305130"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,1]").setFocus

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL-SLOW_I[1,1]").caretPosition = 8

session.findById("wnd[1]").sendVKey 8

session.findById("wnd[0]/usr/ctxtSD_BUKRS-LOW").text = "2350"

session.findById("wnd[0]/usr/ctxtPA_STIDA").text = '02102014"

session.findById("wnd[0]/usr/ctxtPA_STIDA").setFocus

session.findById("wnd[0]/usr/ctxtPA_STIDA").caretPosition = 10

session.findById("wnd[0]").sendVKey 8

session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[2]").select

session.findById("wnd[1]/usr/sub:SAPLSPO5:0101/radSPOPLI-SELFLAG[1,0]").select

session.findById("wnd[1]/usr/sub:SAPLSPO5:0101/radSPOPLI-SELFLAG[1,0]").setFocus

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/usr/ctxtRLGRAP-FILENAME").text = str & "\Consignment dump GP1.XLS"

session.findById("wnd[1]/usr/ctxtRLGRAP-FILENAME").caretPosition = 48

session.findById("wnd[1]").sendVKey 0

 

 

Could you please help on this.

 

Sorry for my poor englsih

 

Thanks & regards,

Pradeep

GuiXT CopyText problem

$
0
0

Hello everyone,

 

I am currently starting to use GuiXT (all components installed) and I have run into a problem with the CopyText function.

 

My goal is to have the script paste the value from Clipboard into the ZCJI3 screen element F[WBS Element]. I tried using the following:

 

CopyText ToScreen="F[WBS Element]" -fromclipboard

 

But I got an error saying:

Please specify a text variable as source or as destination.

 

I tried to circumvent this problem by first CopyTexting from clipboard to a V[ForHelp] and then setting F[WBS Element] to V[ForHelp] but that did not work either. I cannot get the CopyText function to copy anything from the clipboard no matter what I do.

 

Any suggestions as to where the problem may be?

scroll GUI table in VBS - dynamic title

$
0
0

Hi,

 

I need to loop VA02 items table to check which of the current line is selected
I saw this solution  http://scn.sap.com/thread/3316995

 

but in this solution i need to provide in this following line the title:
WshShell.AppActivate "Title of the SAP Window"

 

but the title is  which is dynamic  because every order has different title

 

Any solution for this ?

 

Thanks

 

Mark

Add Table Row with PHP

$
0
0

How do I add data to a table using SAPFRC ? I searched a lot but could not find results.Please help.

 

Thanks


C# Iterating Controls in the GuiUserArea

$
0
0

I am in the process of building an application in C# winforms.

If we think along the lines of meta data, I am trying to capture as much information about the user's open sessions as I can.


I have got as far as obtaining all the session info that I require.


Now I am curious as to how much information about the visible on-screen data I can capture.
My instinctive thought was to iterate the controls and seeing if I could capture text boxes and labels.

However, I am struggling.

Looking at documentation, I see there are various 'FindBy' functions, but all of these appear to be designed to be useful only if you know the names of individual controls already.


Does anyone know how I can walk/iterate through all the controls in the user area, and capture their name/value ?


Many Thanks for any tips !

:)




Code so far ....



class sap_helper


{

    

public  static Dictionary<string, SapInfoItem> get_sapInfo()

    

{

        

Dictionary<string, SapInfoItem> sapInfo = new Dictionary<string, SapInfoItem>();

        

GuiApplication sapGuiApp;


        

SapROTWr.CSapROTWrapper sapROTWrapper = new SapROTWr.CSapROTWrapper();

        

object SapGuilRot = sapROTWrapper.GetROTEntry("SAPGUI");


        

object engine = SapGuilRot.GetType().InvokeMember("GetSCriptingEngine", System.Reflection.BindingFlags.InvokeMethod,

            

null, SapGuilRot, null);


        

sapGuiApp = engine as GuiApplication;


        

int i = sapGuiApp.Children.Count;


        

if (sapGuiApp.Connections.Length > 0)

        

{

            

GuiConnection connection = sapGuiApp.Connections.ElementAt(0) as GuiConnection;


           

foreach (GuiSession child_session in connection.Children)

            

{

                

GuiSession session = child_session as GuiSession;   //connection.Children.ElementAt(0) as GuiSession;


// populate user defined structure

                

SapInfoItem sii = new SapInfoItem();  

                

sii.system_name = session.Info.SystemName;

                

sii.client = session.Info.Client;

                

sii.program = session.Info.Program;

                

sii.screen_number = session.Info.ScreenNumber;

                

sii.handle = session.ActiveWindow.Handle;

                

sii.transaction = session.Info.Transaction;

                 // add structure to dictionary collection

                

sapInfo.Add(sii.handle.ToString("X"), sii);

            

}

        

connection = null;

        

}

        

sapGuiApp = null;

        

SapGuilRot = null;

        

sapROTWrapper = null;


    

return sapInfo;

    

}

   

 


}


Scripting via Citrix Client ?!

$
0
0

Hi there-


next year we get SAP 7.3-and Windows 7 yehaw-

The only problem i have is that its running via a Citrix Server-so there is no direkt Connection possible-

neither a "Drag n Drop" is possible.


via Google i found an "older" thread in this Forum... but it didnt work for me-

 

I can "play" the Scripts if i start them via the "Script Tool" form the Citrix Frame.

 

but i have build me some Access / Excel Tools in which i have a lot of Functions and Sub's what make my life easier.

 

So if there is any way to get a Connection via VBA () i would apreciate any help or suggestions...

Sap script vba excel compare field

$
0
0

Hello,

 

I am new and doesn't know much about scripting.

But can anyone help me with a script that i can use to compare a field from sap and excel.

And if both fields are the same it must enter some data at sap

 

Example.

 

Excel

00069114_P 

 

SAP (MM02 MRP 1 and button MRP AREA)

00069114_P

 

 

0069114_P the same value

 

then it must select the field at sap.

 

 

Sorry for mine bad english.

 

Greetings Raoul

SAP Gui Script to copy text values to clipboard needed

$
0
0

Hi All -

 

New to SAP and never created a SAP GUI script before so this may be easy for some.  I have a custom page in SAP that has 20 text fields on it.  I need to be able to grab the value in any of the 20 fields and place the values into the clipboard.  There are 20 fields but not all will have values.

 

There will always be a value in the first field:

 

session.findById("wnd[0]/usr/txtZF1").text

 

but there may or may not be a value in any of the other 19

 

session.findById("wnd[0]/usr/txtZF2").text

. . .

session.findById("wnd[0]/usr/txtZF20").text

 

The values can be up to 10 characters each and when placed into the clipboard, I need the values with a CR+LF following each so that when pasted they show up as

 

VALUE1
VALUE2
VALUE3

etc...

 

Can anyone create this script for me?

 

Thanks,

 

MDR

Looping for order creation macro

$
0
0

Hello All,

 

I am working on creating macro where i need to enter material numbers, qties, date, etc., This is the script i got in recording.

 

[CODE]

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON").press session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,0]").text = "Material 1" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,1]").text = "Material 2" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,2]").text = "Material 3" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,3]").text = "Material 4" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,0]").text = "50 " session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,1]").text = "48 " session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,2]").text = "4" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,3]").text = "2 "

[/CODE]

 

Could anyone help me on how to give looping to pick the details from excel and update it as line items in order.

 

Materials need to updated are dynamic.

 

[Code]

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,0]").text = "Material 1"

 

etc....

[/Code]

 

thank you.

Export attachments from SAP

$
0
0

Hi Team,

 

Happy Christmas to All.

 

I want to automatically download the attachment from SAP which are uploaded through T-code FB03.

I have recorded below script for downloading the attachments but save as doalog box is not getting recorded.

 

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]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "/nfb03"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/txtRF05L-GJAHR").setFocus

session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"

 

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%ATTA_EXPORT"

session.findById("wnd[1]/tbar[0]/btn[0]").press

 

 

Could somone help me to get the script for downloading attachments from SAP T-code Fb03.

 

Thanks for your support.

Import attachments

$
0
0

Hi Team,

 

Happy Christmas to All.

 

I want to automatically import/upload attachments in SAP through T-code FB03.

I have recorded below script for uploading the attachments.

 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "/nfb03"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "100111498"

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "3220"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2015"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").setFocus

session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"

 

After this script line, i get the popup box which i have attached in JPG format for your reference.

 

Could any of you help me to get the complete script which will enable me to download 1 by 1 attachments on the basis of the information pulled from the excel through below script line

 

session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "100111498"

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "3220"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2015"

 

Thanks for your support and will be waiting for better solution on this.


FB03 Exporting of attachment

$
0
0

Hi guys!

 

I am currently developing a macro tool wherein I can export the attachment of a document using FB03 and saving it in a specific folder.

I was able to create one but I have the following problem:

> I don't know why there is an error with the path of the file whenever I try to link specific paths to a cell from my excel. But when I input the path directly to the VBA, it works. (hope this question was clear. )

> I am a VBA beginner so I would like to loop this macro and I want it to perform the export for a list of documents and not just one.

> Is it possible for me to insert the exported file into the excel sheet next to the document number?

 

Hope I was clear with what intend to do...Please help.

 

THANK YOU SO MUCH!!

 

 

Below are the details that I have in my Excel sheet

 

ABC
1Destination FileC:\Users\LIX2628\Desktop\PUll outs export\
2 Document NumberCo. CodeYear
1200072996u0012014

 

 

And below is the script that I used.

 

Sub FB03export()

 

 

Dim application

 

 

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 196, 15, False

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb03"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = Cells(3, 2).Value

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = Cells(3, 3).Value

session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = Cells(3, 4).Value

session.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus

session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%BDS_START_BDN"

session.findById("wnd[0]/shellcont[1]/shell").selectedNode = "Doc-00000001"

session.findById("wnd[0]/mbar/menu[0]/menu[6]").Select

session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").Text = "C:\Users\LIX2628\Desktop\PUll outs export\"

session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").caretPosition = 42

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[0]/tbar[0]/btn[3]").press

session.findById("wnd[1]/tbar[0]/btn[12]").press

session.findById("wnd[0]/tbar[0]/btn[3]").press

 

 

End Sub

Loop does not work on VBA Script

$
0
0

Hi Guys,

 

I'm having troubles when I try to execute the script below. The first input works fine, but the loop does not.

 

Somebody has a clue what is wrong on the code listed below?

 

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

Dim ApplicationPath, CredentialsPath, ServerPath, FilePath
Dim ExcelApp, ExcelWorkbook, ExcelSheet, Row
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open("C:\temp\Excel_File.xls")
Set ExcelSheet = ExcelWorkbook.Worksheets(1)

Row = 1

Do Until ExcelSheet.Cells(Row,1).Value = ""

session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "mysaplogin"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "*******"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "fd32"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkRF02L-D0210").selected = true
session.findById("wnd[0]/usr/ctxtRF02L-KUNNR").text = ExcelSheet.Cells(Row,1).Value
session.findById("wnd[0]/usr/ctxtRF02L-KKBER").text = ExcelSheet.Cells(Row,2).Value
session.findById("wnd[0]/usr/ctxtRF02L-KKBER").setFocus
session.findById("wnd[0]/usr/ctxtRF02L-KKBER").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/mbar/menu[0]/menu[5]/menu[1]").select
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0

 

Row=Row+1
Loop
ExcelApp.Quit
Set ExcelApp = Nothing
Set ExcelWorkbook = Nothing
Set ExcelSheet = Nothing

SAP SCRIPTING AND PLAYBACK

$
0
0

I HAVE AN QUESTION HOW WE CAN AUTOMATE TO RUN ONE T-CODE WITH MULTIPLE VARIANTS ONE EACH AND EXPORT IT INTO SEPARATE EXCEL FILE.(ALL VARIANT SHOULD BE RUN PARALLELY, MAX:6)

Create script for get current year

$
0
0

Good day!

I need a help please .

 

How do i get the current year, keep in a variable and then write in a text field ?

 

Thanks!

List/Export/Spreadsheet on Script Recording Not saving file name

$
0
0

Hi everyone.

I need help .

I'm trying to run a complet list from SAP automatically.

But I'm stuck in the option

List/Export/Spreadsheet.

 

I need the code for write in the windows popup Save As (from VBS script)

I'm trying save like .MHTML because my other file was created with this type of file.

I'm running the Script Recording option, but is not recording the name placed .Name not saved.jpg

Viewing all 376 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>