Friday, November 23, 2007

sap bdc program for Upload Material Master - Finish Goods

**********************************************************
* Prepare you excel file as per inter table RECORD
* and paste it in text file for uplaoding
**********************************************************

report ZSH_MATL_UP
no standard page heading line-size 255.

include bdcrecx1.

parameters: dataset(132) lower case.

parameters: Mfile like rlgrap-filename default
'h:\tape_lepage\UPLOAD\MATL.txt'.
PARAMETERS: CTY(2) OBLIGATORY.

data: begin of record occurs 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: XFELD
KZSEL_02_005(001),
* data element: XFELD
KZSEL_04_006(001),
* data element: XFELD
KZSEL_05_007(001),
* data element: XFELD
KZSEL_06_008(001),
********
* data element: XFELD
KZSEL_09_009(001),
*******
* data element: XFELD
KZSEL_12_009(001),
* data element: XFELD
KZSEL_13_010(001),
* data element: XFELD
KZSEL_14_011(001),
* data element: XFELD
KZSEL_15_012(001),
* data element: XFELD
KZSEL_17_013(001),
* data element: XFELD
KZSEL_18_014(001),

* data element: XFELD
KZSEL_11_001(001),
* data element: XFELD
KZSEL_11_005(001),
* data element: XFELD
KZSEL_11_006(001),
* data element: XFELD
KZSEL_11_007(001),
* data element: XFELD
KZSEL_11_008(001),



*** data element: XFELD
** KZSEL_11_013(001),
*** data element: XFELD
** KZSEL_12_014(001),
*** data element: XFELD
** KZSEL_13_015(001),
*** data element: XFELD
** KZSEL_17_016(001),
*** data element: XFELD
** KZSEL_18_017(001),
*** data element: XFELD
** KZSEL_13_018(001),
*** data element: XFELD
** KZSEL_14_019(001),



* data element: WERKS_D
WERKS_020(004),
* data element: LGORT_D
LGORT_021(004),
* data element: VKORG
VKORG_022(004),
* data element: VTWEG
VTWEG_023(002),
* data element: MAKTX
MAKTX_024(040),
* data element: MEINS
MEINS_025(003),
* data element: MATKL
MATKL_026(009),
* data element: SPART
SPART_027(002),
* data element: MTPOS_MARA
MTPOS_MARA_028(004),
* data element: BRGEW
BRGEW_029(017),
* data element: GEWEI
GEWEI_030(003),
* data element: NTGEW
NTGEW_031(017),
* data element: MAKTX
MAKTX_032(040),
* data element: MAKTX
MAKTX_033(040),
* data element: MEINS
MEINS_034(003),
* data element: SPART
SPART_035(002),
* data element: MATKL
MATKL_036(009),
* data element: SKTOF
SKTOF_037(001),
* data element: TAXKM
TAXKM_01_038(001),
* data element: TAXKM
TAXKM_02_039(001),
* data element: MAKTX
MAKTX_040(040),
* data element: TAXKM
TAXKM_03_041(001),
* data element: TAXKM
TAXKM_04_042(001),
* data element: MAKTX
MAKTX_043(040),
* data element: MEINS
MEINS_044(003),
* data element: SPART
SPART_045(002),
* data element: MATKL
MATKL_046(009),
* data element: SKTOF
SKTOF_047(001),
* data element: MAKTX
MAKTX_048(040),
* data element: STGMA
VERSG_049(001),
* data element: MTPOS_MARA
MTPOS_MARA_050(004),
* data element: MTPOS
MTPOS_051(004),
* data element: PROVG
PROVG_052(002),
* data element: MAKTX
MAKTX_053(040),
* data element: MEINS
MEINS_054(003),
* data element: BRGEW
BRGEW_055(017),
* data element: GEWEI
GEWEI_056(003),
* data element: NTGEW
NTGEW_057(017),
* data element: MTVFP
MTVFP_058(002),
* data element: TRAGR
TRAGR_059(004),
* data element: LADGR
LADGR_060(004),
* data element: PRCTR
PRCTR_061(010),


