Unlock tables in SAP

My students have found really good way to solve problem when two or more consultants want to work with the same table in edit mode.

Author is unknown.

REPORT ZSENQOFF MESSAGE-ID MT.
CALL ‘C_ENQUEUE’ ID ‘OPCODE’ FIELD ‘F’.
CALL ‘C_WRITE_SYSLOG_ENTRY’ ID ‘TYP’ FIELD ‘C’
ID ‘KEY’ FIELD ‘GES’.
MESSAGE S900 WITH ‘Table locking turned off’.

***
REPORT ZSENQON MESSAGE-ID MT.
CALL ‘C_ENQUEUE’ ID ‘OPCODE’ FIELD ‘T’.
CALL ‘C_WRITE_SYSLOG_ENTRY’ ID ‘TYP’ FIELD ‘C’
ID ‘KEY’ FIELD ‘GER’.
MESSAGE S900 WITH ‘Table locking turned on’.

Don’t use in production system. Only for trainings!


Connect to external database

Once I needed to create a program to download data fro external database into my own. It happened to be very easily.

In DBACOCKPIT transaction create a new connection to a database.

And user it in ABAP like this:

EXEC SQL.
CONNECT TO ‘BSK’
ENDEXEC.
EXEC SQL.
SET CONNECTION ‘BSK’
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / ‘current database name’, DBN.
EXEC SQL.
SET CONNECTION DEFAULT
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / ‘current database name’, DBN.

It’s basic Native SQL ? ABAP. Some SAP notes for reference.

Note 178949 – MSSQL: Database MultiConnect
Note 323151 – Several DB connections with Native SQL


Customize HR Process Workbench (PUST)

Hi.

I hope most of you have heard about PUST transaction. This is convinient  tool to build payroll close process. It’s idea is a chain of steps build from programms that we use in payroll close procedure. We can set variants for each program, build them in a sequence and run all at once (or step by step autmatically). User all needs is to hit Run button and watch it. While it’s running it will show logs for each step/programm and user will understand possible issues with easy.

There is no need to explain all customizing in detail as it’s pretty simple. At first setup Workflow as some particular elements use it for notifications. To do this run though SAP Note 133182 – Process Manager: No process is started.  Program starts – event fires. Program stops – event fires. It allows to run several programms in parallel and use workflows for example to payroll agreements.

For a user it will look like.

pust_2

Read More


Hide Object Manager in PA30

There was a situation when the system was set to run across every personnel number through the whole system. With thousands of employees, it took to much time so system hung out. Why? The user has turned on Object Manager in PA30 to show all employees according to permissions. The system opens transactions, sees object manager and starts loading employees. And hangs out of memory. No way to open transaction as it opens object manager every time. Solution?

Disable Object manager or temporary hide it. In user parameters (transaction SU01, SU3) you can insert these params to hide or disable last search results.

OM_OBJM_NO_DISPLAY X
OM_OBJM_NO_LAST_SEAR X

It will reset current settings for the user.


SAP Scripting

Small instruction about SAP scripting.

Activate SAP Scripting in GUI settings (SAP Logon settings).

Open SAP and hit “Record macro” in GUI menu. Run all needed steps and stop recording.

As a result you’ll get file with script. For example I’ve a script of creating 0015 infotype record:

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 = “pa30”
session.findById(“wnd[0]”).sendVKey 0
session.findById(“wnd[0]/usr/subSUBSCR_PERNR:SAPMP50A:0110/ctxtRP50G-PERNR”).text = “609”
session.findById(“wnd[0]”).sendVKey 0
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-CHOIC”).text = “15”
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-SUBTY”).text = “0030”
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_TIME:SAPMP50A:0330/ctxtRP50G-BEGDA”).text = “100914”
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-SUBTY”).setFocus
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-SUBTY”).caretPosition = 4
session.findById(“wnd[0]/tbar[1]/btn[5]”).press
session.findById(“wnd[0]/usr/txtQ0015-BETRG”).text = “11”
session.findById(“wnd[0]/usr/txtQ0015-BETRG”).setFocus
session.findById(“wnd[0]/usr/txtQ0015-BETRG”).caretPosition = 18
session.findById(“wnd[0]”).sendVKey 11

Then you can put this script as VBA macro into MS Excel, handle it in a right manner (i.e. make a cycle) and automate you regular tasks or data upload/ mass change.

Important: scripting doesn’t understand system errors, system messages. eCATT and SAP Personas understand.