‎2008 Jul 16 6:23 AM
Hi,
I need to upload the ztable with the data given in the excel file.But before uploading I need to do some validation on the fields given in the file.
For example the first field in the file is plant.I need to check whether the value given for the plant in the file exists in T001W table(check table) or not.Similarly for other fields I need to check with the check tables corresponding to them.If the value doesn't exist in the table then it should give a load error as 'Value &&&& not valid for "field".
Can anyone tell me how can I do this validation?
‎2008 Jul 16 6:29 AM
At first upload the excel file to your ABAP program there data will be in the internal table formate.
Validate the data and update the valid records in your custome table.
Regards
Bikas
‎2008 Jul 16 6:36 AM
Hi,
Fetch the data into internal table using gui_upload.
Then fetch the data from T001W into an internal table.
Then to check for your plants,
LOOP AT itab_t001w.
READ TABLE itab_data INTO wa_data WITH KEY werks = wa_t001w-werks.
ENDLOOP.
Proceed like above, itab_data is the internal table where you uplaod your excel data.
Reward if Helpful.
Regards,
Prosenjit.
‎2008 Jul 16 6:48 AM
Hi upload data from flat file by using FM GUI_UPLOAD.
LOOP AT itab.
SELECT SINGLE werks FROM t001w INTO t001w-werks
WHERE werks = itab-werks.
IF SY-SUBRC NE 0.
it_error-field = 'value& field description not available.
APPEND it_error.
CONTINUE.
ENDIF.
then 2nd field check with mapping table...
then 3rd field check with mapping table...
...
.
.
.
.
.
ENDLOOP.
‎2008 Jul 16 6:51 AM
HI,
you need to dowload the data from your flat file to a internal table first. For that you can use FM ' WS_UPLOAD' .
here is a small demo for it,
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'C:\abcd.TXT'
FILETYPE = 'ASC'
TABLES
data_tab = itab
now once you have data in a internal table you can do validations on it in LOOP...........ENDLOOP statement.