Check before update in table
Hi Guru's,
I am a new developper in abap. I have a question concerning the check before the update in a table.
I uploaded a csv file by the function module GUI_DOWNLOAD but now before to do the update I have to check if the correct value for the controlling area and profit centre are used .
I don't know where do my test.
Anyone can help me?
Regards,
Mohamed.
UPDATE
- fill table --> check all values of the file and if one error stop processing and do not update anything in the table
- check if controlling area is correct
- check if profit center is correct
LOOP AT it_datatab INTO wa_datatab.
split wa_datatab at ';' into
wa_cepc_segm-KOKRS
wa_cepc_segm-PRCTR
wa_cepc_segm-DATBI
wa_cepc_segm-DATAB
wa_cepc_segm-SEGMENT.
APPEND i_cepc.
CLEAR i_cepc.
ENDLOOP.
END-OF-SELECTION.
Hi,
Updating a database table
Single-line updates
SELECT * FROM TABLE
COLUMN-UPDATE STATEMENT
UPDATE TABLE
ENDSELECT
Column updates
UPDATE TABLE SET COLUMN-UPDATE STATEMENT
Regards
Similar Messages
-
Enqueue and Dequeue before updating Database table
Hi all,
We are updating database tables using INSERT, MODIFY and UPDATE statements. Since many people will be running the application at the same time we need to lock the table before updating database table. So we need to use ENQUEUE and DEQUEUE functionality for this purpose.
Can any plz explain what are the steps we should follow now?
Thanks in advance.Hi,
Any Database access should carefully handled as multiple applications may be accessing the database at the same time. To read a record from the database you don't need to implement a lock, but to write you need not only locks but also ideally should use the Update Function Modules to comply SAP "All or Nothing" Principle. This will prevent data inconsistency of the database and the data will be proper state. You need to use the COMMIT WORK and ROLLBACK WORK in you code to handle the consistency part of the database.
The best design approach would be seperate the Database Layer completely from the business layers. This will make your code robust and easy to maintain.
As, for the Locking Concepts, you will get multiple resources from SDN as how to create Locks and implement the Locking modules in your code. But more than that what matters is why and how to implement the SAP Locking concepts to make your application run better.
Have a look at the following link
http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Hope this helps.
Thanks,
Samantak. -
Updating database table with DUPLICATE keys
i have an internal table having data as follows.
emp_id name date proj_id activity_id Hours Remarks
101 Pavan 09.10.2007 123 1 2.00 Coding
101 Pavan 09.10.2007 124 2 1.00 Documentation
102 Raj 09.10.2007 123 3 6.00 Testing
Now i need to update a Ztable with above mentioned data.
The structure of the Ztable is as follows.
Mandt emp_id name date proj_id activity_id Hours Remarks
NOte: i have ticked both check boxes for the field MANDT in table.
Rest didnt select the check boxes.
I believe now the field MANDT alone is a primary key for the z-table.
NOw i have tried with UPDATE/INSERT statments to update the database table.
But instead of inserting all the rows, the system is over writing on the same emp_id row.
Even tried with the statments like INSERT INTO <Ztable> values <Internal table> ACCEPTING DUPLICATE KEYS.
But its not getting inserted as a separate row in the table.
Requirement is to insert the multiple rows in the database table without any over writing activity.
Can anyone give me the code to do this?
Regards
PavanHi Pavan,
Please let me know what are the key fields in your Ztable. Try with below code it may help you. change the "Ztablename" as your database table name and I_INTERNAL TABLE as your internal table name. still you are facing the problem please let me know.
lock the custom table before updating the table.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZTABLENAME'
VARKEY =
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
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.
ELSE.
INSERT ZTABLENAME FROM TABLE I_INTERNALTABLE ACCEPTING DUPLICATE KEYS.
COMMIT WORK.
ENDIF.
unlock after updating the custom table After updation is done.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZTABLENAME'
VARKEY =
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' ' -
Catching Exceptions updating z tables.
Hello there, I´m trying to update a z-table , but I´m not sure if the way i´m working is the best , First I do a Select in order to check if the register exists ant then I make an update , but where I can catch any exception.???
SELECT * FROM zpx_ci_docs_proc
INTO TABLE ti_zpx_ci_docs
WHERE nume_docu = num_doc.
If sy-subrc = 0.
update zpx_ci_docs_proc set DATA_ENVI = dat_envi WHERE nume_docu = num_doc.
if sy-subrc = 0.
MESSAGE s000(zpb) WITH
" register update''
endif.
Thanks again.Hi,
Use enqueue FM before updating the table and After updation use dequeue FM.
DO.
Use ENQUEUE_E_TABLE FM
IF sy-subrc = 0.
EXIT.
ENDIF.
ENDDO.
UPDATE statement.
IF sy-subrc = 0.
Use DEQUEUE_E_TABLE FM
ELSE.
Error Handling.
ENDIF.
Do enddo is used to ensure that there are no locks apart from yours on the table before you update it.
Thanks,
Kartavya -
Updating Z table using BADI CUSTOMER_ADD_DATA_CS
Good morning guys,
I need to update some tables Z through some information that I put in a new tab. The problem is I do not know which method I should use.
If anyone can help me I appreciate it.Lucas,
Just a thought -- BADI CUSTOMER_ADD_DATA_CS seems to be more at a screen flow level. Need caution while updating Z table here.
I would recommend using BADI CUSTOMER_ADD_DATA-CHECK_ALL_DATA/SAVE_DATA methods.
Method CHECK_ALL_DATA will be executed right before saving and has access to all tables which are ready to be updated. Final validations before updating Z tables can be performed here. Develop a FM to update Z table and call it in an UPDATE TASK in this method.
Thanks,
VM. -
To create bapi?(function module for bapi i.e. checks and update table)
Hi all,
I want to know how to create BAPI?. means in function module how i hv to put checks and how i will update database table.
thanks and regards
sgBAPI STEP BY STEP PROCEDURE: -
http://www.sap-img.com/abap/bapi-step-by-step-guidance.htm
BAPI Programming guide: -
http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm
BAPI user guide: -
http://help.sap.com/saphelp_46c/helpdata/en/7e/5e115e4a1611d1894c0000e829fbbd/frameset.htm
Example:-
http://www.erpgenie.com/abap/bapi/example.htm
list of all bapis
http://www.planetsap.com/LIST_ALL_BAPIs.htm -
How to lock a database Z table before updating it through a report program
Hi,
How to lock a database Z table before updating it through a report program and also how to unlock it after my updation.
The whole process is done through report program.Hi,
Go to SE11, in the option 'Lock object' enter the name of your lock,
begin with 'E', suppose 'EXXXX' And create. In tab 'Tables' fill the
table name where the record you want to lock exist and select the
lock mode. Lock mode can be shared and exclusive. If 'shared',
when you lock the record, other can also read data, but can not
modify. If 'exclusive', when you lock the record, other can neither
read nor modify the record. After save and activate, you will get two
function module.'ENQUEUE_EXXXX' to lock record,
'DEQUEUE_EXXXX' to release lock on one record.
When use this function module it only lock one record at a time. It
does not lock the table.
Regards,
Omkaram. -
Check two columns and update other table
HI ,
I have a table called trackCenterline .Below is the table.
What i want to do is If the segmentSequenceID is 1 it should pick the corresponding SegmentID i.e 10001 and Check for the same segment id in other table called TrackSegment which is below. and pick the BeginMilepost of that segmentID and Update That
Milepost in a new table .At end SegmentSequenceID number it should pick ENDMilepost and update
TrackCenterline table.
TrackSegment table
In the below table for 10001 SegmentID it should pick BeginMilepost. For end Number of SegmentSequenceID in above table ID ends at 121 for that end sequenceID It should refer TrackSegment table below and pick EndMilepost and should be updated in another
table Milepost column.
after that a new segment starts with new sequence .and so on ...
bhavanaHi Deepa_Deepu,
According to your description, since the issue regards T-SQL. I will help you move the question in the T-SQL forums at
http://social.technet.microsoft.com/Forums/en-US/home?forum=transactsql. It is appropriate and more experts will assist you.
When you want to check two columns from two tables then return some results and update the third table. I recommend you use join function and combine two tables, then use update select from statement for modifying the Mailpost table. You can refer to the
following T-SQL Statement.
-----using join to connect to two tables
select TrackCenterline.FeatureId,TrackCenterline.SegmentId,
TrackCenterline.SegmentSequenceId,TrackSegment.BeginMilepost,TrackSegment.EndMilepost
from dbo.TrackCenterline join dbo.TrackSegment
on TrackCenterline.SegmentId=TrackSegment.SegmentId
order by TrackCenterline.SegmentId, TrackCenterline.SegmentSequenceId
---the result shows as following.
FeatureId SegmentId SegmentSequenceId BeginMilepost EndMilepost
AMK100011 10001 1 61.0000 61.3740
AMK100012 10001 2 61.0000 61.3740
AMK100013 10001 3 61.0000 61.3740
AMK1000121 10001 121 61.0000 61.3740
AMK100021 10002 1 61.1260 61.7240
AMK100023 10002 3 61.1260 61.7240
AMK100033 10003 3 61.3740 62.9530
-----Then you can use update select from statement to modify the Mailpost table, Or you can post the table structure of Mailpost
And for more information, you can review the following article about update statement.
http://www.techonthenet.com/sql/update.php
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
How do i check the compatability of all my version 3 add-ons with version 4 before updating to vesin 4
Here's the link. It's a long list and unfortunately, it's not in alphabetical order. So it'll take some time to go through them:
https://addons.mozilla.org/en-US/firefox/compatibility/report?from=%2Fzh-CN%2Ffirefox%2Fcompatibility%2Freport -
Before the new add-ons manager it was possible to let Firefox check for updates to extensions at startup, and get information about available updates without having them automatically downloaded and installed. It seems that this is not possible any more - either updates are automatically installed without chance to review, or one has to open the add-ons manager to see the result of the update check. How can I get the old behaviour back?
Mac Books have their own repair routines. I would suggest going to the Macbook usage forum and post there. Perhaps someone there can help. I would suggest a DiskRepair.
Cheers!
DALE -
Do I need external hard drive to back up my iMac before update to mountain lion? My is OS 10.6.8.
First, repair your hard drive and permissions:
Repair the Hard Drive and Permissions
Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
Second, make a bootable backup to an external drive using the Restore option of Disk Utility:
Clone using Restore Option of Disk Utility
1. Open Disk Utility in the Utilities folder.
2. Select the destination volume from the left side list.
3. Click on the Restore tab in the DU main window.
4. Select the destination volume from the left side list and drag
it to the Destination entry field.
5. Select the source volume from the left side list and drag it to
the Source entry field.
6. Double-check you got it right, then click on the Restore button.
Destination means the external backup drive. Source means the internal startup drive.
Third, purchase and download Mountain Lion from the App Store. Be sure you meet the requirements for Mountain Lion:
Upgrading to Mountain Lion
To upgrade to Mountain Lion you must have Snow Leopard 10.6.8 or Lion installed. Purchase and download Mountain Lion from the App Store. Sign in using your Apple ID. Mountain Lion is $19.99 plus tax. The file is quite large, over 4 GBs, so allow some time to download. It would be preferable to use Ethernet because it is nearly four times faster than wireless.
OS X Mountain Lion - System Requirements
Macs that can be upgraded to OS X Mountain Lion
1. iMac (Mid 2007 or newer) - Model Identifier 7,1 or later
2. MacBook (Late 2008 Aluminum, or Early 2009 or newer) - Model Identifier 5,1 or later
3. MacBook Pro (Mid/Late 2007 or newer) - Model Identifier 3,1 or later
4. MacBook Air (Late 2008 or newer) - Model Identifier 2,1 or later
5. Mac mini (Early 2009 or newer) - Model Identifier 3,1 or later
6. Mac Pro (Early 2008 or newer) - Model Identifier 3,1 or later
7. Xserve (Early 2009) - Model Identifier 3,1 or later
To find the model identifier open System Profiler in the Utilities folder. It's displayed in the panel on the right.
Are my applications compatible?
See App Compatibility Table - RoaringApps.
For a complete How-To introduction from Apple see Upgrade to OS X Mountain Lion. -
How to update parent and child tables while updating parent table
I have a parent table EMPLOYEE which includes columns (sysid, serviceno,employeename...) sysid is Primary key, serviceno is Unique key and I have child table DEPENDENT includes columns (sysid,employee_sysid,name,dob...) here again SYSID is primary key for DEPENDENTS table, employee_sysid is Foreign key of EMPLOYEE table.
Now I want to change SYSID (using sequence) in EMPLOYEE table which need to be update in DEPENDENTS table as well
Note: I have 10000 records in EMPLOYEE table as well as I have 5 more child tables which need to update new SYSID.
please help mefirst disable the FOREIGN KEY Constraints.
you can update Parent as well as Child record also with help of trigger.
here i am giving you one examlpe..it may help u.
create table parent(id number primary key,name varchar2(100))
create table child_1(id number primary key,p_id number,dob date,
CONSTRAINT FK_id FOREIGN KEY (p_id) REFERENCES parent (ID))
create table child_2(id number primary key,p_id2 number,addr varchar2(1000),
CONSTRAINT FK_id2 FOREIGN KEY (p_id2) REFERENCES parent (ID))
insert some test data to parent and child tables.
alter table child_2 disable constraint FK_id2
alter table child_1 disable constraint FK_id2
CREATE OR REPLACE TRIGGER delete_child
BEFORE UPDATE ON parent
FOR EACH ROW
BEGIN
UPDATE CHILD_1
SET P_ID=:NEW.ID
WHERE P_ID=:OLD.ID;
UPDATE CHILD_2
SET P_ID2 =:NEW.ID
WHERE P_ID2=:OLD.ID;
END;
then Upadte parent table primary key col and check the child tables.
then enable the constraints... -
PL/SQL Trying to update a table through trigger on the same table
Hi everyone my name is Edwin and I'm new to this forum. I hope I can learn a lot from this community and over time contribute to it.
The problem I'm facing at the moment is a tough one. I need to update a table (table a) with a value called block_id. This block_id is generated by a procedure I have written myself, the end result is stored in another table (table b). This block_id needs to be generated after certain rows of table a get updated with a trans_id. The trans_id is all the same for these rows in table a, but the generated block_id isn't. In my code I use an after update on collumn a of table a trigger. So if the the collumn gets updated the trigger fires. The trigger calls the procedure that generates the block_id and the procedure generates table b with all the block_id's. But then I want to update the rows in table a with the generated block_id in table b. The problem is that this self-deadlocks.
You might think that this would call a recursive trigger, but I have written code in the trigger that checks if the block_id isn't allready filled in on table a.
Also I really need all the values wich get updated (table a), so I believe a before update is also out of the question.
And the first update of table a is done through an erp-packet and I can't get at that code, otherwise I would just have run my code from there.
Message was edited by:
user625855CREATE OR REPLACE TRIGGER block_id_trigger AFTER UPDATE ON unload_details_tab
DECLARE
current_transport_id NUMBER;
check_value NUMBER;
check_block_id NUMBER;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
current_transport_id := get_curent_trans_id; --function that gets the current transport_id
check_value := check_site_and_directive(current_transport_id); --function checks if this transport_id should have a block_id
check_block_id := check_for_block_id(current_transport_id); --function checks if there isn't allready a block_id set.
IF check_value = 1 AND check_block_id = 0 THEN
create_blok_id_table(current_transport_id); --this procedure creates the blok_id in temptable
UPDATE unload_details_tab a SET a.block_id = (SELECT DISTINCT b.blok_id FROM temptable b WHERE b.mark = a.mark_1) WHERE a.transport_id = current_transport_id; --this statement should update the table back, if I leave it out everything works fine, but when I leave it I get the self-deadlock error.
ELSE
null;
END IF;
END block_id_trigger;
Ok, I cleaned the code somewhat.
user625855 -
IMPORTANT: SQL Developer 1.2.1 Check For Updates Notice
Please note:
The Check For Updates notification yesterday and today (16th or 17th Aug) included a file with a number mismatch. This caused SQL Developer to continue to prompt for new Updates. This is also why a new installation of SQL Developer 1.2.1.32.00 prompted for Updates. This error has been repaired. You can now use Check for Updates to update from SQL Developer 1.2 to 1.2.1.
It remains true that after you have run Check for Updates that you must do a second restart. This is related to the framework and is a known issue.Without the second restart you will not be able to invoke the SQL Worksheet.
We have identified 2 errors that will be addressed, with new updates sent out using Check for Updates as soon as we can. These two errors are that reports with Charts do not currently work, and non-privileged users can't view tables.
The team apologizes for the inconvenience.
Regards
Sue Harper
Product ManagerHello Sue,
I just proceeded the update on my working machine too.
The version number what I talked about (on this machine) was 1.1.2.25 before and still is the same after the update.
(This is different from my home machine.)
By the way - I had to restart SQL Dev two times before it realized, that it already has the latest updates. One restart still seems to be not enough.
Yes I know that all the extensions has it's own versions.
But for me the question remains: What is the version info under "Help-> About" (in my case 1.1.0.21.) good for? If this number has a meaning - what is it? and if it has no meaning (and only the version number of every single extension is interesting) why does these version number exist at all?
You said: until then I recommend you use the full download.
Question: Is it guarantied, that (at any time) the full download always has all latest extensions ?
Regards
Andre -
I've a scenerio where i've to updated LIKP table, when user save the HUPAST. I've created the BDC program which update the likp table using VL02N transacton. but when i'm calling the BDC from a BADI its giving a error, as i'm trying to update the same delivery number. (Delivery already updated by user).
I'm now trying using events, i've traced an event CHANGED in object type LIKP , which is fired when HUPAST is saved.
How do i update the event changed ??? and call the bdc program from the event.
pls share .
Sanjuhi,
You can do it PAI under module USER_COMMAND. and you can use standard UPDATE/MODIFY/DELETE statements to update ur database table and make sure u use a commit work after the use of ablove mentioned statements.
kindly check this.
PROCESS BEFORE OUTPUT.
MODULE status_9010.
LOOP WITH CONTROL tab_control.
MODULE move_data_to_table.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP WITH CONTROL tab_control.
MODULE move_data_from_table.
ENDLOOP.
*& Module move_data_to_table OUTPUT
This is to move the data from the internal table to the table control
MODULE move_data_to_table OUTPUT.
This is to move the data from the internal table to the table control
zmpets_mode-modecode,zmpets_range-rangeid,zmpets_servfacto-factor are column name of table control
READ TABLE int_factor INDEX tab_control-current_line.
IF sy-subrc = 0.
zmpets_mode-modecode = int_factor-modecode.
zmpets_range-rangeid = int_factor-rangeid.
zmpets_servfacto-factor = int_factor-factor.
ENDIF.
ENDMODULE. " move_data_to_table OUTPUT
*& Module move_data_from_table INPUT
Date is moved from the table control to the Internal Table
MODULE move_data_from_table INPUT.
To move the data from the table control to internal table 'INT_FACTOR'.
int_factor-modecode = zmpets_mode-modecode.
int_factor-rangeid = zmpets_range-rangeid.
int_factor-factor = zmpets_servfacto-factor.
*here if the data is there, it will modify
MODIFY int_factor INDEX tab_control-current_line.
IF sy-subrc NE 0. "data not exixting in table control . ie new data, then append it
APPEND int_factor.
CLEAR int_factor.
ENDIF.
ENDMODULE. " move_data_from_table INPUT
Also refer to this link:
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
<b>Reward points if found helpful ..
Cheers,
Chandra Sekhar.</b>
Maybe you are looking for
-
How to group by more than one fields in crystal reports
Hi How to create groups in crystal reports by more than one fields, like select fields,aggregate functions from table group by a,b,c
-
Is there a free easy to use data base program I can use to keep track of the books my wife reads. She is constantly borrowing books she has already read. I would like to make her a list to check against. The program should alphabetize automatically a
-
Processor speed after Standby Mode
I have the T400 with Windows XP (32bit). Dual P8600 2.4GHz processors & 3GB memory. Fairly new computer so there is plenty of space. I run a macro out of Excel every day. When I run the program it takes about 15 to 20 mins and Excel struggles to
-
Passing parameters from one form to another
Hi, I'm trying to pass parameters from 1 form to another. I would be able to call the form, but the parameters are not passed to the calling form. I do not know what's the problem. Basically, the 2nd form shows up with blank values in all the fields.
-
I'm trying to set up a sync account but when I get to the window with the "Create a new account" and "Connect" nothing happens when I push either of the buttons.