PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 9, 2022

[FIXED] What is # symbol in ABAP?

 July 09, 2022     abap, reference, type-conversion     No comments   

Issue

I found a piece of code like in the picture, in this case I know more or less what it causes, but generally I don't know the #( ) syntax. What is the #( ) syntax and where can I find more about it?

DATA: lv_str TYPE string VALUE 'ABCD'. 
DATA: dref1 TYPE REF TO data. 
DATA: dref2 TYPE REF TO data. 


* Old Syntax 
GET REFERENCE OF LV_STR INTO dref1. 
* New Syntax 
dref2 = REF #( LV_STR ). 
BREAK-POINT.

Solution

The # is a placeholder for the type of the variable. You could write line 11 as this as well:

dref2 = REF data( lv_str ).

That would do the same thing. The # automatically takes the type of the variable on the left, if you don't specify it.

I've not seen it with TYPE REF TO before this, but it's fairly common as VALUE #( )

I haven't found any documentation on the REF #( ) version but here is the official SAP documentation for VALUE #( ), it explains what the # does too.



Answered By - Herr Berthm
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing