08-27-2007 8:45 AM
Hi experts,
I am new to bdc.I know what is is bdc, But i Don't no how to create the bdc program.
can any body explain the steps how to create the bdc program.
08-27-2007 8:49 AM
hi, u can do it by doing recording in shdb transaction.
afterrecording follow the below coding sample for xk01,,,,,,
report ZTEST_BDC
no standard page heading line-size 255.
TYPES: begin of ty_data,
lifnr TYPE lfa1-lifnr,
bukrs type RF02K-BUKRS,
EKORG type RF02K-ekorg,
KTOKK type RF02K-KTOKK,
name1 TYPE lfa1-name1,
sortl TYPE lfa1-sortl,
land1 TYPE lfa1-land1,
AKONT TYPE LFB1-AKONT,
FDGRV TYPE LFB1-FDGRV,
WAERS TYPE LFM1-WAERS,
END OF ty_data.
DATA: itab TYPE TABLE OF ty_data with HEADER LINE.
include bdcrecx1.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:/bdc.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform open_group.
loop at itab.
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-LIFNR'
itab-lifnr."'test2'.
perform bdc_field using 'RF02K-BUKRS'
itab-bukrs."'1000'.
perform bdc_field using 'RF02K-EKORG'
itab-ekorg."'1000'.
perform bdc_field using 'RF02K-KTOKK'
itab-ktokk."'0001'.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
itab-name1."'test2'.
perform bdc_field using 'LFA1-SORTL'
itab-sortl."'TE'.
perform bdc_field using 'LFA1-LAND1'
itab-land1."'iN'.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-AKONT'
itab-akont."'197100'.
perform bdc_field using 'LFB1-FDGRV'
itab-fdgrv."'A1'.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
itab-waers."'inr'.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_transaction using 'XK01'.
endloop.
perform close_group.
if u have any doubt, ask further..
reward points if it is helpful
08-27-2007 8:49 AM
Hi!
The easiest way to create a BDC, if you are starting from a recording.
Go to SM35 transaction, choose recording button.
Create one recording, do the posting step-by-step, what you are wanted to post in the given transaction.
Save the recording, then generate a program with the Program button.
You have the BDC code, you only have to modify the data source (you can upload data, or read from DDIC tables also).
Put your BDC into a LOOP at your selected table and you are finished.
Regards
Tamá
08-27-2007 8:49 AM
hi, u can do it by doing recording in shdb transaction.
afterrecording follow the below coding sample for xk01,,,,,,
report ZTEST_BDC
no standard page heading line-size 255.
TYPES: begin of ty_data,
lifnr TYPE lfa1-lifnr,
bukrs type RF02K-BUKRS,
EKORG type RF02K-ekorg,
KTOKK type RF02K-KTOKK,
name1 TYPE lfa1-name1,
sortl TYPE lfa1-sortl,
land1 TYPE lfa1-land1,
AKONT TYPE LFB1-AKONT,
FDGRV TYPE LFB1-FDGRV,
WAERS TYPE LFM1-WAERS,
END OF ty_data.
DATA: itab TYPE TABLE OF ty_data with HEADER LINE.
include bdcrecx1.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:/bdc.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform open_group.
loop at itab.
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-LIFNR'
itab-lifnr."'test2'.
perform bdc_field using 'RF02K-BUKRS'
itab-bukrs."'1000'.
perform bdc_field using 'RF02K-EKORG'
itab-ekorg."'1000'.
perform bdc_field using 'RF02K-KTOKK'
itab-ktokk."'0001'.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
itab-name1."'test2'.
perform bdc_field using 'LFA1-SORTL'
itab-sortl."'TE'.
perform bdc_field using 'LFA1-LAND1'
itab-land1."'iN'.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-AKONT'
itab-akont."'197100'.
perform bdc_field using 'LFB1-FDGRV'
itab-fdgrv."'A1'.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
itab-waers."'inr'.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_transaction using 'XK01'.
endloop.
perform close_group.
if u have any doubt, ask further..
reward points if it is helpful
08-27-2007 8:56 AM
08-27-2007 9:13 AM
HI,
<b>PERFORM</b> is a Statement used for <b>Calling a Subroutine</b> inside or outside the Program.
A <b>Subroutine</b> is a block of code introduced by <b>FORM</b> and concluded by<b> ENDFORM</b>. To define a subroutine, use the following syntax:
<u>Syntax:</u>
FORM <subr> [<pass>].
<statement block>
ENDFORM.
<subr> - The name of the subroutine.
<pass> - You specify how to pass data to and from the subroutine {mainly for external call}.
The Subroutines for the above Program mentioned by Karthikeyan are as follows.
<b>FORM OPEN_GROUP.</b>
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'SESSION1'
USER = SY-UNAME
KEEP = 'X'.
IF SY-SUBRC <> 0.
WRITE 'ERROR IN OPEN_GROUP'.
ENDIF.
<b>ENDFORM.</b>
<b>FORM BDC_DYNPRO USING PROGRAM DYNPRO.</b>
CLEAR I_BDCDATA.
I_BDCDATA-PROGRAM = PROGRAM.
I_BDCDATA-DYNPRO = DYNPRO.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
<b>ENDFORM.</b>
<b>FORM BDC_FIELD USING FNAM FVAL.</b>
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
<b>ENDFORM.</b>
<b>FORM BDC_TRANSACTION USING TCODE.</b>
CALL FUNCTION 'BDC_INSERT'
EXPORTING TCODE = TCODE
TABLES DYNPROTAB = I_BDCDATA.
<b>ENDFORM.</b>
<b>FORM CLOSE_GROUP.</b>
CALL FUNCTION 'BDC_CLOSE_GROUP'.
<b>ENDFORM.</b> " CLOSE_GROUP
With Regards,
Padmam.
08-27-2007 8:51 AM
Hi,
Plz go through the below links..
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://www.sapdevelopment.co.uk/bdc/bdchome.htm
Regards,
Nagaraj