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

Insert data base table

naveen_inuganti2
Active Contributor
0 Likes
541

Hi....

Iam having five records in my database tables.... with 5 fields.... now iam added a new field to that table...

I want to insert entries into that fielf through program..

Suggest me logic...

Thank you,

Naveen.I

1 ACCEPTED SOLUTION
Read only

GauthamV
Active Contributor
0 Likes
518

hi,

check this sample code.

TABLES : zgm_table.

data : it_data type standard table of zgm_table,

wa_data type zgm_table.

wa_data-name = 'ABC'.

wa_data-city = 'JAPAN'.

wa_data-role = 'ASSOCIATE'.

wa_data-salary = 26000.

append wa_data to it_data.

modify zgm_table from table it_data.

IF sy-subrc = 0.

MESSAGE 'records created succesfully' TYPE 'S'.

ENDIF.

or

wa_data-name = 'ABC'.

wa_data-city = 'JAPAN'.

wa_data-role = 'ASSOCIATE'.

wa_data-salary = 38000.

append wa_data to it_data.

update zgm_table from table it_data.

reward points if hlpful.

4 REPLIES 4
Read only

Former Member
0 Likes
518

Hi,

Use the MODIFY on Database table for the filed that you added.

Read only

GauthamV
Active Contributor
0 Likes
519

hi,

check this sample code.

TABLES : zgm_table.

data : it_data type standard table of zgm_table,

wa_data type zgm_table.

wa_data-name = 'ABC'.

wa_data-city = 'JAPAN'.

wa_data-role = 'ASSOCIATE'.

wa_data-salary = 26000.

append wa_data to it_data.

modify zgm_table from table it_data.

IF sy-subrc = 0.

MESSAGE 'records created succesfully' TYPE 'S'.

ENDIF.

or

wa_data-name = 'ABC'.

wa_data-city = 'JAPAN'.

wa_data-role = 'ASSOCIATE'.

wa_data-salary = 38000.

append wa_data to it_data.

update zgm_table from table it_data.

reward points if hlpful.

Read only

Former Member
0 Likes
518

Hi,

Try using UPDATE SET.

Code below is direct extract from ABAPDOCU



PARAMETERS: table    TYPE c LENGTH 30, 
            column   TYPE c LENGTH 30, 
            old_curr TYPE sycurr. 

DATA: set_expr  TYPE string, 
      condition TYPE string. 

CONCATENATE column ` = 'EUR'` 
            INTO set_expr. 

CONCATENATE column ` = old_curr` 
            INTO condition. 

TRY. 
    UPDATE (table) 
    SET    (set_expr) 
    WHERE  (condition). 
  CATCH cx_sy_dynamic_osql_error. 
    MESSAGE `Error in update!` TYPE 'I'. 
ENDTRY. 

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
518

Try this sample code.

data : begin of itab occurs 0 with header line.

f1(10), f2(10), f3(10), f4(10), f5(10),

end of itab.

itab-f1 = 'india'. itab-f2 = 'usa'. itab-f3 = 'japan'. itab-f4 = 'china'

itab-f5 = 'srilanka'.

append itab.

loop at itab.

update ZTABLE CLIENT SPECIFIED SET.

ZTABLE-F1 = ITAB-F1.

ZTABLE-F2 = ITAB-F2

.....

IF SY-SUBRC = O.

COMMIT WORK.

ELSE.

ROLLBACK WORK.

ENDIF.

ENDLOOP.