Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Customer BDC

Hi all,

Can anyone given me a sol. where i m wrong.Its a customer bdc but when i transfer the data from template then the result of BDC is wrong.

The data is not feed in the right place otherwise the bdc is working fine.

report zbdc_sd_xd01

no standard page heading line-size 255.

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

  • S E L E C T I O N S C R E E N *

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

selection-screen : begin of block b1 with frame.

parameters : p_file like rlgrap-filename obligatory,

mode_a radiobutton group r1,

mode_n radiobutton group r1.

selection-screen : end of block b1.

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

  • I N T E R N A L T A B L E S *

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

data : begin of bdcdata occurs 0.

include structure bdcdata.

data : end of bdcdata.

data: begin of itab occurs 0,

      • First Screen

kunnr like kna1-kunnr,

bukrs like knb1-bukrs,

vkorg like knvv-vkorg,

vtweg like knvv-vtweg,

spart like knvv-spart,

ktokd like kna1-ktokd,

      • Address

anred like kna1-anred,

name1 like kna1-name1,

name2 like kna1-name2,

name3 like kna1-name3,

name4 like kna1-name4,

sortl like kna1-sortl,

ort01 like kna1-ort01,

pstlz like kna1-pstlz,

          • ort02 LIKE kna1-ort02,

land1 like kna1-land1,

regio like kna1-regio,

  • spras like kna1-spras,

telf1 like kna1-telf1,

telf2 like kna1-telf2,

      • Control Data

brsch like kna1-brsch,

lzone like kna1-lzone,

      • CIN

ecc like j_1imocust-j_1iexcd,

regno like j_1imocust-j_1iexrn,

range like j_1imocust-j_1iexrg,

ediv like j_1imocust-j_1iexdi,

comm like j_1imocust-j_1iexco,

cust like j_1imocust-j_1iexcicu,

cst like j_1imocust-j_1icstno,

lst like j_1imocust-j_1ilstno,

      • Contact Person

name01 like knvk-name1,

pafkt01 like knvk-pafkt,

      • Account Management

akont like knb1-akont,

      • Payment Transactions

zwels like knb1-zwels,

      • Sales

vkbur like knvv-vkbur,

kdgrp like knvv-kdgrp,

waers like knvv-waers,

konda like knvv-konda,

kalks like knvv-kalks,

pltyp like knvv-pltyp,

lprio like knvv-lprio,

      • Shipping

vsbed like knvv-vsbed,

  • untto like knvv-untto,

  • uebto like knvv-uebto,

      • Billing Docu

inco1 like knvv-inco1,

inco2 like knvv-inco2,

zterm like knvv-zterm,

ktgrd like knvv-ktgrd,

taxkd1 like knvi-taxkd,

taxkd2 like knvi-taxkd,

end of itab.

data: zmode,

gv_flag.

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

  • AT SELECTION SCREEN ON VALUE REQUEST *

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

at selection-screen on value-request for p_file.

call function 'WS_FILENAME_GET'

exporting

def_filename = space

def_path = space

mask = ',.,..'

mode = space

title = space

importing

filename = p_file

exceptions

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

others = 5.

if sy-subrc <> 0 and sy-subrc <> 3.

message e102(yb) with 'Error Selecting File'(007).

endif.

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

  • S T A R T OF S E L E C T I O N *

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

start-of-selection.

perform upload.

perform process_data.

end-of-selection.

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

  • F O R M U P L O A D *

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

form upload.

call function 'WS_UPLOAD'

exporting

filename = p_file

filetype = 'DAT'

tables

data_tab = itab

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

no_authority = 10

others = 11.

if sy-subrc <> 0.

write: 'ERROR WHILE RUNNING WS_UPLOAD.'.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. "upload

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

  • F O R M P R O C E S S _ D A T A *

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

*perform open_group.

form process_data.

if mode_a eq 'X'.

zmode = 'A'.

elseif mode_n eq 'X'.

zmode = 'E'.

endif.

*start-of-selection.

