Documente Academic
Documente Profesional
Documente Cultură
(intelligence)
In the previous document Script Recording & Playback for Dummies we learnt how to create a simple script in
order to execute steps automatically in SAP.
Now, lets introduce two new concepts to make this tool more powerful.
Lets suppose that you create a script to create documents in SAP. In this case you probably need to get the
document number generated by the system when Save button is pressed.
In this case, we need to add the following sentence:
For example, suppose that we create a script to create planner orders, where the information that we introduce
is:
Column1 = Order Type = LA
Column2 = Material
Column3 = MRP Area or Plant
Column4 = Quantity
Column5 = End Basic Date
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nmd11"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRM61P-PASCH").text = cOL1
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtPLAF-MATNR").text = cOL2
session.findById("wnd[0]/usr/ctxtPLAF-BERID").text = cOL3
session.findById("wnd[0]/usr/tabsTABTC/tabpTAB01/ssubINCLUDE1XX:SAPLM61O:0711/
subINCLUDE711_1:SAPLM61O:0802/txtPLAF-GSMNG").text = cOL4
session.findById("wnd[0]/usr/tabsTABTC/tabpTAB01/ssubINCLUDE1XX:SAPLM61O:0711/
subINCLUDE711_1:SAPLM61O:0802/ctxtPLAF-PEDTR").text = cOL5
session.findById("wnd[0]/usr/tabsTABTC/tabpTAB01/ssubINCLUDE1XX:SAPLM61O:0711/
subINCLUDE711_1:SAPLM61O:0802/ctxtPLAF-PEDTR").setFocus
session.findById("wnd[0]/usr/tabsTABTC/tabpTAB01/ssubINCLUDE1XX:SAPLM61O:0711/
subINCLUDE711_1:SAPLM61O:0802/ctxtPLAF-PEDTR").caretPosition = 8
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[11]").press
NEXT
Suppose that we need to execute some steps only if we achieve certain condition. In this case, we can add if
logic in the script.
For example, we can enter in one column an X to indicate that the condition was achieved. Then in the script
we have to add the IF and END IF:
As an example, here you can see a script that create new BINs in WM (LS01N) and execute the stock transfer
(LT10) from the old to the new BIN only if there was stock in the old BIN:
session.findById("wnd[0]/tbar[0]/okcd").text = "/NLS01N"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtLAGP-LGNUM").text = COL1
session.findById("wnd[0]/usr/ctxtLAGP-LGTYP").text = COL2
session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").text = COL3
session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").setFocus
session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").caretPosition = 6
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/ctxtLAGP-
LGBER").text = COL4
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/txtLAGP-
VERIF").text = COL5
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/ctxtLAGP-
KOBER").text = COL6
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/ctxtLAGP-
LPTYP").text = COL7
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/txtLAGP-
LGEWI").text = COL8
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/txtLAGP-
LKAPV").text = COL9
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/txtLAGP-
LKAPV").setFocus
session.findById("wnd[0]/usr/tabsFUNC_TABSTRIP/tabpALLG/ssubD0400_S:SAPML01S:4001/txtLAGP-
LKAPV").caretPosition = 8
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/usr/ctxtLAGP-LGTYP").text = COL2
session.findById("wnd[1]/usr/ctxtLAGP-LGPLA").text = COL3
session.findById("wnd[1]/usr/ctxtLTAK-BWLVS").text = "999"
session.findById("wnd[1]/usr/chkRL03T-SQUIT").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
END IF
session.findById("wnd[0]/tbar[0]/okcd").text = "/NLS02N"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtLAGP-LGNUM").text = COL1
session.findById("wnd[0]/usr/ctxtLAGP-LGTYP").text = COL11
session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").text = COL3
session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").caretPosition = 6
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[14]").press
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
NEXT