Skip to Content
author's profile photo Former Member
Former Member

Not able to update database?

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 08:14 AM

    update statement work if the entries already exist in z table, otherwise it wont work, use Insert ot Modify statement..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 08: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 08: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 .

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.