*perform open_group.

loop at itab.

refresh bdcdata.

clear bdcdata.

perform bdc_dynpro using 'SAPMF02D' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KTOKD'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

      • First Screen

perform bdc_field using 'RF02D-KUNNR' itab-kunnr.

perform bdc_field using 'RF02D-BUKRS' itab-bukrs.

perform bdc_field using 'RF02D-VKORG' itab-vkorg.

perform bdc_field using 'RF02D-VTWEG' itab-vtweg.

perform bdc_field using 'RF02D-SPART' itab-spart.

perform bdc_field using 'RF02D-KTOKD' itab-ktokd.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-TELF2'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

      • Address

perform bdc_field using 'KNA1-ANRED' itab-anred.

perform bdc_field using 'KNA1-NAME1' itab-name1.

perform bdc_field using 'KNA1-NAME2' itab-name2.

perform bdc_field using 'KNA1-NAME3' itab-name3.

perform bdc_field using 'KNA1-NAME4' itab-name4.

perform bdc_field using 'KNA1-SORTL' itab-sortl.

perform bdc_field using 'KNA1-ORT01' itab-ort01.

perform bdc_field using 'KNA1-PSTLZ' itab-pstlz.

          • PERFORM bdc_field USING 'KNA1-ORT02' itab-ort02.

perform bdc_field using 'KNA1-LAND1' itab-land1.

perform bdc_field using 'KNA1-REGIO' itab-regio.

perform bdc_field using 'KNA1-SPRAS' 'EN'. "itab-spras.

perform bdc_field using 'KNA1-TELF1' itab-telf1.

perform bdc_field using 'KNA1-TELF2' itab-telf2.

      • Control Data

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LZONE'.

perform bdc_field using 'BDC_OKCODE'

'=OPFI'.

perform bdc_field using 'KNA1-BRSCH' itab-brsch.

perform bdc_field using 'KNA1-LZONE' itab-lzone.

      • CIN

perform bdc_dynpro using 'SAPLJ1I_MASTER' '0200'.

perform bdc_field using 'BDC_OKCODE'

'=CIN_CUSTOMER_FC2'.

perform bdc_field using 'BDC_CURSOR'

'J_1IMOCUST-J_1IEXCICU'.

perform bdc_field using 'J_1IMOCUST-J_1IEXCD' itab-ecc.

perform bdc_field using 'J_1IMOCUST-J_1IEXRN' itab-regno.

perform bdc_field using 'J_1IMOCUST-J_1IEXRG' itab-range.

perform bdc_field using 'J_1IMOCUST-J_1IEXDI' itab-ediv.

perform bdc_field using 'J_1IMOCUST-J_1IEXCO' itab-comm.

perform bdc_field using 'J_1IMOCUST-J_1IEXCICU' itab-cust.

perform bdc_dynpro using 'SAPLJ1I_MASTER' '0200'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_field using 'BDC_CURSOR'

'J_1IMOCUST-J_1ILSTNO'.

perform bdc_field using 'J_1IMOCUST-J_1ICSTNO' itab-cst.

perform bdc_field using 'J_1IMOCUST-J_1ILSTNO' itab-lst.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-BRSCH' itab-brsch.

perform bdc_field using 'KNA1-LZONE' itab-lzone.

perform bdc_dynpro using 'SAPMF02D' '0125'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-NIELS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-BRSCH' itab-brsch.

