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

Stop Processing

Former Member
0 Likes
657

Hi,

I am uploading a file using Gui_upload and got all entries into a internal table(T_TAB).

1)I found some error and captured those error records.Now I want to stop the processing and raise an error message say 'Error in Input file' and display those error records.It should not go for further processing.

How can i do it??

2)In my table T_TAB,i have material numbers.I want to raise an error message if i found any invalid material numbers and display those error records and system should not do processing?

How Can i do it?

Please its urgent.....

Points will be rewarded...........

5 REPLIES 5
Read only

Former Member
0 Likes
610

Hi Madan,

loop at t_tab table and check for validation....

i.e.

inside loop write a select query where you chek for material validation..

If Sy-subrc not equal to zero..

then stop . and display the error message..

data:
  w_matnr like mara matnr.    " Declare variable
  
  
  loop at t_tab .
  
    select single matnr 
      from mara 
      into w_matnr
     where matnr eq t_tab-matnr.
     
     if sy-subrc ne 0.
     message 'Invalid material ' type 'S' .
       stop.
     endif.
     
  endloop.

Best Regards,

Brijesh

Read only

0 Likes
610

Select stmt inside a loop is a great performance issue and i cant raise an error message because i will not be able to display error records...

Read only

0 Likes
610

Hi Madan,

It will be a performance issue, but we dont have option because all the records are in the internal table and for checking all material it should be processed inside the loop..

As you mentioned above that you want to stop processing if any invalid material occurs..So I suggested you to stop processing using STOP statement.Yo ucan also Print that

invalid material.

Now if you want to display all invalid materials then capture it to another internal table and display it.

If sy-subrc ne 0.
 append t_tab-matnr into t_tab2.
endif.

Best Regards,

Brijesh.

Read only

madan_ullasa
Contributor
0 Likes
610

first method.

loop at the table where you have the records... use an 'if' condition..

if (error).

message 'Error record' type 'E'.

endif..

the process stops...

second method..

capture all the error records in an internal table....

after the processing of the table having the uploaded values, check if the error values internal table is intial. if initial no errors in the uploaded table... if not initial, output this errors and exit out of the prog..

hope this helps and this is what u were looking for..

regards,

Madan..

Read only

Former Member
0 Likes
610

Please, check this code.



LOOP AT t_tab.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    input              = t_tab-matnr
 IMPORTING
   OUTPUT             = t_tab-matnr.
  MODIFY t_tab.
ENDLOOP.

 SELECT matnr
   FROM  mara
    INTO   TABLE t_mara
FOR ALL ENTRIES IN t_tab
  WHERE matnr = t_tab-matnr.
  IF sy-subrc EQ 0.
    LOOP AT t_tab.
       READ TABLE t_mara WITH KEY matnr = t_tab-matnr.
       IF sy-subrc NE 0.
           populate error table
       ENDIF.
    ENDLOOP.
  ENDIF.

Edited by: Rajesh on Jul 11, 2008 8:51 AM