Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

bdc-call transaction method

this is the bdc program i wrote and its not getting executed. no syntax errors. but the error i am getting is -' unable to read from download file'.

-


REPORT ZSAMPLE_BDC.

  • Table for BDC data

DATA: BEGIN OF tb_bdcdata OCCURS 0.

INCLUDE STRUCTURE bdcdata.

DATA: END OF tb_bdcdata.

  • Messages table for Call Transaction

DATA: BEGIN OF tb_bdcmsg OCCURS 0.

INCLUDE STRUCTURE bdcmsgcoll.

DATA: END OF tb_bdcmsg.

  • Table for reading the file data

DATA: BEGIN OF tb_file OCCURS 0,

mbrsh LIKE mara-mbrsh,

mtart LIKE mara-mtart,

maktx LIKE makt-maktx,

meins LIKE mara-meins,

matkl LIKE mara-matkl,

END OF tb_file.

DATA: w_holddate LIKE sy-datum.

CLEAR w_holddate.

w_holddate = sy-datum - 1.

  • Read the file

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'C:\file.txt'

filetype = 'ASC'

TABLES

data_tab = tb_file

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.

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

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

ENDIF.

  • Fill the BDC data table

LOOP AT tb_file.

PERFORM fill_bdc USING:

  • Initial screen

'SAPLMGMM' '0060' 'X' space space,

space space space 'RMMG1-MBRSH' tb_file-mbrsh,

space space space 'RMMG1-MTART' tb_file-mtart,

space space space 'BDC_OKCODE' 'AUSW',

  • Select views

'SAPLMGMM' '0070' 'X' space space,

space space space 'MSICHTAUSW-KZSEL(01)' 'X',

space space space 'MSICHTAUSW-KZSEL(02)' 'X',

space space space 'BDC_OKCODE' '=ENTR',

  • Basic data 1

'SAPLMGMM' '4004' 'X' space space,

space space space 'MAKT-MAKTX' tb_file-maktx,

space space space 'MARA-MEINS' tb_file-meins,

space space space 'MARA-MATKL' tb_file-matkl,

space space space 'BDC_OKCODE' '=SP02',

  • Basic data 2

'SAPLMGMM' '4004' 'X' space space,

space space space 'BDC_OKCODE' '=BU'.

CALL TRANSACTION 'MM01'

USING tb_bdcdata

MODE 'A'

UPDATE 'S'

MESSAGES INTO tb_bdcmsg.

LOOP AT tb_bdcmsg.

WRITE:/ tb_bdcmsg-msgv1.

ENDLOOP.

CLEAR: tb_bdcmsg,

tb_bdcdata.

REFRESH: tb_bdcmsg,

tb_bdcdata.

ENDLOOP.

&----


*& Form fill_bdc

&----


  • text

----


FORM fill_bdc USING p_prog

p_dynpro

p_dynbegin

p_fnam

p_fval.

CLEAR tb_bdcdata.

tb_bdcdata-program = p_prog.

tb_bdcdata-dynpro = p_dynpro.

tb_bdcdata-dynbegin = p_dynbegin.

tb_bdcdata-fnam = p_fnam.

tb_bdcdata-fval = p_fval.

APPEND tb_bdcdata.

endform.

-


The contents of file.txt are as follows:

'a' 'wood' 'a very big log of wood' kg 'abcd'

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question