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: 

Uploading info records by using BDC

Former Member
0 Kudos
509

Hi all,

Does any one having knowledge in uploading info records (ME11) by using BDC.

Problem arises when going for multiple scales.

Can any one let me know how proceed this BDC.

Regards,

Raj

2 REPLIES 2

Former Member
0 Kudos
124

Hi

see the sample code for the ME11 BDC

REPORT zmm_info_i_info_rec_upload

NO STANDARD PAGE HEADING

LINE-SIZE 255.

  • Tables

TABLES mara.

  • Standard Include for Selection Screen

INCLUDE bdcrecx1.

  • Internal Table for Upload Data

DATA: BEGIN OF i_info_rec OCCURS 0,

lifnr(010), " Vendor No

matnr(018), " Material No

ekorg(004), " Purchase Orgn

werks(004), " Plant

  • normb(001), " Std (Info Category)

  • General data

  • urzla(003),

  • telf1(016),

  • meins(003),

  • umrez(006),

  • umren(006),

  • Purchase Orgn data 1

aplfz(003), " Planned Delivery Time

ekgrp(003), " Purchase Group

netpr(014), " Net Price

  • waers(005), " Currency

END OF i_info_rec.

  • Parameters

PARAMETERS p_file LIKE rlgrap-filename.

  • At selection-screen on Value Request for file Name

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  • Get the F4 Values for the File

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = p_file.

  • Start Of Selection

START-OF-SELECTION.

*To Upload Flat file

CALL FUNCTION 'UPLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

TABLES

data_tab = i_info_rec

EXCEPTIONS

conversion_error = 1

invalid_table_width = 2

invalid_type = 3

no_batch = 4

unknown_error = 5

gui_refuse_filetransfer = 6

OTHERS = 7.

  • Open the BDC Session

PERFORM open_group.

  • Upload the Data from Internal Table

LOOP AT i_info_rec.

PERFORM bdc_dynpro USING 'SAPMM06I' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EINE-WERKS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'EINA-LIFNR'

i_info_rec-lifnr.

PERFORM bdc_field USING 'EINA-MATNR'

i_info_rec-matnr.

PERFORM bdc_field USING 'EINE-EKORG'

i_info_rec-ekorg.

PERFORM bdc_field USING 'EINE-WERKS'

i_info_rec-werks.

  • Get the Material Type and Populate the Info Category

  • of Standard or Pipeline

CLEAR mara.

SELECT SINGLE mtart INTO mara-mtart FROM mara

WHERE matnr = i_info_rec-matnr.

IF mara-mtart = 'PIPE'.

PERFORM bdc_field USING 'RM06I-PIPEL'

'X'.

ELSE.

PERFORM bdc_field USING 'RM06I-NORMB'

'X'.

ENDIF.

  • General Data

PERFORM bdc_dynpro USING 'SAPMM06I' '0101'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EINA-MAHN1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

  • PERFORM bdc_field USING 'EINA-URZLA'

  • i_info_rec-urzla.

  • PERFORM bdc_field USING 'EINA-TELF1'

  • i_info_rec-telf1.

  • PERFORM bdc_field USING 'EINA-MEINS'

  • i_info_rec-meins.

  • PERFORM bdc_field USING 'EINA-UMREZ'

  • i_info_rec-umrez.

  • PERFORM bdc_field USING 'EINA-UMREN'

  • i_info_rec-umren.

  • Purchase Orgn data 1

PERFORM bdc_dynpro USING 'SAPMM06I' '0102'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EINE-NETPR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'EINE-APLFZ'

i_info_rec-aplfz.

PERFORM bdc_field USING 'EINE-EKGRP'

i_info_rec-ekgrp.

PERFORM bdc_field USING 'EINE-WEBRE'

'X'.

PERFORM bdc_field USING 'EINE-NETPR'

i_info_rec-netpr.

  • PERFORM bdc_field USING 'EINE-WAERS'

  • i_info_rec-waers.

  • Purchase Orgn Data 2

