‎2008 Jul 11 3:20 AM
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...........
‎2008 Jul 11 3:32 AM
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
‎2008 Jul 11 3:47 AM
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...
‎2008 Jul 11 4:13 AM
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.
‎2008 Jul 11 3:33 AM
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..
‎2008 Jul 11 4:18 AM
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