perform bdc_dynpro using 'SAPMF02D' '0340'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

      • Contact Person

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-PAFKT(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNVK-NAME1(01)' itab-name01.

perform bdc_field using 'KNVK-PAFKT(01)' itab-pafkt01.

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

      • A/C Management

perform bdc_dynpro using 'SAPMF02D' '0210'.

perform bdc_field using 'BDC_CURSOR'

'KNB1-ZUAWA'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNB1-AKONT' itab-akont.

perform bdc_dynpro using 'SAPMF02D' '0215'.

perform bdc_field using 'BDC_CURSOR'

'KNB1-ZWELS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

      • Payment Transactions

*if itab-kultg ne space. "UC 25.01

perform bdc_field using 'KNB1-ZWELS' itab-zwels.

                    • PERFORM bdc_dynpro USING 'SAPMF02D' '0220'.

                    • PERFORM bdc_field USING 'BDC_CURSOR'

                    • 'KNB5-MAHNA'.

                    • PERFORM bdc_field USING 'BDC_OKCODE'

                    • '/00'.

*endif. "UC 25.01

perform bdc_dynpro using 'SAPMF02D' '0610'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_dynpro using 'SAPMF02D' '0310'.

perform bdc_field using 'BDC_CURSOR'

                    • 'KNVV-PLTYP'.

'KNVV-KALKS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

      • Sales

perform bdc_field using 'KNVV-VKBUR' itab-vkbur.

perform bdc_field using 'KNVV-KDGRP' itab-kdgrp.

perform bdc_field using 'KNVV-WAERS' itab-waers.

perform bdc_field using 'KNVV-KONDA' itab-konda.

perform bdc_field using 'KNVV-KALKS' itab-kalks.

perform bdc_field using 'KNVV-PLTYP' itab-pltyp.

perform bdc_dynpro using 'SAPMF02D' '0315'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-UEBTO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

      • Shipping

perform bdc_field using 'KNVV-LPRIO' itab-lprio.

perform bdc_field using 'KNVV-VSBED' itab-vsbed.

perform bdc_dynpro using 'SAPMF02D' '0320'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-KTGRD'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

      • Billing Document

perform bdc_field using 'KNVV-INCO1' itab-inco1.

perform bdc_field using 'KNVV-INCO2' itab-inco2.

perform bdc_field using 'KNVV-ZTERM' itab-zterm.

perform bdc_field using 'KNVV-KTGRD' itab-ktgrd.

perform bdc_dynpro using 'SAPMF02D' '1350'.

perform bdc_field using 'BDC_CURSOR'

'KNVI-TAXKD(02)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNVI-TAXKD(01)' itab-taxkd1.

perform bdc_field using 'KNVI-TAXKD(02)' itab-taxkd2.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'BDC_CURSOR'

'KNVP-PARVW(01)'.

at last.

gv_flag = 'X'.

endat.

call transaction 'XD01' using bdcdata mode zmode.

clear bdcdata.

refresh bdcdata.

endloop.

endform. "process_data

----


  • FORM open_group *

----


form open_group.

skip.

skip.

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

user = sy-uname

keep = 'X'.

write: /(30) 'BDC_OPEN_GROUP'(i02),

(12) 'returncode:'(i05),

sy-subrc.

endform. "open_group

----


  • FORM bdc_dynpro *

----


form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata.

endform. "bdc_dynpro

----


  • FORM bdc_field *

----


form bdc_field using fnam fval.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

append bdcdata.

endform. "bdc_field

----


  • FORM close_group *

----


form close_group.

call function 'BDC_CLOSE_GROUP'.

write: /(30) 'BDC_CLOSE_GROUP'(i04),

(12) 'returncode:'(i05),

sy-subrc.

endform. "close_group

----


  • FORM bdc_transaction *

----


form bdc_transaction using tcode.

data : l_subrc like sy-subrc.

l_subrc = sy-subrc.

call function 'BDC_INSERT'

exporting

tcode = tcode

tables

dynprotab = bdcdata.

if gv_flag = 'X'.

write: /(25) 'BDC_INSERT'(i03),

tcode,

(12) 'returncode:'(i05),

sy-subrc,' RECORD:',sy-index.

endif.

refresh bdcdata.

endform. "bdc_transaction

----


  • FORM bdc_okcode *

----


form bdc_okcode using fnam value(p_code) type c.

clear bdcdata.

move: 'BDC_OKCODE' to bdcdata-fnam,

p_code to bdcdata-fval.

append bdcdata.

endform. "bdc_okcode

Tags:
Not what you were looking for? View more on this topic or Ask a question