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 notes for mm01 & me21n

Former Member
0 Kudos
128

hi gurus,

i want notes for creating materials and to create purchase order using bdc and to upload some datas using that recording from datas in note pad or any external file with screen shots. if any body sent to it ll be very useful to me...

thanks in advance

arun

2 REPLIES 2

Former Member
0 Kudos
82

Hi,

check the codes for mm01 and me21n.

mm01

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

report ZBHMAT no standard page heading line-size 255.

DATA:BEGIN OF ITAB OCCURS 0,

MATNR LIKE RMMG1-MATNR,

MBRSH LIKE RMMG1-MBRSH,

MTART LIKE RMMG1-MTART,

KZSEL LIKE MSICHTAUSW-KZSEL,

WERKS LIKE RMMG1-WERKS,

VKORG LIKE RMMG1-VKORG,

VTWEG LIKE RMMG1-VTWEG,

MAKTX LIKE MAKT-MAKTX,

MEINS LIKE MARA-MEINS,

SKTOF LIKE MVKE-SKTOF,

TAXKM LIKE MG03STEUER-TAXKM,

GEWEI LIKE MARA-GEWEI,

MTVFP LIKE MARC-MTVFP,

TRAGR LIKE MARA-TRAGR,

LADGR LIKE MARC-LADGR,

END OF ITAB.

DATA BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:/BHARAT/MAT.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = ITAB.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'MATERIAL'

KEEP = 'X'

USER = SY-UNAME

PROG = SY-CPROG.

LOOP AT ITAB.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MATNR'.

perform bdc_field using 'RMMG1-MATNR'

ITAB-MATNR.

perform bdc_field using 'RMMG1-MBRSH'

ITAB-MBRSH.

perform bdc_field using 'RMMG1-MTART'

ITAB-MTART.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-KZSEL(04)'.

perform bdc_field using 'MSICHTAUSW-KZSEL(04)'

ITAB-KZSEL.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-WERKS'.

perform bdc_field using 'RMMG1-WERKS'

ITAB-WERKS.

perform bdc_field using 'RMMG1-VKORG'

ITAB-VKORG.

perform bdc_field using 'RMMG1-VTWEG'

ITAB-VTWEG.

perform bdc_field using 'BDC_OKCODE'

'ENTR'.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MVKE-SKTOF'

ITAB-SKTOF.

perform bdc_field using 'MG03STEUER-TAXKM(01)'

ITAB-TAXKM.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLMGMM' '4200'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MVKE-SKTOF'

ITAB-SKTOF.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARA-GEWEI'

ITAB-GEWEI.

perform bdc_field using 'MARC-MTVFP'

ITAB-MTVFP.

perform bdc_field using 'MARA-TRAGR'

ITAB-TRAGR.

perform bdc_field using 'MARC-LADGR'

ITAB-LADGR.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MM01'

TABLES

DYNPROTAB = BDCTAB.

REFRESH 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.

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

me21n

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

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,

bharat.

0 Kudos
82

hi bharat,

thanks for ur kind reply....

it ll be more helpfull for me, if u can send me with screen shots....

regards,

arun