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

problem creating vendor

Former Member
0 Likes
759

Hi Guys,

i was just creating a vendor for my own use. while creating vendor using transaction xk01 the account group field is creating problems. Can you please give me an example of step by step creation of a vendor using xk01

3 REPLIES 3
Read only

Former Member
0 Likes
552

Hi,

The account group specifies that whether a Vendor number has to be assigned by us or you wants the system to generate an internal number depending on the different Company Codes and Pur.Orgns'.

Do you wants to creat some vendors using BDC.

Here is the sample code of BDC for vednor creation:

REPORT zmm_vendor_master_upload

NO STANDARD PAGE HEADING

LINE-SIZE 255.

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

  • ABAP Name : ZMM_VENDOR_MASTER_UPLOAD

  • Description : This Program is used to Upload the Vendor Master.

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

  • Modification Log:

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

  • Date Programmer Correction Description

  • ---- ---------- ---------- -----------

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

  • Standard Include for Selection Screen

INCLUDE bdcrecx1.

  • Internal Table for Upload Data

DATA: BEGIN OF i_vendor OCCURS 0,

bukrs(004), " Company Code

ekorg(004), " Purchase Orgn

ktokk(004), " Account Group

  • Address Screen

anred(015), " Title

name1(035), " Name1

sortl(010), " Sort Field

name2(035), " Name2

name3(035), " Contact Person1

name4(035), " Contact Person 2

stras(035), " Street

pfach(010), " PO Box

ort01(035), " City

pstlz(010), " Postal Code

land1(003), " Country

spras(002), " Language

telf1(016), " Telephone No

telfx(031), " Fax Number

lfurl(132), " URL-Mail Id

  • Material Group Characteristics

  • klart(003), " Class Type '010'

  • class(018), " Class 'Vendor'

  • mname_01(030), " Characteristic

  • mname_02(030), " Characteristic

  • mname_03(030), " Characteristic

mwert_01(030), " Charct.Value

mwert_02(030), " Charct.Value

mwert_03(030), " Charct.Value

  • Control Data

emnfr(010), " Manufact.Part No

  • Bank Details

banks_01(003), " Country of Bank1

banks_02(003), " Country of Bank2

bankl_01(015), " Bank Key of 1

bankl_02(015), " Bank Key of 2

bankn_01(018), " Account No Bank1

bankn_02(018), " Account No Bank2

  • Accounting Info

akont(010), " Reconcillation Account

zuawa(003), " Sort Key

fdgrv(010), " Cash Management Group

  • Payment Transactions

zterm(004), " Payment terms

  • reprf(001), " Check Double Inv.

zwels(010), " Payment Method

hbkid(005), " House Bank

  • xpore(001), " Individ.Payment

  • Correspondence

mahns(001), " Dunning Level

xausz(001), " Account Statement

  • Withholding Tax Details

qland(003), " Withholding Tax Country

witht_01(002), " WH tax Type

  • wt_withcd(002), " WH Tax Code

  • wt_subjct(001), " Indicator:WH Tax

  • Purchasing Data

waers(005), " Currency

zterm1(004), " Payment Terms

END OF i_vendor.

  • Data Variables & Constants

CONSTANTS : c_x VALUE 'X'. " Flag

  • Paramters

PARAMETERS: p_file LIKE ibipparms-path. " 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.

  • Open the BDC Session

PERFORM open_group.

  • Upload the File into internal Table

CALL FUNCTION 'UPLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

TABLES

data_tab = i_vendor

EXCEPTIONS

conversion_error = 1

invalid_table_width = 2

invalid_type = 3

no_batch = 4

unknown_error = 5

gui_refuse_filetransfer = 6

OTHERS = 7.

IF sy-subrc <> 0.

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

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

ENDIF.

  • Upload the Data from Internal Table

LOOP AT i_vendor.

PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF02K-KTOKK'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RF02K-BUKRS'

i_vendor-bukrs.

PERFORM bdc_field USING 'RF02K-EKORG'

i_vendor-ekorg.

PERFORM bdc_field USING 'RF02K-KTOKK'

i_vendor-ktokk.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-SPRAS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=KLAS'.

PERFORM bdc_field USING 'LFA1-ANRED'

i_vendor-anred.

PERFORM bdc_field USING 'LFA1-NAME1'

i_vendor-name1.

PERFORM bdc_field USING 'LFA1-SORTL'

i_vendor-sortl.

PERFORM bdc_field USING 'LFA1-NAME2'

i_vendor-name2.

PERFORM bdc_field USING 'LFA1-NAME3'

i_vendor-name3.

PERFORM bdc_field USING 'LFA1-NAME4'

i_vendor-name4.

