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

Raise no_more-data and endless loop

Former Member
0 Likes
3,620

Hi all experts,

I am having trouble with raise no_more_data statement. If i don't use it, my code will be endless.

However, if i use it, there is no data inserted in S076 table.
Where should i use it?

Hi all experts,

I am having trouble with raise no_more_data statement. If i don't use it, my code will be endless.

However, if i use it, there is no data inserted in S076 table.
Where should i use it?

12 REPLIES 12
Read only

Former Member
0 Likes
3,548

Hello Sophanith,

If you want to exit the loop you can use the EXIT instruction or declare a variable and assign a value such that if it holds out the loop:

DO n TIMES

if lv_counter = 100.

  EXIT.

endif.

add 1 to lv_counter.

ENDDO

I hope you help.

Read only

0 Likes
3,548

Hi,

I have use exit, but no data inserted in s076 table.

Read only

Former Member
0 Likes
3,548

Hi,

Try like this:


ELSE.

insert S076 from TABLE t_data.


commit work.

raise no_more_data.

ENDIF.

Read only

0 Likes
3,548

Hi,

t_data is the exit table of Structure such as S076....S999, so no need to use insert.
If i try to use insert as you mentioned above, it will give error.

Read only

0 Likes
3,548

Hi,

If it is a User Exit, better use EXIT keyword instead of raising an error(raise no_more_data) as suggested by Pranav Agrawal

Regards

Read only

Former Member
0 Likes
3,548

Hi Sophinath,

I would too suggest you to use EXIT keyword, to fulfill your purpose.

BR/Thanks

Pranav Agrawal

Read only

Former Member
0 Likes
3,548

Hi Sophanith,

pls send the complete code (where exactly you are inserting data into table: S076).

Regards,

Prasad

Read only

0 Likes
3,548

HI,

"Append wa_ta_data to t_data"  is the statement that i used to insert data to s076.
t_data is the default of exit EXIT_RMCAF000_001.

Read only

0 Likes
3,548

Hi,

1. It is clear that, if you need to insert data, then you shoud not raise exception

2. why you are using, RAISE NO_MORE_DATA after ENDLOOP. Based on your conditions satisfied use EXIT statement inside LOOP if you want to comeout.

let me know if it is not clear.

Regards,

Prasad

Read only

0 Likes
3,548

HI,

if i do not use RAISE_NO_MORE_DATA, this code will be endless till time run out.

Any ideas?

Read only

0 Likes
3,548

It is endless loop, i don't know why?


IMPORT keyfgr           TO p_keyfgr              FROM MEMORY ID 'CM_KEYFGR'.
IMPORT vrsioz           TO p_vrsioz              FROM MEMORY ID 'CM_VRSIOZ'.
IMPORT spmon            TO p_spmon               FROM MEMORY ID 'CM_SPMON'.
IMPORT SEL              TO g_sel                 FROM MEMORY ID 'CM_SEL'.
IMPORT num_format       TO g_num_format          FROM MEMORY ID 'CM_NUM_FORMAT'.
IMPORT t445a            TO wa_t445a              FROM MEMORY ID 'CM_T445A'.
IMPORT fcst_filedata    TO GT_fcst_filedata      FROM MEMORY ID 'CM_FCST_FILEDATA'.
IMPORT tmc1k            TO gt_tmc1k[]            FROM MEMORY ID 'CM_TMC1K'.
IMPORT horzncnt         TO gt_horzncnt[]         FROM MEMORY ID 'CM_HORZNCNT'.
IMPORT inputfile_fields TO gt_inputfile_fields[] FROM MEMORY ID 'CM_INPUTFILE_FIELDS'.

LOOP AT GT_horzncnt INTO WA_horzncnt. "COUNT ROW AND COL
ENDLOOP.

"-- Execute Functionality by table Structure
     case i_gstru.
       when 'S076'. "-- Table S076.
"-- Delete Header line at first pass.
         if i_index = 1.

           delete GT_fcst_filedata index 1.

         endif.

LOOP AT GT_fcst_filedata INTO WA_fcst_filedata.

* IF CL EQ 1."WA_horzncnt-ROWNUMBER.
*   LEAVE PROGRAM.
* ENDIF.

   CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
     EXPORTING
       INPUT              = WA_fcst_filedata-FIELD2
    IMPORTING
      OUTPUT             wa_t_data_S076-PMNUX
    EXCEPTIONS
      LENGTH_ERROR       = 1
      OTHERS             = 2
             .

   wa_t_data_S076-ssour = space.
   wa_t_data_S076-WENUX = WA_fcst_filedata-FIELD1.
   wa_t_data_S076-basme = WA_fcst_filedata-FIELD3.
*  wa_t_data_S076-VRSIO = p_vrsioz.


    "-- Check if Field Exists in S076e
    select single * into  wa_c_data_S076e
                    from  S076e
                    where ssour = wa_t_data_S076-ssour
                    and   PMNUX = wa_t_data_S076-PMNUX
                    and   WENUX = wa_t_data_S076-WENUX.

   IF SY-SUBRC <> 0.
     continue. "-- Exit Current Loop Record Processing
   ENDIF.

   v_per_amt_ind = 3.

   DO WA_horzncnt-horzncnt + 1 TIMES.
       v_per_amt_ind = v_per_amt_ind + 1.

             move    v_per_amt_ind       to  v_per_amt_field+22(2).
             assign (v_per_amt_field)    to  <fs_per_amt_idx>.
             if <fs_per_amt_idx> is ASSIGNED.
               move    <fs_per_amt_idx>    to  wa_t_data_S076-ABSAT.
               wa_t_data_S076-SPMON = p_spmon.
               append wa_t_data_S076 to T_DATA.
               ADD 1 TO P_SPMON.
               unassign: <fs_per_amt_idx>.

             ENDIF.
   ENDDO.
   clear wa_t_data_S076.
ENDLOOP.

ENDCASE.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,548

Use the RAISE NO_MORE_DATA when no data was found (when T_DATA[] is empty/initial at end of LOOP/ENDLOOP) and not when last data was found , in this cas exit from LOOP if required and let the FM send data back to caller of the customer-exit.

NB: you should send data back in packet of I_PSIZE  records, so the customer-exit will be called til you raise the NO_MORE_DATA. Read the parameters and enhancement documentation.

Regards,

Raymond