Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with SELECT Query by 2 Threads in SAP ABAP

former_member578547
Participant
383

Hi Friends,

I am using Number Range(Numbers) in Z table. When 2 threads are reading same SELECT Query at same time, same number is assigned to required Variable. Can you help me to fix the issue ?

Thanks,

Balaji.T.

10 REPLIES 10

BiberM
Active Participant
214

Your Problem ist the complience to the ACID-principles (https://en.wikipedia.org/wiki/ACID).

From the point of view of thread 2 the database behaves as if thread 1 was not there. Therefor these two accesses need to be serialized. Thread 2 is allowed to pick a number only after thread 1 is finished picking a number. If you need to ensure that there is no missing number in your Z table (thread 1 takes a number but fails to complete) you need to serialize even further.

What parts of your threads need to be serialized highly depends on the needs of your function.

former_member578547
Participant
0 Kudos
214

Hi Michael,

Thank you for your quick reply. I am new to Serializing Concept in SAP ABAP. Please help me to serialize below Select Query(Z Table: ZMAT_XYZ which is having Number Range Values). This below is my Select Query I am using in ABAP code.

SELECT ean_category sequence prefix threshold status
INTO CORRESPONDING FIELDS OF TABLE lt_ean_data
FROM ZMAT_XYZ
WHERE ean_category = 'UC'.

As you understood, 2nd Thread is using same data of Internal table ( LT_EAN_DATA) existed in 1st Thread. Hence 2nd Thread is failing finally.

Thanks,

Balaji.T.

0 Kudos
214

Can you try creating number range object and use that instead of select ??

0 Kudos
214

I guess then u will have to put a lock on the table before reading and release imeediately once done. Try to check for lock in loop like 3 times else give error message.

0 Kudos
214

Dear Balaji

If you are not using number range objects.....

Try to use lock after the select statement.

select * FROM ZMAT_XYZ FOR UPDATE ......

Make sure you issue commit statement to release locks

Regards,

Venkat

former_member578547
Participant
0 Kudos
214

Hi Jyothir,

No , I can't create Number range object as an alternative of ZMAT_XYZ table. ZMAT_XYZ table is having many EAN categories, which is flexible to the Business.

Thanks,

Balaji.T.

0 Kudos
214

As Jelena said: "Please use Comment button to reply to the answers. "Submit your Answer" is meant to add a new answer to the original question. Read "Before answering"."

0 Kudos
214

HI

BADI of MM01 to be used based on material type, number range to be picked.

214

Sorry but how is this relevant to OP's question? This is about assigning a number in a Z table. I've read all the comments and fail to understand how it was deducted that this has anything to do with MM01.

Jelena
Active Contributor
214

SAP provides standard number range functionality exactly for this purpose, this blog can get you started: https://blogs.sap.com/2015/05/29/number-ranges-things-to-keep-in-mind/

Number range is not an alternative to Z table, it allows to simplify generation of new numbers to be used with your Z table.

P.S. Please use Comment button to reply to the answers. "Submit your Answer" is meant to add a new answer to the original question. Read "Before answering".