Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Asset does not exist

Max2
Discoverer
0 Kudos

Hi guys,

I would like to read out the activation data of an assest from transaction AS02 in Powershell, but unfortunately the scripts tells me that the asset does not exist, but when I use it in SAP GUI I find the asset.

 

 

 

[Reflection.Assembly]::LoadFile("C:\Windows\Microsoft.NET\assembly\GAC_64\sapnco\v4.0_3.1.0.42__50436dca5c7f7d23\sapnco.dll") > $Null
[Reflection.Assembly]::LoadFile("C:\Windows\Microsoft.NET\assembly\GAC_64\sapnco_utils\v4.0_3.1.0.42__50436dca5c7f7d23\sapnco_utils.dll") > $Null

Function Get-Destination {

      #-Connect paramters-----------------------------------------------
        
        $cfgParams = New-Object SAP.Middleware.Connector.RfcConfigParameters

        #---TEST---
        $cfgParams.Add("NAME", "SAP")
        $cfgParams.Add("ASHOST", "xx.xx.xxx.xx")

        $cfgParams.Add("SYSNR", "00")
        $cfgParams.Add("CLIENT", "100")

        $cfgParams.Add("USER", "user")
        $cfgParams.Add("PASSWD", "password")

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

    }

  #-Sub Invoke-SAPFunctionModule----------------------------------------
 $destination = Get-Destination

[SAP.Middleware.Connector.IRfcFunction]$bapiChangeAsset = $destination.Repository.CreateFunction("BAPI_FIXEDASSET_GETDETAIL")

$bapiChangeAsset.SetValue("COMPANYCODE", "0001")
$bapiChangeAsset.SetValue("ASSET", "31745")

$bapiChangeAsset.Invoke($destination)

[SAP.Middleware.Connector.IRfcStructure]$return = $bapiChangeAsset.GetStructure("RETURN")
           
Write-Host $return.GetValue("MESSAGE")    

 

 

5 REPLIES 5

raymond_giuseppi
Active Contributor
0 Kudos

You pass the asset in an external format. During SAP GUI session, it is implicitly converted to internal format, but not during background processing (without GUI)

  • The domain of asset number (ANLN1) carries the ALPHA conversion exit routine.
  • So you can convert (on SAP size) your external format to internal format using FM CONVERSION_EXIT_ALPHA_INPUT ('31745' -> '000000031745') - In your case for an external call, you should use BAPI_CONVERSION_EXT2INT1 (external to internal format convertor)

0 Kudos

Hey thanks for your help but online I can't find much about BAPI_CONVERSION_EXT2INT1 and on the support page also finds what helps me so I tried to delete the whole thing like this

 

$ItemAnlage = 31745
$ItemAnlage = "0000000" + $ItemAnlage

$destination = Get-Destination

[SAP.Middleware.Connector.IRfcFunction]$bapiChangeAsset = $destination.Repository.CreateFunction("BAPI_FIXEDASSET_GETDETAIL")

$bapiChangeAsset.SetValue("COMPANYCODE", "0001")
$bapiChangeAsset.SetValue("ASSET", $ItemAnlage)
$bapiChangeAsset.SetValue("SUBNUMBER", "0")

$bapiChangeAsset.Invoke($destination)

 

Unfortunately this did not work and now it tells me that the attachment 000000031745 does not exist

0 Kudos

Subnumber is a character field of length 4, try to replace "0" with "0000".

0 Kudos

Thanks, now it works

0 Kudos

 

Small sample in Abap for conversion BAPI external format to internal format

 

 

  MOVE 'BUS1022' TO CONVERSION_LS-OBJTYPE.
  MOVE 'GETDETAIL' TO CONVERSION_LS-METHOD.

  MOVE 'ASSET' TO CONVERSION_LS-PARAMETER.
  MOVE '1234' TO CONVERSION_LS-EXT_FORMAT.
  APPEND CONVERSION_LS TO CONVERSION_LT.

  MOVE 'SUBNUMBER' TO CONVERSION_LS-PARAMETER.
  MOVE '0' TO CONVERSION_LS-EXT_FORMAT.
  APPEND CONVERSION_LS TO CONVERSION_LT.

  CALL FUNCTION 'BAPI_CONVERSION_EXT2INT1'
    DESTINATION LV_BACKEND
    TABLES
      DATA   = CONVERSION_LT
      RETURN = RETURN.

    LOOP AT CONVERSION_LT INTO CONVERSION_LS.
      MOVE CONVERSION_LS-INT_FORMAT TO <INTVALUE>. " 000000001234 and 0000
      MOVE CONVERSION_LS-CONV_LEN TO <LENGTH>. " 012 et 004
    ENDLOOP.

 

You can find the requesed values in transaction BAPI

raymond_giuseppi_1-1709639752368.png

 

raymond_giuseppi_0-1709639747325.png