*ADDED
* data element: MAKTX
MAKTX_062_1(040),
* data element: MEINS
MEINS_063_1(003),
* data element: EKGRP
EKGRP_064_1(003),
******

* data element: MAKTX
MAKTX_062(040),
* data element: MEINS
MEINS_063(003),
* data element: EKGRP
EKGRP_064(003),
* data element: DISMM
DISMM_065(002),
* data element: DISPO
DISPO_066(003),
* data element: DISLS
DISLS_067(002),
* data element: BSTMI
BSTMI_068(017),
* data element: BSTMA
BSTMA_069(017),
* data element: MAKTX
MAKTX_070(040),
* data element: BESKZ
BESKZ_071(001),
* data element: LGPRO
LGPRO_072(004),
* data element: RGEKM
RGEKZ_073(001),
* data element: DZEIT
DZEIT_074(003),
* data element: FHORI
FHORI_075(003),
* data element: MAKTX
MAKTX_076(040),
* data element: PERKZ
PERKZ_077(001),
* data element: MTVFP
MTVFP_078(002),
* data element: MAKTX
MAKTX_079(040),
* data element: MAKTX
MAKTX_080(040),
* data element: MEINS
MEINS_081(003),
* data element: LGPRO
LGPRO_082(004),
* data element: DZEIT
DZEIT_083(003),
* data element: MAKTX
MAKTX_084(040),
* data element: MEINS
MEINS_085(003),
* data element: DATTP
IPRKZ_086(001),
* data element: MAKTX
MAKTX_087(040),
* data element: BRGEW
BRGEW_088(017),
* data element: GEWEI
GEWEI_089(003),
* data element: NTGEW
NTGEW_090(017),
* data element: PRCTR
PRCTR_091(010),
* data element: MAKTX
MAKTX_092(040),
* data element: MEINS
MEINS_093(003),
* data element: SPART
SPART_094(002),
* data element: BKLAS
BKLAS_095(004),
* data element: VPRSV
VPRSV_096(001),
* data element: PEINH
PEINH_097(006),
* data element: STPRS
STPRS_098(015),
* data element: MAKTX
MAKTX_099(040),
* data element: MAKTX
MAKTX_100(040),
* data element: MEINS
MEINS_101(003),
* data element: CK_EKALREL
EKALR_102(001),
* data element: HRKFT
HRKFT_103(004),
* data element: AWSLS
AWSLS_104(006),
* data element: PRCTR
PRCTR_105(010),
* data element: CK_LOSGR
LOSGR_106(017),
* data element: MAKTX
MAKTX_107(040),
* data element: BKLAS
BKLAS_108(004),
* data element: VPRSV
VPRSV_109(001),
* data element: PEINH
PEINH_110(006),
* data element: STPRS
STPRS_111(015),
end of record.

*** End generated data section ***

start-of-selection.


CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = MFILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = record
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.
WRITE:/ 'SY-SUBRC:', SY-SUBRC.
ENDIF.



LOOP AT RECORD.

*perform open_dataset using dataset.
*perform open_group.
*
*do.
*
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.

perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(15)'.
perform bdc_field using 'BDC_OKCODE'
'=P+'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
record-KZSEL_02_005.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
record-KZSEL_04_006.
perform bdc_field using 'MSICHTAUSW-KZSEL(05)'
record-KZSEL_05_007.
perform bdc_field using 'MSICHTAUSW-KZSEL(06)'
record-KZSEL_06_008.
*****
perform bdc_field using 'MSICHTAUSW-KZSEL(09)'
record-KZSEL_09_009.
*****
perform bdc_field using 'MSICHTAUSW-KZSEL(12)'
record-KZSEL_12_009.
perform bdc_field using 'MSICHTAUSW-KZSEL(13)'
record-KZSEL_13_010.
perform bdc_field using 'MSICHTAUSW-KZSEL(14)'
record-KZSEL_14_011.
perform bdc_field using 'MSICHTAUSW-KZSEL(15)'
record-KZSEL_15_012.
perform bdc_field using 'MSICHTAUSW-KZSEL(17)'
record-KZSEL_17_013.
perform bdc_field using 'MSICHTAUSW-KZSEL(18)'
record-KZSEL_18_014.



perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_11_001.
perform bdc_field using 'MSICHTAUSW-KZSEL(05)'
record-KZSEL_11_005.
perform bdc_field using 'MSICHTAUSW-KZSEL(06)'
record-KZSEL_11_006.
perform bdc_field using 'MSICHTAUSW-KZSEL(07)'
record-KZSEL_11_007.
perform bdc_field using 'MSICHTAUSW-KZSEL(08)'
record-KZSEL_11_008.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSICHTAUSW-DYTXT(01)'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_dynpro using 'SAPLMGMM' '0070'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSICHTAUSW-DYTXT(14)'.
*perform bdc_field using 'BDC_OKCODE'
* '=ENTR'.
*perform bdc_field using 'MSICHTAUSW-KZSEL(13)'
* record-KZSEL_13_018.
*perform bdc_field using 'MSICHTAUSW-KZSEL(14)'
* record-KZSEL_14_019.


perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-DISPR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-WERKS'
record-WERKS_020.
perform bdc_field using 'RMMG1-LGORT'
record-LGORT_021.
perform bdc_field using 'RMMG1-VKORG'
record-VKORG_022.
perform bdc_field using 'RMMG1-VTWEG'
record-VTWEG_023.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_024.
perform bdc_field using 'MARA-MEINS'
record-MEINS_025.
perform bdc_field using 'MARA-MATKL'
record-MATKL_026.
perform bdc_field using 'MARA-SPART'
record-SPART_027.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_028.
perform bdc_field using 'BDC_CURSOR'
'MARA-NTGEW'.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_029.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_030.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_031.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_032.

perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_033.
perform bdc_field using 'MARA-MEINS'
record-MEINS_034.
perform bdc_field using 'MARA-SPART'
record-SPART_035.
perform bdc_field using 'MARA-MATKL'
record-MATKL_036.
perform bdc_field using 'MVKE-SKTOF'
record-SKTOF_037.
perform bdc_field using 'MG03STEUER-TAXKM(01)'
record-TAXKM_01_038.
perform bdc_field using 'MG03STEUER-TAXKM(02)'
record-TAXKM_02_039.
perform bdc_field using 'BDC_CURSOR'
'MVKE-AUMNG'.
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'
record-MAKTX_040.
perform bdc_field using 'MG03STEUER-TAXKM(03)'
record-TAXKM_03_041.

IF CTY = 'CA'.
perform bdc_field using 'MG03STEUER-TAXKM(04)'
record-TAXKM_04_042.
ENDIF.

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'
record-MAKTX_043.
perform bdc_field using 'MARA-MEINS'
record-MEINS_044.
perform bdc_field using 'MARA-SPART'
record-SPART_045.
perform bdc_field using 'MARA-MATKL'
record-MATKL_046.
perform bdc_field using 'MVKE-SKTOF'
record-SKTOF_047.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_048.
perform bdc_field using 'MVKE-VERSG'
record-VERSG_049.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_050.
perform bdc_field using 'MVKE-MTPOS'
record-MTPOS_051.
perform bdc_field using 'MVKE-PROVG'
record-PROVG_052.
perform bdc_field using 'BDC_CURSOR'
'MVKE-PRAT1'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_053.
perform bdc_field using 'MARA-MEINS'
record-MEINS_054.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_055.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_056.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_057.
perform bdc_field using 'MARC-MTVFP'
record-MTVFP_058.
perform bdc_field using 'MARA-TRAGR'
record-TRAGR_059.
perform bdc_field using 'MARC-LADGR'
record-LADGR_060.
perform bdc_field using 'BDC_CURSOR'
'MARC-PRCTR'.
perform bdc_field using 'MARC-PRCTR'
record-PRCTR_061.

perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_062_1.
perform bdc_field using 'MARA-MEINS'
record-MEINS_063_1.
perform bdc_field using 'MARC-EKGRP'

record-EKGRP_064_1.


perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_062.
perform bdc_field using 'MARA-MEINS'
record-MEINS_063.
perform bdc_field using 'MARC-EKGRP'
record-EKGRP_064.
perform bdc_field using 'BDC_CURSOR'
'MARC-DISPO'.
perform bdc_field using 'MARC-DISMM'
record-DISMM_065.
perform bdc_field using 'MARC-DISPO'
record-DISPO_066.
perform bdc_field using 'MARC-DISLS'
record-DISLS_067.
perform bdc_field using 'MARC-BSTMI'
record-BSTMI_068.
perform bdc_field using 'MARC-BSTMA'
record-BSTMA_069.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_070.
perform bdc_field using 'MARC-BESKZ'
record-BESKZ_071.
perform bdc_field using 'MARC-LGPRO'
record-LGPRO_072.
perform bdc_field using 'MARC-RGEKZ'
record-RGEKZ_073.
perform bdc_field using 'BDC_CURSOR'
'MARC-DZEIT'.
perform bdc_field using 'MARC-DZEIT'
record-DZEIT_074.
perform bdc_field using 'MARC-FHORI'
record-FHORI_075.
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'
record-MAKTX_076.
perform bdc_field using 'MARC-PERKZ'
record-PERKZ_077.
perform bdc_field using 'MARC-MTVFP'
record-MTVFP_078.
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'
record-MAKTX_079.
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'
record-MAKTX_080.
perform bdc_field using 'MARA-MEINS'
record-MEINS_081.
perform bdc_field using 'MARC-LGPRO'
record-LGPRO_082.
perform bdc_field using 'MARC-DZEIT'
record-DZEIT_083.
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'
record-MAKTX_084.
perform bdc_field using 'MARA-MEINS'
record-MEINS_085.
perform bdc_field using 'MARA-IPRKZ'
record-IPRKZ_086.
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'
record-MAKTX_087.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_088.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_089.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_090.
perform bdc_field using 'MARC-PRCTR'
record-PRCTR_091.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_092.
perform bdc_field using 'MARA-MEINS'
record-MEINS_093.
perform bdc_field using 'MARA-SPART'
record-SPART_094.
perform bdc_field using 'BDC_CURSOR'
'MBEW-STPRS'.
perform bdc_field using 'MBEW-BKLAS'
record-BKLAS_095.
perform bdc_field using 'MBEW-VPRSV'
record-VPRSV_096.
perform bdc_field using 'MBEW-PEINH'
record-PEINH_097.
perform bdc_field using 'MBEW-STPRS'
record-STPRS_098.
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'
record-MAKTX_099.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_100.
perform bdc_field using 'BDC_CURSOR'
'MARC-AWSLS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_101.
perform bdc_field using 'MBEW-EKALR'
record-EKALR_102.
perform bdc_field using 'MBEW-HRKFT'
record-HRKFT_103.
perform bdc_field using 'MARC-AWSLS'
record-AWSLS_104.
perform bdc_field using 'MARC-PRCTR'
record-PRCTR_105.
perform bdc_field using 'MARC-LOSGR'
record-LOSGR_106.
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'
record-MAKTX_107.
perform bdc_field using 'MBEW-BKLAS'
record-BKLAS_108.
perform bdc_field using 'MBEW-VPRSV'
record-VPRSV_109.
perform bdc_field using 'MBEW-PEINH'
record-PEINH_110.
perform bdc_field using 'MBEW-STPRS'
record-STPRS_111.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.

**enddo.
**
**perform close_group.
**perform close_dataset using dataset.

No comments:

Blog Archive