11-30-2007 5:42 AM
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.
11-30-2007 5: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
11-30-2007 5:47 AM
Hi,
Dont use UPDATE Statement. You can use MODIFY when you are trying to update the standard sap tables.
Cheers,
Bujji
11-30-2007 5: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
11-30-2007 5: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
11-30-2007 5:51 AM
I HAVE DECLARED INTERNAL TABLE IN THE FOLLOWING WAY
types: begin of ty_itab,
kunnr type kunnr,
land1 type LAND1_GP,
end of ty_itab.
data: it_itab type standard table of ty_itab initial size 0.
data: wa_itab type ty_itab.
11-30-2007 6:01 AM
loop at it_itab into wa_itab.
update kna1 set land1 = wa_itab-land1 where kunnr = wa_itab-kunnr.
endloop.
11-30-2007 6:03 AM
Hi Babji,
Fine...if the data already exists n u r trying to midify then..
use
Modify kna1 from itab .
else use..
kna1-kunnr = itab-kunnr.
kna1-land =.....
Insert kna1 .
Regards,
Kaveri
11-30-2007 5:48 AM
Hi,
There is a mismatch in the structure of internal table . Make sure the structure of internal table is correct.
Regards,
Vani.
11-30-2007 5: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
11-30-2007 6: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
11-30-2007 6: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...