PERFORM bdc_dynpro USING 'SAPMM06I' '0105'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EINE-ANGNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

  • Text Overview Screen

PERFORM bdc_dynpro USING 'SAPMM06I' '0103'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM06I-LTEX1(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

  • Save

PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=YES'.

  • Call The Transaction

PERFORM bdc_transaction USING 'ME11'.

ENDLOOP.

  • Close the BDC Session

PERFORM close_group.

Regards

Anji

Former Member
0 Kudos
124

Goto transaction SHBD enter a recording name and specify the transaction code.

Enter the test data and save it , it will actomatically create a bdc program.

now select that recording name and click create program icon and specify the program name.

This is the program which was created using transaction SHDB for XD01.

include bdcrecx1.

parameters: dataset(132) lower case.

      • DO NOT CHANGE - the generated data section - DO NOT CHANGE ***

*

  • If it is nessesary to change the data section use the rules:

  • 1.) Each definition of a field exists of two lines

  • 2.) The first line shows exactly the comment

  • '* data element: ' followed with the data element

  • which describes the field.

  • If you don't have a data element use the

  • comment without a data element name

  • 3.) The second line shows the fieldname of the

  • structure, the fieldname must consist of

  • a fieldname and optional the character '_' and

  • three numbers and the field length in brackets

  • 4.) Each field must be type C.

*

      • Generated data section with specific formatting - DO NOT CHANGE ***

data: begin of record,

  • data element: KUN16

KUNNR_001(016),

  • data element: BUKRS

BUKRS_002(004),

  • data element: VKORG

VKORG_003(004),

  • data element: VTWEG

VTWEG_004(002),

  • data element: SPART

SPART_005(002),

  • data element: KTOKD

KTOKD_006(004),

  • data element: ANRED

ANRED_007(015),

  • data element: NAME1_GP

NAME1_008(035),

  • data element: SORTL

SORTL_009(010),

  • data element: NAME2_GP

NAME2_010(035),

  • data element: STRAS_GP

STRAS_011(035),

  • data element: PFACH

PFACH_012(010),

  • data element: ORT01_GP

ORT01_013(035),

  • data element: PSTLZ

PSTLZ_014(010),

  • data element: ORT02_GP

ORT02_015(035),

  • data element: PFORT_GP

PFORT_016(035),

  • data element: PSTL2

PSTL2_017(010),

  • data element: LAND1_GP

LAND1_018(003),

  • data element: REGIO

REGIO_019(003),

  • data element: SPRAS

SPRAS_020(002),

  • data element: TELX1

TELX1_021(030),

  • data element: TELF1

TELF1_022(016),

  • data element: TELFX

TELFX_023(031),

  • data element: TELF2

TELF2_024(016),

  • data element: TELTX

TELTX_025(030),

  • data element: TELBX

TELBX_026(015),

  • data element: URL

KNURL_027(132),

  • data element: STCD1

STCD1_028(016),

  • data element: STCD2

STCD2_029(011),

  • data element: BBBNR

BBBNR_030(007),

  • data element: BBSNR

BBSNR_031(005),

  • data element: BUBKZ

BUBKZ_032(001),

  • data element: BRSCH

BRSCH_033(004),

  • data element: LZONE

LZONE_034(010),

  • data element: KUKLA

KUKLA_035(002),

  • data element: BRSCH

BRSCH_036(004),

  • data element: UMSA1

UMSA1_037(020),

  • data element: UWAER

UWAER_038(005),

  • data element: UMJAH

UMJAH_039(004),

  • data element: JMZAH

JMZAH_040(006),

  • data element: JMJAH

JMJAH_041(004),

  • data element: BANKS

BANKS_01_042(003),

  • data element: BANKK

BANKL_01_043(015),

  • data element: BANKN

BANKN_01_044(018),

  • data element: ABLAD

ABLAD_01_045(025),

  • data element: KNKAL

KNFAK_01_046(002),

  • data element: CIVVE

CIVVE_047(001),

  • data element: ANRED_AP

ANRED_01_048(030),

  • data element: ANRED_AP

ANRED_02_049(030),

  • data element: NAMEV_VP

