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: 

How can hard code values in an internal table?

Former Member
0 Kudos

How can hard code values in an internal table?

I need to do the following>>>>

Put 1 into itab-num(01)(internal tables first row)

Put 2 into itab-num(02)(internal tables second row)

Put 3 into itab-num(03)(internal tables third row).

<b>PS:</b>I dont have option of fetching from a table after making entries of 1,2 and 3.

Regards,

Shashank.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

itab-num = '1'.

append itab.

itab-num = '2'.

append itab.

itab-num = '3'.

append itab.

loop at itab.

write : / itab-num.

endloop.

regards

shiba dutta

8 REPLIES 8

Former Member
0 Kudos

hi ,

u mean u want to add one more column in the internal table . can u be specific

regards

reena

0 Kudos

Hi Reena,

I have defined an Internal table ITAB with only one feild:NUM as follows.

DATA: BEGIN OF ITAB OCCURS 0,

NUM(02),

END OF ITAB.

I just need to put values into the internal table like

1 into ITAB-NUM(01)>>FIRST ROW OF itab.

2 into ITAB-NUM(02)>>SECOND ROW OF itab.

3 into ITAB-NUM(03)>>THIRD ROW OF itab.

0 Kudos

hi ,

u can do like this .

loop at itab.

itab-num1 = 1

itab-num2 = 2

itab-num3 = 3.

append itab.

endloop.

and can u tell me what is that num(01) i mean the numbers in the bracket . u have declared only one field inthe declaration. and how can u use 01, 02,03. can u tel about this.

reply back if u have doubts

regards

reena

Former Member
0 Kudos

itab-num = '1'.

append itab.

itab-num = '2'.

append itab.

itab-num = '3'.

append itab.

loop at itab.

write : / itab-num.

endloop.

regards

shiba dutta

Former Member
0 Kudos

Hi,

first of all you take a field for storing the number (1,2,3 etc) in your internal table.

after that you fill the remaining fields using select statement or some other way.

after filling use the below code.

data : v_num type i.

loop at itab.

v_num = v_num + 1.

itab-number = v_num.

modify itab.

endloop.

Former Member
0 Kudos

Hi,

For better understanding use the below code

data: begin of itab occurs 0,

sno type i,

eno(4) type n,

name(20) type c,

addr(20) type c,

end of itab.

data: v_num type i.

itab-eno = 1200.

itab-name = 'KUMAR'.

itab-addr = 'HYDERABAD'.

append itab.

clear itab.

itab-eno = 1560.

itab-name = 'RAJ'.

itab-addr = 'PUNE'.

append itab.

clear itab.

itab-eno = 1780.

itab-name = 'SAILESH'.

itab-addr = 'MUMBAI'.

append itab.

clear itab.

loop at itab.

v_num = v_num + 1.

itab-sno = v_num.

modify itab.

endloop.

write:/5 'Sno',

20 'Eno',

35 'Name',

60 'Address'.

write /5 sy-uline(62).

loop at itab.

write:/5 itab-sno,

20 itab-eno,

35 itab-name,

60 itab-addr.

endloop.

Former Member
0 Kudos

Hi,

refer the below code

data: begin of itab occurs 0,

sno type i,

eno(4) type n,

name(20) type c,

addr(20) type c,

end of itab.

data: v_num type i.

itab-eno = 1200.

itab-name = 'KUMAR'.

itab-addr = 'HYDERABAD'.

append itab.

clear itab.

itab-eno = 1560.

itab-name = 'RAJ'.

itab-addr = 'PUNE'.

append itab.

clear itab.

itab-eno = 1780.

itab-name = 'SAILESH'.

itab-addr = 'MUMBAI'.

append itab.

clear itab.

loop at itab.

v_num = v_num + 1.

itab-sno = v_num.

modify itab.

endloop.

write:/5 'Sno',

20 'Eno',

35 'Name',

60 'Address'.

write /5 sy-uline(62).

loop at itab.

write:/5 itab-sno,

20 itab-eno,

35 itab-name,

60 itab-addr.

endloop.

PritamKunal
Participant
0 Kudos

Hi Shashank

There is a solution of your problem with me.

What you can do create an internal table which will contain all the field you want with one extra field you want to hard code. Select fields from db table into corresponding field and then loop into table. inside the loop you can modify your fields as want. you can hard code row wise or what ever way you want like dynamically.

Pritam