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

ABAP Statments

Former Member
0 Likes
1,224

Hello,

Can any body please let me know the below statments meanings. As I am new to ABAP so I am unable to understand the syntax.

1.

   acgl_item-shkzg      =   *acgl_item-shkzg.
  acgl_item
-hkont      *acgl_item-hkont.
  acgl_item
-konto_txt  =   *acgl_item-konto_txt.

In the above statements what is the use of '*' while assigning the values.

2.

  DATA: io_edidd type ref to DATA.

  o_edidd = io_edidd.

  FIELD-SYMBOLS: <lt_edidd> TYPE tab_edidd.

  ASSIGN o_edidd->* TO <lt_edidd>.

In the anove statement, what is the use of '*' .

Kindly guide me to understand the syntax.

Thanks in advance.

Shreya

10 REPLIES 10
Read only

former_member186413
Participant
0 Likes
1,169

1 * actually is the namespace for some purpose. Usually It is reservation for old value. 

2 * is used with '->*' for dereferencing pointer.

Read only

0 Likes
1,169

Hello Wang,

I am not clear with your answer, could you please elaborate your answer ?

1 * actually is the namespace for some purpose. Usually It is reservation for old value.

What is that purpose, it gets reserved ?

2. is used with '->*' for dereferencing pointer

You are speaking about derefrencing but in my case it has been refered to field symbol and been assigned the value to the field symbol.

Thanks,

Shreya

Read only

gouravkumar64
Active Contributor
0 Likes
1,169

Hi,

First case:-

1) AGCL_item is a structure here,

If you want to define the same table & work area twice in TABLES section, you define once normally and with an asterisk (*) for the second time.

second case:-

2)Its is using for performance improvement purpose.

*->* is like  pointer in C,so here it is for pass by reference.

Hope it is little clear.

If U got answer.close this thread by mark it as answered.

Thnaks

Gourav.

Read only

0 Likes
1,169

Hello Gourav,

I am unclear with your answer for the 1st one.

Here the structure AGCL_item has not been defined twice, rather the values have been reassigned to the same structure. But my question is even if we were not be using the '*' while assigning the same result could have been achieved. I might be wrong. If you can guide me it will be better for me to understand the logic behind this.

Thanks,

Shreya

Read only

0 Likes
1,169

The answer for your first question is very clear from Gourav. If you have experienced any programming language, you can't have both variable with same name within one program, therefore there are namespace schematic via different type of program language. ABAP simply can use '*" to differentiate. 

It is good programming habit, try to bring a good external document. Actually it is up to you to re-name another variable which might have same meaning with the variable within the program.

Read only

0 Likes
1,169

The answer for your first question is very clear from Gourav. If you have experienced any programming language, you can't have both variable with same name within one program, therefore there are namespace schematic via different type of program language. ABAP simply can use '*" to differentiate. 

It is good programming habit, try to bring a good external document. Actually it is up to you to re-name another variable which might have same meaning with the variable within the program.

Read only

0 Likes
1,169

I love Gourav's answer, his answer is quite good.

Read only

0 Likes
1,169

Hi Shreya,

Some points regarding to query.

Now SAP is R/3 u know,

Actually it is a hangover from SAP R/2,

when multiple work areas for a table and 'SELECT INTO TABLE' were unavailable and should not be used.

Instead you should use SELECT INTO TABLE,  or 'LOOP AT Internal table into Work Area'.

the * just creates a workarea under that name for the same table, so that you can select <columns> from makt into *makt if you are picking up one line.

Like MIRROR TABLE.

Example:- (rough code)

*makt IS THE MIRROR TABLE FOR THE SAP TABLE makt. It is the location / container for the unchanged values after a selection from a table.

In a module pool screen if you change a screen value, you can see in debugging mode the original and changed values in these 2 containers.

select * into iknvp

          from knvp

          where kunn2 eq inhdr-saprmnumber

            and vkorg eq inhdr-salesorg .

* Pickup first sold-to party for this ship to party

          select single kunnr into iknvp-kunnr

from *knvp

              where kunnr eq iknvp-kunnr

              and vkorg eq iknvp-vkorg.

          if sy-subrc = 0.

            move iknvp-kunnr to inhdr-saptknumber.

endif.

so,

If you have a specific requirement of selecting from the same table twice, the mirror table comes into play.

hope it is clear now.

Thanks

Gourav.

Read only

Former Member
0 Likes
1,169

Hi,

I have found a link (with answered mark).

http://scn.sap.com/thread/1266455

hope it helps.

Avirat

Read only

Former Member
0 Likes
1,169

Thank you very much @ Hai,Gaourav and Virat. It's quite clear now.

Regards,

Sherya