2014 Mar 13 10:39 AM
Hi fellow ABAP developers!
I have just spotted a bit of ABAP in a bespoke report program that has me flumoxed.
This is it (with some anonymization);
*----------------------------------------------------------------------------------------------------
TYPES: tt_chg_ptrs_in TYPE STANDARD TABLE OF bdcp,
tt_ztable TYPE SORTED TABLE OF ztable WITH UNIQUE KEY matnr.
DATA: l_it_chg_ptrs_in TYPE tt_chg_ptrs_in,
l_it_ztable TYPE tt_ztable.
IF l_it_chg_ptrs_in(*) IS NOT INITIAL
OR l_it_ztable[] IS NOT INITIAL.
.
.
ENDIF.
*----------------------------------------------------------------------------------------------------
The (*) appendage appears to behave in the same way as the [] variant when refering to the complete set of itab entries. I checked this out in debug just to be certain that the l_it_chg_ptrs_in(*) reference returned the same data as l_it_chg_ptrs_in[].
Is this a new (or old) lanuage element?
Who can shed some light on this for me?
Cheers all,
Mike
2014 Mar 13 3:18 PM
2014 Mar 13 10:51 AM
Welcome to 7.40, this syntax is explained in table_exp - Table Expressions. (can be found from changes in Release 7.40 in ABAP - Release-Specific Changes.)
Regards,
Raymond
2014 Mar 13 11:25 AM
Thanks for the speedy reply Raymond,
This client is currently on 620.
Sadly, I couldn't see a reference to the itab(*) syntax in the table_exp - Table Expressions keyword documentation. 😞
Could you be more specific please? Where in this document would I find the explanation you alluded to?
Regards,
Mike
2014 Mar 13 1:32 PM
2014 Mar 13 1:46 PM
No worries Raymond.
I'd love to hear from anyone else who knows why this (*) syntax exists.
Mike
2014 Mar 13 2:56 PM
Weird,
I just checked what this syntax does in de debugger, but it seems to be exactly the same as without (*)
I'm guessing this is used in other programming languages and the abap compiler just doesn't mind.
Kind regards, Rob Dielemans
2014 Mar 13 2:58 PM
2014 Mar 13 3:14 PM
Hey Mike,
Try the coffee corner to speculate on why would SAP allow this syntax?
There are a couple of others, you can use >< instead of <> for instance.
Cheers!
2014 Mar 14 7:49 AM
you can use >< instead of <> for instance
But only outside classes
http://help.sap.com/abapdocu_740/en/index.htm?file=abenobsolete_logexp_op.htm
2014 Mar 13 3:18 PM
2014 Mar 13 5:31 PM
Well, well, a full text search for (*) in the ABAP documentation leads us to substring access.
If off is smaller than the length of dobj, an asterisk (*) can be
specified for len. The upper limit of dobj then determines the upper limit of the memory area. And guess what, you can also write struct+0(*) or itab+0(*).
With other words, an Offset-/Length addition +0(*), +0, or (*) that denotes the full field seems to be simply ignored by the compiler. And that's why you can add it even to fields where a substring access is normally forbidden - an itab+1(*) gives a syntax error..
Cheers!
Horst
2014 Mar 14 8:53 AM
Thank you Horst. My curiosity is satisfied (for the moment, at least).
Mike