NAMEV_01_050(035),

  • data element: NAMEV_VP

NAMEV_02_051(035),

  • data element: NAME1_GP

NAME1_01_052(035),

  • data element: NAME1_GP

NAME1_02_053(035),

  • data element: TELF1

TELF1_01_054(016),

  • data element: TELF1

TELF1_02_055(016),

  • data element: ABTNR_PA

ABTNR_01_056(004),

  • data element: ABTNR_PA

ABTNR_02_057(004),

  • data element: AKONT

AKONT_058(010),

  • data element: DZTERM

ZTERM_059(004),

  • data element: MAHNA

MAHNA_060(004),

  • data element: BZIRK

BZIRK_061(006),

  • data element: AWAHR

AWAHR_062(003),

  • data element: WAERS_V02D

WAERS_063(005),

  • data element: KALKS

KALKS_064(001),

  • data element: LPRIO

LPRIO_065(002),

  • data element: KZAZU_D

KZAZU_066(001),

  • data element: ANTLF

ANTLF_067(001),

  • data element: PERFK

PERFK_068(002),

end of record.

      • End generated data section ***

start-of-selection.

perform open_dataset using dataset.

perform open_group.

do.

read dataset dataset into record.

if sy-subrc <> 0. exit. endif.

perform bdc_dynpro using 'SAPMF02D' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KTOKD'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

record-KUNNR_001.

perform bdc_field using 'RF02D-BUKRS'

record-BUKRS_002.

perform bdc_field using 'RF02D-VKORG'

record-VKORG_003.

perform bdc_field using 'RF02D-VTWEG'

record-VTWEG_004.

perform bdc_field using 'RF02D-SPART'

record-SPART_005.

perform bdc_field using 'RF02D-KTOKD'

record-KTOKD_006.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-KNURL'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-ANRED'

record-ANRED_007.

perform bdc_field using 'KNA1-NAME1'

record-NAME1_008.

perform bdc_field using 'KNA1-SORTL'

record-SORTL_009.

perform bdc_field using 'KNA1-NAME2'

record-NAME2_010.

perform bdc_field using 'KNA1-STRAS'

record-STRAS_011.

perform bdc_field using 'KNA1-PFACH'

record-PFACH_012.

perform bdc_field using 'KNA1-ORT01'

record-ORT01_013.

perform bdc_field using 'KNA1-PSTLZ'

record-PSTLZ_014.

perform bdc_field using 'KNA1-ORT02'

record-ORT02_015.

perform bdc_field using 'KNA1-PFORT'

record-PFORT_016.

perform bdc_field using 'KNA1-PSTL2'

record-PSTL2_017.

perform bdc_field using 'KNA1-LAND1'

record-LAND1_018.

perform bdc_field using 'KNA1-REGIO'

record-REGIO_019.

perform bdc_field using 'KNA1-SPRAS'

record-SPRAS_020.

perform bdc_field using 'KNA1-TELX1'

record-TELX1_021.

perform bdc_field using 'KNA1-TELF1'

record-TELF1_022.

perform bdc_field using 'KNA1-TELFX'

record-TELFX_023.

perform bdc_field using 'KNA1-TELF2'

record-TELF2_024.

perform bdc_field using 'KNA1-TELTX'

record-TELTX_025.

perform bdc_field using 'KNA1-TELBX'

record-TELBX_026.

perform bdc_field using 'KNA1-KNURL'

record-KNURL_027.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LZONE'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-STCD1'

record-STCD1_028.

perform bdc_field using 'KNA1-STCD2'

record-STCD2_029.

perform bdc_field using 'KNA1-BBBNR'

record-BBBNR_030.

perform bdc_field using 'KNA1-BBSNR'

record-BBSNR_031.

perform bdc_field using 'KNA1-BUBKZ'

record-BUBKZ_032.

perform bdc_field using 'KNA1-BRSCH'

record-BRSCH_033.

perform bdc_field using 'KNA1-LZONE'

record-LZONE_034.

