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: 

bdc

Former Member
0 Kudos

hi all,

i had to develop bdc program to upload data to ml10. and also i had to upload data

to multiple line items

multiple line items include activity number and quantity correspondingly.

can any body tell me hou to upload data to ml10 multiple line items, and also sample code.

thanks in advance

siva

1 REPLY 1

Former Member
0 Kudos

Hi,

This is bdc program is for purchase order.have alook at it

report ZBH_PURORDER no standard page heading line-size 255.

PARAMETERS:P_FILE LIKE IBIPPARMS-PATH.

DATA FILENAME TYPE STRING.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = sy-cprog

dynpro_number = sy-dynnr

IMPORTING

file_name = P_FILE.

START-OF-SELECTION.

FILENAME = P_FILE.

DATA:BEGIN OF XTAB OCCURS 0,

TYP,

DES(255) TYPE C,

END OF XTAB.

DATA:BEGIN OF ITAB OCCURS 0,

SUPERFIELD LIKE MEPO_TOPLINE-SUPERFIELD,

EKORG LIKE MEPO1222-EKORG,

EKGRP LIKE MEPO1222-EKGRP,

BUKRS LIKE MEPO1222-BUKRS,

END OF ITAB.

DATA:BEGIN OF JTAB OCCURS 0,

N(4) TYPE C,

EMATN LIKE MEPO1211-EMATN,

MENGE(13) TYPE C,

NETPR(13) TYPE C,

NAME1 LIKE MEPO1211-NAME1,

END OF JTAB.

DATA:BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA:DELIMITER VALUE '*'.

DATA A TYPE I.

DATA M(4) TYPE N.

DATA L_FNAM(30) TYPE C.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME

FILETYPE = 'ASC'

TABLES

DATA_TAB = XTAB.

LOOP AT XTAB.

IF XTAB-TYP = 'H'.

SPLIT XTAB-DES AT DELIMITER INTO ITAB-SUPERFIELD ITAB-EKORG ITAB-EKGRP

ITAB-BUKRS.

JTAB-N = JTAB-N + 1.

APPEND ITAB.

ELSEIF XTAB-TYP = 'I'.

SPLIT XTAB-DES AT DELIMITER INTO JTAB-EMATN JTAB-MENGE JTAB-NETPR

JTAB-NAME1.

APPEND JTAB.

ENDIF.

ENDLOOP.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'PORDER'

KEEP = 'X'

USER = SY-UNAME.

LOOP AT ITAB.

A = SY-TABIX.

REFRESH BDCTAB.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'BDC_CURSOR'

'MEPO_TOPLINE-SUPERFIELD'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_OKCODE'

'=MEV4000BUTTON'.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'BDC_CURSOR'

'MEPO1222-EKORG'.

perform bdc_field using 'MEPO1222-EKORG'

ITAB-EKORG.

perform bdc_field using 'MEPO1222-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MEPO1222-BUKRS'

ITAB-BUKRS.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_OKCODE'

'=MEV4001BUTTON'.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'MEPO1222-EKORG'

ITAB-EKORG.

perform bdc_field using 'MEPO1222-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MEPO1222-BUKRS'

ITAB-BUKRS.

M = 1.

LOOP AT JTAB.

IF JTAB-N = A.

WRITE:/ JTAB.

CONCATENATE 'MEPO1211-EMATN(' M ')' INTO L_FNAM.

perform bdc_field using 'BDC_CURSOR'

L_FNAM.

perform bdc_field using L_FNAM

JTAB-EMATN.

CONCATENATE 'MEPO1211-MENGE(' M ')' INTO L_FNAM.

perform bdc_field using L_FNAM

JTAB-MENGE.

CONCATENATE 'MEPO1211-NETPR(' M ')' INTO L_FNAM.

perform bdc_field using L_FNAM

JTAB-NETPR.

CONCATENATE 'MEPO1211-NAME1(' M ')' INTO L_FNAM.

perform bdc_field using L_FNAM

JTAB-NAME1.

M = M + 1.

ENDIF.

ENDLOOP.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'MEPO1222-EKORG'

ITAB-EKORG.

perform bdc_field using 'MEPO1222-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MEPO1222-BUKRS'

ITAB-BUKRS.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_CURSOR'

'MEPO1319-MATKL'.

perform bdc_field using 'MEPO1319-SPINF'

'X'.

perform bdc_field using 'BDC_OKCODE'

'=MESAVE'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'ME21N'

TABLES

DYNPROTAB = BDCTAB.

ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCTAB.

BDCTAB-PROGRAM = PROGRAM.

BDCTAB-DYNPRO = DYNPRO.

BDCTAB-DYNBEGIN = 'X'.

APPEND BDCTAB.

ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCTAB.

BDCTAB-FNAM = FNAM.

BDCTAB-FVAL = FVAL.

APPEND BDCTAB.

ENDFORM.

FLAT FILE:

H1171611000001*1000

ICPU116000*1000

ILEY BOARD1010000*1000

IMOUSE66000*1000

H1171711000001*1000

ICPU580000*1000

H1171701000001*1000

IMOUSE33000*1000

ILEY BOARD1010000*1000

Rgds,

Prajith