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

regarding bdc

Former Member
0 Likes
409

how to upload a flat file containing records with different views.

thanks

prasanna kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
395

Hi

I believe you are talking about the Material master views.

IF so you can use SAP standard program RMDATIND. This is the most recommend for material master.

Use LSMW with Direct input, which is much easier instead of writing code.

Hope this is what you are expecting.

BR

Sree

3 REPLIES 3
Read only

Former Member
0 Likes
396

Hi

I believe you are talking about the Material master views.

IF so you can use SAP standard program RMDATIND. This is the most recommend for material master.

Use LSMW with Direct input, which is much easier instead of writing code.

Hope this is what you are expecting.

BR

Sree

Read only

0 Likes
395

hi sreekanth it is not suggestable to use standard program to upload data becoz if the flat file contains error records that same gets updated in database .

can u give me code with flat file with different views.

thanks & regards

prasanna kumar

Read only

0 Likes
395

Jaya,

In that case write a preprocessor program, which will take the business file performs all the validations and then creates a new file with vaild records in that. Use this newly created file with SAP standard programs.

In generally for each view of material master, we will create a new program to avoid all sorts of confusion.

Coming to the code.

when file is in Application server

FORM upload_pfile.

OPEN DATASET p_pfile FOR INPUT IN TEXT MODE.

*--Display Error message if file could not be opened.

IF sy-subrc NE 0.

MESSAGE e000 WITH text-029.

EXIT.

ENDIF.

**--Move records one by one to a string and then process

DO.

READ DATASET p_pfile INTO wa_flatfile.

IF sy-subrc = 0.

MOVE wa_flatfile TO tbl_flatfile.

COLLECT tbl_flatfile.

CLEAR: tbl_flatfile,

wa_flatfile.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_pfile.

ENDFORM. " upload_pfile

If the file is on PC

FORM upload_ufile.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_ufile

filetype = c_ftype

TABLES

data_tab = tbl_flatfile

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10.

IF sy-subrc NE 0.

MESSAGE s000 WITH text-052.

ENDIF.

ENDFORM. " upload_ufile

BR

Sree