cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Transaction Name

Former Member
0 Kudos

Hi all,

Let say the script

session.Info().Transaction <- this gives you the transaction code. How about name?

Eg. SU3 - Maintain User Own Data

Possible? I search through the API could not find any.

Cheers

Sato

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Eric,

as far as I know is the text of the transaction not part of the SAP GUI and I don't know also a method to get them.

Here is another way to get the text direct from the table TSTCT of the transaction, inside an SAP GUI Script:


'-Begin-----------------------------------------------------------------

  '-Directives----------------------------------------------------------
    Option Explicit

  '-Constants-----------------------------------------------------------
    Const RFC_OK = 0

  '-Function GetTACText-------------------------------------------------
    Function GetTACText(TAC, Language)

      '-Variables-------------------------------------------------------
        Dim SAP, hRFC, rc, hFuncDesc, hFunc, hTable, RowCount, i, Row
        Dim hRow, charBuffer, charField

      Set SAP = CreateObject("COMNWRFC")
      If IsObject(SAP) Then
        hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _
          "CLIENT=001, USER=BCUSER")
        If hRFC Then
          hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "RFC_READ_TABLE")
          If hFuncDesc Then
            hFunc = SAP.RfcCreateFunction(hFuncDesc)
            If hFunc Then
              rc = SAP.RfcSetChars(hFunc, "QUERY_TABLE", "TSTCT")
              rc = SAP.RfcSetChars(hFunc, "DELIMITER", "~")
              If SAP.RfcGetTable(hFunc, "OPTIONS", hTable) = RFC_OK Then
                hRow = SAP.RfcAppendNewRow(hTable)
                rc = SAP.RfcSetChars(hRow, "TEXT", _
                  "TCODE = '" & TAC & "' AND SPRSL = '" & Language & "'")
              End If
              If SAP.RfcInvoke(hRFC, hFunc) = RFC_OK Then
                If SAP.RfcGetTable(hFunc, "DATA", hTable) = RFC_OK Then
                  rc = SAP.RfcGetRowCount(hTable, RowCount)
                  rc = SAP.RfcMoveToFirstRow(hTable)
                  For i = 1 To RowCount
                    Row = SAP.RfcGetCurrentRow(hTable)
                    rc = SAP.RfcGetChars(Row, "WA", charBuffer, 512)
                    charField = Split(charBuffer, "~")
                    GetTACText = charField(2)
                  Next
                End If
              End If
            rc = SAP.RfcDestroyFunction(hFunc)
            End If
          End If
          rc = SAP.RfcCloseConnection(hRFC)
        End If
        Set SAP = Nothing
      End If
    End Function

  '-Main----------------------------------------------------------------
    MsgBox "TACText for SU03 = " & GetTACText("SU03", "E")

'-End-------------------------------------------------------------------

The example shows how to get the transaction text from SU03 in English language.

I use CCo to get an access to the table.

Cheers

Stefan

Former Member
0 Kudos

Thank Stefan. You got it right.

Cheers

Answers (0)