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

Updating database table from internal table

I am updating the database table from internal table for this is have used the following syntax

Update kna1 from table itab.

And it is giving error message as the work are itab is not long enough.

Please help me.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 05:45 AM

    Hi

    modifying datbase table useing internal table

    advises before updating this datbase table plz lock that table to avoid incosistency

    write the logic for modifying

    • Modify the database table as per new dunning procedure

    MODIFY fkkvkp FROM TABLE lt_fkkvkp .

    and finally unlock the table

    example

    *To lock table for further operations

    constants: lc_tabname TYPE rstable-tabname VALUE 'FKKVKP' . "FKKVKP

    CALL FUNCTION 'ENQUEUE_E_TABLE'

    EXPORTING

    tabname = lc_tabname

    EXCEPTIONS

    foreign_lock = 1

    system_failure = 2

    OTHERS = 3.

    IF sy-subrc EQ 0.

    • To fetch all the contract accounts for customers of the segment

    • Households/SME.

    PERFORM fetch_contract_accounts using lc_tabname .

    ENDIF. " IF sy-subrc EQ 0.

    *wrote the logic

    • Modify the database table as per new dunning procedure from internal table

    MODIFY fkkvkp FROM TABLE lt_fkkvkp .

    *unlock the tbale

    CALL FUNCTION 'DEQUEUE_E_TABLE'

    EXPORTING

    TABNAME = uc_tabname .

    Reward if usefull

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 05:47 AM

    Hi,

    Dont use UPDATE Statement. You can use MODIFY when you are trying to update the standard sap tables.

    Cheers,

    Bujji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 05:47 AM

    hi,

    1. give it inside a loop.

    2. check whether itab has exact fields..

    loop at itab.

    update dbtable from itab.

    endloop.

    With Rgds,

    S.Barani

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 05:48 AM

    Hi Babji,

    If the data already exists in the db table then u go for update n u need to give the primary key wher u want it to update the kna1 table..

    ellse u need to use INsert...

    what error r u getting exactly...

    Regards,

    Kaveri

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 05:48 AM

    Hi,

    There is a mismatch in the structure of internal table . Make sure the structure of internal table is correct.

    Regards,

    Vani.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 05:52 AM

    Hi,

    Refer this code

    &----


    *& Form SUB_READ_UPDATE_BSEG

    &----


    • text

    ----


    FORM sub_read_update_bseg.

    IF NOT it_final[] IS INITIAL.

    LOOP AT it_final INTO wa_final.

    UPDATE bseg SET zuonr = wa_final-ccnum

    WHERE bukrs EQ wa_final-bukrs

    AND belnr EQ wa_final-vbeln

    AND rfzei EQ wa_final-rfzei

    AND saknr NE ' '.

    ENDLOOP.

    *--Message data updated successfully

    MESSAGE i888 WITH text-002.

    LEAVE LIST-PROCESSING.

    ELSE.

    *--Message No data found

    MESSAGE i888 WITH text-003.

    LEAVE LIST-PROCESSING.

    ENDIF.

    ENDFORM. " SUB_READ_UPDATE_BSEG

    Regards,

    PRashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 06:25 AM

    Hi babji,

    It is not used Update Statement. You can use MODIFY Statement.

    <b>Modify <d.table> from table <itab> where <condition>.</b>

    Regards,

    s.suresh.

    reward if useful...

    Message was edited by:

    suresh selvarajan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 06:26 AM

    Hi babji,

    It is not used <b>Update</b> Statement. You can use <b>Modify</b> Statement.

    <b>Modify <d.table> from table <itab> where <condition>.</b>

    Regards,

    s.suresh.

    reward if useful...

    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.