2009 Mar 02 11:18 PM
Hi guys, I've a problem, I've a table Z and many users use it in dialogue, the program use INSERT and DELETE constantly and the program there is a sentence
INSERT TABLE ITAB FROM ztabla.
When I do a debugger to the program, and I come to the sentence INSERT and want to go to the next step, the program doesn,t go to the next step (F5) because many users use it, anybody can help me please, sry for the bad english
2009 Mar 03 5:47 AM
hi,
you can check for if the record exits or not by checking the sy-subrc and then put the logic of either INSERT or MODIFY the records
FORM INSERT_INTO_TABLE .
LOOP AT it_tab into wa_tab.
INSERT z_tablename FROM wa_tab
*check sy-subrc here to understand if update was suucessful
if sy-subrc = 0.
BREAK_POINT.
COMMIT WORK.
else....
MODIFY table here
ENDLOOP.
ENDFORM. " WRITE_OUT
thanks
2009 Mar 02 11:39 PM
I hope these was some issue in the code, if you want to insert the data into database table ...check the below code.
Adding single lines
TABLES SPFLI.
DATA WA TYPE SPFLI.
WA-CARRID = 'LH'.
WA-CITYFROM = 'WASHINGTON'.
...
INSERT INTO SPFLI VALUES WA.
WA-CARRID = 'UA'.
WA-CITYFROM = 'LONDON'.
...
INSERT SPFLI FROM WA.
SPFLI-CARRID = 'LH'.
SPFLI-CITYFROM = 'BERLIN'.
...
INSERT SPFLI.
Regards,
~Satya
2009 Mar 03 12:22 AM
Thanks Satya, but my problem is "Problem when I use stament INSERT", because many user do UPDATE (INSERT and DELETE) at same table Z and at the same time, so I dont know how to do because the process are queued and this process is in dialogue ...
2009 Mar 03 12:50 AM
Hi,
In that case you need to create lock objects for the table, in this way you can lock the table while updating the table.
Regards,
~Satya
2009 Mar 03 1:13 AM
Exactly, but there's a other problem, this program must be worked for many users at same time, if I created a lock object, only 1 user could be work and the others don't work =(
2009 Mar 03 4:28 AM
HI..,
Just create copy of that table into Z nd lock objects ... Then users do their work with Original table ...
2009 Mar 03 5:00 AM
Hi David,
You are not getting any syntax errors with your INSERT statement ?
INSERT TABLE ITAB FROM ztabla.
Pl. check
thanks\
Mahesh
Edited by: Mahesh Reddy on Mar 3, 2009 6:00 AM
2009 Mar 03 3:18 PM
The stament INSERT works perfectly, the problem is when I use this stament, because many users work with a program and they do INSERT and DELETE on this table Z, when a user work whit this table, others can not, how can I do to all user can UPDATE table Z at the same time
Sry for my bad english ...
La sentencia INSERT funciona perfectamente, el problema se da cuando un usuario trabaja con la transaccion que actualiza la tabla Z y los otros no pueden porque ese usuario la esta bloqueando, y los procesos estan encolados, la pregunta seria como hacer para que todos los usuarios puedan actualizar la tabla Z al mismo tiempo
2009 Mar 03 3:24 PM
The answer is still lock objects. You can lock a single row of the table at a time and then multiple users will be able to update it at the same time.
Please see:
[SAP Locking Concept.|http://help.sap.com/saphelp_47x200/helpdata/EN/c2/2d7037ecc92a7ee10000009b38f8cf/frameset.htm]
Rob
Edited by: Rob Burbank on Mar 3, 2009 10:27 AM
2009 Mar 03 9:44 PM
Thanks Rob, I see that 2 users cant UPDATE the same row in a table, the link is very interesting, thanks you =D
2009 Mar 03 9:47 PM
Hi,
In that case you need to create lock objects for the table, in this way you can lock the table while updating the table.
Regards,
~Satya
2009 Mar 03 9:57 PM
Hi,
As you are doing either INSERT or DELETE, there shouldn't be much complication. You need not to use any locking when you are inserting any value. But when you will delete a data, at that time as well I don't think it should create any problem, as no other user is going to modify the same document. Only problem I can think of, to handing with a deleted data. I think you can lock that particular row, before deletion and before deleting a data, you can do a select and check whether that is a existing data or not. If sy-subrc eq 0, then only you can proceed for deletion.
Kuntal
2009 Mar 03 5:47 AM
hi,
you can check for if the record exits or not by checking the sy-subrc and then put the logic of either INSERT or MODIFY the records
FORM INSERT_INTO_TABLE .
LOOP AT it_tab into wa_tab.
INSERT z_tablename FROM wa_tab
*check sy-subrc here to understand if update was suucessful
if sy-subrc = 0.
BREAK_POINT.
COMMIT WORK.
else....
MODIFY table here
ENDLOOP.
ENDFORM. " WRITE_OUT
thanks