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

BDC Direct Input

Former Member
0 Likes
394

Hi

can any of you giv me an simple example of BDC Direct input method.

Vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
363

Hi,

TABLES: kna1.

DATA: BEGIN OF itab1 OCCURS 0,

str(255),

END OF itab1.

DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'D:\ABAP EVE\ffile1.txt'

filetype = 'ASC'

TABLES

data_tab = itab1

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

no_authority = 10

OTHERS = 11.

IF sy-subrc <> 0.

WRITE:/ 'sorry'.

ELSE.

LOOP AT itab1.

SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.

APPEND itab2.

ENDLOOP.

IF sy-subrc = 0.

LOOP AT itab2.

WRITE:/ itab2-kunnr,itab2-name1.

INSERT INTO kna1 VALUES itab2.

ENDLOOP.

IF sy-subrc = 0.

WRITE:/ 'inserted'.

ELSE.

WRITE:/ 'not inserted'.

ENDIF.

ELSE.

WRITE:/ 'fail'.

ENDIF.

ENDIF.

Flat file data

10001,Sadney

10003,Yogesh

20005,Madan

Save this flat file in above path.

reward,if it is useful.

Thanks,

Chandu

1 REPLY 1
Read only

Former Member
0 Likes
364

Hi,

TABLES: kna1.

DATA: BEGIN OF itab1 OCCURS 0,

str(255),

END OF itab1.

DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'D:\ABAP EVE\ffile1.txt'

filetype = 'ASC'

TABLES

data_tab = itab1

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

no_authority = 10

OTHERS = 11.

IF sy-subrc <> 0.

WRITE:/ 'sorry'.

ELSE.

LOOP AT itab1.

SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.

APPEND itab2.

ENDLOOP.

IF sy-subrc = 0.

LOOP AT itab2.

WRITE:/ itab2-kunnr,itab2-name1.

INSERT INTO kna1 VALUES itab2.

ENDLOOP.

IF sy-subrc = 0.

WRITE:/ 'inserted'.

ELSE.

WRITE:/ 'not inserted'.

ENDIF.

ELSE.

WRITE:/ 'fail'.

ENDIF.

ENDIF.

Flat file data

10001,Sadney

10003,Yogesh

20005,Madan

Save this flat file in above path.

reward,if it is useful.

Thanks,

Chandu