‎2007 Sep 08 6:35 AM
HI all good morning.
am uploading some data to database using gui_upload FM after completion of upload program will generate a serial number, program is working fine for single user , but when 2 or more user using the same program to upload the data then all data is stored in a single serial number, i want to store the data in different serial number. am using 'enqueue_e_table' and "dequeue_e_table" function modules to lock and unlock the table . but its not working am getting same problem again. please help me to solve this problem.
code:
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
TABNAME = 'zporder'
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.
ENDIF.
Regards
Prajeala.k
Message was edited by:
prajwal k
Message was edited by:
prajwal k
‎2007 Sep 08 6:48 AM
Hello Prajwal,
If you use 'ENQUEUE_E_TABLE' FM,It locks the SE16 Transaction for that table.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
TABNAME = 'zporder' -> it should be Upper case ZPORDER
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
Thanks
Seshu
‎2007 Sep 08 7:02 AM
HI seshu:
i changed table name to upper case am still geting the same problem.
please tell me what is that " It locks the SE16 Transaction for that table".
i dont no how to use lock FM. please explain.
thanks for u r replay .
Regards
prajwal
‎2007 Sep 08 7:54 AM
I have tested, you can lock complete table at SE16 if you use below logic
Lock FM - 'ENQUEUE_E_TABLE'
Unlock FM - 'DEQUEUE_E_TABLE'
Here i am using ZTEST99 Table and i am able to lock complete table
REPORT ZSAI1.
tables : ztest99.
start-of-selection.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZTEST99'
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.
ENDIF.
break sy-uname.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZTEST99'
VARKEY =
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
.
Thanks
Seshu
‎2007 Sep 08 8:08 AM
Hi seshu.
please take a look at my code . am still geting problem.
REPORT zrepp LINE-SIZE 800 MESSAGE-ID aod.
TABLES:zporder,makt,S886,kna1.
DATA : BEGIN OF lv_order1 OCCURS 0.
INCLUDE STRUCTURE zporder.
DATA : END OF lv_order1.
DATA : BEGIN OF lv_order OCCURS 0.
INCLUDE STRUCTURE zporder.
DATA : END OF lv_order.
DATA : BEGIN OF lv_order2 OCCURS 0.
INCLUDE STRUCTURE zporder.
DATA : END OF lv_order2.
DATA : BEGIN OF ITAB OCCURS 0,
SLNO TYPE zporder-SLNO,
END OF ITAB.
DATA : path1 TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : path LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK B1.
start-of-selection.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZPORDER'
VARKEY = sy-mandt
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.
ENDIF.
break sy-uname.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZPORDER'
VARKEY =
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
.
SELECT SLNO INTO lv_order-SLNO FROM ZPORDER.
APPEND lv_order.
ENDSELECT.
SORT lv_order DESCENDING BY SLNO.
DATA : NO TYPE ZPORDER-SLNO,
werks type s886-werks,
maktx type makt-maktx.
LOOP AT lv_order FROM 0 TO 1.
NO = LV_ORDER-SLNO.
ENDLOOP.
NO = NO + 1.
LOOP AT LV_ORDER1.
LV_ORDER1-SLNO = NO .
MODIFY LV_ORDER1.
ENDLOOP.
*************************START Check*******************************
data : num2 type zporder-zser_no,
num1 type zporder-zser_no.
num1 = 1.
write 😕 'Wrong Entries'.
SKIP.
uline.
format color 6 intensified on.
write : sy-vline,'S.No',50'Reason', 150 sy-vline.
format color intensified off.
*format inverse off.
uline.
loop at lv_order1.
data : pr type n.
data : pr1 type n,
PT TYPE N,
pr2 type n.
data : name1 type kna1-name1,
QUT1 TYPE ZPORDER-QTY1,
QUT2 TYPE ZPORDER-QTY1,
QUT3 TYPE ZPORDER-QTY1,
QT1 TYPE ZPORDER-QTY1,
QT2 TYPE ZPORDER-QTY1,
QT3 TYPE ZPORDER-QTY1.
clear : pr1, pr,pr2.
if num1 = lv_order1-zser_no .
num1 = num1 + 1.
customer code check***********************************
*select single werkS from S886 into werks where PKUNAG = lv_order1-cust.
select single werks from s886 into werks where PKUNAG = lv_order1-cust
and werks = lv_order1-werks.
if sy-subrc <> 0.
MESSAGE w008(ykmessage) WITH zporder-cust.
write 😕 sy-vline,lv_order1-zser_no,'Customer Code'.
format color 6 inverse on.
write : lv_order1-cust.
format color off.
format inverse off.
write : 'is not Present',150 sy-vline.
PT = 1.
uline.
else.
pr = 1.
endif.
************************************************************************
******************Plant check*****************************************
select single werks from s886 into werks where werks = lv_order1-werks
.
if werks <> lv_order1-werks.
write : sy-vline,lv_order1-zser_no, 'Plant Name'.
format color 6 inverse on.
write : lv_order1-werks.
format color off.
format inverse off.
write : 'is Not present',150 sy-vline.
PT = 1.
uline.
else.
pr2 = 1.
endif.
************************************************************************
****************material code check***********************************
select single maktx from makt into maktx where matnr = lv_order1-matnr.
if sy-subrc <> 0.
MESSAGE w003(ykmessage) WITH lv_order1-matnr.
write : sy-vline,lv_order1-zser_no, 'Material Code'.
format color 6 inverse on.
write : lv_order1-matnr.
format color off.
format inverse off.
write : 'is Not Present',150 sy-vline.
PT = 1.
uline.
else.
pr1 = 1.
endif.
************************************************************************
order type check ***********************************
if lv_order1-ORDTYPE <> 'ZCR'.
write : sy-vline,lv_order1-zser_no, 'Order type not equal to ZCR', 150
sy-vline.
uline.
PT = 1.
pr1 = 0.
*EXIT.
ENDIF.
************************************************************************
********************date field check**********************************
IF LV_ORDER1-PODATE = 0 OR LV_ORDER1-BILL = 0 OR LV_ORDER1-PRICE = 0.
WRITE : sy-vline,lv_order1-zser_no, 'Please Enter valid Date',150
sy-vline.
uline.
PT = 1.
pr1 = 0.
*EXIT.
ENDIF.
************************************************************************
************************UOM Check*************************************
if LV_ORDER1-MEINS = ' ' .
WRITE : sy-vline,lv_order1-zser_no,'Please Enter the valid UOM',150
SY-VLINE.
ULINE.
PR1 = 0.
PT = 1.
ENDIF.
if pr = 1 AND pr1 = 1 AND pr2 = 1.
move lv_order1 to lv_order2.
append lv_order2.
endif.
else.
************************************************************************
******************serial No repeatation check*************************
data : r type n.
r = 1.
num2 = lv_order1-zser_no.
EXIT.
endif.
************************************************************************
endloop.
if r = 1.
write 😕 'S.No', lv_order1-zser_no,'in zser_no field is repeating'.
endif.
************************************************************************
if pt = 1.
skip 2.
write 😕 ' Correct the wrong Entries then upload to Data Base'.
endif.
skip 3.
write 😕 'Correct Entries'.
SKIP.
uline.
format color 6 intensified on.
write : SY-VLINE,'No ','C.Code ',' Cus.Name '
,' Mat.Code',' Plant ',' QTY1',
' QTY2',' QTY3',' Total QTY', 150 SY-VLINE.
format color intensified off.
**********************Output Display**********************************
loop at lv_order2.
CLEAR QT1.
qut1 = qut1 + lv_order2-qty1.
qut2 = qut2 + lv_order2-qty2.
qut3 = qut3 + lv_order2-qty3.
qt1 = lv_order2-qty1 + lv_order2-qty2 + lv_order2-qty3.
QT2 = QT2 + QT1.
select single name1 from kna1 into name1 where kunnr = lv_order2-cust.
ULINE.
format color 6 inverse on.
write : sy-vline, lv_order2-zser_no.
*format color off.
format color intensified off.
format inverse off.
write : lv_order2-CUST,name1,lv_order2-matnr,
lv_order2-WERKS,lv_order2-QTY1,lv_order2-QTY2,lv_order2-QTY3,QT1,
150 SY-VLINE.
endloop.
uline.
FORMAT COLOR 3 INTENSIFIED ON.
WRITE : SY-VLINE,' Total QTY ',
79 QUT1,QUT2,QUT3,QT2.
************************************************************************
*****************upload to database ZPORDER***************************
IF PT = 0 AND R = 0.
LOOP AT LV_ORDER2.
INSERT ZPORDER FROM LV_ORDER2.
AT LAST.
MESSAGE i010(ykmessage) WITH NO.
ENDAT.
ENDLOOP.
ELSE.
CALL FUNCTION 'COPO_POPUP_TO_GOON'
EXPORTING
TEXTLINE1 = 'You can not upload the Data '
TEXTLINE2 = 'There are some wrong Data'
TEXTLINE3 = 'in flat file '
TITEL = 'Exit the program '
IMPORTING
ANSWER = confirmation.
.
endif.
************************************************************************
*************find phat for flat file**********************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR path.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = 'C:\Order'
def_path = 'e:\'
mask = ',.,..'
mode = 'O'
title = 'OPEN'
IMPORTING
filename = path
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
************************************************************************
************upload function *******************************************
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = path
filetype = 'DAT'
TABLES
data_tab = lv_order1
EXCEPTIONS
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE w008(ykmessage) WITH zporder-cust.
ENDIF.