PERFORM bdc_field USING 'LFA1-STRAS'

i_vendor-stras.

PERFORM bdc_field USING 'LFA1-PFACH'

i_vendor-pfach.

PERFORM bdc_field USING 'LFA1-ORT01'

i_vendor-ort01.

PERFORM bdc_field USING 'LFA1-PSTLZ'

i_vendor-pstlz.

PERFORM bdc_field USING 'LFA1-LAND1'

i_vendor-land1.

PERFORM bdc_field USING 'LFA1-SPRAS'

i_vendor-spras.

PERFORM bdc_field USING 'LFA1-TELF1'

i_vendor-telf1.

PERFORM bdc_field USING 'LFA1-TELFX'

i_vendor-telfx.

PERFORM bdc_field USING 'LFA1-LFURL'

i_vendor-lfurl.

PERFORM bdc_dynpro USING 'SAPLCLCA' '0602'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-KLART'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'RMCLF-KLART'

'010'. "i_vendor-klart.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=AUSW'.

PERFORM bdc_field USING 'RMCLF-CLASS(01)'

'Vendor'."i_vendor-class.

PERFORM bdc_dynpro USING 'SAPLCTMS' '0109'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RCTMS-MWERT(03)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BACK'.

PERFORM bdc_field USING 'RCTMS-MNAME(01)'

'MATERIALGROUP'." i_vendor-mname_01.

PERFORM bdc_field USING 'RCTMS-MNAME(02)'

'MATERIALGROUP'." i_vendor-mname_02.

PERFORM bdc_field USING 'RCTMS-MNAME(03)'

'MATERIALGROUP'." i_vendor-mname_03.

PERFORM bdc_field USING 'RCTMS-MWERT(01)'

i_vendor-mwert_01.

PERFORM bdc_field USING 'RCTMS-MWERT(02)'

i_vendor-mwert_02.

PERFORM bdc_field USING 'RCTMS-MWERT(03)'

i_vendor-mwert_03.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENDE'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-ANRED'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-EMNFR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'LFA1-EMNFR'

i_vendor-emnfr.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKN(02)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'LFBK-BANKS(01)'

i_vendor-banks_01.

PERFORM bdc_field USING 'LFBK-BANKS(02)'

i_vendor-banks_02.

PERFORM bdc_field USING 'LFBK-BANKL(01)'

i_vendor-bankl_01.

PERFORM bdc_field USING 'LFBK-BANKL(02)'

i_vendor-bankl_02.

PERFORM bdc_field USING 'LFBK-BANKN(01)'

i_vendor-bankn_01.

PERFORM bdc_field USING 'LFBK-BANKN(02)'

i_vendor-bankn_02.

  • PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • 'LFBK-BANKS(01)'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=VW'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFB1-FDGRV'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'LFB1-AKONT'

i_vendor-akont.

PERFORM bdc_field USING 'LFB1-ZUAWA'

i_vendor-zuawa.

PERFORM bdc_field USING 'LFB1-FDGRV'

i_vendor-fdgrv.

PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFB1-XPORE'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'LFB1-ZTERM'

i_vendor-zterm.

PERFORM bdc_field USING 'LFB1-REPRF'

c_x. "i_vendor-reprf.

PERFORM bdc_field USING 'LFB1-ZWELS'

i_vendor-zwels.

PERFORM bdc_field USING 'LFB1-HBKID'

i_vendor-hbkid.

PERFORM bdc_field USING 'LFB1-XPORE'

c_x. "i_vendor-xpore.

PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFB5-MAHNS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'LFB5-MAHNS'

i_vendor-mahns.

PERFORM bdc_field USING 'LFB1-XAUSZ'

i_vendor-xausz.

PERFORM bdc_dynpro USING 'SAPMF02K' '0610'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBW-WT_SUBJCT(01)'.

PERFORM bdc_field USING 'LFB1-QLAND'

i_vendor-qland.

PERFORM bdc_field USING 'LFBW-WITHT(01)'

i_vendor-witht_01.

  • PERFORM bdc_field USING 'LFBW-WT_WITHCD(01)'

  • i_vendor-wt_withcd.

PERFORM bdc_field USING 'LFBW-WT_SUBJCT(01)'

c_x.

PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFM1-ZTERM'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_field USING 'LFM1-WAERS'

i_vendor-waers.

PERFORM bdc_field USING 'LFM1-ZTERM'

i_vendor-zterm1.

PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF02K-LIFNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=VW'.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=YES'.

  • Call the Transaction

PERFORM bdc_transaction USING 'XK01'.

ENDLOOP.

  • Close the BDc Session

PERFORM close_group.

Regards,

Anji

Read only

Former Member
0 Likes
552

hi,

