Application Development and Automation 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: 
Read only

Interesting itab(*) syntax in a custom program

mike_m1
Explorer
0 Likes
2,067

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

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
2,032

Maybe would know, let's see if he can be paged...


Thomas

11 REPLIES 11
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,032

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

Read only

0 Likes
2,032

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

Read only

0 Likes
2,032

Sorry, I did not look carefully enough, mistake [] for ()...

For this syntax I'm perplex too, seems to be allowed for structure, variable and internal tables, but not exactly (no redefinition of type) as var+0(*) or var+offset( *) if only character fields.

Regards,

Raymond

Read only

0 Likes
2,032

No worries Raymond.

I'd love to hear from anyone else who knows why this (*) syntax exists.

Mike

Read only

Former Member
0 Likes
2,032

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

Read only

0 Likes
2,032

Cheers Rob.

I appreciate your time.

Read only

0 Likes
2,032

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!

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
2,032

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

Read only

ThomasZloch
Active Contributor
0 Likes
2,033

Maybe would know, let's see if he can be paged...


Thomas

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
2,032

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

Read only

0 Likes
2,032

Thank you Horst. My curiosity is satisfied (for the moment, at least).

Mike