Application Development 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: 

How to Update single field from database table?

Former Member
0 Kudos

Hi All,

I am running one application from that i want to update LFIMG field in LIPS Table. i try with this code, but total record updated,

i want to update lfimg field only? please any suggestion on change code?

loop at lt_it_lips into ls_it_lips.

wa_lips-vbeln = ls_it_lips-vbeln.

wa_lips-posnr = ls_it_lips-posnr.

wa_lips-lfimg = ls_it_lips-lfimg - ls_it_lips-PICK_QTY.

*MODIFY it_lips from wa_lips

*TRANSPORTING lfimg where vbeln = ls_it_lips-vbeln ." TRANSPORTING lfimg .

APPEND wa_lips to it_lips.

endloop.

  • lock the table

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'LIPS'

  • VARKEY = ship_no

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

MODIFY LIPS from wa_lips .

if sy-subrc is initial.

COMMIT WORK .

else.

ROLLBACK work.

endif.

endloop.

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'LIPS'.

Thanks,

VEnkat.

2 REPLIES 2

Former Member
0 Kudos

Hi Venkat,

I hope LFIMG is not one of the primary key of the LIPS table.

If it is the primary key then you need to delete and insert a new record

If it is not the primary key then make sure the wa_lips has got all the primary key details from the lips table. The LFIMG of wa_lips should have new value.

Regards

raymond_giuseppi
Active Contributor
0 Kudos

To update a set of fields check the syntax at [UPDATE dbtab|http://help.sap.com/abapdocu_70/en/ABAPUPDATE.htm] [SET set_expression [WHERE sql_cond] |http://help.sap.com/abapdocu_70/en/ABAPUPDATE_SOURCE.htm#&#38;ABAP_ALTERNATIVE_1@1@]

But LIPS is a SAP standard table AND MUST NOT BE DIRECTLY UPDATED BY OPEN (or native) SQL STATEMENTS. Look for a correct solution like [BAPI|http://www.sdn.sap.com/irj/scn/advancedsearch?query=bapiLIPSupdate] or even BDC if none found. But first look if standard transactions allow you to update this field, if no, there may be a good reason to forbid this.

Regards,

Raymond