‎2009 Sep 09 9:10 AM
Hello gururs,
i have created a structure which contains data from mara and makt tables. now i want to data of this structure to my own created database table starting with 'z'. program is done in module screen, where user enters data. so when user hits save button, it select data from mara and makt and save it in 'z' database. now data is coming in strcure not passing it to database..
for that i have used following code.
data : i_tab type ztest_cm(standard table).
WHEN 'SAVE'. status in program
PERFORM UPDATE_DB.
SELECT SINGLE * FROM MAKT INTO CORRESPONDING FIELDS OF ZSTRUC_CM(structure) working
WHERE MATNR = ZSTRUC_CM-MATNR.
SELECT SINGLE MEINS FROM MARA INTO CORRESPONDING FIELDS OF ZSTRUC_CM working
WHERE MATNR = ZSTRUC_CM-MATNR.
MOVE-CORRESPONDING ZSTRUC_CM TO I_TAB. not working
UPDATE ZTEST_CM FROM ZSTRUC_CM. not working
‎2009 Sep 09 10:52 AM
Hi Vikram,
New entry into database table should be through INSERT statement.
If you want to modify the record which is already present in a atbale, then use MODIFY or UPDATE.
And try checking Sy-subrc after each database statements so that you will know the type of error based on the value returned by sy-subrc.
Hope this helps
Rgds,
Sripal
‎2009 Sep 09 9:14 AM
update statement work if the entries already exist in z table, otherwise it wont work, use Insert ot Modify statement..
‎2009 Sep 09 9:15 AM
Hi,
>
> MOVE-CORRESPONDING ZSTRUC_CM TO I_TAB. not working
>
> UPDATE ZTEST_CM FROM ZSTRUC_CM. not working
Instead of the move statement you need to use the append work area to internal table statement. you need to have the same structure for the work area and the internal tbale.
Then use the modify data base table from internal table statement.
Regards
Ansari
‎2009 Sep 09 9:40 AM
Use
MODIFY ZTEST_CM FROM TABLE ZSTRUC_CM.
COMMIT WORK.
Always use modify as it take cares to check which records already exists in table based on primary fields and updates only the ones not present.
Always while updating in Z tables or any transaparent tables, you have to use COMMIT WORK as it commits your data to the data base level.
Please search the forum before asking these questions;you will get your solution .
Thanks .
‎2009 Sep 09 10:52 AM
Hi Vikram,
New entry into database table should be through INSERT statement.
If you want to modify the record which is already present in a atbale, then use MODIFY or UPDATE.
And try checking Sy-subrc after each database statements so that you will know the type of error based on the value returned by sy-subrc.
Hope this helps
Rgds,
Sripal