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

Question for creating domain

Former Member
0 Likes
5,890

Hi Experts,

I am working on an ABAP report where in I need to create a database table. Inside the database table I have to create a field called "employee worked hours" which should be in the format of 14.5 (i.e employee worked 14 and half hours). I was struck in creating a new z data element/domain for this. Please help me in creating one. What datatype do I need to give here.

Thanks,

Nani

Hi Experts,

I am working on an ABAP report where in I need to create a database table. Inside the database table I have to create a field called "employee worked hours" which should be in the format of 14.5 (i.e employee worked 14 and half hours). I was struck in creating a new z data element/domain for this. Please help me in creating one. What datatype do I need to give here.

Thanks,

Nani

19 REPLIES 19
Read only

guilherme_frisoni
Contributor
0 Likes
5,581

Hi Nani,

you should use a Decimal Data Type with 1 or 2 decimal places.

But about half hour, you will have to convert 30 minutes in 0.5 hours. Not a big problem, just convert everything to minutes and then divide by 60.

Regards,

Frisoni

Read only

mtremblay-savard
Participant
5,581

Hi Nani,

Here is how to create a simple domain :
1 - go to transaction SE11

2 - select the radio button for domain and type the name you want for you domain.

3 - click on create.

4 - enter the description and then enter the data type. in your case i guess "DEC" (no. characters : 8, Decimal place : 4) should work

5 - then simply activate it. (CTRL+F3)

I hope this can help you!

Best Regards,
Max

Read only

edgar_nagasaki
Contributor
0 Likes
5,581

Hi Nani,

Would suggest you to use predefined type DEC or FLTP (then set number of integer and decimal places) in your data element.

Regards,

Edgar

Read only

Kartik2
Contributor
0 Likes
5,581

Hi,

You can have a look at standard available domains and use it. One such domain is 'P15_HMINA'. Please try to find if any standard domain exists to suit your requirement, if it does not then take help of standard domains and create a custom domain.

Regards,

Kartik

Read only

Former Member
0 Likes
5,581

Hi Nani,

  Go to transaction SE11 and create domain and select datatype as DEC and specify no of characters and decimal places you want. And create data element and specify this domain in data element and use this data element in you z table.

DEC is used to hold the decimal places

Read only

Former Member
0 Likes
5,581

HI,

You can do it without creating data element as well. Please check the following screenshot

Regards

Purnand

Read only

Former Member
0 Likes
5,581

Hi,

The best way for this,as already been suggested by many, is to create a new domain with DEC type and specify the no. decimal places required.

BR

Nitin

Read only

gaurab_banerji
Active Participant
0 Likes
5,581

Create a Domain with

data type DEC

no. of characters 8

decimal places 2

in case you want to enter data as 14,30 but save as 14.5 then you need conversion routines for this.

Read only

kumud
Active Contributor
0 Likes
5,581

Why do you want to create a new data element? If you are sure of your requirement, did you take a look at already existing data element - CATSHOURS?

Regards,

Kumud

Read only

Former Member
0 Likes
5,581

Hi,

I don't much experience in ABAP. I just have a question. Do we need to create a data element only when we don't have any standard data element of the data type and length which we require? Its not a must although. Secondly, ex- if I require a data element with char 10, how do I find the standard data element with the same data type and length?

Regards

Purnand

Read only

vigneshyeram
Active Participant
0 Likes
5,581

Dear Purnand,

i think there are no particular steps to find, you need to search it.

You can create in following ways:-

1) you can add field in a ztable without creating data element by choosing pre-defined data type.

2) you can create z* data element without creating domain by selectin pre-defined data type.

3) you can create z* data element without creating z*domain by selecting standard domain like we have CHAR010.

4) you can create z* data element and z* domain too.

Hope it helps you.

Kindly let me know your feedback.

Thanks & Regards,

Vignesh Yeram

Read only

Former Member
0 Likes
5,581

Hi,

Thank you for the reply but my question was that suppose i need the data element/predefined type of char 10. There are many standard data elements with this data type and length. Is there any way to find it? Like above she has suggested CATSHOURS.

Regards

Purnand

Read only

vigneshyeram
Active Participant
0 Likes
5,581

Dear Purnand,

I think there no standard way to find it, you just need to go where data element and predefined and do F4 which will show all the list.

Thanks & Regards,

Vignesh Yeram

Read only

ksourabh
Explorer
0 Likes
5,581

I prefer directly insert field like 'ZWHR' in table & assign the data element as  'P15_HMINA' as mentioned above or create separate DE as datatype DEC.

for ex.

Read only

vigneshyeram
Active Participant
0 Likes
5,581

Dear Nani,

You can create z* domain of data type DEC or while defining data element you can choose the radiobutton predefined type as DEC or Directy while adding fields in a table without entering data element you can give data type as DEC.

Hope it helps you.

Kindly let me know your feedback.

Thanks & Regards,

Vignesh Yeram

Read only

JonathanM
Contributor
0 Likes
5,581

Hi Nani,

You don't need to create a new domain for this.

You could copy an existing data element from the Time elements of infotype 0007 like: MOSTD, WOSTD, STDTG etc to a customer data element.

Then rename it and set your own descriptions and texts.

Pay attention for the translations...

Best regards,

Jonathan

Read only

Former Member
0 Likes
5,581

Hello Everybody,

Thankyou so much for all the replies you sent me. Upon reviewing all replies, I went ahead and created a custom data type (ZHOURS) with custom domain (ZHOUR_DOM). I have given the data type as DEC and decimal places 1.

Now, when I execute my ALV grid report, the output by default shows as 0.0 for that hours coloum. Now, lets say I enter remove 0.0 and enter 5 on one of the row. I debugging mode my ALV internal table is showing 5 as 0.5 (which is wrong). I am not sure where the conversion is taking place for this and changing 5 to 0.5....Any good suggestions?

Thanks,

Nani

Read only

0 Likes
5,581

Hi Experts,

Can anyone please shed some light on this.....?

Thanks,

Nani

Read only

0 Likes
5,581

put as 5.0 and try. i faced this problem once so i did a conversion routine.