Go through this program(creation of vendor).Using session method

report z_bdc_kiran

no standard page heading line-size 255.

data:begin of itab occurs 0,

bukrs like rf02k-bukrs,

ktokk like rf02k-ktokk,

anred like lfa1-anred,

name1 like lfa1-name1,

sortl like lfa1-sortl,

land1 like lfa1-land1,

end of itab.

data:it_bdc type table of bdcdata with header line,

it_messages type table of bdcmsgcoll with header line,

it_mess(125),cnt type i.

*include bdcrecx1.

start-of-selection.

perform upload.

loop at itab.

perform bdc_dynpro using 'SAPMF02K' '0105'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-BUKRS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-BUKRS'

itab-bukrs.

perform bdc_field using 'RF02K-KTOKK'

itab-ktokk.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-ANRED'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'LFA1-ANRED'

itab-anred.

perform bdc_field using 'LFA1-NAME1'

itab-name1.

perform bdc_field using 'LFA1-SORTL'

itab-sortl.

perform bdc_field using 'LFA1-LAND1'

itab-land1.

  • perform bdc_transaction using 'FK01'.

call transaction 'FK01' using it_bdc mode 'N' messages into it_messages.

if sy-subrc <> 0.

cnt = cnt + 1.

if cnt = 1.

perform open_group.

endif.

perform bdc_insert.

endif.

clear :it_bdc[],it_bdc.

endloop.

perform format_messages.

if cnt > 1.

perform close_group.

endif.

form upload .

call function 'UPLOAD'

  • EXPORTING

  • CODEPAGE = ' '

  • FILENAME = ' '

  • FILETYPE = ' '

  • ITEM = ' '

  • FILEMASK_MASK = ' '

  • FILEMASK_TEXT = ' '

  • FILETYPE_NO_CHANGE = ' '

  • FILEMASK_ALL = ' '

  • FILETYPE_NO_SHOW = ' '

  • LINE_EXIT = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • SILENT = 'S'

  • IMPORTING

  • FILESIZE =

  • CANCEL =

  • ACT_FILENAME =

  • ACT_FILETYPE =

tables

data_tab = itab

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • INVALID_TABLE_WIDTH = 2

  • INVALID_TYPE = 3

  • NO_BATCH = 4

  • UNKNOWN_ERROR = 5

  • GUI_REFUSE_FILETRANSFER = 6

  • OTHERS = 7

.

  • 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

form bdc_dynpro using program dynpro.

clear it_bdc.

it_bdc-program = program.

it_bdc-dynpro = dynpro.

it_bdc-dynbegin = 'X'.

append it_bdc.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

if fval <> ''.

clear it_bdc.

it_bdc-fnam = fnam.

it_bdc-fval = fval.

append it_bdc.

endif.

endform.

&----


*& Form FORMAT_MESSAGES

&----


form format_messages .

loop at it_messages.

call function 'FORMAT_MESSAGE'

exporting

id = it_messages-msgid

lang = sy-langu

no = it_messages-msgnr

v1 = it_messages-msgv1

v2 = it_messages-msgv2

v3 = it_messages-msgv3

v4 = it_messages-msgv4

importing

msg = it_mess

  • EXCEPTIONS

  • NOT_FOUND = 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.

write:/10 it_mess.

endloop.

endform. " FORMAT_MESSAGES

&----


*& Form BDC_INSERT

&----


form bdc_insert .

call function 'BDC_INSERT'

exporting

tcode = 'fk01'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

tables

dynprotab = it_bdc

exceptions

internal_error = 1

not_open = 2

queue_error = 3

tcode_invalid = 4

printing_invalid = 5

posting_invalid = 6

others = 7

.

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. " BDC_INSERT

&----


*& Form open_group

&----


form open_group .

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

  • DEST = FILLER8

group = 'KIRRU1'

  • HOLDDATE = FILLER8

keep = 'X'

user = sy-uname

  • RECORD = FILLER1

prog = sy-cprog

  • IMPORTING

  • QID =

exceptions

client_invalid = 1

destination_invalid = 2

group_invalid = 3

group_is_locked = 4

holddate_invalid = 5

internal_error = 6

queue_error = 7

running = 8

system_lock_error = 9

user_invalid = 10

others = 11

.

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. " open_group

&----


*& Form CLOSE_GROUP

&----


form close_group .

call function 'BDC_CLOSE_GROUP'

  • EXCEPTIONS

  • NOT_OPEN = 1

  • QUEUE_ERROR = 2

  • OTHERS = 3

.

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. " CLOSE_GROUP

Award points.

cheers!

sri

Read only

Former Member
0 Likes
552

can you say what error have been encountered by you, if the error say anything abt configuration