Application Development 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: 

BDC _ ME21N

Former Member
0 Kudos

Hi All,

i have some doubts in bdc

1. How handle Table Control in bdc and how to implement that in t'code VA01 and

send me program coding also and tell me handle t'code ME21N..

2. Which is the best method in bdc to handle upload data by Session or Call Transaction.

3.What is d/w Direct Input and batch input.

Thanx & Regards,

Srinivas

4 REPLIES 4

Former Member

Former Member
0 Kudos

HI

<b>1. How handle Table Control in bdc and how to implement that in t'code VA01 and

send me program coding also and tell me handle t'code ME21N</b>

Table Control in BDC

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

The concept is easy: it has to indicate the index of the table control in the field name, so if you have to populate the first record of table control:

BDC-FIELDNAME = <FIELDNAME>(01).

If you fill the second row:

BDC-FIELDNAME = <FIELDNAME>(02).

and so....

Now the problem is usually on how many records you have to load, because u can fill only the rows of table control available in the screen, If you have more records than it can be displayed yuo have to simulate the command to go next page.

The number of recod can be displayed can depend on pc resolution and many program haven't command to go to next page (in this case it could be impossible create a BDC program9.

A way to create a bdc program resolution indipendent is to work on the first and second row.

- Place the first hit in the first row of bdc;

- Place the second insert in the second row of bdc;

- Place the last hit to the top of table control;

- Place the next hit in the second row;

- Place the last hit to the top of table control;

- Place the next hit in the second row;

- .... and so

<b>2. Which is the best method in bdc to handle upload data by Session or Call Transaction</b>

Batch Input and CALL TRANSACTION are both data transfer methods. Batch Input usually are used to transfer large amount of data. For example you are implementing a new SAP project, and of course you will need some data transfer from legacy system to SAP system. If there is no standard batch input program, direct input program, you would need to write your own data transfer program and it is going to be batch input program. CALL TRANSACTION methods is real-time method, whenever you run the program CALL TRANSACTION can be triggered. CALL TRANSACTION is used especially for integration actions between two SAP systems or between different modules. Users sometimes wish to do something like that click a button or an item then SAP would inserts or changes data automatically. Here CALL TRANSACTION should be considered. You use CALL TRANSACTION and you do everything automatically, collect necessary data, call transaction and so do database update. If any error occurs, show the user them.

Batch Input

With the Batch Input method, an ABAP program reads the external data that is to be entered in the R/3 System and stores the data in a “batch input session”. The session records the actions that are required to transfer data into the system using normal SAP transactions.

When the program has generated the session, you can run the session to execute the SAP transactions in it. You can explicitly start and monitor a session with the batch input management function (by choosing System - Services - Batch Input), or have the session run in the background processing session.

It offers management of sessions, support for playing back and correcting sessions that contain errors, and detailed logging. Your program prepares the data and stores it in a batch input session. A session is a collection of transaction data for one or more transactions. Batch input sessions are maintained by the system in the batch input queue. You can process batch input sessions in the background processing system.

Your program must open a session in the queue before transferring data to it, and must close it again afterwards. All of these operations are performed by making function modules calls from the ABAP program.

The most important aspects of the session interface are:

Asynchronous processing

Transfer data for multiple transactions

Synchronous database update. During processing, no transaction is started until the previous transaction has been written to the database.

A batch input processing log is generated for each session

Sessions cannot be generated in parallel. The batch input program must not open a session until it has closed the preceding session.

CALL TRANSACTION

In the second method, your program uses the ABAP statement CALL TRANSACTION USING to run an SAP transaction. External data doesn’t have to be deposited in a session for later processing. Instead, the entire batch input process takes place inline in your program. With CALL TRANSACTION USING, the system process the data more quickly than with batch input sessions. Unlike batch input sessions, CALL TRANSACTION USING does not automatically support interactive correction or logging functions.

Your program prepares the data and then calls the corresponding transaction that is then processed immediately.

The most important features of CALL TRANSACTION USING are:

Synchronous processing

Transfer of data from an individual transaction each time the statement CALL TRANSACTION USING is called

You can update the database both synchronously and asynchronously. The program specifies the update type.

Separate LUW (Logical Units of Work) for the transaction. The system executes a database commit immediately before and after the CALL TRANSACTION USING statement.

No batch input processing log

Session method.

1) Assynchronous processing.

2) can tranfer large amount of data.

3) processing is slower.

4) error log is created

5) data is not updated until session is processed.

Call transaction.

1) Synchronous processing

2) can transfer small amount of data

3) processing is faster.

4) errors need to be handled explicitly

5) data is updated automatically

The most important aspects of the CALL TRANSACTION is - Asynchronous processing - Transfers data for a single transaction -

