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: 

SELECTsentence returns sy-subrc = 4 in PRD client

Former Member
0 Kudos

Hi;

I´m facing this problem, is a Z development that works ok in DEV client and in PRD client doesn't.

the problem is in a select sentece, this program has been running for a long time and sudenly it fails.

this is the select code original that started failing just yesterday:

SELECT * FROM mchb

WHERE matnr = t_eban-matnr AND

werks = t_eban-reswk AND "utilzar el centro suministrador no el werks

lvorm = ' ' AND "CHAR 1 0 Petición de borrado para datos (todos) de stock lotes

sperc = ' ' AND "CHAR 1 0 Indicador de bloqueo para inventario

clabs > 0. " sacar solo los lotes que tangan saldo.

      • here other sentences

ENDELECT.

this select in PRD client returns sy-subrc = 4, but when i browse the mchb table with se16 tcode it has data, i put the same matnr werks lvorm = '' sperc = '' and clbas > 0 and i get data.

so i decide to change a little bit the code, because i tryed recompilng the Z report in DEV a pass it to PRD again but it didn´t work.

this is the new code tha works ok in DEV client but not in PRD client:

SELECT * INTO TABLE tmchb FROM mchb

WHERE matnr = t_eban-matnr AND

werks = t_eban-reswk AND "utilzar el centro suministrador no el werks

lvorm = '' AND "CHAR 1 0 Petición de borrado para datos (todos) de stock lotes

sperc = '' AND "CHAR 1 0 Indicador de bloqueo para inventario

clabs > 0. " sacar solo los lotes que tangan saldo.

so, as can you see i just created an internal table TMCHB just to take the data in a table, but it displays sy-subrc = 4 again.

Any help.

David Fúnez

Corp. Mandofer

8 REPLIES 8

PedroGuarita
Active Contributor
0 Kudos

Without the rest of the code it's dificult to see what is the problem, the coding seems ok so could you please give more details, for example, the select from EBAN.

0 Kudos

The t_eban table has no problem, it has data.

before the select there is a LOOP to the t_eban table to look for tha MATNR in MCHB.

LOOP AT t_eban.

SELECT * INTO TABLE tmchb FROM mchb

WHERE matnr = t_eban-matnr AND

Thanks on advance

0 Kudos

Yes, i figured that you were doing it in a loop and there would be data in it, otherwise it wouldn't reach that select. Anyway the suggestion to use for all entries instead of the select inside a loop is good and you should consider it, but still doesn't seem to be the cause of the problem. You could try changing the where clause a bit, sometimes = ' ' can be tricky, try something like


...
LVORN NE 'X' and 
SPERC not in ('X','A')
...

this just to see if it returns anything. If this doesn't work, then my guess is that there is a problem with the indexes and you might want to talk to administration to recreate the indexes on that table.

Edited by: Pedro Guarita on Mar 2, 2010 5:30 PM

0 Kudos

I personally dont like select * from <dbtab>

if you can use the fields you want.. that would be nice...

rather than select in side a loop, can you use for all entries of that table... that way some extent of your long run might be reduced.

0 Kudos

hi,

it is a performance if we code select inside loop.

Instead of we can use forallentries.

Try to use the above code which i mentioned.

Former Member
0 Kudos

Hi,

Don't try to use Select and Endselect. Instead of why can not use FORALLENTRIES with SELECT Statement. It will optimize the performance.

Try the below code.

if t_eban is not initial.

SELECT * INTO TABLE tmchb FROM mchb

for all entries in t_eban

WHERE matnr = t_eban-matnr AND

werks = t_eban-reswk AND "utilzar el centro suministrador no el werks

lvorm = '' AND "CHAR 1 0 Petición de borrado para datos (todos) de stock lotes

sperc = '' AND "CHAR 1 0 Indicador de bloqueo para inventario

clabs > 0. " sacar solo los lotes que tangan saldo.

endif.

Edited by: subas Bose on Mar 2, 2010 6:18 PM

Former Member
0 Kudos

Hi,

Check how MATNR is stored in MCHB in production. (with/out leading zero's)

SELECT * FROM mchb

WHERE matnr = t_eban-matnr AND <-- make sure both variables are in sync If possible pad matnr with leading zeros ..

Regards,

Srini.

Former Member
0 Kudos

solved