‎2020 Oct 11 9:08 AM
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.
‎2020 Oct 11 9:30 AM
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
‎2020 Oct 11 10:36 AM
‎2020 Oct 11 10:22 AM
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.
‎2020 Oct 11 10:29 AM
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.
‎2020 Oct 11 10:32 AM
‎2020 Oct 11 2:13 PM
You can see that both data elements have the same attributes, so there's no difference for ABAP. Choose the one you want.
‎2020 Oct 11 2:15 PM
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.
‎2020 Oct 11 6:30 PM
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.