Ab1005 - Data Upload - BDC, Call Transaction - V1.0: India Sap Coe, Slide 1
Ab1005 - Data Upload - BDC, Call Transaction - V1.0: India Sap Coe, Slide 1
Demonstration
Exercises Help Me
5
India SAP CoE, Slide 2
Demonstration
Exercises Help Me
5
India SAP CoE, Slide 3
Introduction
Purpose Use
Purpose
BDC stand for BATCH DATA COMMUNICATION Through this concept we transfer the data into SAP R/3 System Legacy System R/3 System
Data
BATCH INPUT
Purpose
cont.
Batch input is used to transfer large amounts of data into the SAP system. In this topic, we will learn the basics of batch input. There are 2 types of transfers Conversions and interfaces. Conversions: This type of transfer refers to a one-time transfer from a legacy system to the SAP system. In this case, the legacy system is the old system that is being replaced by the SAP system. Interfaces: This type of transfer refers to an ongoing transfer from a complementary system to the SAP system. In this case, the complementary system is a system that will run along side the SAP system.
Use
This is used for uploading the master data and different type of application data from legacy system to SAP R/3 system like as: Create Vendor using transaction (FK01), Change Vendor using transaction (FK02)
Demonstration
Exercises Help Me
5
India SAP CoE, Slide 8
WS_UPLOAD
ABAP/4 PROGRAM
Application server
Internal table
Read Dataset
Dialog Program
A dialog program conducts a dialog with the user. As a result of user input the program executes which in turn displays an output or changes the database in a consistent way. A transaction code can be connected to dialog program which calls the corresponding program
BDC Program.
BDCDATA Structure
To simulate user dialogue, you must know the following information: 1. Online program name, 2. Screen numbers, 3. Field names 4. Field values
The BDCDATA ABAP Dictionary structure is used in a batch input program to collect this information for an entire transaction.
India SAP CoE, Slide 16
TEST1
For our example, we will use the Change Vendor transaction (FK02) to add a street address to an already existing vendor.
Company code
Address
Name
Computers, Inc
Street
City
Step #3 Determine how to proceed in the transaction (save the record by clicking on the Save pushbutton or pressing the F11 key).
PROGRAM SAMPF02K
FNAM
FVAL
METHOD #2 METHOD #3
Prepare a BDCDATA structure for the transaction that you wish to run.
Prepare a internal table to store error messages Tab_Mess like structure of BDCMSGCOLL. With a CALL TRANSACTION USING statement, call the transaction and prepare the BDCDATA structure. For example: CALL TRANSACTION MM01' USING BDCDATA MODE 'A' UPDATE 'S'. MESSAGES INTO TAB_MESS.
Value 0 <=1000 Explanation Successful Error in dialog program Batch input error
IF SY-SUBRC <> 0.
<Error_handling>. ENDIF.
> 1000
Function Modules
BDC_OPEN_GROUP
CALL FUNCTION BDC_OPEN_GROUP EXPORTING CLIENT GROUP HOLDDATE KEEP USER EXCEPTIONS CLIENT_INVALID .. OTHERS = 11. =1
= = = = =
<client> <session name> <lock session until date> <keep or delete session> <user name>
BDC_INSERT
CALL FUNCTION BDC_INSERT EXPORTING TCODE TABLES DYNPROTAB EXCEPTIONS INTERNAL_ERROR .. OTHERS = 5. =1 = <bdc internal table> = <transaction code>
BDC_CLOSE_GROUP
CALL FUNCTION BDC_CLOSE_GROUP EXCEPTIONS NOT_OPEN QUEUE_ERROR OTHERS =1 =2 =3
An on-line user can start the session using the batch input menu options. (To access the batch input options, choose System
SM35
You can submit the background job RSBDCSUB to start a session in background processing. If several sessions have the same name, RSBDCSUB starts them all.
Direct Input
To enhance the batch input procedure, the system offers the direct input technique, especially for transferring large amounts of data. In contrast to batch input, this technique does not create sessions, but stores the data directly. It does not process screens. To enter the data into the corresponding database tables directly, the system calls a number of function modules that execute any necessary checks. In case of errors, the direct input technique provides a restart mechanism. However, to be able to activate the restart mechanism, direct input programs must be executed in the background only. To maintain and start these programs, use program RBMVSHOW or Transaction BMV0. It is better to use BDC method unless data volume is very high, as validations are very critical to data upload in SAP. Examples for direct input programs are:
Demonstration
Exercises Help Me
5
India SAP CoE, Slide 31
Demonstration
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 Error Handling Example- Batch Input Method Summary
India SAP CoE, Slide 32
CODEPAGE
FILENAME FILETYPE TABLES DATA_TAB EXCEPTIONS
= IBM'
= P_UFILE = 'DAT'
= INT_TAB
=1 =2 =3
=6 =7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR OTHERS = 10 . =9
And then close the application server file CLOSE DATASET <dsn>
India SAP CoE, Slide 38
The internal table used to collect the transactions information must be declared LIKE BDCDATA.
ENDFORM.
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.
.
Vendor Company code
TEST1
TEST2
Address
Address
Computer Land
10 Walnut St. Boston
Philadelphia
REPORT Y180DM10.
Step #1 Step #2 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.
Step #8
Step #9
Example #1 - Subroutines
FORM FILL_BDC_TAB. REFRESH BDC_TAB. CLEAR BDC_TAB. PERFORM POPULATE_BDC_TAB USING: 1 SAPMF02K 0106, RF02K-LIFNR INREC-VENDNUM, RF02K-D0010 X, 1 SAPMF02K 0110, LFA1-STRAS, INREC-STREET, BDC_OKCODE, /11. ENDFORM. 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. FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.
With synchronous updating, we can check SY-SUBRC to determine the success of the transaction and the actual update to the database.
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
ERROR
Send the record(s) in error to an error file. Create a batch input session with the record(s) in error.
Error Handling
To store error messages ( CALL TRANSACTION ) data: begin of Tab_Mess occurs 0. include structure bdcmsgcoll. data : end of Tab_Mess,
cont.
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_MESSMSGTYP , Tab_MESS-MSGID. ENDIF.
TEST1
In this example, we will create a batch input session to add a street address to an already existing vendor (TEST1)
Company code
Address
Name
Street City
REPORT Y180DM08. DATA: BDC_TAB LIKE STANDARD TABLE OF BDCDATA INITIAL SIZE 6 WITH HEADER LINE, SESSION LIKE APQ1-GROUPID VALUE DEMO #8.
Step #1
Step #3
START-OF-SELECTION. CALL FUNCTION BDC_OPEN_GROUP EXPORTING CLIENT = SY-MANDT GROUP = SESSION USER = SY-USERNAME EXCEPTIONS. PERFORM FILL_BDC_TAB. CALL FUNCTION BDC_INSERT EXPORTING TCODE = FK02 TABLES DYNPROTAB = BDC_TAB EXCEPTIONS. CALL FUNCTION BDC_CLOSE_GROUP EXCEPTIONS.
Step #4
Step #5
Example #1 - Subroutines
FORM FILL_BDC_TAB. REFRESH BDC_TAB. CLEAR 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. 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. FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.
ENDFORM.
Summary
Research Transaction
Execute BDC Program Batch Input Session Control Process Batch Input Session SAP Database Updated
India SAP CoE, Slide 53
Demonstration
Exercises Help Me
5
India SAP CoE, Slide 54
Exercises
Exercise-01 Using call transaction method Mode N
Upload the attached file. Create the vendor using transaction XK01 Display the output report.
Exercises
Exercise -02 Using Batch Input Session Method Run Mode Background
Upload the attached file. Create the material master using transaction MM01 Create the session and run.
Demonstration
Exercises Help Me
5
India SAP CoE, Slide 57
Help Me
Start date
General data Job name Job class
Steps
Status
Target host
ABAP/4
External program
ABAP/4 program
Name Variant Language <name of report program> <name of variant> E
Immediate
Date/Time
After Job
After Event
Jobs can be scheduled to run after an event has been triggered/raised.
Jobs can be scheduled to run after another job has been completed.
If you start a job based on a date/time or an event, you can schedule the job to run at regular intervals, not just at a particular time.
Periodic job
Hourly Daily
By checking the Periodic Job option, you can specify that the job run at regular intervals.
With the Period Values pushbutton, you can schedule the job to run hourly, daily, weekly, monthly, etc.
X Start status-depend.
After clicking on the After Job pushbutton, you must specify the name of the job that must be completed before this job will run.
If you check the Start status-depend. option, this job will run only if the specified job ends successfully.
Event Parameter
<event name>
<parameter>
After clicking on the After Event pushbutton, you must specify the name of the event that must be raised before this job will run. You can distinguish between different occurrences of a particular event by specifying a parameter.
X Periodic job
If you check the Periodic Job option, the system starts a new job each time the specified event is raised.
Triggering/Raising Events
To trigger/raise an event from within an ABAP/4 program, you must call the BP_EVENT_RAISE function module.
CALL FUNCTION BP_EVENT_RAISE EXPORTING EVENTID = <event name> EVENTPARM = TARGET_INSTANCE = EXCEPTIONS BAD_EVENTID =1 The only required EVENTID_DOES_NOT_EXIST = 2 exporting parameter is the EVENTID_MISSING =3 name of the event to raise. RAISE_FAILED =4 OTHERS = 5.
Job Processing
Job Overview
Scheduler
Job
Dispatcher
Job
Job Processing
Transaction SM50
Start Module
Job Step #1 Job Step #2 Job Step #3 End Module
PRINT SPOOL
Job Processing
List
All WRITE statement output from job step.
Job Overview
Transaction SM37
Job Status
Job Overview
<data>
<id1> <data>
<id2> <data2>
JOB_SUBMIT
JOB_SUBMIT Exporting: authcknam = <user> jobcount = <job #> jobname = <job name> report = <report> variant = <variant> Background Job <job name> <job #> Step #1
Step #2
JOB_CLOSE
JOB_CLOSE Exporting: jobcount = <job #> jobname = <job name> sdlstrtdt = <start date> sdlstrttm = <start time> strtimmed = <flag1> Importing: job_was_released = <flag2> Background Job <job name> <job #> Step #1
Step #2
Session Overview
Process Batch Input Session
Locked 01/31/97
Tran 5 5
Screen 10 10
Session SESSION3
Date 01/04/97
Time 11:00:00
Locked
Created by DANTHON
Tran 1
Screen 2
Authorization DANTHON
Session Log
Log Created 01/08/1997 15:12:30
Time 15:12:30 15:12:31 15:12:31 15:12:31 15:12:31 15:12:31 15:12:31 15:12:31 15:12:31 15:12:31 Tran FK02 FK02 FK02 Screen
User DANTHON
Message S00300 Session SESSION3 is being SAPMF02K 0110 SF2056 Changes have been made SAPMF02K 0110 SF2056 Changes have been made SAPMF02K 0106 EF2163 Vendor TESTX has not been created S00370 S00363 S00364 S00365 S00366 S00382 Processing Statistics 3 transactions read 2 transactions processed 1 transactions with errors 0 transactions deleted Batch input processing ended
Processing Modes
Process Batch Input Session in the FOREGROUND DISPLAY ERRORS ONLY when processing batch input session.
Processing Options
/bdel /n /bda /bde /bend Delete Transaction Next Transaction Process/Foreground Display errors only Cancel
Program RSBDCSUB
Important Tips
Function Modules:
GUI_UPLOAD -------Upload flat file from presentation server to application server FORMAT_MESSAGE---------Formats message WS_FILENAME_GET-------Call file selector BDC_OPEN_GROUP, BDC_INSERT, BDC_CLOSE_GROPUP----Create&Maintain Sessions
Transaction codes:
SM35-----Process session,
Tables:
T100-------Table for Messages
Includes:
BDCRECXX, BDCRECXY, BDCRECX1.
Structures:
BDCDATA, BDCMSGCOLL
India SAP CoE, Slide 82
END of Session