Application Development 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: 

Naming conventions for data types

Former Member
0 Kudos
1,616

In my functional specs I have been given field names

Client Number

Record Type

Customer Name and so on

I need to create custom data types for all these and assign them to std values (vbak-kunnr, adrc-name1)

I am trying to determine what is the best naming convention to use for my custom data types

Would the convention be to use, new_kunnr, new_adrc_name1 or perhaps just ClientNumber, RecordType, CustomerName and so on

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos
452

Hi,

You don't need to create data type/element for your coding purposes.

You can declare work areas (WA).


data: wa_new_kunnr(15) type c. 

wa_new_kunnr = vbak-kunnr. 

Regards,

Ferry Lianto

13 REPLIES 13

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
452

<i>create custom data types for all these and assign them to std values</i>

If you are referring to creating new data elements and assigning them directly to the fields in a standard table, I would highly suggest NOT doing this.

Regards,

Rich Heilman

ferry_lianto
Active Contributor
0 Kudos
452

Hi,

You can try something like this.

ZNEW_KUNNR.

ZADRC_NAME1.

Regards,

Ferry Lianto

Former Member
0 Kudos
452

Hi Rich

All I want to do is

data: new_kunnr(15) type c

new_kunnr = vbak-kunnr

Am I creating a new data type here?

I need to come up with a consistent naming convention for my fields as I have many of them

Former Member
0 Kudos
452

Hi,

if you are refering for custom data types, defined in your abap program, there is no convention at all. You are free to choose your variable names.

If you ar talking about sap objects, like domains or data elements, then you must follow SAP conventions.

The main convention is that your SAP objects must begin with 'Z' ou 'Y' .

Regards,

ferry_lianto
Active Contributor
0 Kudos
453

Hi,

You don't need to create data type/element for your coding purposes.

You can declare work areas (WA).


data: wa_new_kunnr(15) type c. 

wa_new_kunnr = vbak-kunnr. 

Regards,

Ferry Lianto

0 Kudos
452

Then Ferry, has you answer here, normally though, WA would indicate a header line for an internal table. You will see other naming conventions for single data types. For example.

v_kunnr " Variable

or

lv_kunnr " Local Variable

or

gv_kunnr " Global Varible

Regards,

Rich Heilman

Former Member
0 Kudos
452

but if I were to chose my variable names as CustomerNumber, RecordTypeand so on rather than wa_kunnr ... would that be a non sap thing to do. I ask this cos I have a Java background and thats how we would name variables

0 Kudos
452

Camel Casing is not possible in ABAP as it is case insensitive for the variables unlike Java is

0 Kudos
452

You can use any datatype name you like. But it is best to use meaningful names such as

W_BILLING_METHOD instead of W_KVGR4.

The same is for internal tables. I have seen an internal table with the following definition

BEGIN OF T_DATA....

FIELD1(10),

FIELD2(10),

FIELD3(10),

.........

END OF T_DATA

etc.....

Former Member
0 Kudos
452

Unsure

Former Member
0 Kudos
452

I think its best I include my scenario so people can better answer my question

My report has four different parts, each has a filler, record type, customer number which need to be initialized to certain values that are different

The four parts are Name/Address, Credit Order, Sub total and Total

Name/Address has Record type = A , customer number = vbak-kunnr

Credit Order has Record type = R, customer number = vbak-kunnr

SubTotal has Record type= space and customer number = 99

Total has Record type = S and customer number = 9999

So I have to create variables for these and am trying to figure out a proper naming convention

I could do RecordType_Name, RecordType_CreditOrder and so on but that does not seem the best way to me. Any ideas!

0 Kudos
452

Hi Megan,

Usually we use the keyword TYPES to declare user-defined data types. The naming convention we follow is type_s_<typename>.

In order to declare data objects the naming convention is w_<objname>. In the same way,

For internal tables it is t_<tabname>.

For work areas it is wa_<work area-name>.

For parameters it is p_<parameter-name>.

For select-options it is s_<name>.

So according to ur requirement u use the above mentioned naming convention in ur report. Hope u get satisfied with my reply.

Regards,

Swapna.

Former Member
0 Kudos
452

Thank You!