Skip to Content
0

How to store translation statistics numbers to vbs variable values?

Apr 26, 2017 at 08:33 AM

57

avatar image

Hello,

Is there an alternative to getting translation statistics data in transaction SLLS in a translation system, i.e. the alternatove to this process: Translation System -> Transaction SLLS -> Set Parameters -> Display Statistisc

The result is to get the number of lines to be translated. This approach is not good for vbs scripts as the displayed number of lines are not fileds which can be set as variable valuses in vbs.

I've tried transaction SE16 and the table SLLS_STATS_ATTR but I keep getting the message that there are no entries for the given key.

I've entered the source and target language, the translation area and the worklist number.

The table SLLS_STATSDATA gives me the info, but it's for all records. So again I would have to download and preprocess before I could use the summary numbers only.

Is there a possibility to get the total number of lines by new/modified/available in the vbs as value?

Thank you.

Regards,

Sebastjan

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Stefan Schnell
Apr 28, 2017 at 06:38 AM
1

Hello Sebastjan,

there are solutions to solve your problem. Here is a solution with PowerShell, because I don't use VBScript anymore, it is deprecated. I advice you to use PowerShell as well instead VBScript. In my case I use the RFC-enabled function module RFC_READ_TABLE with .NET Connector NCo. I call the function module with the table SFLIGHT and the column SEATSMAX to sum it up. The data is a string, so it is necessary to convert it to CSV via ConvertFrom-CSV first to use Measure-Object method. So it is very easy to get the sum of a column, average, minimum or maximum.

#-Begin-----------------------------------------------------------------

  #-Sub Load-NCo--------------------------------------------------------
    Function Load-NCo {

      $ScriptDir = $PSScriptRoot

      If ([Environment]::Is64BitProcess) {
        $Path = $ScriptDir + "\x64\"
      }
      Else {
        $Path = $ScriptDir + "\x86\"
      }

      [Reflection.Assembly]::LoadFile($Path + "sapnco.dll") > $Null
      [Reflection.Assembly]::LoadFile($Path + "sapnco_utils.dll") > $Null

    }

  #-Function Get-Destination--------------------------------------------
    Function Get-Destination {

      #-Connection parameters-------------------------------------------
        $cfgParams = New-Object SAP.Middleware.Connector.RfcConfigParameters
        $cfgParams.Add("NAME", "TEST")
        $cfgParams.Add("ASHOST", "NSP")
        $cfgParams.Add("SYSNR", "00")
        $cfgParams.Add("CLIENT", "001")
        $cfgParams.Add("USER", "BCUSER")

        $SecPasswd = Read-Host -Prompt "Passwort" -AsSecureString
        $ptrPasswd = [Runtime.InteropServices.Marshal]::SecureStringToBStr($SecPasswd)
        $Passwd = [Runtime.InteropServices.Marshal]::PtrToStringBStr($ptrPasswd)
        $cfgParams.Add("PASSWD", $Passwd)

      Return [SAP.Middleware.Connector.RfcDestinationManager]::GetDestination($cfgParams)

    }
  
  #-Sub Read-Table------------------------------------------------------
    Function Read-Table () {

      $destination = Get-Destination

      #-Metadata--------------------------------------------------------
        [SAP.Middleware.Connector.IRfcFunction]$rfcFunction = 
          $destination.Repository.CreateFunction("RFC_READ_TABLE")

      #-Set import parameter--------------------------------------------
        $rfcFunction.SetValue("QUERY_TABLE", "SFLIGHT")
        $rfcFunction.SetValue("DELIMITER", ";")

        [SAP.Middleware.Connector.IRfcTable]$Fields = `
          $rfcFunction.GetTable("FIELDS")
        $Fields.Append()
        $Fields.SetValue(0, "SEATSMAX")

      #-Call function module--------------------------------------------
        Try {
          $rfcFunction.Invoke($destination)

          #-Get column names--------------------------------------------
            ForEach ($Row in $Fields) {
              $ColumnNames = $ColumnNames + $Row.GetValue("FIELDNAME") + ";"
            }
            $ColumnNames = $ColumnNames.Substring(0, $ColumnNames.Length - 1)
            $strCSV = $ColumnNames + "`r`n"

          [SAP.Middleware.Connector.IRfcTable]$Table = `
            $rfcFunction.GetTable("DATA")

          #-Get table data----------------------------------------------
            ForEach ($Row in $Table) {
              $strCSV = $strCSV + $Row.GetValue("WA").ToString().Trim() + "`r`n"
            }

          $CSV = ConvertFrom-Csv $strCSV -Delimiter ";"
          $CSV | Measure-Object "SEATSMAX" -Sum

        }
        Catch {
          Write-Host "Exception" $_.Exception.Message "occured"
        }

    }

  #-Sub Main------------------------------------------------------------
    Function Main () {
      If ($PSVersionTable.PSVersion.Major -ge 5) {
        Load-NCo
        Read-Table
      }
    }

  #-Main----------------------------------------------------------------
    Main

#-End-------------------------------------------------------------------

You can find more information to use NCo with PowerShell here.

Let us know your results.

Cheers
Stefan


sflight-sum.jpg (13.0 kB)
Share
10 |10000 characters needed characters left characters exceeded