Chapter 3
Chapter 3.1 - Use functions of the SAP BAPI's
With the transaction BAPI in your SAP system, the world of all BAPIs released for RFC and their functions opens up with the BAPI Explorer. In order to receive all information about an object such as a WBS element, information from other tables is required in addition to information from the leading table PRPS. The simplest method for this is to use a suitable BAPI or its functionalities.
To use the functions of a BAPI, open the desired BAPI with the Function Builder, which can be found in the BAPI Explorer on the Tools tab.
Chapter 3.2 - Determine the status of WBS elements
For our PRPS file, we need additional information about the status of the WBS elements. Externally, the status is displayed for the user in the language selected in the logon. The SAP Bapi's only use the English language version. Internally, the status is managed as a key in the JEST table. The respective text version can be found in tables TJ02 for the system status and TJ30 for the user status.
Functionalty
The BAPI BAPI_BUS2054_GET_STATUS can be used to read the active system status and user status for a list of WBS elements (BAPI_WBS_ELEMENTS). Active system statuses are output via the English-language key. Active user statuses are output via the key in the relevant logon language if there is a translation of the status in the underlying status profile into the logon language or the maintenance language of the status profile corresponds to the logon language. If the status in the status profile does not exist in the logon language, the key is output in the maintenance language of the status profile.Notes
The return parameter RETURN contains an error message if an error has occurred during processing. After the call, the messages generated during processing are in the BAPI_STATUS_RESULT table.
Further information
You can find more information in the SAP library under Project System -> Structures -> Interfaces of the Project System -> PS-EPS Interface to External Project Management Systems.
With the WBS elements we work with the following status.
'REL' (FREI) release (I0002)
set
'LKD' (SPER) locked (I0043)
set / reset
'TECO' (TABG) technically complete (I0045)
set / reset
'CLSD' (ABGS) closed (I0046)
set / reset
'AALK' (KTSP) account blocked (I0064)
set / reset
'MDLK' (SDSP) master data locked (I0065)
set / reset
'DLFL' (LÖVM) deletion flag (I0076)
set / reset
Determining the status via the associated SAP tables JEST and TJ02 for the system status or JEST and TJ30 for the user status is somewhat complex. It is more elegant and faster with the associated BAPI BAPI_BUS2054_GET_STATUS or the use of the included functions that we can view with the Function Builder.
I'll show you how to do it now:
We use the function module BAPI_BUS2054_GET_STATUS to get the status of a WBS-Element conveniently.
In our Access file we create the module SAP_RFC_Status with the following routines:
Option Compare Database
Option Explicit
' *********************************************************************************
' Declarations
' *********************************************************************************
Public Const acStatusBack As Boolean = False
Public Const acStatusForward As Boolean = True
Dim IMessage As Object
Dim IEResult As Object
Dim IRETURN As Object
Dim oBAPI_TRANSACTION_ROLLBACK As Object
Dim oBAPI_TRANSACTION_ROLLBACK_RETURN As Object
Dim PI_WBS_SYSTEM_STATUS As Object
Public oBAPI_BUS2054_SET_STATUS As Object
Private oBAPI_BUS2054_GET_STATUS As Object
Public oCOMMIT_WORK_WAIT As Object
Dim oI_WBS_ELEMENTS As Object
Dim oE_USER_STATUS As Object
Dim oE_SYSTEM_STATUS As Object
Public Sub WBS_BAPI_BUS2054_GETDATA_STATUS_SHORT(remaining As Boolean)
' *********************************************************************************
' RFC_Read_Table Download with extensive selection options
' *********************************************************************************
Dim DB As Database
Dim RC As Object
Dim GetDatei As String, StKrit As String, StKritA As String, HWBS As String
Dim RST As Object, RSTA As Recordset
Dim intx As Integer
Dim MDate As Date, Mtime As Date
Dim ANZ_R2 As Long
'**************Export*****************************
Dim oI_MAX_ROWS As Object
'**************Tables*****************************
Dim I, J, J2, m, ANZ_R, Anz_C As Long
On Error GoTo Error
'******** RFC LOGON ****************
If Not sapConnection Is Nothing Then
If sapConnection.IsConnected <> 1 Then
If RFC_Connect() = False Then Exit Sub
End If
Else
If RFC_Connect() = False Then Exit Sub
End If
'******** RFC LOGON END ************
Call RemoveFC(FunctionCtrl, "BAPI_BUS2054_GETDATA")
Call RemoveFC(FunctionCtrl, "oBAPI_BUS2054_GET_STATUS")
If Not oBAPI_BUS2054_GET_STATUS Is Nothing Then Set oBAPI_BUS2054_GET_STATUS = Nothing
If Not oE_USER_STATUS Is Nothing Then Set oE_USER_STATUS = Nothing
If Not oE_SYSTEM_STATUS Is Nothing Then Set oE_SYSTEM_STATUS = Nothing
If Not oI_WBS_ELEMENTS Is Nothing Then Set oI_WBS_ELEMENTS = Nothing
If Not oE_USER_STATUS Is Nothing Then Set oE_USER_STATUS = Nothing
If Not oE_SYSTEM_STATUS Is Nothing Then Set oE_SYSTEM_STATUS = Nothing
Set DB = CurrentDb()
Set oBAPI_BUS2054_GET_STATUS = FunctionCtrl.Add("BAPI_BUS2054_GET_STATUS")
ANZ_R2 = oBAPI_BUS2054_GET_STATUS.Tables("I_WBS_ELEMENTS").Rows.Count
If ANZ_R2 > 0 Then
oBAPI_BUS2054_GET_STATUS.Tables("I_WBS_ELEMENTS").Rows.Remove
oBAPI_BUS2054_GET_STATUS.Tables("I_WBS_ELEMENTS").FREETABLE
End If
If oBAPI_BUS2054_GET_STATUS.Tables("E_USER_STATUS").Rows.Count > 0 Then
oBAPI_BUS2054_GET_STATUS.Tables("E_USER_STATUS").Rows.Remove
oBAPI_BUS2054_GET_STATUS.Tables("E_USER_STATUS").FREETABLE
End If
If oBAPI_BUS2054_GET_STATUS.Tables("E_SYSTEM_STATUS").Rows.Count > 0 Then
oBAPI_BUS2054_GET_STATUS.Tables("E_SYSTEM_STATUS").Rows.Remove
oBAPI_BUS2054_GET_STATUS.Tables("E_SYSTEM_STATUS").FREETABLE
End If
Set oI_WBS_ELEMENTS = oBAPI_BUS2054_GET_STATUS.Tables("I_WBS_ELEMENTS")
Set oE_USER_STATUS = oBAPI_BUS2054_GET_STATUS.Tables("E_USER_STATUS")
Set oE_SYSTEM_STATUS = oBAPI_BUS2054_GET_STATUS.Tables("E_SYSTEM_STATUS")
ANZ_R2 = oI_WBS_ELEMENTS.RowCount
Application.SetOption "Confirm Action Queries", False
DoCmd.RunSQL "UPDATE PRPS SET PRPS.[SyStat] = '' , PRPS.[USRStat] = '' ;"
'**************************************************************
' Load all WBS
'**************************************************************
If remaining Then
StKrit = "SELECT PRPS.* " & " FROM PRPS"
Else
StKrit = "SELECT PRPS.* " & " FROM PRPS WHERE SYSTAT = ''"
End If
m = 0
Set RST = DB.OpenRecordset(StKrit)
RST.MoveFirst
While Not RST.EOF()
If Not IsNull(RST!POSID) Then
m = m + 1
oI_WBS_ELEMENTS.Rows.Add
oI_WBS_ELEMENTS(m, "WBS_ELEMENT") = RST!POSID
End If
RST.MoveNext
Wend
ANZ_R = oI_WBS_ELEMENTS.RowCount
RST.Close
oBAPI_BUS2054_GET_STATUS.Call
m = 0
ANZ_R = oE_SYSTEM_STATUS.RowCount
'**************************************************************
For J = 1 To ANZ_R
HWBS = oE_SYSTEM_STATUS.Value(J, "WBS_ELEMENT")
StKrit = "SELECT PRPS.* " & " FROM PRPS WHERE POSID = '" & HWBS & "'"
Set RST = DB.OpenRecordset(StKrit)
While Not RST.EOF()
RST.Edit
m = m + 1
RST!SYSTAT = RST!SYSTAT & " " & oE_SYSTEM_STATUS.Value(J, "SYSTEM_STATUS")
If oE_SYSTEM_STATUS.Value(J, "SYSTEM_STATUS") = "CLSD" Or _
oE_SYSTEM_STATUS.Value(J, "SYSTEM_STATUS") = "DLFL" Then
RST!FLCLSD = True
Else
End If
RST.Update
RST.MoveNext
Wend
RST.Close
Next J
' *********************************************************************************
ANZ_R = oE_USER_STATUS.RowCount
For J = 1 To ANZ_R
HWBS = oE_USER_STATUS.Value(J, "WBS_ELEMENT")
StKrit = "SELECT PRPS.* " & " FROM PRPS WHERE POSID = '" & HWBS & "'"
Set RST = DB.OpenRecordset(StKrit)
While Not RST.EOF()
RST.Edit
m = m + 1
RST!USRStat = RST!USRStat & " " & oE_USER_STATUS.Value(J, "USER_STATUS")
RST.Update
RST.MoveNext
Wend
RST.Close
Next J
' *********************************************************************************
Exit_HoleDaten:
If Not RST Is Nothing Then Set RST = Nothing
If Not RSTA Is Nothing Then Set RSTA = Nothing
If Not DB Is Nothing Then Set DB = Nothing
ResetStatusTables
If Not oI_WBS_ELEMENTS Is Nothing Then Set oI_WBS_ELEMENTS = Nothing
If Not oE_USER_STATUS Is...