Application Development 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: 

Uplaoding excel file for BDC program

Former Member
0 Kudos

Hi,

I am making a BDC program to uplaod material pricing condition i want the code to uplaod data with excel file also is at header field name required or not , and is it required to filed remaning filed lenght with zero like as matnr filed lenght is 18 if my code is 1000 is it required to write as 0000000000001000., also what changes are required if i m uplaoding a text file.

regards,

zafra

4 REPLIES 4

Former Member
0 Kudos

Hi,

Since you want to upload through Excel file for your referencr u can give the header name but in Intenal table the header name u might discard.........

Please check ih Conversion Exit is there for the particular field, if it is present,than u can ddirectly update no nedd to for '000...'

Regards

Arbind.

Former Member
0 Kudos

Use Conversion_Exit FM's.

Manas M.

Former Member
0 Kudos

Hi,

For uploading data into internal table from excel before recording you can try doing,

(code}

DATA: it_raw TYPE truxs_t_text_data.

&----


*&Function module called to upload xls data into an internal table

&----


CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_field_seperator = 'X'

i_line_header = 'X'

i_tab_raw_data = it_raw

i_filename = p_file "file path browsed

TABLES

i_tab_converted_data = it_upload[] "int table populated

EXCEPTIONS

conversion_failed = 1 "browsed file's data

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

After uploading data into internal table it_upload,

Then for MATNR field you can apply conversion exit that is,

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' "This FM will append leading zeroes with the material no to 18 length

EXPORTING

INPUT = it_upload-matnr

IMPORTING

OUTPUT = it_upload-matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Hope it helps

Regards

Mansi

0 Kudos

OK