‎2007 Apr 10 4:25 AM
Hi SDN's,
I m new to abap.
could u plz help me.
let us take i m having a table with two fields say eno, ename.
i want to insert da data during runtime,
when i executed, it should display two fields.
i wants to insert data in two fileds, this data sholud save in db table.
how to do that.
plz guide me
thanks in advance
‎2007 Apr 10 4:48 AM
Hi Renu,
First declare a itab with the fields u want to fill the data base table.
data: begin of itab occurs 0,
eno type string,
ename type tsring,
end of itab.
fill the itab with the data u want to store in database table.
then using insert statement u can insert the data into database table.
insert dbtale from table itab.
<b>u can also insert into database table without using internal table.</b>
tables : databasetable.
databasetable-eno = 'value'.
databasetable-ename = 'value'.
insert databasetable.
here databasetable acts as work area and insert is done into database table from workarea.
‎2007 Apr 10 4:31 AM
Hi..
data:
begin of itab occurs 0,
eno , " data types of dbtable
ename, " data types of dbtable
end of itab.
2. Fill the itab with some values.
3. <b>INSERT <dbtab> FROM TABLE <itab> [ACCEPTING DUPLICATE KEYS] .</b>
‎2007 Apr 10 4:47 AM
Hi Renu,
You can generate Table Maintenance, and then inster the values into DB as shown
1. Go to SE11 and enter the table for which u want to enter values
2. Go to <b>Utilities</b> from menu bar
3. Clk on Table Maintenance Generator
4. Choose Authorization Group and Function Group
5. Clk on Execute.
once u create Table Maintenance, to enter the values go to
1. SM30
2. Enter the Table Maintence name
then it will take you to a screen where you can enter and save the values into DB.
‎2007 Apr 10 4:48 AM
Hi Renu,
First declare a itab with the fields u want to fill the data base table.
data: begin of itab occurs 0,
eno type string,
ename type tsring,
end of itab.
fill the itab with the data u want to store in database table.
then using insert statement u can insert the data into database table.
insert dbtale from table itab.
<b>u can also insert into database table without using internal table.</b>
tables : databasetable.
databasetable-eno = 'value'.
databasetable-ename = 'value'.
insert databasetable.
here databasetable acts as work area and insert is done into database table from workarea.
‎2007 Apr 10 4:57 AM
hi frinds,
i dont want to insert while writing code.
when i executed my program, i screen should hav to input fields,
in those fileds i hav to write the data. when i press save button, these two input field values should save in data base.
plz tell me
‎2007 Apr 10 5:28 AM
hi renu ,
for that u have to declare it as parameters soething like this
parameters: databasetable-eno ,
databasetable-ename .
case 'button'.
when 'save' .
insert databasetable.
endcase.
ravi
‎2007 Apr 10 6:42 AM
hi ravi,
could u plz provide me sample code.
it wolud be very helpful for me.
thanks in advance
‎2007 Apr 10 6:57 AM
hi,
chk this.
REPORT ztestreport .
DATA : BEGIN OF int OCCURS 0,
client LIKE ztable-client,
emp_name LIKE ztable-emp_name,
emp_id LIKE ztable-emp_id,
END OF int.
parameters: p_name(35) tyep c ,
P_empno(10)n type c.
databasetable-ename .
start-of-selection.
case 'button'.
when 'save' .
int-client = sy-mandt.
int-emp_name = p_name.
int-emp_id = P_empno.
APPEND int.
INSERT ztable FROM TABLE int.
COMMIT WORK.
endcase.
rgds
Anversha
‎2007 Apr 10 7:06 AM
i hav done same thing what u hav done.
but its throughing sme error like
the work are "int" is not long enough
what does it mean
‎2007 Apr 10 7:19 AM
hi,
chnage it like this and try.
may be length is an issue.
parameters: p_name like ztable-emp_name,
P_empno like ztable-emp_id.rgds
Anver
‎2007 Apr 10 7:38 AM
hi anversha,
i hav done, and its getting executed also.
but its not saving data in database.
y so.
i m giving the code, hav a look n find out whats wrong in this
plzzzz
DATA : BEGIN OF itab OCCURS 3,
empno LIKE zemp-empno,
empname LIKE zemp-ename,
doj like zemp-doj,
END OF itab.
parameters: p_empno like itab-empno,
P_name like itab-empname,
p_doj like itab-doj.
tables zemp.
start-of-selection.
case 'button'.
when 'save' .
itab-empname = p_name.
itab-empno = P_empno.
itab-doj = p_doj.
APPEND itab.
insert zemp into itab.
COMMIT WORK.
endcase.
‎2007 Apr 10 7:41 AM
hi renu,
i dont have an sys to check my code just use this logic to develop it it will work
ravi
‎2007 Apr 10 7:45 AM
hi,
error is here
<b>insert zemp into itab.</b>
chnage like this.
INSERT zemp FROM TABLE itab.Rgds
Anver
‎2007 Apr 10 8:04 AM
‎2007 Apr 10 6:45 AM
hi,
chk this.
REPORT ztestreport .
DATA : BEGIN OF int OCCURS 0,
client LIKE ztable-client,
emp_name LIKE ztable-emp_name,
emp_id LIKE ztable-emp_id,
END OF int.
int-client = '501'.
int-emp_name = 'Test Data'.
int-emp_id = '0001'.
APPEND int.
INSERT ztable FROM TABLE int.
COMMIT WORK.Rgds
Anver
‎2007 Apr 10 6:52 AM
hi anversha,
here ur coding for to inseet data like
int-client = '501'.
int-emp_name = 'Test Data'.
int-emp_id = '0001'
but i want to insert this data during runtime when i executed da program.dats wat i m asking
but any ways thanks for ur reply.
do u knw how to do dat method
‎2007 Apr 10 7:00 AM
Hi Renushree,
Is it possible for you to use select options,one for emp no and other for emp name.
So when you execute it wil insert to the database tables.
No need of internal tables in that case or not much code.
Regards,
Ponraj.s.