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

Select into internal table with default entry for every select

Former Member
0 Likes
1,923

Hi ABAPers,

I want to select data from a custom (Z)table into internal table with a defalut value 'GM' do be added at end of every row selected from custom table into internal table.

I can do it at internal table level but I want to do it at database select level itself.

Ex: 

1 abc 34 monday january 2011 GM
2 bbc 34 monday january 2011 GM
3 cbc 34 monday january 2011 GM
4 dbc 34 monday january 2011 GM

How do we acheive above..

-Dep

Hi ABAPers,

I want to select data from a custom (Z)table into internal table with a defalut value 'GM' do be added at end of every row selected from custom table into internal table.

I can do it at internal table level but I want to do it at database select level itself.

Ex: 

1 abc 34 monday january 2011 GM
2 bbc 34 monday january 2011 GM
3 cbc 34 monday january 2011 GM
4 dbc 34 monday january 2011 GM

How do we acheive above..

-Dep

8 REPLIES 8
Read only

Former Member
0 Likes
1,407

Hi,

Write select..endselect as :

data : begin of it_pa0001 occurs 0,

pernr like pa0001-pernr,

field1(2),

end of it_pa0001.

select pernr from pa0001 into it_pa0001-pernr

where pernr <> ''.

it_pa0001-field1 = 'GM'.

append it_pa0001.

endselect.

Regards,

Srini.

Read only

0 Likes
1,407

Hi Srini,

I dont want use select ..endselect.

Read only

Former Member
0 Likes
1,407

Hi,

Actually iam not clear what exactly is ur requirement ?

Do you want to update the GM value in the DB table or internal table ?

If you are having the last field value GM'' in the DB table then write the field in the selection criteria.

i.e

where field = 'GM'

If you want to update the internal table then select the data from the DB table then write

wa-field = 'GM'.
Modify it from wa transporting field.

Regards,

Madhukar Shetty

Read only

0 Likes
1,407

Hi Madhu,

The value 'GM' is not in DB table.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,407

Hi,

In your internal table, try to make the value as 'GM' by default.

Otherwise, after selected the values from database, modify the internal table with the field value in one shot using transporting.

Read only

0 Likes
1,407

Hi Jaya,

Thanks for you reply,

I tried the first option you told that didnt work as all records are populated but the defalut value is not.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,407

Hi,

Check my second option. I tis working.

types : begin of ty,

matnr type matnr,

field(2) ,

end of ty.

data : itab type standard table of ty,

wa type ty.

select matnr into corresponding fields of table itab from mara up to 10 rows.

wa-field = 'GM'.

modify itab from wa transporting field where field is initial .

loop at itab into wa .

write : / wa-matnr, wa-field.

endloop.

Read only

0 Likes
1,407

Hi Jaya,

Your solution is working fine but how about the first option if that would work my issue will be completely resolved.

--Dep