Skip to Content
author's profile photo Former Member
Former Member

BDC Program

Dear sir,

i need model program of Product cost collector using kkf6n transaction bdc

Program

Thanks

withregards,

Meena

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 26, 2007 at 05:02 AM

    Hi

    the BDC program should be in this format

    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 doesn’t 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 transaction’s 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.

    i am giving you example for Change Vendor you practice for ur tcode

    For our example, we will use the “Change Vendor” transaction (“FK02”) to add a street address to an already existing vendor.

    Step #1

    Use “System&#61664;Status” menu path to determine online program name (SAPMF02K), screen number (0110)

    Step #2

    Use “F1” key and “Technical Info” pushbutton in each screen field to be filled to determine the field name.

    Step #3

    Determine how to proceed in the transaction

    (save the record by clicking on the ‘Save’ pushbutton or pressing the ‘F11’ key).

    BDC Table Contents

    After researching the transaction we can determine the contents of the BDC table.

    PROGRAM DYNPRO DYNBEGIN FNAM FVAL

    SAMPF02K 0106 X

    RF02K-LIFNR TEST1

    RF02K-D0110 X

    SAMPF02K 0110 X

    LFA1-STRAS 123 Main St.

    BDC_OKCODE /11

    Batch Input Methods

    “CALL TRANSACTION USING”

    STATEMENT

    Call transaction - for data transfer

    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.

    Syntax:

    CALL TRANSACTION <tcode>

    USING <bdc_tab>

    MODE <mode>

    UPDATE <update>

    A Display all

    E Display errors only

    N No display

    S Synchronous

    A Asynchronous

    L Local update

    The process flow of CALL TRANSACTION

    A program that uses CALL TRANSACTION USING to process legacy data should execute thefollowing steps:

    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.

    IF SY-SUBRC <> 0.

    <Error_handling>.

    ENDIF.

    Overview of Batch Input Session

    The first batch input method is to create a batch input session. It is the processing of this batch input session that updates the database, not the execution of the batch input program.

    Reward if usefull

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.