2008 Apr 20 6:03 AM
Hi
i have to create a BDC Program for updating the entries of standard price of materials by finding accounting view for specified materials
can any one pls let me know the logic and sample code...
its urgent
Thanks
2008 Apr 20 7:24 AM
hi,
this coding might healp you out
REPORT ZMM_AMP_MATERIAL_EXTENSION
NO STANDARD PAGE HEADING LINE-SIZE 255.
TABLES : MAKT,MARC,MBEW.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR TYPE MARA-MATNR,
VERPR(11)," TYPE MBEW-VERPR,
END OF ITAB.
DATA : MAKTX TYPE MAKT-MAKTX,
EKGRP TYPE MARC-EKGRP,
SSQSS TYPE MARC-SSQSS,
QZGTP TYPE MARC-QZGTP,
VPRSV TYPE MBEW-VPRSV,
BKLAS TYPE MBEW-BKLAS,
PEINH(5)." TYPE MBEW-PEINH.
DATA : IT_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
DATA : WA_ITAB LIKE ITAB.
FIELD-SYMBOLS: <FS1> TYPE ANY.
SELECTION-SCREEN BEGIN OF BLOCK DATA WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME DEFAULT 'C:\WINDOWS\Desktop' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK DATA.
SELECTION-SCREEN BEGIN OF BLOCK FRAME .
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT 5(75) TEXT-002.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT 1(30) TEXT-003.
SELECTION-SCREEN COMMENT 31(20) TEXT-004.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT 1(75) TEXT-005.
SELECTION-SCREEN END OF BLOCK FRAME.
INCLUDE BDCRECX1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 24
I_END_ROW = 60000
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
LOOP AT IT_EXCEL.
ASSIGN COMPONENT IT_EXCEL-COL OF STRUCTURE
WA_ITAB TO <FS1>.
<FS1> = IT_EXCEL-VALUE.
AT END OF ROW.
MOVE-CORRESPONDING: WA_ITAB TO ITAB.
APPEND ITAB.
CLEAR WA_ITAB.
ENDAT.
ENDLOOP.
START-OF-SELECTION.
PERFORM OPEN_GROUP.
LOOP AT ITAB.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = ITAB-MATNR
IMPORTING
OUTPUT = ITAB-MATNR.
SELECT SINGLE * FROM MAKT WHERE MATNR EQ ITAB-MATNR.
IF SY-SUBRC EQ 0.
MAKTX = MAKT-MAKTX.
ENDIF.
SELECT SINGLE * FROM MARC WHERE MATNR EQ ITAB-MATNR AND WERKS EQ '1000'.
IF SY-SUBRC EQ 0.
EKGRP = MARC-EKGRP.
SSQSS = MARC-SSQSS.
QZGTP = MARC-QZGTP.
ENDIF.
SELECT SINGLE * FROM MBEW WHERE MATNR EQ ITAB-MATNR.
IF SY-SUBRC EQ 0.
VPRSV = MBEW-VPRSV.
BKLAS = MBEW-BKLAS.
PEINH = MBEW-PEINH.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1_REF-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=AUSW'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR'
ITAB-MATNR.
PERFORM BDC_FIELD USING 'RMMG1-MBRSH'
'M'.
PERFORM BDC_FIELD USING 'RMMG1_REF-MATNR'
ITAB-MATNR.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(13)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=P+'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(03)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(04)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(06)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(09)'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(13)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SCHL'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(12)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(13)'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0080'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1_REF-VTWEG'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-WERKS'
'1004'.
PERFORM BDC_FIELD USING 'RMMG1_REF-WERKS'
'1000'.
PERFORM BDC_FIELD USING 'RMMG1-VKORG'
'1004'.
PERFORM BDC_FIELD USING 'RMMG1_REF-VKORG'
'1000'.
PERFORM BDC_FIELD USING 'RMMG1-VTWEG'
'50'.
PERFORM BDC_FIELD USING 'RMMG1_REF-VTWEG'
'12'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'MVKE-DWERK'
'1004'.
PERFORM BDC_FIELD USING 'MVKE-SKTOF'
'X'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MG03STEUER-TAXKM(01)'.
PERFORM BDC_FIELD USING 'MG03STEUER-TAXKM(01)'
'8'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4200'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'MVKE-DWERK'
'1004'.
PERFORM BDC_FIELD USING 'MVKE-SKTOF'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MVKE-KTGRM'.
PERFORM BDC_FIELD USING 'MVKE-VERSG'
'2'.
PERFORM BDC_FIELD USING 'MVKE-KTGRM'
'04'.
PERFORM BDC_FIELD USING 'MVKE-MTPOS'
'NORM'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MARC-LADGR'.
PERFORM BDC_FIELD USING 'MARA-TRAGR'
'0001'.
PERFORM BDC_FIELD USING 'MARC-LADGR'
'0010'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'MARC-EKGRP'
EKGRP.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=PB01'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'MARC-SSQSS'
SSQSS.
PERFORM BDC_FIELD USING 'MARC-QZGTP'
QZGTP.
PERFORM BDC_DYNPRO USING 'SAPLQPLS' '0100'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMQAM-ARGUMENT'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WEIT'.
PERFORM BDC_FIELD USING 'RMQAM-INSMK'
'X'.
PERFORM BDC_FIELD USING 'RMQAM-HPZ'
'X'.
PERFORM BDC_FIELD USING 'RMQAM-QKZVERF'
'06'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'MARC-SSQSS'
SSQSS.
PERFORM BDC_FIELD USING 'MARC-QZGTP'
QZGTP.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
MAKTX.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MBEW-VERPR'.
PERFORM BDC_FIELD USING 'MBEW-BKLAS'
BKLAS.
PERFORM BDC_FIELD USING 'MBEW-VPRSV'
VPRSV.
PERFORM BDC_FIELD USING 'MBEW-PEINH'
PEINH.
PERFORM BDC_FIELD USING 'MBEW-VERPR'
ITAB-VERPR.
PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=YES'.
PERFORM BDC_TRANSACTION USING 'MM01'.
PERFORM CLOSE_GROUP.
ENDLOOP.