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

key fields declaration

Former Member
0 Likes
1,290

Hi,

i have this declaration:

<b>data: begin of tab1 occurs 0,

mat(18) type c,

anno(4) type n,

mese(2) type n,

tipval(3) type n,

imp(9) type p decimals 2,

qty(9) type p decimals 3,

end of tab1.</b>

How can I declare the fields <b>mat</b>, <b>anno</b> and <b>mese</b> as a key field?

thanks a lot.

C.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,112

Hi,

U can't give the key fields directly for those fields.U can give in the following way:

<b>data: begin of tab1 occurs 0,

mat(18) type c,

anno(4) type n,

mese(2) type n,

tipval(3) type n,

imp(9) type p decimals 2,

qty(9) type p decimals 3,

end of tab1,

it_tab1 like table of tab1 with Unique key mat anno mese with Header Line.</b>

Regards,

Padmam.

5 REPLIES 5
Read only

Former Member
0 Likes
1,112

Hi,

DATA itab { {TYPE tabkind OF [REF TO] type}

| {LIKE tabkind OF dobj} }

[WITH key] .

regards,

shardul shah

data : begin of itab occurs 0,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

loekz like ekpo-loekz,

aedat like ekpo-aedat,

matnr like ekpo-matnr,

end of itab.

data : x_tab like table of itab with key ebeln with header line.

Message was edited by:

Shardul Shah

Read only

Former Member
0 Likes
1,112

Hi

Where you wants to create/use them as key fields

in the internal table or DB table?

In the database table you can just tick the field after FIELD

there is nothing to be done for the internal table.

Reward points for useful Answers

Regards

Anji

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,112

Hi,

OCCURS is obsolete, you can instead use TYPE STANDARD TABLE along with WITH KEY addition to define the key.

<b>TYPES: begin of tab1,

mat(18) type c,

anno(4) type n,

mese(2) type n,

tipval(3) type n,

imp(9) type p decimals 2,

qty(9) type p decimals 3,

end of tab1.

DATA: itab type standard table of tab1 with key mat anno mese.</b>

Regards,

Sesh

/

Read only

Former Member
0 Likes
1,113

Hi,

U can't give the key fields directly for those fields.U can give in the following way:

<b>data: begin of tab1 occurs 0,

mat(18) type c,

anno(4) type n,

mese(2) type n,

tipval(3) type n,

imp(9) type p decimals 2,

qty(9) type p decimals 3,

end of tab1,

it_tab1 like table of tab1 with Unique key mat anno mese with Header Line.</b>

Regards,

Padmam.

Read only

abdul_hakim
Active Contributor
0 Likes
1,112

Hi,

Use the below code..

data: begin of tab1,

mat(18) type c,

anno(4) type n,

mese(2) type n,

tipval(3) type n,

imp(9) type p decimals 2,

qty(9) type p decimals 3,

end of tab1.

data itab like table of tab1 with unique key mat anno mese.

dont use occurs 0 method as itis obsolete and wont be supported in OO Context..

Cheers,

Hakim

Mark all useful answers..