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 MM02

Former Member
0 Likes
515

hi,

tell me how we can extend matnr in a plant using bdc.

plz give me also tcode that which tcode are used for it recording

also provide programm codes

i want to update

matnr

plant

storage fields.

plz help me

hi,

tell me how we can extend matnr in a plant using bdc.

plz give me also tcode that which tcode are used for it recording

also provide programm codes

i want to update

matnr

plant

storage fields.

plz help me

3 REPLIES 3
Read only

Former Member
0 Likes
463

Hi,

Try the BAPI 'BAPI_MATERIAL_SAVEDATA' instead of BDC.

Read only

Former Member
0 Likes
463

Hi,

Use the Below Code :

&----


*& Report ZMMGB_MM02PLANPRICE_BDC

*&

&----


*&

*&

&----


report zmmgb_mm02planprice_bdc.

tables : marc.

data: begin of bdcdata occurs 0.

include structure bdcdata.

data: end of bdcdata.

data: w_tcode like sy-tcode, " Transaction code

w_tkstatus like t130m-pstat, " SAP Transaction status

w_anzgstatus like t130m-pstat, " Summary Display status

w_t130m like t130m, " Transaction control: mat.master

w_bilds like t133a-bilds, " Screen sequence

w_dytxt like t133b-dytxt, " View description

w_linex(5) type c, " View # in table

w_line like sy-tabix, " View # on selection screen

w_num like sy-tabix,

w_matnr like mara-matnr, " Material

w_mtart like mara-mtart, " Material type

w_vpsta like mara-vpsta, " Material maintenance status

w_pstat like t134-pstat. " Material type maintenance status

data: begin of it_views occurs 30.

include structure mbildtab. " Selection Views

data: end of it_views.

data : mbrsh(1) type c,

mtart(4) type c,

kzsel(20) type c,

price(14) type c,

pdate(10) type c,

dytxt(20) type c,

pos(2) type n.

data : begin of itab occurs 0,

matnr like mara-matnr, "Material

werks like t001w-werks, "Plant

zplp1 like mbew-zplp1, "Planned Price1

zpld1 like mbew-zpld1, "Planned Price1 Date

end of itab.

parameters : upd as checkbox.

start-of-selection.

check upd eq 'X'.

perform upload_data.

loop at itab.

refresh bdcdata.

perform get_viewpos.

w_linex = w_linex - 17 .

pos = w_linex+2(2).

concatenate 'MSICHTAUSW-KZSEL(' pos ')' into kzsel.

concatenate 'MSICHTAUSW-DYTXT(' pos ')' into dytxt.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MATNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RMMG1-MATNR'

itab-matnr . "'93110989'.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(08)'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

dytxt. "'MSICHTAUSW-DYTXT(05)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using kzsel "'MSICHTAUSW-KZSEL(05)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-WERKS'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

itab-werks. "'7100'.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

move itab-zplp1 to price.

perform bdc_field using 'BDC_CURSOR'

'MBEW-ZPLP1'.

perform bdc_field using 'MBEW-ZPLP1'

price. "'103.00'.

PERFORM convert_date_external.

perform bdc_field using 'MBEW-ZPLD1'

pdate. "'27.03.2008'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

call transaction 'MM02' using bdcdata mode 'A' update 'S'.

clear : itab,price,pdate,pos,w_linex.

endloop.

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata.

endform. "BDC_DYNPRO

----


  • Insert field *

----


form bdc_field using fnam fval.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

append bdcdata.

endform. "BDC_FIELD

&----


*& Form GET_VIEWPOS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_viewpos .

if itab-matnr na sy-abcde.

unpack itab-matnr to itab-matnr.

endif.

select single * from marc where matnr = itab-matnr and

werks = itab-werks.

if sy-subrc eq 0.

w_tcode = 'MM02'. "Change view

endif.

call function 'MATERIAL_INIT'

exporting

tcode = w_tcode