While for session method -It does not update transaction figures until the session has been processed.

Processing batch input data with CALL TRANSACTION USING is the faster of the two recommended data transfer methods. In this method, legacy data is processed inline in your data transfer program.

Call Transaction method makes an immediate call on the transaction and upload starts immediately.,

Session method only creates a session of the whole recording including all the values that have to be inserted,it does not insert values into the system. This session can be invoked anytime to upload values

In short call transaction is immediates

session is not immediate

Synchronous is simoultaneous upload

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.

Asynchornous is non-simultaneous upload

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.

<b>3.What is d/w Direct Input and batch input</b>

Batch Input

With the Batch Input method, an ABAP program reads the external data that is to be entered in the R/3 System and stores the data in a “batch input session”. The session records the actions that are required to transfer data into the system using normal SAP transactions.

When the program has generated the session, you can run the session to execute the SAP transactions in it. You can explicitly start and monitor a session with the batch input management function (by choosing System - Services - Batch Input), or have the session run in the background processing session.

It offers management of sessions, support for playing back and correcting sessions that contain errors, and detailed logging. Your program prepares the data and stores it in a batch input session. A session is a collection of transaction data for one or more transactions. Batch input sessions are maintained by the system in the batch input queue. You can process batch input sessions in the background processing system.

Your program must open a session in the queue before transferring data to it, and must close it again afterwards. All of these operations are performed by making function modules calls from the ABAP program.

The most important aspects of the session interface are:

Asynchronous processing

Transfer data for multiple transactions

Synchronous database update. During processing, no transaction is started until the previous transaction has been written to the database.

A batch input processing log is generated for each session

Sessions cannot be generated in parallel. The batch input program must not open a session until it has closed the preceding session.

Direct Input (DINP)

With direct input, the SAP function modules execute the consistency checks. However with batch input, these consistency checks are executed with help of the screens. This means that direct input has considerable performance advantages. But there are a few programs for direct input, you can use them if it accomplishes your goal. Direct Input programs work like that they update database tables directly. As you know that it is forbidden to update SAP database tables directly, since consistency and security should be considered. Exceptions are these direct input programs. So you are not able to write custom ABAP direct input programs. But of course you can write ABAP programs to update custom database tables (Z tables), if you are sure all about consistency.

So why SAP has created direct input programs? Because SAP wanted to enhance the batch input procedure, since batch input is slower. SAP offers the direct input technique, especially for transferring large amount of data. In contrast to batch input, this technique does not create sessions, but stores, updates, inserts data directly. 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 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.

Examples for direct input programs are:

RFBIBL00 - FI

RMDATIND - MM

RVAFSS00 - SD

RAALTD11 - AM

RKEVEXTO - CO-PA

<b>Reward if usefull</b>

Former Member
0 Kudos

ME21N is an EnjoySAP transaction and not suitable for batch input. If you must use batch input, use ME21 instead.

Rob

Former Member
0 Kudos

Hi Srinivas,

My suggetion for cut down your work by using BAPI to create Purchase order rather then using BDC...BAPI handles all the screen no need of handelling it separately as we are handeling it in BDC....

Please find the code to create Purchase order....

DATA : BEGIN OF IT_BAPIEKKOC.
        INCLUDE STRUCTURE BAPIEKKOC.
DATA : END OF IT_BAPIEKKOC.

DATA : BEGIN OF IT_BAPIEKKOA.
        INCLUDE STRUCTURE BAPIEKKOA.
DATA : END OF IT_BAPIEKKOA.

DATA : BEGIN OF IT_BAPIADDRESS.
        INCLUDE STRUCTURE BAPIADDRESS.
DATA : END OF IT_BAPIADDRESS.

DATA : GV_PO_NUMBER LIKE BAPIEKKOC-PO_NUMBER.

DATA : BEGIN OF IT_BAPIEKPOC OCCURS 0.
        INCLUDE STRUCTURE BAPIEKPOC.
DATA : END OF IT_BAPIEKPOC.

DATA : BEGIN OF IT_BAPIEKPOA OCCURS 0.
        INCLUDE STRUCTURE BAPIEKPOA.
DATA : END OF IT_BAPIEKPOA.

DATA : BEGIN OF IT_BAPIEKET OCCURS 0.
        INCLUDE STRUCTURE BAPIEKET.
DATA : END OF IT_BAPIEKET.

DATA : BEGIN OF IT_BAPIEKKN OCCURS 0.
        INCLUDE STRUCTURE BAPIEKKN.
DATA : END OF IT_BAPIEKKN.

DATA : BEGIN OF IT_BAPIEKPOTX OCCURS 0.
        INCLUDE STRUCTURE BAPIEKPOTX.
DATA : END OF IT_BAPIEKPOTX.

DATA : BEGIN OF IT_BAPIRETURN OCCURS 0.
        INCLUDE STRUCTURE BAPIRETURN.
DATA : END OF IT_BAPIRETURN.


LOOP AT <HEADER>

LOOP AT <ITEM>
ENDLOOP   " AT ITEM
    CALL FUNCTION 'BAPI_PO_CREATE'
      EXPORTING
        PO_HEADER                        = IT_BAPIEKKOC
        PO_HEADER_ADD_DATA               = IT_BAPIEKKOA
        HEADER_ADD_DATA_RELEVANT         = ' '
        PO_ADDRESS                       = IT_BAPIADDRESS
        SKIP_ITEMS_WITH_ERROR            = ' '
        ITEM_ADD_DATA_RELEVANT           = ' '
**   HEADER_TECH_FIELDS               =
      IMPORTING
        PURCHASEORDER                    = GV_PO_NUMBER
      TABLES
        PO_ITEMS                         = IT_BAPIEKPOC
        PO_ITEM_ADD_DATA                 = IT_BAPIEKPOA
        PO_ITEM_SCHEDULES                = IT_BAPIEKET
        PO_ITEM_ACCOUNT_ASSIGNMENT       = IT_BAPIEKKN
        PO_ITEM_TEXT                     = IT_BAPIEKPOTX
        RETURN                           = IT_BAPIRETURN
**   PO_LIMITS                        =
**   PO_CONTRACT_LIMITS               =
**   PO_SERVICES                      =
**   PO_SRV_ACCASS_VALUES             =
**   PO_SERVICES_TEXT                 =
**   PO_BUSINESS_PARTNER              =
**   EXTENSIONIN                      =
**   POADDRDELIVERY                   =
              .
*****/ then you have to call the transactio commit function module to commit the *****same...

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

*****/ For displaying return messages of creation or in error...

    AT FIRST.
      FORMAT COLOR 4 INTENSIFIED ON.
      WRITE : /1(142) SY-ULINE,
              /1 SY-VLINE,
               2 'Purchase Orders Creation',
             142 SY-VLINE.
    ENDAT.
    LOOP AT IT_BAPIRETURN.
      CLEAR GV_MESSAG.
      FORMAT COLOR 4 INTENSIFIED OFF.
      WRITE :/1(142) SY-ULINE.
      WRITE :/1 SY-VLINE,
              3 GV_PO_NUMBER,
             22 SY-VLINE,
             24 IT_VBAK-VBELN,
             39 SY-VLINE.
      IF IT_BAPIRETURN-TYPE = 'S'.
        FORMAT COLOR 5 INTENSIFIED ON.
        GV_MESSAG = 'S-Success'.
      ELSEIF IT_BAPIRETURN-TYPE = 'E'.
        FORMAT COLOR 6 INTENSIFIED ON.
        GV_MESSAG = 'E-Error'.
      ELSEIF IT_BAPIRETURN-TYPE = 'W'.
        FORMAT COLOR 3 INTENSIFIED ON.
        GV_MESSAG = 'W-Warning'.
      ELSEIF IT_BAPIRETURN-TYPE = 'I'.
        FORMAT COLOR 4 INTENSIFIED ON.
        GV_MESSAG = 'I-Info'.
      ELSEIF IT_BAPIRETURN-TYPE = 'A'.
        FORMAT COLOR 5 INTENSIFIED ON.
        GV_MESSAG = 'A-Abort'.
      ENDIF.
      WRITE : 41 GV_MESSAG,
              54 SY-VLINE,
              56 IT_BAPIRETURN-MESSAGE,
             142 SY-VLINE.
      CLEAR GV_MESSAG.
      WRITE : /1(142) SY-ULINE.
      GV_FLAG1 = GV_FLAG.
    ENDLOOP.
    GV_FLAG = GV_FLAG + 1.
    CLEAR : IT_BAPIEKKOC,
            IT_BAPIEKKOA,
            IT_BAPIEKPOC,
            IT_BAPIEKET,
            IT_BAPIEKKN.
    REFRESH : IT_BAPIEKPOC,
              IT_BAPIEKET,
              IT_BAPIEKKN.
    AT LAST.
      FORMAT COLOR 4 INTENSIFIED ON.
      WRITE : /1 SY-VLINE,
               3 'End of Purchase Order Creation',
               142 SY-VLINE.
      WRITE : /1(142) SY-ULINE.
      SKIP 1.
    ENDAT.

ENDLOOP. " AT HEADER.

In the above bapi you have to pass data in the header parameter and item tables after uploading data from your local system....

Any other clarification please let me know....

Reward Points...

Cheers,

Enjoy...

Sagun Desai...