‎2008 Jun 20 7:59 AM
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
‎2008 Jun 20 8:03 AM
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.
‎2008 Jun 20 8:01 AM
Hi,
Use the MODIFY on Database table for the filed that you added.
‎2008 Jun 20 8:03 AM
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.
‎2008 Jun 20 8:05 AM
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.
‎2008 Jun 20 9:31 AM
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.