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

BDC Data transfer - Session method...?

Former Member
0 Likes
888

Dear All,

How to Transfer data using BDC Session method? - Step-by-step Process.

Regards,

Dharmesh

5 REPLIES 5
Read only

Former Member
0 Likes
802

Hi

sapbrain contains pdf illustrating how u can perform BDC

Check out the link

http://www.sapbrain.com/Tutorials/tuto_download.html

P.S award points if helpful..

Read only

Former Member
0 Likes
802

hi,

this will be usefull to u

2.1. Steps for submitting data for Batch Processing

1. Analyze the transactions for which a BDC program.

The user has to determine the sequence of screens in the transactions and the information about all the fields in every screen. To do this the user must run the transaction .

Then select System  Status. This will give the screen number and the module pool associated with this screen of the transaction. These two are the most important fields that the user would need in order to write the BDC program.

2. Use transaction SE38 to write the BDC program. This ABAP/4 program should reads the external data that is to be entered in the SAP System and stores the data in a "batch-input session." A session stores the actions that are required to enter data using normal SAP transactions. This is done by basically using three functions:

BDC_OPEN_GROUP

BDC_INSERT

BDC_CLOSE_GROUP.

3. To create a batch input session, use the function BDC_OPEN_GROUP. This function has the following 5 parameters :

a. CLIENT which is by default set to SY_MANDT. It is the client in which the session is to be processed.

b. GROUP which is the name of the BDC session. This parameter is important because it is with this name that the user will recognize the BDC session in the batch input queue. Using this name process the BDC session.

c. USER which is usually set to SY-UNAME. It is the user name for starting the session in background.

d. KEEP indicates whether the session should be kept or deleted after processing. If ‘ ‘ then the session is deleted. If ‘X’ then the session is retained even after it is successfully processed without any errors.

e. HOLDDATE Lock date. The session is locked and may not be processed until after the date that is specified. Default: No lock date, session can be processed immediately. A lock date is optional.

4. Populate the bdcdata table .

The user may define the table as follows:

DATA: BEGIN OF BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF BDCDATA.

This bdcdata structure has the following fields:

• PROGRAM

Name of the program.

• DYNPRO

Number of the screen. Set this field only in the first record for the screen.

• DYNBEGIN

Indicates the first record for the screen. Set this field to X only in the first record for the screen. (Reset to ' ' (blank) for all other records.)

• FNAM

Name of a field in the screen. The FNAM field is not case-sensitive.

• FVAL

Value for the field named in FNAM.

5. The next step is to submit the BDC session. Use the BDC_INSERT function module to add a transaction to a batch input session. Specify the transaction that is to be started in the call to BDC_INSERT.

BDC_INSERT takes the following parameters:

• TCODE

The code of the transaction that is to be run. TCODE is an EXPORTING parameter in the function module.

• DYNPROTAB

The BDCDATA structure that contains the data that is to be processed by the transaction. DYNPROTAB is a tables parameter in the function module.

6. The final step is to close the BDC session. Use the BDC_CLOSE_GROUP function module to close a session. Once a session is closed, it can be processed.

7. Running this program will create a batch input session by the name that is specified in the GROUP parameter in the BDC_CREATE_GROUP function call.

8. Transaction SM35 can be used to process the submitted session. This transaction can be used to check the status of all BDC sessions.

2.2. Summary: Creating Batch Input Session:

• Open Batch Input group

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = GROUP

USER = USER

KEEP = KEEP.

• Fill in the Data for Transaction in an internal table 'BDCDATA'

FORM INSERT_SCREEN USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

FORM INSERT_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM.

• Insert Transacton

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'ME21'

TABLES

DYNPROTAB = BDCDATA.

• Close Batch Input group

CALL FUNCTION 'BDC_CLOSE_GROUP'.

Finally to process Batch Input Session, first execute the BDC ABAP. This will create

a BDC session. Run transaction 'SM35' & processes the BDC session.

regards,

padma.

Read only

Former Member
0 Likes
802

Use the below steps.

IT_ITAB needs to filled with the BDCDATA

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'MATERIAL'

KEEP = 'X'

USER = sy-uname

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.

ENDIF.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MM01'

TABLES

dynprotab = IT_ITAB

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.

ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3

Regards,

GSR.

Read only

Former Member
0 Likes
802

hi,,

regards,

padma

Message was edited by: padma balakrishnan

Read only

Former Member
0 Likes
802

hi Dharmesh,

check this out..

SESSION METHOD

About Session method

In this method you transfer data from internal table to database table through sessions.

In this method, an ABAP/4 program reads the external data that is to be entered in the SAP System and stores the data in session. A session stores the actions that are required to enter your data using normal SAP transaction i.e., Data is transferred to session which in turn transfers data to database table.

Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e., data for screen fields, to which screen it is passed, the program name behind it, and how the next screen is processed.

When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session or have the session run in the background processing system.

Unless session is processed, the data is not transferred to database table.

BDC_OPEN_GROUP

You create the session through program by BDC_OPEN_GROUP function.

Parameters to this function are:

• User Name: User name

• Group: Name of the session

• Lock Date: The date on which you want to process the session.

• Keep: This parameter is passed as ‘X’ when you want to retain session after

processing it or ‘ ‘ to delete it after processing.

BDC_INSERT

This function creates the session & data is transferred to Session.

Parameters to this function are:

• Tcode: Transaction Name

• Dynprotab: BDC Data

BDC_CLOSE_GROUP

This function closes the BDC Group. No Parameters.

Some additional information for session processing

When the session is generated using the KEEP option within the BDC_OPEN_GROUP, the system always keeps the sessions in the queue, whether it has been processed successfully or not.

However, if the session is processed, you have to delete it manually. When session processing is completed successfully while KEEP option was not set, it will be removed automatically from the session queue. Log is not removed for that session.

If the batch-input session is terminated with errors, then it appears in the list of INCORRECT session and it can be processed again. To correct incorrect session, you can analyze the session. The Analysis function allows to determine which screen and value has produced the error. If you find small errors in data, you can correct them interactively, otherwise you need to modify batch input program, which has generated the session or many times even the data file.

Note: Award Points if Helpful