12-21-2006 4:30 AM
can u send me the step by step process for a BDC program
i had given a excel sheet with field names and length .....that is to be uploaded
it is material master(MM01)
thanks in advance
12-21-2006 4:33 AM
12-21-2006 4:33 AM
12-21-2006 4:36 AM
hello,
http://www.sap-img.com/abap/learning-bdc-programming.htm
Regards,
Sourabh
PS:Reward points if helpful
12-21-2006 4:49 AM
Hi,
Check these links.
http://help.sap.com/saphelp_erp2005/helpdata/en/fa/097119543b11d1898e0000e8322d00/frameset.htm
http://myweb.dal.ca/hchinni/sap/bdc_home.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&;
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://www.sapdevelopment.co.uk/bdc/bdchome.htm
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
-Priyanka.
12-21-2006 4:53 AM
Hi,
1. do the recording for the tcode MM01 using the transaction SHDB.
Fill all the fields (given in the excel sheet) with values .
2. Save the recording, and then go back a screen and go to the overview.
3. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording.
4. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes:
4.1 create an internal table which contains all the fields in the excel sheet.
4.2 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB separated, use this internal table to upload).
4.3 After the open-group, Loop on the uploaded data in the internal table. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data ( here you can enter data from the itab like itab-matnr).
4.4. After perform bdc_transaction, end the loop (endloop).
12-21-2006 4:54 AM
Hi,
for the bdc upload
step1. go to the Transaction SHDb and create a new recording for the transaction MM01 and save the recording.
step 2: from the same transaction select the recording and go the program.
Note: if you have ur file in presentation server insted of open dataset use gui_upload.
make the needed necessary changes in the coding.
i've attached the sample coding, keep that as reference and do according to your need.
-
REPORT zmm01_bdc
NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE bdcrecx1.
DATA: dataset(132) TYPE c.
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: 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: MATNR
matnr_006(018),
data element: MBRSH
mbrsh_007(001),
data element: MTART
mtart_008(004),
data element: XFELD
kzsel_01_009(001),
data element: XFELD
kzsel_02_010(001),
data element: MAKTX
maktx_011(040),
data element: MEINS
meins_012(003),
data element: MATKL
matkl_013(009),
data element: MTPOS_MARA
mtpos_mara_014(004),
data element: MAKTX
maktx_015(040),
END OF record.
DATA l_lines TYPE i .
DATA it_record LIKE TABLE OF record WITH HEADER LINE .
DATA wa_record LIKE record .
End generated data section ***
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename ='C:\MM01_FILE.TXT'
filetype = 'ASC'
has_field_separator = '#'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = it_record
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_dataset USING dataset.
PERFORM open_group.
DO.
READ DATASET dataset INTO record.
IF sy-subrc <> 0. EXIT. ENDIF.
LOOP AT it_record INTO wa_record.
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(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
record-kzsel_01_004.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(02)'
record-kzsel_02_005.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMMG1-MATNR'
record-matnr_006.
PERFORM bdc_field USING 'RMMG1-MBRSH'
record-mbrsh_007.
PERFORM bdc_field USING 'RMMG1-MTART'
record-mtart_008.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
record-kzsel_01_009.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(02)'
record-kzsel_02_010.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'MAKT-MAKTX'
record-maktx_011.
PERFORM bdc_field USING 'BDC_CURSOR'
'MARA-MATKL'.
PERFORM bdc_field USING 'MARA-MEINS'
record-meins_012.
PERFORM bdc_field USING 'MARA-MATKL'
record-matkl_013.
PERFORM bdc_field USING 'MARA-MTPOS_MARA'
record-mtpos_mara_014.
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_015.
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.
11-06-2007 6:14 AM
11-06-2007 6:16 AM
hi,
i want to know about bdc table control pls can anyone provide any material.
11-06-2007 6:17 AM
Hi
Transaction Recorder (SHDB)
How to Upload Presentation Server Flat file to SAP R/3 system???
How to upload application server file to R/3 system?
Definition
Example - Call Transaction Method
Transaction Recorder (SHDB)
Before you work with the Batch Input methods, you should know the purpose of the tool
Transaction Recorder.
Use:
You can use the transaction recorder to record a series of transactions and their screens.
Features:
You can use the recording to create
Data transfer programs that use batch input or CALL TRANSACTION
Batch input sessions
Test data
Function modules.
Note: It doesnt record F1, F4 and Scrollbar movements
Upload Flat file from Presentation Server to SAP R/3
CALL FUNCTION GUI_UPLOAD'
EXPORTING
CODEPAGE = IBM'
FILENAME = P_UFILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = INT_TAB
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 NE 0.
MESSAGE E999(FR) WITH 'ERROR IN FILE UPLOAD'.
ENDIF.
Upload file from application server to SAP R/3
Open the the application server file
OPEN DATASET <dsn> FOR INPUT <mode>
Read the data from application server file
READ DATASET <dsn> INTO <wa>
And then close the application server file
CLOSE DATASET <dsn>
Definition- Declaring BDC Table
DATA: BDC_TAB LIKE STANDARD TABLE OF
BDCDATA INITIAL SIZE 6
WITH HEADER LINE .
The internal table used to collect the transactions information must be declared LIKE BDCDATA.
Filling BDC Table Method #1
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-PROGRAM = SAPMF02K.
BDC_TAB-DYNPRO = 01016.
BDC_TAB-DYNBEGIN = X.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = RF02K-LIFNR.
BDC_TAB-FVAL = TEST1.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = RF02K-D0010.
BDC_TAB-FVAL = X.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-PROGRAM = SAPMF02K.
BDC_TAB-DYNPRO = 0110.
BDC_TAB-DYNBEGIN = X.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = LFA1-STRAS.
BDC_TAB-FVAL = 123 Main St..
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = BDC_OKCODE.
BDC_TAB-FVAL = /11.
APPEND BDC_TAB.
ENDFORM.
Filling BDC Table Method #2
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING:
1 SAPMF02K 0106,
RF02K-LIFNR TEST1,
RF02K-D0010 X,
1 SAPMF02K 0110,
LFA1-STRAS, 123 Main St.,
BDC_OKCODE, /11.
ENDFORM.
FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.
CLEAR BDC_TAB.
IF FLAG = 1.
BDC_TAB-PROGRAM = VAR1.
BDC_TAB-DYNPRO = VAR2..
BDC_TAB-DYNBEGIN = X.
ELSE.
BDC_TAB-FNAM = VAR1.
BDC_TAB-FVAL = VAR2.
ENDIF.
APPEND BDC_TAB.
ENDFORM.
This two subroutine method to fill the BDC table is preferable because the POPULATE_BDC_TABLE subroutine is reusable throughout all batch input programs.
Example #1 - Change Vendor (Call Transaction Method)
Example #1- Declaration Section
REPORT Y180DM10.
DATA: BDC_TAB LIKE STANDARD TABLE OF
BDCDATA INITIAL SIZE 6 WITH HEADER LINE.
INFILE(20) VALUE /tmp/bc180_file4.
DATA: BEGIN OF INREC.
VENDNUM LIKE LFA1-LIFNR.
STREET LIKE LFA1-STRAS.
END OF INREC.
PARAMETERS: DISPMODE DEFAULT A,
UPDAMODE DEFAULT S.
START-OF-SELECTION.
OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.
DO.
READ DATASET INFILE INTO INREC.
IF SY-SUBRC < > 0. EXIT. ENDIF.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION FK02
USING BDC_TAB
MODE DISPMODE
UPDATE UPDAMODE.
IF SY-SUBRC < > 0.
WRITE: /ERROR.
ENDIF.
ENDDO.
CLOSE DATASET INFILE.
synchronous updating
DO.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION FK02
USING BDC_TAB
MODE N
UPDATE S.
IF SY-SUBRC < > 0.
WRITE: /ERROR.
ENDIF.
ENDDO.
With synchronous updating, we can check SY-SUBRC to determine the success of the transaction and the actual update to the database.
asynchronous updating
DO.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION FK02
USING BDC_TAB
MODE N
UPDATE A.
IF SY-SUBRC < > 0.
WRITE: /ERROR.
ENDIF.
ENDDO.
With asynchronous updating, we can check SY-SUBRC to determine the success of the transaction only, not the actual update to the database.
Error Handling
Write an error report.
Send the record(s) in error to an error file.
Create a batch input session with the record(s) in error.
To store error messages ( CALL TRANSACTION )
data: begin of Tab_Mess occurs 0.
include structure bdcmsgcoll.
data : end of Tab_Mess,
CALL TRANSACTION FK02 USING BDC_TAB MODE N UPDATE S
MESSAGES INTO TAB_MESS.
IF SY-SUBRC NE 0.
WRITE: / Tab_MESS-TCODE, Tab_MESS-DYNUMB, Tab_MESS-MSGTYP ,
Tab_MESS-MSGID.
ENDIF.
Reward if usefull
11-06-2007 7:19 AM
Hi experts,
what is d/w between set/get parameters?
Thanks & Regards,
Ramesh.d
02-18-2015 11:53 AM
for the same recording pf MM01,
while i execute i'm getting the message as "Error Opening dataset, return code: 8".
what does that mean ?
Thanks,
Narsareddyy
02-18-2015 12:05 PM