2008 Feb 04 2:24 PM
data: i_aad_tab type standard table zxxv_aad_tab
IF NOT i_aad_tab[] IS INITIAL .
UPDATE zxxv_aad_tab FROM TABLE i_aad_tab[].
IF sy-subrc EQ 0.
* MESSAGE successful update.
LEAVE TO SCREEN '1000'.
ENDIF.
ENDIF.
please help the update doesn't work . can anyone advise
i_aad_tab contain same structure as the update database table and it contain value selected on the selection screen
2008 Feb 04 2:29 PM
That means atleast one line of ut internal table entry is not matching database strcture enrty..check it out once
2008 Feb 04 2:29 PM
Hi,
Try this
data: i_aad_tab type standard table zxxv_aad_tab
IF NOT i_aad_tab[] IS INITIAL .
MODIFY zxxv_aad_tab FROM TABLE i_aad_tab.
IF sy-subrc EQ 0.
MESSAGE successful update.
LEAVE TO SCREEN '1000'.
ENDIF.
ENDIF.
Regards,
Satish
2008 Feb 04 2:29 PM
2008 Feb 04 2:30 PM
hi newbie82,
change like:
IF sy-subrc EQ 0.
COMMIT WORK.
...
ELSE.
ROLLBACK WORK.
ENDIF.
hope this helps
ec
2008 Feb 04 2:34 PM
by since my internal table has same types as my database table the primary key is the same
note: the sy-subrc = 4 and i don't know why
2008 Feb 04 2:33 PM
Hi,
Check SY-DBCNT value after UPDATE, it will give the number of records updated
Also check SY-SUBRC
If, in the database, there is no row with the same content of the primary key for a row in the internal table, or if the change would lead to a double entry in a unique secondary key, the respective row is not changed and sy-subrc is set to 4. If the internal table is empty, sy-subrc is set to 0
use MODIFY and checkout if it works
2008 Feb 04 2:41 PM
thanks for the tips SY-DBCNT it's because i am updating a field which is the primary key
2008 Feb 04 2:43 PM
That means atleast one line of ut internal table entry is not matching database strcture enrty..check it out once
2008 Feb 04 3:21 PM
i am updating a field which is also a primary key in my database table
. i used modify and it created a new record which i don't want . and with update it won't undate since if i make changes to primary key it doesn't find the record .
not being able to use update and modify . i think the only option is to remove promary key in the field that i am updating . i need your advise?
2008 Feb 04 3:29 PM
you can select all entries from table zxxv_aad_tab into an internal table and than loop through i_aad_tab and check if the entry you created exists already in the DB (i. e. READ TABLE with key fields), than if sy-subrc is not zero, than you can delete from your internal table.
something like this:
DATA : gt_aad_tab TYPE HASHED TABLE OF zxxv_aad_tab
WITH UNIQUE KEY (list key fields here).
SELECT * FROM zxxv_aad_tab INTO gt_aad_tab.
LOOP AT i_aad_tab.
READ TABLE gt_aad_tab WITH KEY all key field TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
*delete entry from i_aad_tab
ENDIF.
ENDLOOP.
2008 Feb 04 3:33 PM
no i can't do that since what ever the record i am selecting i need to change the value of one of the primary key fields
the purpose is to update the database value
2008 Feb 04 3:41 PM
Hi,
Just to make sure, have you checked if that Z table has the keys defined correctly (SE11), otherwise your abap statements won't work as expected if table definition is not defined as required.
Hope it helps.
Regards,
Gilberto Li
2008 Feb 04 7:00 PM
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |