Thursday, January 8, 2009

Batch Data Communication (BDC)

Creating a BDC program.

Requirement:

Upload vendor master using BDCs.
1. Create the text file (use tab button between values to keep uniform distance)
210 0001 0001 0001 Mr. Dallas dl

Lord Krishna Bank IN 950000



2. Goto Tcode SHDB.
3. Click on new recording
4. enter tcode XK01
5. enter
6. create a dummy record
7. save.
8. back
9. select the recording
10. click on program
11. enter program and enter
12. enter short description
13. click on source code
14. double click on BDCREXX1.
15. click on display
16. copy all
17. Back
18. Change program name to include ZTEXT_BDCREX
19. Double click on that
20. Paste code which was copied earlier
21. Activate
22. come back
23. comment all data set statements
( one has to comment a lot performs and datasets, that depends on type of transaction being recorded)
24. Make record to be an internal table writing occurs 0.
DATA: BEGINF OF RECORD OCCURS 0.
After include, write following:
PARAMETERES: P_FILE TYPE RLGRP-FILENAME.
DATA V_FILE TYPE STRING.

Before Start-of-selection,
AT SELECTION-SCREEN ON VALUE REQUEST FOR P_FILE.

CALL FUNCTION ‘F4_FILENAME’.
EXPORTING
PROGRAM_NAME = SYST_CPROG
DYNPRO_NUMBER = SYST_DYNNR
FIELD_NAME = ‘P_FILE’
IMPORTING
FILENAME = P_FILE
25. After START-OF-SELECTION:
START-OF-SELECTION.
V_FILE = P_FILE.
And call the function ‘gui_upload’.
CALL FUNCTION ‘GUI_UPLOAD.
EXPORTING FILENAME = V_FILE
FILETYPE = ‘ASC’.
HAS_FIELD_SEPERATOR = ‘X’.
TABLE
DATA_TAB = RECORD.

26. comment DO and write LOOP at record.
27. comment ENDDO and write ENDLOOP.
28. Execute the program.
29. select call transaction radio button
30. enter processing mode as A
31. in the file name, enter the file path
32. execute

Running Bdc Program Through Session Method
1. Execute the program
2. select “Generate Session’ radio button
3. enter session name
4. tick mark “Keep Session”
5. Enter the filename
6. execute
7. goto SM35
8. Select the session click on process
9. Select background
10. Enter
11. Analysing the background session
12. SM36
13. Click on own jobs.

Scheduling Background Program
1. SM36
2. enter the jobname
3. click on step
4. enter the program name and variant name
5. check and save and come back
6. click immediate
7. start condition.save.check.

Steps to write a BDC program
1. Identify the fields
Press F1 on field, click on technical info.
2. Fill BDCDATA internal table.
BDC data structure
a. Rogram
b. Dynpro
c. Dynbegin
d. Fname
e. Fval
3. Call the transaction
Processing mode in call transaction:
- A = Display all screens
- E= Display error.
- N = Background processing
4. Update Mode
a. L = Dialog work process will update the data
b. S = Synchronous update (update work processor will update)
If 1-100 records are updated and error is in 50th record, then 1-49 will be updated.In synchronous update the sy-subrc is set to 0 only when the particular transaction is executed and also the changes have done to the database,
c. A = asynchronous update work process will update. Incase error is 50th record, then 1-49 records will be updated and 50th will logged as an error. In asynchronous update the sy-subrc is set to 0 if  the transaction is executed without any fail, not the database changes.

Difference between Call Transaction and session method.
Call Transaction Session Method
i. Synchronous Asynchronous

ii. Error needs to be handled Automatically
Manually

iii. Used for relatively less records More records

iv. No function modules are called Multiple transactions called
and used to update one transaction.

v. No session is created. Session is created.
The function modules called are:
• BDC_OPEN_GROU
• BDC_INSERT
• BDC_CLOSE_GROUP.

No comments: