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

validating of flat file before uploading

Former Member
0 Likes
1,661

hi all,

is there any method to validate a flat file before uploading the records to the database for uploading we may use session or call transaction method.

thanks in advance

hi all,

is there any method to validate a flat file before uploading the records to the database for uploading we may use session or call transaction method.

thanks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
943

Hello Ramesh,

Populate the data into one internal table using (GUI_UPLOAD function module)-> Loop the internal table-> Do the validation for each field of the internal table.

This is a way to validate the data before passing it to a BDC.

Hope this will helpful.

Regards,

Bhavana

Read only

Former Member
0 Likes
943

hi

normally as BDC is processed through screens, the screen validations are already done for the same. in case any error occurs in the processing, it is validated on the screen can be observed in session (in case of session method) or BDCMSGCOLL (in case of calltransaction method).

if you dont want to validate in run time, and want to do all the validations before processing, you can read each record of the uploaded internal table using LOOP statement, and do the necessary validations.

thanks

pavan

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
943

Hi

Populate the data into one internal table using (GUI_UPLOAD function module)-> Loop the internal table-> Do the validation for each field of the internal table.

This is a way to validate the data before passing it to a BDC.

Validation in the sense generally we will check and split the line items while handling with BDC.

Regards,

kumar

Read only

0 Likes
943

can you provide sample code for that

Read only

Former Member
0 Likes
943

For Checking the file Format.

CALL METHOD cl_gui_frontend_services=>file_exist

EXPORTING

file = w_l_file

RECEIVING

result = w_file_fg

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

wrong_parameter = 3

not_supported_by_gui = 4

OTHERS = 5.

and then for data up load in to internal table

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_file

i_begin_col = 1

i_begin_row = 2

i_end_col = 9

i_end_row = 5000

TABLES

intern = it_excel

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

to get the data ino our required format of internal table

LOOP AT it_excel INTO is_excel.

CASE is_excel-col.

WHEN c_col_0001.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = is_excel-value

IMPORTING

date_internal = w_date.

IF sy-subrc <> 0.

MESSAGE i000(ymmm) WITH 'Enter valid Date in Excel'.

ENDIF.

is_data-cdate = w_date. "OB Delivery Creation date

CLEAR:w_date.

WHEN c_col_0002.

is_data-stsan = is_excel-value. "STSA Number

WHEN c_col_0003.

is_data-matnr = is_excel-value. "Material Number

WHEN c_col_0004.

TRANSLATE is_excel-value TO UPPER CASE.

is_data-lgort = is_excel-value. "Storage Location.

WHEN c_col_0005.

is_data-charg = is_excel-value. "Batch Number

WHEN c_col_0006.

is_data-menge = is_excel-value. "Quantity in KG

WHEN c_col_0007.

is_data-chnum = is_excel-value. "Delivery Challan Number

WHEN c_col_0008.

is_data-fagnt = is_excel-value. "Forwarding Agent – 1

WHEN c_col_0009.

is_data-vnumb = is_excel-value. "Vehicle License Plate Number

ENDCASE.

AT END OF row.

APPEND is_data TO it_data.

CLEAR: is_data,is_excel.

ENDAT.

ENDLOOP.

SORT it_data BY cdate.

And then do the validation.

I worked on this.

IF it is use full Give some points.