2009 Jul 08 4:29 AM
Hi experts,
i am trying to use import and export to avoid another user accessing a table when a user is performing some action on the particular table.
DATA: text1 TYPE c.
IMPORT text1 FROM MEMORY ID 'Y222'.
* IF sy-subrc = 0.
IF text1 = 'X'.
MESSAGE e000(z1) WITH 'SOME USER IS ACCESSING THE PROGRAM'.
* ENDIF.
ELSE.
* DATA: text1 TYPE c VALUE 'X'.
EXPORT text1 = 'X' TO MEMORY ID 'Y222'.
PERFORM update_dbase.
FREE MEMORY ID 'Y222'.
ENDIF.but import not working.
similarly, i tried using GET and SET parameter id', for the same purpose.
DATA : repid1 LIKE sy-repid.
CLEAR repid1.
GET PARAMETER ID 'Y222' FIELD repid1.
IF repid1 = 'YMCONFLA_N'.
MESSAGE e000(z1) WITH 'SOME USER IS ACCESSING THE PROGRAM'.
ELSE.
DATA : repid LIKE sy-repid VALUE 'YMCONFLA_N'.
SET PARAMETER ID 'Y222' FIELD repid.
PERFORM update_dbase.
CLEAR repid.
ENDIF.this also not working.
in PERFORM update_dbase.
loop at itab.
SELECT SINGLE * FROM zy222 WHERE ebeln = itab-ebeln
AND ebelp = itab-item
AND xblnr = itab-xblnr.
IF sy-subrc = 0.
zy222-ebeln = itab-ebeln.
zy222-ebelp = itab-item.
zy222-xblnr = itab-xblnr.
zy222-flag = itab-status.
zy222-eindt = itab-eindt.
zy222-matnr = itab-matnr .
zy222-qty = itab-qty .
MODIFY zy222.
COMMIT WORK.
ELSE.
zy222-ebeln = itab-ebeln.
zy222-ebelp = itab-item.
zy222-xblnr = itab-xblnr.
zy222-flag = itab-status.
zy222-eindt = itab-eindt.
zy222-matnr = itab-matnr .
zy222-qty = itab-qty .
INSERT zy222.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
endloop.i tried using the enqueue and dequeue_eztable FM's. but my TL says not to use that.
is there anyway to achieve the result using these memory id's? and what mistake i am doing here. plz guide me.
thanks,
Sakthi.
Hi experts,
i am trying to use import and export to avoid another user accessing a table when a user is performing some action on the particular table.
DATA: text1 TYPE c.
IMPORT text1 FROM MEMORY ID 'Y222'.
* IF sy-subrc = 0.
IF text1 = 'X'.
MESSAGE e000(z1) WITH 'SOME USER IS ACCESSING THE PROGRAM'.
* ENDIF.
ELSE.
* DATA: text1 TYPE c VALUE 'X'.
EXPORT text1 = 'X' TO MEMORY ID 'Y222'.
PERFORM update_dbase.
FREE MEMORY ID 'Y222'.
ENDIF.but import not working.
similarly, i tried using GET and SET parameter id', for the same purpose.
DATA : repid1 LIKE sy-repid.
CLEAR repid1.
GET PARAMETER ID 'Y222' FIELD repid1.
IF repid1 = 'YMCONFLA_N'.
MESSAGE e000(z1) WITH 'SOME USER IS ACCESSING THE PROGRAM'.
ELSE.
DATA : repid LIKE sy-repid VALUE 'YMCONFLA_N'.
SET PARAMETER ID 'Y222' FIELD repid.
PERFORM update_dbase.
CLEAR repid.
ENDIF.this also not working.
in PERFORM update_dbase.
loop at itab.
SELECT SINGLE * FROM zy222 WHERE ebeln = itab-ebeln
AND ebelp = itab-item
AND xblnr = itab-xblnr.
IF sy-subrc = 0.
zy222-ebeln = itab-ebeln.
zy222-ebelp = itab-item.
zy222-xblnr = itab-xblnr.
zy222-flag = itab-status.
zy222-eindt = itab-eindt.
zy222-matnr = itab-matnr .
zy222-qty = itab-qty .
MODIFY zy222.
COMMIT WORK.
ELSE.
zy222-ebeln = itab-ebeln.
zy222-ebelp = itab-item.
zy222-xblnr = itab-xblnr.
zy222-flag = itab-status.
zy222-eindt = itab-eindt.
zy222-matnr = itab-matnr .
zy222-qty = itab-qty .
INSERT zy222.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
endloop.i tried using the enqueue and dequeue_eztable FM's. but my TL says not to use that.
is there anyway to achieve the result using these memory id's? and what mistake i am doing here. plz guide me.
thanks,
Sakthi.
2009 Jul 08 4:40 AM
Quick question, why is your team lead telling you NOT to use the enqueue functionality? That's what it's there for!
2009 Jul 08 4:45 AM
hi Neil,
I too asked the same, but he said, it gives some problem and asked me to try out using memory id's. so i am trying with these. If you can get a solution, help me.
thanks.
2009 Jul 08 4:52 AM
You need to ask him what these called problems. Using Export / Import is simply not a viable solution.
By not using the enqueue / dequeue you cannot guarantee the integrity of your data.
2009 Jul 08 5:05 AM
Dear sakthi
1. let the code which u had wriiten with import and export be there.Comment that for a moment.
2. write ur code Enqueue and dequeue and test it and it will be working fine...now comment this code.....
uncomment point 1 and show to ur team lead and say it does not work with that. And comment it.
Now uncomment point2 and show to ur teamlead.
Still if he says to use import and export then ask him,whats the problem...since both the codes are infront of him, he has to give u a reasonable answer...
But i believe Enqueue and dequeue should be used for locking DB table entries....and import and export are used for passing data from 1 program to another program.
Regards
Sajid
2009 Jul 08 5:28 AM
hi neil and sajid,
i did the same as you both said, actually,
the output is in alv grid controls(editable) and when the user edits some value and press save button, it should be saved to ztable and during that time, other user can able to c the output but when he edits and press save button, that time only the error message has tobe displayed.
the problem is when i used the enqueue and dequeue FM's, the first user can able to do the work correctly, but when the second user tries to work on it, the output itself not getting displayed and before that itself, the error message is shown.
CALL FUNCTION 'ENQUEUE_EZY222'
EXPORTING
mode_zy222 = 'E'
mandt = sy-mandt.
IF sy-subrc = 0.
MESSAGE e000(z1) WITH 'SOME USER IS ACCESSING THE PROGRAM'.
ELSE.
PERFORM update_dbase.
CALL FUNCTION 'DEQUEUE_EZY222'
EXPORTING
mode_zy222 = 'E'
mandt = sy-mandt.
ENDIF.
2009 Jul 08 6:16 AM
The whole point of enqueue / dequeue is to lock the data when in change mode. If user A is changing the data user B should be allowed to change the data irrespective of whether or not user A has saved his changes.
2009 Jul 08 6:33 AM
Dear Sakthi,
What Neil has said was right.
1. if user A is changing then user B cant go for change mode,he can go for only display mode.
2. in ur code in the PERFORM update_dbase.u can replace with the following code for better performance and modify statement acts as both insert and update(modify),so u need not have seperate code for insert.I dont think in ur program u r using LUW concept (ur perform is not PERFORM update_dbase in update task),so there wont be any need for commit work.
loop at itab.
zy222-ebeln = itab-ebeln.
zy222-ebelp = itab-item.
zy222-xblnr = itab-xblnr.
zy222-flag = itab-status.
zy222-eindt = itab-eindt.
zy222-matnr = itab-matnr .
zy222-qty = itab-qty .
MODIFY zy222.
endloop.Regards
Sajid
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |