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 program to upload multiple line items

Former Member
0 Likes
576

hi all,

i am developing bdc program to upload multiple line items for ml10.

i am uploading folling fields

spec_no

astyp

txz01,

sort1,

waers,

matkl,

ekorg,

srvpos ' service number

menge. 'quantity

service number and quantity are line items.

i have developed a code which is taking single record only, it is not working for multiple service no and quantity.

include bdcrecx1.

parameters: filename like rlgrap-filename.

data: begin of record,

SPEC_NO(10),

ASTYP(4),

TXZ01(40),

SORT1(20),

WAERS(5),

MATKL(9),

EKORG(4),

  • NEW_ROW(10),

SRVPOS(18),

MENGE(13),

end of record.

data: itab_program like record occurs 0 with header line.

***

****************************************************

  • At Selection Screen

****************************************************

at selection-screen on value-request for filename.

perform query_filename changing filename.

****************************************************

*START-OF-SELECTION

*****************************************************

start-of-selection.

*-- Upload flat data to ITAB.

perform upload_to_itab.

*{ chg001 -- modified as per requirement

perform open_group.

loop at itab_program.

perform upload_programs.

endloop.

perform close_group.

----


  • FORM UPLOAD_TO_ITAB *

----


  • ........ *

----


form upload_to_itab.

call function 'WS_UPLOAD'

exporting

  • CODEPAGE = ' '

filename = filename

filetype = 'DAT'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

tables

data_tab = itab_program

  • 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 <> 0.

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

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

write : 'File opening error.'.

endif.

endform.

----


  • FORM QUERY_FILENAME *

----


  • ........ *

----


  • --> P_FILENAME *

----


form query_filename changing p_filename.

data : tmp_filename like filename.

call function 'WS_FILENAME_GET'

exporting

def_filename = filename

mask = ',.txt,.txt.'

mode = 'O'

title = 'Select the file to Upload'

importing

filename = tmp_filename

exceptions

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

if sy-subrc = 0.

filename = tmp_filename.

endif.

endform.

*******************************************

*perform open_group.

&----


*& Form UPLOAD_programs

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form upload_programs.

perform bdc_dynpro using 'SAPLMLSM' '0100'.

perform bdc_field using 'BDC_CURSOR'

'TEMP_SPEC-ASTYP'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'TMP_SPEC-SPEC_NO'

ITAB_PROGRAM-SPEC_NO.

perform bdc_field using 'TMP_SPEC-ASTYP'

ITAB_PROGRAM-ASTYP.

*****************************************************************SCREEN1

perform bdc_dynpro using 'SAPLMLSM' '0200'.

perform bdc_field using 'BDC_CURSOR'

'TMP_SPEC-EKORG'.

perform bdc_field using 'BDC_OKCODE'

'=SRV'.

perform bdc_field using 'TMP_SPEC-TXZ01'

ITAB_PROGRAM-TXZ01.

perform bdc_field using 'TMP_SPEC-SORT1'

ITAB_PROGRAM-SORT1.

perform bdc_field using 'TMP_SPEC-WAERS'

ITAB_PROGRAM-WAERS.

perform bdc_field using 'TMP_SPEC-MATKL'

ITAB_PROGRAM-MATKL.

perform bdc_field using 'TMP_SPEC-EKORG'

ITAB_PROGRAM-EKORG.

*****************************************************************END OF SCREEN2

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=BZE'.

*perform bdc_field using 'RM11P-HEADTEXT'

  • ITAB_PROGRAM-TXZ01.

perform bdc_field using 'BDC_SUBSCR'

'SAPLMLSP'.

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=BZE'.

perform bdc_field using 'BDC_CURSOR'

'ESLL-MENGE(01)'.

perform bdc_field using 'ESLL-SRVPOS(01)'

ITAB_PROGRAM-SRVPOS.

perform bdc_field using 'ESLL-MENGE(01)'

ITAB_PROGRAM-MENGE.

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=SAV'.

perform bdc_field using 'BDC_SUBSCR'

'SAPLMLSP'.

perform bdc_transaction using 'ML10'.

endform. " UPLOAD_programs

can any body help me in this regard.

thanks in advance

siva

2 REPLIES 2
Read only

Former Member
0 Likes
433

Hi,

include bdcrecx1.

parameters: filename like rlgrap-filename.

data: begin of record,

SPEC_NO(10),

ASTYP(4),

TXZ01(40),

SORT1(20),

WAERS(5),

MATKL(9),

EKORG(4),

  • NEW_ROW(10),

SRVPOS(18),

MENGE(13),

end of record.

data: itab_program like record occurs 0 with header line.

***

****************************************************

  • At Selection Screen

****************************************************

at selection-screen on value-request for filename.

perform query_filename changing filename.

****************************************************

*START-OF-SELECTION

*****************************************************

start-of-selection.

*-- Upload flat data to ITAB.

perform upload_to_itab.

*{ chg001 -- modified as per requirement

perform open_group.

loop at itab_program.

perform upload_programs.

endloop.

perform close_group.

----


  • FORM UPLOAD_TO_ITAB *

----


  • ........ *

----


form upload_to_itab.

call function 'WS_UPLOAD'

exporting

  • CODEPAGE = ' '

filename = filename

filetype = 'DAT'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

tables

data_tab = itab_program

  • 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 <> 0.

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

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

write : 'File opening error.'.

endif.

endform.

----


  • FORM QUERY_FILENAME *

----


  • ........ *

----


  • --> P_FILENAME *

----


form query_filename changing p_filename.

data : tmp_filename like filename.

call function 'WS_FILENAME_GET'

exporting

def_filename = filename

mask = ',.txt,.txt.'

mode = 'O'

title = 'Select the file to Upload'

importing

filename = tmp_filename

exceptions

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

if sy-subrc = 0.

filename = tmp_filename.

endif.

endform.

*******************************************

*perform open_group.

&----


*& Form UPLOAD_programs

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form upload_programs.

perform bdc_dynpro using 'SAPLMLSM' '0100'.

perform bdc_field using 'BDC_CURSOR'

'TEMP_SPEC-ASTYP'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'TMP_SPEC-SPEC_NO'

ITAB_PROGRAM-SPEC_NO.

perform bdc_field using 'TMP_SPEC-ASTYP'

ITAB_PROGRAM-ASTYP.

*****************************************************************SCREEN1

perform bdc_dynpro using 'SAPLMLSM' '0200'.

perform bdc_field using 'BDC_CURSOR'

'TMP_SPEC-EKORG'.

perform bdc_field using 'BDC_OKCODE'

'=SRV'.

perform bdc_field using 'TMP_SPEC-TXZ01'

ITAB_PROGRAM-TXZ01.

perform bdc_field using 'TMP_SPEC-SORT1'

ITAB_PROGRAM-SORT1.

perform bdc_field using 'TMP_SPEC-WAERS'

ITAB_PROGRAM-WAERS.

perform bdc_field using 'TMP_SPEC-MATKL'

ITAB_PROGRAM-MATKL.

perform bdc_field using 'TMP_SPEC-EKORG'

ITAB_PROGRAM-EKORG.

*****************************************************************END OF SCREEN2

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=BZE'.

*perform bdc_field using 'RM11P-HEADTEXT'

  • ITAB_PROGRAM-TXZ01.

perform bdc_field using 'BDC_SUBSCR'

'SAPLMLSP'.

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=BZE'.

<b>l_no = 0.

loop at i_items into wa_items.</b><b>l_no = l_no + 1.

concatenate 'ESLL-SRVPOS(' l_no ')' into l_srvpos.</b>

perform bdc_field using<b> l_srvpos

wa_items-SRVPOS</b>.

<b>concatenate 'ESLL-MENGE(' l_no ')' into l_menge.</b>

perform bdc_field using <b>l_menge</b>

<b>wa_items-MENGE.</b>

<b>ENDLOOP.</b>

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=SAV'.

perform bdc_field using 'BDC_SUBSCR'

'SAPLMLSP'.

perform bdc_transaction using 'ML10'.

endform. " UPLOAD_programs

declare l_no of type i.

Best regards,

Prashant

Read only

0 Likes
433

hi prasanth,

thanks for ur quick response, i need explanation regarding ur code, hou to upload the flat file.

is that i had to keep two flat files, i had to declaere internal tabla i_items. etc.

thanks in advance

siva