perform bdc_dynpro using 'SAPMF02D' '0125'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-JMJAH'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-KUKLA'

record-KUKLA_035.

perform bdc_field using 'KNA1-BRSCH'

record-BRSCH_036.

perform bdc_field using 'KNA1-UMSA1'

record-UMSA1_037.

perform bdc_field using 'KNA1-UWAER'

record-UWAER_038.

perform bdc_field using 'KNA1-UMJAH'

record-UMJAH_039.

perform bdc_field using 'KNA1-JMZAH'

record-JMZAH_040.

perform bdc_field using 'KNA1-JMJAH'

record-JMJAH_041.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_CURSOR'

'KNBK-BANKN(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNBK-BANKS(01)'

record-BANKS_01_042.

perform bdc_field using 'KNBK-BANKL(01)'

record-BANKL_01_043.

perform bdc_field using 'KNBK-BANKN(01)'

record-BANKN_01_044.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_CURSOR'

'KNBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0340'.

perform bdc_field using 'BDC_CURSOR'

'KNVA-KNFAK(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNVA-ABLAD(01)'

record-ABLAD_01_045.

perform bdc_field using 'KNVA-KNFAK(01)'

record-KNFAK_01_046.

perform bdc_dynpro using 'SAPMF02D' '0340'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0370'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-CIVVE'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNA1-CIVVE'

record-CIVVE_047.

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-ABTNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNVK-ANRED(01)'

record-ANRED_01_048.

perform bdc_field using 'KNVK-ANRED(02)'

record-ANRED_02_049.

perform bdc_field using 'KNVK-NAMEV(01)'

record-NAMEV_01_050.

perform bdc_field using 'KNVK-NAMEV(02)'

record-NAMEV_02_051.

perform bdc_field using 'KNVK-NAME1(01)'

record-NAME1_01_052.

perform bdc_field using 'KNVK-NAME1(02)'

record-NAME1_02_053.

perform bdc_field using 'KNVK-TELF1(01)'

record-TELF1_01_054.

perform bdc_field using 'KNVK-TELF1(02)'

record-TELF1_02_055.

perform bdc_field using 'KNVK-ABTNR(01)'

record-ABTNR_01_056.

perform bdc_field using 'KNVK-ABTNR(02)'

record-ABTNR_02_057.

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0210'.

perform bdc_field using 'BDC_CURSOR'

'KNB1-AKONT'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNB1-AKONT'

record-AKONT_058.

perform bdc_dynpro using 'SAPMF02D' '0215'.

perform bdc_field using 'BDC_CURSOR'

'KNB1-ZTERM'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNB1-ZTERM'

record-ZTERM_059.

perform bdc_dynpro using 'SAPMF02D' '0220'.

perform bdc_field using 'BDC_CURSOR'

'KNB5-MAHNA'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNB5-MAHNA'

record-MAHNA_060.

perform bdc_dynpro using 'SAPMF02D' '0230'.

perform bdc_field using 'BDC_CURSOR'

'KNB1-VRSNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02D' '0310'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNVV-BZIRK'

record-BZIRK_061.

perform bdc_field using 'KNVV-AWAHR'

record-AWAHR_062.

perform bdc_field using 'KNVV-WAERS'

record-WAERS_063.

perform bdc_field using 'KNVV-KALKS'

record-KALKS_064.

perform bdc_dynpro using 'SAPMF02D' '0315'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-LPRIO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNVV-LPRIO'

record-LPRIO_065.

perform bdc_field using 'KNVV-KZAZU'

record-KZAZU_066.

perform bdc_field using 'KNVV-ANTLF'

record-ANTLF_067.

perform bdc_dynpro using 'SAPMF02D' '0320'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-PERFK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNVV-PERFK'

record-PERFK_068.

perform bdc_dynpro using 'SAPMF02D' '1350'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0324'.

perform bdc_field using 'BDC_CURSOR'

'KNVP-PARVW(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_transaction using 'XD01'.

enddo.

perform close_group.

perform close_dataset using dataset.

Reward if found helpful....

Cheers,

Chandra Sekhar.