kz_berprf = 'X'

importing

it130m = w_t130m

tkstatus = w_tkstatus

exceptions

no_authority = 1

wrong_call = 2

kstatus_empty = 3

tkstatus_empty = 4

aktyp_tcode_mismatch = 5

tcode_not_found = 6

material_article_mismatch = 7

others = 8.

if sy-subrc <> 0.

write: 'MATERIAL_INIT error code =', sy-subrc.

exit.

endif.

  • 2. Get Material type and maintenance statuses

select single matnr mtart vpsta from mara

into (w_matnr, w_mtart, w_vpsta)

where matnr = itab-matnr.

  • if sy-subrc <> 0.

  • write: 'Material', material, 'not in material master'.

  • exit.

  • endif.

select single pstat from t134 into w_pstat

where mtart = w_mtart.

if sy-subrc <> 0.

write: 'Material type', w_mtart, 'not found'.

endif.

  • 3. Get Screen Sequence for Tcode/Material

call function 'BILDSEQUENZ_IDENTIFY'

exporting

materialart = w_mtart

tcode_ref = w_t130m-trref

importing

bildsequenz = w_bilds

exceptions

wrong_call = 1

not_found = 2

others = 3.

if sy-subrc <> 0.

write: 'BILDSEQUENZ_IDENTIFY error code =', sy-subrc.

exit.

endif.

  • 4. Get Summary status (TransactionMaterialMaterial Type)

call function 'ANZGSTATUS_SETZEN'

exporting

aktyp = w_t130m-aktyp

marastatus = w_vpsta

t134status = w_pstat

tkstatus = w_tkstatus

importing

anzgstatus = w_anzgstatus

exceptions

anzgstatus_empty = 1

wrong_call = 2

others = 3.

if sy-subrc <> 0.

write: 'ANZGSTATUS_SETZEN error code =', sy-subrc.

exit.

endif.

  • 5. Get all selection views:

call function 'SELECTION_VIEWS_FIND'

exporting

bildsequenz = w_bilds

pflegestatus = w_anzgstatus

tables

bildtab = it_views

exceptions

call_wrong = 1

empty_selection = 2

others = 3.

if sy-subrc <> 0.

write: 'SELECTION_VIEWS_FIND error code =', sy-subrc.

exit.

endif.

  • 5. Get view #:

read table it_views with key auswg = 35 . "35 - Costing View 2

if sy-subrc = 0.

w_linex = sy-tabix.

  • else.

  • write: 'View', view, 'not found'.

  • exit.

endif.

endform. " GET_VIEWPOS

&----


*& Form CONVERT_DATE_EXTERNAL

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form convert_date_external .

call function 'CONVERT_DATE_TO_EXTERNAL'

exporting

date_internal = itab-zpld1

importing

date_external = pdate

exceptions

date_internal_is_invalid = 1

others = 2.

if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " CONVERT_DATE_EXTERNAL

&----


*& Form UPLOAD_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form upload_data .

data : file_table type file_table occurs 0,

fwa type file_table,

filename type string,

rc type i.

call method cl_gui_frontend_services=>file_open_dialog

exporting

window_title = 'Open File'

  • DEFAULT_EXTENSION =

  • DEFAULT_FILENAME =

  • FILE_FILTER =

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

  • WITH_ENCODING =

changing

file_table = file_table

rc = rc

  • USER_ACTION =

  • FILE_ENCODING =

exceptions

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

others = 5

.

if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

read table file_table index 1 into fwa.

filename = fwa-filename.

call function 'GUI_UPLOAD'

exporting

filename = filename

filetype = 'DAT'

  • IMPORTING

  • FILELENGTH =

tables

data_tab = itab

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

others = 6 .

if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " UPLOAD_DATA

Regards,

N.

Reward Points if Helpful.

Read only

Former Member
0 Likes
463

Hi Jayant ,

Use Transaction SHDB for recording the transaction MM01.