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

Field name Vs. Data element.

vicky31
Explorer
0 Likes
8,387

When we are creating a structure using TYPES then we use the field name after the TYPE keyword(ERDAT, ERNAM, etc.). But sometimes we use data elements after the TYPE keyword(VBELN_VA). Now I'm really confused when to use which one.

TYPES: BEGIN OF ty_order,
         VBELN TYPE VBELN_VA,
         ERDAT TYPE ERDAT,
         ERNAM TYPE ERNAM,
         MATNR TYPE MATNR,
         POSNR TYPE POSNR,
         KWMENG TYPE KWMENG,
         NETWR TYPE NETWR,
      END OF ty_order.
8 REPLIES 8
Read only

maheshpalavalli
Active Contributor
6,067

You are not actually giving field name after type, you actually are giving data element name itself there.

Double click on all the names(data elements) that are after type and it will navigate you to the respective data elements.

the field name and data element name can be same in the typea definition and it will not cause any issue.

Regards,

Mahesh

Read only

0 Likes
6,067

Thank you.

Read only

Sandra_Rossi
Active Contributor
0 Likes
6,067

Do it as you wish. Don't you have already an opinion which one you prefer and why?

Personally, I like to use the table and column name, I find it more clear because people are used to work with table columns, not data elements, you don't lose time to determine the data element (if any), etc.

Read only

Sandra_Rossi
Active Contributor
0 Likes
6,067

I realize that maybe you don't say what I thought you were saying 🙂

Are you talking about this other alternative?

TYPES: BEGIN OF ty_order,
         VBELN  TYPE VBAP-VBELN,
         ERDAT  TYPE VBAP-ERDAT,
         ERNAM  TYPE VBAP-ERNAM,
         MATNR  TYPE VBAP-MATNR,
         POSNR  TYPE VBAP-POSNR,
         KWMENG TYPE VBAP-KWMENG,
         NETWR  TYPE VBAP-NETWR,
      END OF ty_order.

Or are you confused about VBELN_VA?

TYPES: BEGIN OF ty_order,
         VBELN TYPE VBELN_VA, " <==== why is it VBELN_VA and not VBELN?
         ERDAT TYPE ERDAT,
         ERNAM TYPE ERNAM,
         MATNR TYPE MATNR,
         POSNR TYPE POSNR,
         KWMENG TYPE KWMENG,
         NETWR TYPE NETWR,
      END OF ty_order.

NB: since ABAP 7.40, you may use inline declarations which reduce a lot this kind of declarations (like SELECT ... INTO TABLE @DATA( itab ) ...). Also, these lines may be automatically generated by using ADT (based on inline declaration of SELECT). But it's not always possible, manual typing is still needed.

Read only

vicky31
Explorer
0 Likes
6,067

Second one.

Why is it VBELN_VA and not VBELN?

Read only

Sandra_Rossi
Active Contributor
6,067

You can see that both data elements have the same attributes, so there's no difference for ABAP. Choose the one you want.

Read only

matt
Active Contributor
6,067

The reason this happens is because different teams work on different parts of SAP and don't always re-use. Maybe the text is different, maybe the package the element is in.

Read only

bhavya_bhat
Explorer
0 Likes
6,067

You can use either VBELN_VA or VBELN after 'TYPE' since both refers to the data element in the ABAP dictionary. It is easier to use/reuse the readily available field names when you are creating a structure referring to fields of a database table. When the fields are not present, then you can create a data element or refer to one already created and use after TYPE.