Application Development and Automation 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: 
Read only

internal table in OO method

Former Member
0 Likes
714

Hi,

I am new to ABAP Objects, and I am trying to implement a Business Add-Inn. I have created a new method, where I define an internal table and then use a function to read data and store it.

The problem is, the function ends correctly, and while debugging I can see that the internal table (i_1001) has data. But after the exception check, the program jumps the LOOP instruction and goes directly to the next instruction. What can the problem be?

I am writing the code in case it helps:

-

-


DATA : d_evento TYPE HRTEM_INTEZW-eveid,

d_fecha TYPE HRTEM_INTEZW-adate,

d_linea_1001 TYPE p1001,

d_tipo_evento TYPE objec-objid,

t_l_objeto TYPE STANDARD TABLE OF HROBJECT INITIAL SIZE 1,

t_objeto TYPE HROBJECT.

TYPES : i_tabla_1001 TYPE STANDARD TABLE OF P1001 INITIAL SIZE 0.

DATA: i_1001 TYPE i_tabla_1001.

  • Inicialización de variables locales.

CLEAR : d_linea , d_num_lineas , d_evento, d_fecha , d_linea_1001, d_tipo_evento.

REFRESH : i_1001 . CLEAR : i_1001.

break-point.

  • Se busca el tipo de evento al que está vinculado el evento, para

  • obtener la tipología del evento (que hereda del tipo evento).

REFRESH t_l_objeto.

CLEAR t_objeto.

t_objeto-plvar = '01'.

t_objeto-otype = 'E'.

t_objeto-objid = me->evento.

APPEND t_objeto TO t_l_objeto.

CALL FUNCTION 'RH_READ_INFTY'

EXPORTING

AUTHORITY = 'DISP'

WITH_STRU_AUTH = 'X'

INFTY = '1001'

ISTAT = '1'

BEGDA = d_fecha

ENDDA = '99991231'

TABLES

INNNN = i_1001

OBJECTS = t_l_objeto

EXCEPTIONS

ALL_INFTY_WITH_SUBTY = 1

NOTHING_FOUND = 2

NO_OBJECTS = 3

WRONG_CONDITION = 4

WRONG_PARAMETERS = 5

OTHERS = 6

.

IF SY-SUBRC <> 0.

CASE SY-SUBRC.

WHEN '1'.

MESSAGE 'Infotipos con subtipo especificado al leer inf1001'

TYPE 'E'.

WHEN '2'.

MESSAGE 'No hay datos para la selección del inf 1001'

TYPE 'E'.

WHEN '3'.

MESSAGE 'La tabla de objetos está vacía al leer el inf 1001'

TYPE 'E'.

WHEN '4'.

MESSAGE 'Condición errónea el leer el inf 1001' TYPE 'E'.

WHEN '5'.

MESSAGE 'Parámetros erróneos el leer el inf 1001' TYPE 'E'.

WHEN OTHERS.

MESSAGE 'Error al leer el inf 1001' TYPE 'E'.

ENDCASE.

ENDIF.

LOOP AT i_1001 INTO d_linea_1001 WHERE RSIGN = 'A' AND RELAT = '20' .

d_tipo_evento = d_linea_1001-sobid.

CLEAR d_linea_1001.

ENDLOOP.

me->tipo_evento = d_tipo_evento.

REFRESH t_l_objeto.

-

-


It jumps from the IF control of exceptions to the last instruction (REFRESH t_l_objeto). sy-subrc gets the value 4 while it jumps.

Any idea about what can the problem be?

Thanks in advance.

Nerea.

1 ACCEPTED SOLUTION
Read only

MichaelTe
Contributor
0 Likes
664

Hello Nerea,

perhaps in the internal table there is not a line which mets the condition you give at start of the loop.

> LOOP AT i_1001 INTO d_linea_1001 WHERE RSIGN = 'A' AND RELAT = '20' .

Is there a line in the internal table with field RSIGN containing 'A' and with field RELAT containing '20'?

Regards Michael

5 REPLIES 5
Read only

MichaelTe
Contributor
0 Likes
665

Hello Nerea,

perhaps in the internal table there is not a line which mets the condition you give at start of the loop.

> LOOP AT i_1001 INTO d_linea_1001 WHERE RSIGN = 'A' AND RELAT = '20' .

Is there a line in the internal table with field RSIGN containing 'A' and with field RELAT containing '20'?

Regards Michael

Read only

Former Member
0 Likes
664

Hi,

In ur code, just try the following in the loop..endloop.

LOOP AT i_1001 INTO d_linea_1001.

d_tipo_evento = d_linea_1001-sobid.

CLEAR d_linea_1001.

ENDLOOP.

me->tipo_evento = d_tipo_evento.

Now, if the loop block works and subrc value is zero, the problem is with the WHERE condition in your loop statement.

Try and revert back.

Reward if helpful.

Regards

Read only

Former Member
0 Likes
664

Hi,

I have already tryed coding the LOOP with no WHERE addition, but it does not process the LOOP. Besides, there is a line in the internal table that matchs the where condition, so the problem wouldn't be that.

Thanks.

Nerea.

Read only

0 Likes
664

IN debug mode, what is the value of SY-SUBRC at the statement IF SY-SUBRC <> 0.? Quite possible, your MESSAGE statement is causing the 'jump'.. set the sy-subrc to 0 in debug & see if loops through..

~Suresh

Read only

0 Likes
664

Hi,

I have solved the problem. The sy-subrc is 0, the problem was not that, I have changed it to :

IS SY-SUBRC <> 0.

...

ELSE.

LOOP.

ENDIF.

Ir works now, I suppose the MESSAGE statement was causing the 'jump'...

thank you very much Suresh.

Nerea