BDC Data transfer - Session method...?

Dear All,
How to Transfer data using BDC Session method? - Step-by-step Process.
Regards,
Dharmesh

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.

Similar Messages

  • BDC Batch input session method

    Hi ,
               I am new to SAP progamming. Pls let me know the basics of BDC Batch Input session method and Call transaction method. I want to know the pros and cons of both methods with justification. Please help me in this regarding.

    Hi,
    Session method.
    1) synchronous 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) asynchronous processing
    2) can transfer small amount of data
    3) processing is faster.
    4) errors need to be handled explicitly
    5) data is updated automatically
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    Session method:
    1. Data migration is done in two steps .. Generate session and Process session.
    So resouces can be used efficiently. good for bulkdata migration.
    2. Session method generates error log when u process a session.
    3. No SY-SUBRC can be returned after each transaction is called.
    4. Provides synchronous Updation only...
    Call transaction method:
    1. Data migration is done in single steps ..bcoz Transactions are called immediately after filling BDCDATA table. So good for small amount of data.
    2. We have to collect error messages using BDCMSGCOLL Table
    3. Returns SY-SUBRC and Messages ..after each Call Transaction..very useful feature for further processing based on the Status and Messages..
    4. Supports Asynch or Synch Updation.
    Example code for session method
    Here is the porgram for Purchase order
    REPORT zmm0069 NO STANDARD PAGE HEADING
                                      MESSAGE-ID z0
                                      LINE-SIZE  132
                                      LINE-COUNT 65(2).
                         Internal Tables                                 *
    *Internal table for the purchasing info records fields.
      DATA: BEGIN OF i_inforecord OCCURS 0,
            matnr(18),
            lifnr(10),
            uom(3),
            ekgrp(3),
            planned_time(3),
            under_tol(3),
            over_tol(3),
            qty(10),
            price_cat(5),
            inco(3),
            designation(28),
            netpr(13),
            scale_qty1(10),
            scale_pr1(13),
            scale_qty2(10),
            scale_pr2(13),
            scale_qty3(13),
            scale_pr3(10),
            scale_qty4(13),
            scale_pr4(10),
            scale_qty5(13),
            scale_pr5(10),
            scale_qty6(13),
            scale_pr6(10),
            scale_qty7(13),
            scale_pr7(10),
            scale_qty8(13),
            scale_pr8(10),
            scale_qty9(13),
            scale_pr9(10),
            scale_qty10(13),
            scale_pr10(10),
            END OF i_inforecord.
    Internal table for Old and New Vendor number
      DATA : BEGIN OF i_lfb1 OCCURS 1,
             lifnr(10),
             altkn(10),
             END   OF i_lfb1.
    Declare internal table for Call Transaction and BDC Session
      DATA: i_bdc_table LIKE bdcdata OCCURS 0 WITH HEADER LINE.
                         Global Variables                                *
      DATA: g_counter(2) TYPE n,
            g_field_name(18) TYPE c,
            zc_yes  TYPE syftype VALUE 'X'.
                         Selection Screen                                *
      SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
      PARAMETERS: p_fname1 TYPE localfile .
      SELECTION-SCREEN SKIP 1.
      SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
      PARAMETERS: p_rloc1 AS CHECKBOX  DEFAULT 'X'.
      SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
      PARAMETERS p_group(12) OBLIGATORY DEFAULT 'ZPURCHINFO'.
      SELECTION-SCREEN END OF BLOCK c.
      SELECTION-SCREEN END OF BLOCK b.
      SELECTION-SCREEN END OF BLOCK a.
    **WRITE the report header
      TOP-OF-PAGE.
        INCLUDE zheading.
                         Start of selection                              *
      START-OF-SELECTION.
    Load Input file
        PERFORM f_load_input_file.
    Create BDC records.
        PERFORM create_bdc_records .
    *&      Form  Create_BDC_records
          Perform the BDC for the records in the internal table
      FORM create_bdc_records .
        IF NOT i_inforecord[] IS INITIAL.
    Open BDC session
          PERFORM open_bdc_session.
          SELECT lifnr altkn FROM lfb1 INTO TABLE i_lfb1
                              FOR ALL ENTRIES IN i_inforecord
                              WHERE altkn = i_inforecord-lifnr.
    Sorting the Internal table for better performance
          SORT i_lfb1 BY altkn.
          LOOP AT i_inforecord.
    ***Mapping Old Vendor number to the new Vendor number
            READ TABLE i_lfb1 WITH KEY altkn = i_inforecord-lifnr BINARY
                                                                  SEARCH.
            IF sy-subrc EQ 0.
              i_inforecord-lifnr = i_lfb1-lifnr.
            ENDIF.
            CLEAR i_bdc_table[].
            PERFORM insert_screen_header.
         call transaction 'ME11' using i_bdc_table
                       mode 'A'.
         CLEAR i_bdc_table.
          ENDLOOP.
          CLEAR i_inforecord[].
          PERFORM close_bdc_session.
    Release the BDC sessions created
          PERFORM release_bdc.
        ENDIF.
      ENDFORM.                    " open_group
    *&      Form  bdc_dynpro_start
          Start the screen for the transfer of fields
      FORM bdc_dynpro_start  USING    p_g_program_1
                                      p_g_screen.
        CLEAR i_bdc_table.
        i_bdc_table-program  = p_g_program_1.
        i_bdc_table-dynpro   = p_g_screen.
        i_bdc_table-dynbegin = 'X'.
        APPEND i_bdc_table.
      ENDFORM.                    " bdc_dynpro_start_start
    *&      Form  bdc_insert_field
           Insert field                                                  *
      FORM bdc_insert_field USING f_name f_value.
        IF f_value <> space.
          CLEAR i_bdc_table.
          i_bdc_table-fnam = f_name.
          i_bdc_table-fval = f_value.
          APPEND i_bdc_table.
        ENDIF.
      ENDFORM.                    "bdc_insert_field
    *&      Form  open_bdc_session
          Open a BDC session
      FORM open_bdc_session .
    Open BDC session and create and update records
        CALL FUNCTION 'BDC_OPEN_GROUP'
          EXPORTING
            client                    = sy-mandt
          DEST                      = FILLER8
            group                     = p_group
          HOLDDATE                  = FILLER8
            keep                      = 'X'
            user                      = sy-uname
          RECORD                    = FILLER1
          PROG                      = SY-CPROG
        IMPORTING
          QID                       =
       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.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDFORM.                    " create_bdc_session
    *&      Form  insert_screen_header
          Screen flow for the transfer of fields
      FORM insert_screen_header .
    First Screen 100
        PERFORM bdc_dynpro_start USING 'SAPMM06I' '0100'.
        PERFORM bdc_insert_field USING:'BDC_CURSOR' 'EINA-LIFNR',
                                       'BDC_OKCODE' '/00',
                                       'EINA-LIFNR' i_inforecord-lifnr,
                                       'EINA-MATNR' i_inforecord-matnr,
                                       'EINE-EKORG' '1000',
                                       'RM06I-NORMB' zc_yes.
    Next Screen 101
        PERFORM bdc_dynpro_start USING 'SAPMM06I' '0101'.
        PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'EINA-MAHN1',
                                         'BDC_OKCODE' '/00',
                                         'EINA-MEINS' i_inforecord-uom.
    *Next Screen 102
        PERFORM bdc_dynpro_start USING 'SAPMM06I' '0102'.
        PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'EINE-INCO2',
                                     'EINE-APLFZ' i_inforecord-planned_time,
                                     'EINE-EKGRP' i_inforecord-ekgrp,
                                     'EINE-NORBM' i_inforecord-qty.
        PERFORM bdc_insert USING  'EINE-UEBTK' ' '.
        PERFORM bdc_insert_field USING:'EINE-PEINH' i_inforecord-scale_qty1,
                                       'EINE-BPRME' i_inforecord-uom,
                                       'EINE-UNTTO' '5',
                                       'EINE-UEBTO' '25',
                                       'EINE-MEPRF' i_inforecord-price_cat,
                                       'EINE-NETPR' i_inforecord-netpr,
                                       'EINE-INCO1' i_inforecord-inco,
                                      'EINE-INCO2' i_inforecord-designation.
    Checking for Scale quantities
        IF i_inforecord-scale_qty2 = space.
          PERFORM bdc_insert_field  USING 'BDC_OKCODE' '=BU'.
          PERFORM insert_bdc_new.
        ELSE.
          PERFORM bdc_insert_field  USING 'BDC_OKCODE' '=KO'.
    Next Screen 201
          PERFORM bdc_dynpro_start USING 'SAPMV13A' '0201'.
          PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'RV13A-DATAB',
                                            'BDC_OKCODE' '=PSTF'.
    Next Screen 201
          PERFORM bdc_dynpro_start USING 'SAPMV13A' '0201'.
          PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'KONP-KSCHL(01)',
                                           'BDC_OKCODE' '=PSTF',
                                           'RV130-SELKZ(01)' zc_yes.
    LAST SCREEN 303
          PERFORM bdc_dynpro_start USING 'SAPMV13A' '0303'.
          PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'KONM-KBETR(03)',
                                           'BDC_OKCODE' '=SICH'.
    Counter to Loop the Item level entry
          g_counter = 0.
          PERFORM scale_entry USING i_inforecord-scale_qty2
                                    i_inforecord-scale_pr2.
          PERFORM scale_entry USING i_inforecord-scale_qty3
                                    i_inforecord-scale_pr3.
          PERFORM scale_entry USING i_inforecord-scale_qty4
                                    i_inforecord-scale_pr4.
          PERFORM scale_entry USING i_inforecord-scale_qty5
                                    i_inforecord-scale_pr5.
          PERFORM scale_entry USING i_inforecord-scale_qty6
                                    i_inforecord-scale_pr6.
          PERFORM scale_entry USING i_inforecord-scale_qty7
                                    i_inforecord-scale_pr7.
          PERFORM scale_entry USING i_inforecord-scale_qty8
                                    i_inforecord-scale_pr8.
          PERFORM scale_entry USING i_inforecord-scale_qty9
                                    i_inforecord-scale_pr9.
          PERFORM scale_entry USING  i_inforecord-scale_qty10
                                     i_inforecord-scale_pr10.
          PERFORM insert_bdc_new.
        ENDIF.
      ENDFORM.                    " insert_screen_header
    *&      Form  insert_bdc
          Insert BDC
      FORM insert_bdc_new .
        CALL FUNCTION 'BDC_INSERT'
           EXPORTING
             tcode                  = 'ME11'
          POST_LOCAL             = NOVBLOCAL
          PRINTING               = NOPRINT
          SIMUBATCH              = ' '
          CTUPARAMS              = ' '
           TABLES
             dynprotab              = i_bdc_table
        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.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CLEAR i_bdc_table[].
      ENDFORM.                    " insert_bdc
    *&      Form  close_bdc_session
         Close the BDC session
      FORM close_bdc_session .
        CALL FUNCTION 'BDC_CLOSE_GROUP'
             EXCEPTIONS
                  not_open    = 1
                  queue_error = 2
                  OTHERS      = 3.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDFORM.                    " close_bdc_session
    *&      Form  f_load_input_file
          Upload the file
      FORM f_load_input_file.
    Check always Local file for upload
        IF p_rloc1 = zc_yes.
          CALL FUNCTION 'WS_UPLOAD'
               EXPORTING
                    filename                = p_fname1
                    filetype                = 'DAT'
               TABLES
                    data_tab                = i_inforecord
               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 <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            STOP.
          ENDIF.
        ENDIF.
      ENDFORM.                    " f_load_input_file
    *&      Form  release_bdc
         Release the session
      FORM release_bdc.
        SUBMIT rsbdcsub WITH mappe EQ p_group
                        WITH von EQ sy-datum
                        WITH bis EQ sy-datum
                        WITH fehler EQ '.'
                        EXPORTING LIST TO MEMORY
                        AND RETURN.
      ENDFORM.                    " release_bdc
    *&      Form  scale_entry
          Populate the Scale quantities
         -->P_SCALE_QTY
         -->P_SCALE_PRICE
      FORM scale_entry USING    p_scale_qty
                                p_scale_price.
    Increment the Counter
        g_counter = g_counter + 1.
        IF p_scale_qty <> space.
          CONCATENATE 'KONM-KSTBM('  g_counter  ')' INTO g_field_name.
          PERFORM bdc_insert_field USING g_field_name p_scale_qty.
          CONCATENATE 'KONM-KBETR('  g_counter  ')' INTO g_field_name.
          PERFORM bdc_insert_field USING g_field_name p_scale_price.
        ENDIF.
      ENDFORM.
    *&      Form  bdc_insert
          To uncheck the Unlimited (UEBTK)
      FORM bdc_insert USING  f_name f_value.
        CLEAR i_bdc_table.
        i_bdc_table-fnam = f_name.
        i_bdc_table-fval = f_value.
        APPEND i_bdc_table.
      ENDFORM.                    " bdc_insert
    Reward points if it is usefull ....
    Cheers,
    Chandra Sekhar.

  • Bdc data transfer

    Hai anybody plz help me, How to upload open purchase orders. Where should i to give the condition for extracting only open purchase orders from all p.o's.

    Somu,
    just refer:
    List of opened purchase order.
    And use BAPI_PO_CREATE for uoload po.
    Amit.

  • HT3887 My iMac won't communicate with my mouse.  It keeps saying "wireless connection undiscoverable".  This is the first time I have set up my equipment after having a Data Transfer session yesterday. It's a brand new computer.  How can I fix this?

    How do I get my iMac to communicate with my mouse.  It keeps saying "wireless connection not discoverable". Thanks

    Hey Jeanette
    If you have a USB mouse handy, you can plug it in and use it to navigate to the Bluetooth settings in System Preferences to get the mouse to pair again. There are also troubleshooting steps in the article below for getting the mouse to pair as well.
    Troubleshooting wireless mouse and keyboard issues
    http://support.apple.com/kb/TS3048
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • BDC Program - Session Method For Add and Edit Data

    Hi,
    How to write a BDC program (For Session Method) to upload Sales Order Data (VA01) and at the same
    time to modify the data if the Order exists?
    Thanks
    Murthy

    Hi,
    go to SHDB
            Create a project and recording the Va01 and then u write the code for That recording.

  • What is difference bet  call transaction and session method in BDC

    hi
    what is difference bet  call transaction and session method in BDC
    thanks.

    Hi,
    Session method.
    1) synchronous 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) asynchronous processing
    2) can transfer small amount of data
    3) processing is faster.
    4) errors need to be handled explicitly
    5) data is updated automatically
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    call Transaction or session method ?
    Thanks,
    Reward If Helpful.

  • Error occured in bdc(session method)

    hai,
    i was written one bdc program with session method but unfortunatly it's throwing some error like bdc_group is invalid.
    this problem happening at when i was going to give the file path through f4 in selection screen it's showing like  BDC_OPEN_GROUP, group .. is invalid
    iam sending my coding also plz give me the clarifications abt this one.
               SESSION METHOD           **********************
    TYPES : BEGIN OF TY_DATA,
           LIFNR TYPE LIFNR,
           EKORG TYPE EKORG,
           KTOKK TYPE KTOKK,
           NAME1 TYPE NAME1_GP,
           SORTL TYPE SORTL,
           LAND1 TYPE LAND1_GP,
           WAERS TYPE BSTWA,
           END OF TY_DATA.
    DATA : WA_DATA TYPE TY_DATA,
           WA_BDCDATA TYPE BDCDATA,
           WA_BDCMSGCOLL TYPE BDCMSGCOLL.
    DATA : IT_DATA TYPE TABLE OF TY_DATA,
           IT_BDCDATA TYPE TABLE OF BDCDATA,
           IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.
    DATA : V_FILE TYPE STRING.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER : PA_FILE LIKE FC03TAB-PL00_FILE, "OBLIGATORY default 'C:\MAHESH\IT_FILE.TXT'
                P_GROUP LIKE APQI-GROUPID OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
      PERFORM GET_F4_FOR_FILE USING PA_FILE.
      V_FILE = PA_FILE.
      PERFORM UPLOAD_FILE_TO_ITAB USING V_FILE CHANGING IT_DATA.
      PERFORM OPEN_SESSION USING P_GROUP.
      LOOP AT IT_DATA INTO WA_DATA.
        REFRESH IT_BDCDATA.
    FIRST SCREEN DETAILS
        PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0107' 'X'.
    **** FIELD DETAILS
        PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'RF02K-KTOKK'.
    OK CODES
        PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '/00'.
    **** FILED LIFNR
        PERFORM FILL_FIELD_DETAILS USING 'RF02K-LIFNR' WA_DATA-LIFNR.
    FIELD EKORG
        PERFORM FILL_FIELD_DETAILS USING 'RF02K-EKORG' WA_DATA-EKORG.
    **** FIELD KTOKK
        PERFORM FILL_FIELD_DETAILS USING 'RF02K-KTOKK' WA_DATA-KTOKK.
    SECOND SCREEN DETAILS
        PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0110' 'X'.
    FIELD CURSOR
        PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'lfa1-land1'.
    OK CODES
        PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
    field NAME
        PERFORM FILL_FIELD_DETAILS USING 'LFA1-NAME1' WA_DATA-NAME1.
    field SORTL
        PERFORM FILL_FIELD_DETAILS USING 'LFA1-SORTL' WA_DATA-SORTL.
    field LAND1
        PERFORM FILL_FIELD_DETAILS USING 'LFA1-LAND1' WA_DATA-LAND1.
    THIRD SCREEN DETAILS
        PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0310' 'X'.
    FIELD CURSOR
        PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'LFM1-WAERS'.
    OK CODES
        PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
       ******** field SORTL
        PERFORM FILL_FIELD_DETAILS USING 'LFM1-WAERS' WA_DATA-WAERS.
        PERFORM BDC_INSERT USING 'MK01' IT_BDCDATA.
      ENDLOOP.
      PERFORM CLOSE_SESSION.
    *&      Form  GET_F4_FOR_FILE
    FORM GET_F4_FOR_FILE  USING    P_PA_FILE.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          FIELD_NAME = 'PA_FILE'
        CHANGING
          FILE_NAME  = PA_FILE.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " GET_F4_FOR_FILE
    *&      Form  UPLOAD_FILE_TO_ITAB
    FORM UPLOAD_FILE_TO_ITAB  USING    FP_V_FILE
                              CHANGING FP_IT_DATA LIKE IT_DATA.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME            = FP_V_FILE
          FILETYPE            = 'ASC'
          HAS_FIELD_SEPARATOR = 'X'
        TABLES
          DATA_TAB            = FP_IT_DATA.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " UPLOAD_FILE_TO_ITAB
    *&      Form  OPEN_SESSION
    FORM OPEN_SESSION  USING    FP_P_GROUP.
      CALL FUNCTION 'BDC_OPEN_GROUP'
       EXPORTING
         CLIENT                    = SY-MANDT
      DEST                      = FILLER8
         GROUP                     = FP_P_GROUP
      HOLDDATE                  = FILLER8
         KEEP                      =  'X'
         USER                      = SY-UNAME
      IF SY-SUBRC = 0.
        WRITE : / 'PROCESS THE SESSION',FP_P_GROUP,'USING SM35'.
      ENDIF.
    ENDFORM.                    " OPEN_SESSION
    *&      Form  FILL_SCREEN_DETAILS
    FORM FILL_SCREEN_DETAILS  USING PROGRAM
                                    DYNPRO
                                    DYNBEGIN.
      WA_BDCDATA-PROGRAM = PROGRAM.
      WA_BDCDATA-DYNPRO  = DYNPRO.
      WA_BDCDATA-DYNBEGIN = DYNBEGIN.
      APPEND WA_BDCDATA TO IT_BDCDATA.
      CLEAR WA_BDCDATA.
    ENDFORM.                    " FILL_SCREEN_DETAILS
    *&      Form  FILL_FIELD_DETAILS
    FORM FILL_FIELD_DETAILS  USING  FNAM FVAL.
      WA_BDCDATA-FNAM = FNAM.
      WA_BDCDATA-FVAL = FVAL.
      APPEND WA_BDCDATA TO IT_BDCDATA.
      CLEAR WA_BDCDATA.
    ENDFORM.                    " FILL_FIELD_DETAILS
    *&      Form  BDC_INSERT
    FORM BDC_INSERT  USING FP_TCODE TYPE SYTCODE
                           FP_IT_BDCDATA LIKE IT_BDCDATA.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE     = FP_TCODE
        TABLES
          DYNPROTAB = FP_IT_BDCDATA.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " BDC_INSERT
    *&      Form  CLOSE_SESSION
    FORM CLOSE_SESSION .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
      NOT_OPEN          = 1
      QUEUE_ERROR       = 2
      OTHERS            = 3
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " CLOSE_SESSION

    hai,
    i was written one bdc program with session method but unfortunatly it's throwing some error like bdc_group is invalid.
    this problem happening at when i was going to give the file path through f4 in selection screen it's showing like  BDC_OPEN_GROUP, group .. is invalid
    iam sending my coding also plz give me the clarifications abt this one.
               SESSION METHOD           **********************
    TYPES : BEGIN OF TY_DATA,
           LIFNR TYPE LIFNR,
           EKORG TYPE EKORG,
           KTOKK TYPE KTOKK,
           NAME1 TYPE NAME1_GP,
           SORTL TYPE SORTL,
           LAND1 TYPE LAND1_GP,
           WAERS TYPE BSTWA,
           END OF TY_DATA.
    DATA : WA_DATA TYPE TY_DATA,
           WA_BDCDATA TYPE BDCDATA,
           WA_BDCMSGCOLL TYPE BDCMSGCOLL.
    DATA : IT_DATA TYPE TABLE OF TY_DATA,
           IT_BDCDATA TYPE TABLE OF BDCDATA,
           IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.
    DATA : V_FILE TYPE STRING.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER : PA_FILE LIKE FC03TAB-PL00_FILE, "OBLIGATORY default 'C:\MAHESH\IT_FILE.TXT'
                P_GROUP LIKE APQI-GROUPID OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
      PERFORM GET_F4_FOR_FILE USING PA_FILE.
      V_FILE = PA_FILE.
      PERFORM UPLOAD_FILE_TO_ITAB USING V_FILE CHANGING IT_DATA.
      PERFORM OPEN_SESSION USING P_GROUP.
      LOOP AT IT_DATA INTO WA_DATA.
        REFRESH IT_BDCDATA.
    FIRST SCREEN DETAILS
        PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0107' 'X'.
    **** FIELD DETAILS
        PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'RF02K-KTOKK'.
    OK CODES
        PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '/00'.
    **** FILED LIFNR
        PERFORM FILL_FIELD_DETAILS USING 'RF02K-LIFNR' WA_DATA-LIFNR.
    FIELD EKORG
        PERFORM FILL_FIELD_DETAILS USING 'RF02K-EKORG' WA_DATA-EKORG.
    **** FIELD KTOKK
        PERFORM FILL_FIELD_DETAILS USING 'RF02K-KTOKK' WA_DATA-KTOKK.
    SECOND SCREEN DETAILS
        PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0110' 'X'.
    FIELD CURSOR
        PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'lfa1-land1'.
    OK CODES
        PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
    field NAME
        PERFORM FILL_FIELD_DETAILS USING 'LFA1-NAME1' WA_DATA-NAME1.
    field SORTL
        PERFORM FILL_FIELD_DETAILS USING 'LFA1-SORTL' WA_DATA-SORTL.
    field LAND1
        PERFORM FILL_FIELD_DETAILS USING 'LFA1-LAND1' WA_DATA-LAND1.
    THIRD SCREEN DETAILS
        PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0310' 'X'.
    FIELD CURSOR
        PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'LFM1-WAERS'.
    OK CODES
        PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
       ******** field SORTL
        PERFORM FILL_FIELD_DETAILS USING 'LFM1-WAERS' WA_DATA-WAERS.
        PERFORM BDC_INSERT USING 'MK01' IT_BDCDATA.
      ENDLOOP.
      PERFORM CLOSE_SESSION.
    *&      Form  GET_F4_FOR_FILE
    FORM GET_F4_FOR_FILE  USING    P_PA_FILE.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          FIELD_NAME = 'PA_FILE'
        CHANGING
          FILE_NAME  = PA_FILE.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " GET_F4_FOR_FILE
    *&      Form  UPLOAD_FILE_TO_ITAB
    FORM UPLOAD_FILE_TO_ITAB  USING    FP_V_FILE
                              CHANGING FP_IT_DATA LIKE IT_DATA.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME            = FP_V_FILE
          FILETYPE            = 'ASC'
          HAS_FIELD_SEPARATOR = 'X'
        TABLES
          DATA_TAB            = FP_IT_DATA.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " UPLOAD_FILE_TO_ITAB
    *&      Form  OPEN_SESSION
    FORM OPEN_SESSION  USING    FP_P_GROUP.
      CALL FUNCTION 'BDC_OPEN_GROUP'
       EXPORTING
         CLIENT                    = SY-MANDT
      DEST                      = FILLER8
         GROUP                     = FP_P_GROUP
      HOLDDATE                  = FILLER8
         KEEP                      =  'X'
         USER                      = SY-UNAME
      IF SY-SUBRC = 0.
        WRITE : / 'PROCESS THE SESSION',FP_P_GROUP,'USING SM35'.
      ENDIF.
    ENDFORM.                    " OPEN_SESSION
    *&      Form  FILL_SCREEN_DETAILS
    FORM FILL_SCREEN_DETAILS  USING PROGRAM
                                    DYNPRO
                                    DYNBEGIN.
      WA_BDCDATA-PROGRAM = PROGRAM.
      WA_BDCDATA-DYNPRO  = DYNPRO.
      WA_BDCDATA-DYNBEGIN = DYNBEGIN.
      APPEND WA_BDCDATA TO IT_BDCDATA.
      CLEAR WA_BDCDATA.
    ENDFORM.                    " FILL_SCREEN_DETAILS
    *&      Form  FILL_FIELD_DETAILS
    FORM FILL_FIELD_DETAILS  USING  FNAM FVAL.
      WA_BDCDATA-FNAM = FNAM.
      WA_BDCDATA-FVAL = FVAL.
      APPEND WA_BDCDATA TO IT_BDCDATA.
      CLEAR WA_BDCDATA.
    ENDFORM.                    " FILL_FIELD_DETAILS
    *&      Form  BDC_INSERT
    FORM BDC_INSERT  USING FP_TCODE TYPE SYTCODE
                           FP_IT_BDCDATA LIKE IT_BDCDATA.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE     = FP_TCODE
        TABLES
          DYNPROTAB = FP_IT_BDCDATA.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " BDC_INSERT
    *&      Form  CLOSE_SESSION
    FORM CLOSE_SESSION .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
      NOT_OPEN          = 1
      QUEUE_ERROR       = 2
      OTHERS            = 3
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " CLOSE_SESSION

  • BDC ( Call Session Method)

    how to make bdc using call session method.

    Hi,
    Use this code,you can easily understand which u want to know
    DATA: BEGIN OF itab OCCURS 0,
          str(255),
          END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0,
          lifnr LIKE lfa1-lifnr,
          name1 LIKE lfa1-name1,
          ort01 LIKE lfa1-ort01,
          END OF itab1.
    DATA: jtab LIKE bdcdata OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                = 'D:\ABAP EVE\ffile5.txt'
        filetype                = 'ASC'
      TABLES
        data_tab                = itab
      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
        no_authority            = 10
        OTHERS                  = 11.
    IF sy-subrc <> 0.
      WRITE:/ 'no file exist'.
    ENDIF.
    LOOP AT itab.
      SPLIT itab-str AT ',' INTO itab1-lifnr itab1-name1 itab1-ort01.
      APPEND itab1.
    ENDLOOP.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
       client                    = sy-mandt
      DEST                      = FILLER8
       group                     = 'ZCSSESSIONM1'
      HOLDDATE                  = FILLER8
       keep                      = 'X'
       user                      = sy-uname
      RECORD                    = FILLER1
      PROG                      = SY-CPROG
    IMPORTING
      QID                       =
    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.
    LOOP AT itab1.
      PERFORM prginfo USING 'SAPMZBDCCT' '123'.
      PERFORM fldinfo USING 'i01' itab1-lifnr.
      PERFORM fldinfo USING 'i02' itab1-name1.
      PERFORM fldinfo USING 'i03' itab1-ort01.
    CALL TRANSACTION 'ZCSBDCCT' USING jtab.
      CALL FUNCTION 'BDC_INSERT'
       EXPORTING
         tcode                  = 'ZCSBDCCT'
        POST_LOCAL             = NOVBLOCAL
        PRINTING               = NOPRINT
        SIMUBATCH              = ' '
        CTUPARAMS              = ' '
        TABLES
          dynprotab              = jtab
       EXCEPTIONS
         internal_error         = 1
         not_open               = 2
         queue_error            = 3
         tcode_invalid          = 4
         printing_invalid       = 5
         posting_invalid        = 6
         OTHERS                 = 7.
    ENDLOOP.
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    *&      Form  prginfo
          text
         -->PRGNAME    text
         -->SCRNUMBER  text
    FORM prginfo USING prgname scrnumber.
      CLEAR jtab.
      REFRESH jtab.
      jtab-program = prgname.
      jtab-dynpro = scrnumber.
      jtab-dynbegin = 'X'.
      APPEND jtab.
    ENDFORM.                    "prginfo
    *&      Form  fldinfo
          text
         -->FLDNM      text
         -->FLDVAL     text
    FORM fldinfo USING fldnm fldval.
      CLEAR jtab.
      jtab-fnam = fldnm.
      jtab-fval = fldval.
      APPEND jtab.
    ENDFORM.                    "fldinfo
    MPP CODE.
    TOP-INCLUDE.
    DATA: OK_CODE TYPE SY-UCOMM.
    DATA: I01(10),I02(20),I03(26).
    DATA: WA TYPE LFA1.
    PAI
    CASE OK_CODE.
       WHEN 'INSERT'.
         MOVE I01 TO WA-LIFNR.
         MOVE I02 TO WA-NAME1.
         MOVE I03 TO WA-ORT01.
         INSERT INTO LFA1 VALUES WA.
         IF SY-SUBRC = 0.
           MESSAGE I001(ZCSMSG).
         ELSE.
           MESSAGE I002(ZCSMSG).
         ENDIF.
       WHEN 'EXIT'.
         LEAVE PROGRAM.
    ENDCASE.
    Create the 3 io's in layout and 2 pushbuttons(exit,insert).
    Open SM35 TCode -> select the session -> Click on "Process" from application toolbar
    -> select mode of execution(foreground/background) -> click on "process".
    Flatfile data:
    300001,Yogesh,Secundrabad
    320003,Wreline,Mexico
    320004,Alexme,New York
    And store this in "D:\ABAP EVE\ffile5.txt" path
    Reward,if it is useful.
    Thanks,
    Chandu.

  • BDC Program for T-code MI10 in Session Method.

    hi everyone,
      I want a  BDC Program in Session Method using t-code MI10.
    If also ther is no pgms for this T-code, then can anybody send me a bdc program using Session Method...
    With Regards,
    Seevangi

    hi everyone,
      I want a  BDC Program in Session Method using t-code MI10.
    If also ther is no pgms for this T-code, then can anybody send me a bdc program using Session Method...
    With Regards,
    Seevangi

  • BDC ---Data maintainance at flat file

    Hi All,
    Iam a BI resource learning ABAP.
    I have started learning abap in that currently working with BDC.
    Here iam trying to extract data from flat file(note pad) for practice purpose and extraxting data by session method fore ground process.
    Here in flat file i want to maintain two table of data and want to insert this data in related tables.
    i have created note pad file
    for vendor data and customer data have maintained data horizontally like
    lifnr    name1     land1     kunnr    name1   land1
    1      xx               US      2        yyyy            UK
    Finally the data is geting inserted in the lfa1 and kna1 table are like
    lifnr 1 record s at vendor table and kunnr2 record is at customer table.
    but now i want to maintain data at note pad as in vertical like
    lifnr    name1     land1 (not maintaining these fileds in note pad only values giving in note pad)
    1      xx               US
    kunnr    name1   land1
    2        yyyy            UK
    So is there any way to maintain my data in note pad like this.
    please advice.
    regards
    Saha

    hie
    I hope i understood you well, you want to maintain many records in your flat file you are still able to pick them all.  Please elaborate what you mean by maintaining your records in vertical format???
    Vendor file
    1,200,ABC,02
    2,200,DEF,02
    Customer file
    1,200,QWE,02
    2,200,SDW,02
    The two sets of data seem to be different ie Customer and Vendor thus i think you should maintain the two as separate files and pick both at the same time.
    regards
    Isaac Prince

  • Can we use Call transaction and session method in same program ?

    Hi experts,
                     Is it suggested to use call Transaction and session method in the same Program ?
                     i have a doubt , why cant we use multiple call transactions in same program instead of session method if we have multiple transaction updations ?

    Hi Dengyong Zhang,
    we can use the call transation and session method in same program.
    However for better performance it's benificial to use call trasaction method of BDC. but if u want to upload very large amount of data then Session method is more preferable to use.
    Session method is one of the method of BDC.
    U can also use BAPI to upload the data in SAP but it's a different concept than BDC. Performance wise BAPI is more advantageous than BDC.

  • Call transaction , and session  method in the same program

    hi experts,
                Can anybody tell me in which cases we will use both call transaction and session methods in same program
    if possible send me example code.
    Regards
    Trinadh

    Hi Dengyong Zhang,
    we can use the call transation and session method in same program.
    However for better performance it's benificial to use call trasaction method of BDC. but if u want to upload very large amount of data then Session method is more preferable to use.
    Session method is one of the method of BDC.
    U can also use BAPI to upload the data in SAP but it's a different concept than BDC. Performance wise BAPI is more advantageous than BDC.

  • Creation of Material using BDC Session method & global class

    Hi
    Creation of Material using BDC Session method & global class by using oops.
    can anyone plz help me out

    Hi,
    it looks like it's not possible to call this BAPI wihtout material number. Here is a quote from BAPI documentation.
    When creating material master data, you must transfer the material
    number, the material type, and the industry sector to the method. You
    must also enter a material description and its language.
    Cheers

  • BDC using session method

    hai
    can anyone post me bdc using session method plz

    Hi,
    ABAP BDC SESSION METHOD SAMPLE CODE
    pool of form routines
    include zmppn001.
    Define BDC Table Structure
    data: begin of itab_bdc_tab occurs 0.
    include structure bdcdata.
    data: end of itab_bdc_tab.
    Input record layout of Leagcy File
    data: begin of itab_xcel occurs 0,
    matnr(18) type c,
    werks(4) type c,
    alnag(2) type c,
    verid(4) type c,
    text1(40) type c,
    bstmi like mkal-bstmi,
    bstma like mkal-bstma,
    adatu(10) type c,
    bdatu(10) type c,
    stlal(2) type c,
    stlan(1) type c,
    serkz(1) type c,
    mdv01(8) type c,
    elpro(4) type c,
    alort(4) type c,
    end of itab_xcel.
    data: begin of lt_pp04_cache occurs 0,
    matnr like itab_xcel-matnr,
    werks like itab_xcel-werks,
    alnag like itab_xcel-alnag,
    plnnr like mapl-plnnr,
    arbpl like crhd-arbpl,
    ktext like crtx-ktext,
    end of lt_pp04_cache.
    data: v_ssnnr(4) type n,
    v_lines_in_xcel like sy-tabix,
    v_ssnname like apqi-groupid,
    v_trans_in_ssn type i,
    wa_xcel LIKE itab_xcel,
    l_tabix like sy-tabix,
    v_matnr like rc27m-matnr,
    v_plnnr like mapl-plnnr,
    v_plnal like mapl-plnal,
    v_tcode like sy-tcode value 'C223',
    v_plnty like plas-plnty value 'R',
    v_objty like crhd-objty value 'A',
    v_plpo_steus like plpo-steus value 'PP04',
    v_verwe like crhd-verwe value '0007'.
    Parameters
    selection-screen: skip 3.
    selection-screen: begin of block 1 with frame.
    parameters: p_name like rlgrap-filename
    default 'C:\My Documents\InputFile.txt'
    obligatory,
    bdc session name prefix
    p_bdcpfx(6) default 'ZPVCRT'
    obligatory,
    number for transction per BDC session
    p_trnssn type i
    default 2000 obligatory,
    retain the BDC session after successfull execution
    p_keep like apqi-qerase
    default 'X',
    user who will be executing BDC session
    p_uname like apqi-userid
    default sy-uname
    obligatory.
    selection-screen: end of block 1.
    possible entry list (F4 dropdown) for input file name
    at selection-screen on value-request for p_name.
    *-SELECT FILE FROM USERS LOCAL PC
    call function 'WS_FILENAME_GET'
    exporting
    DEF_FILENAME = ' '
    def_path = 'C:\Temp\'
    mask = ',.,..'
    mode = 'O'
    title = 'Select File '(007)
    importing
    filename = p_name
    RC =
    exceptions
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    others = 5.
    if sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    begin the show
    start-of-selection.
    read data from input file
    perform transfer_xcel_to_itab.
    loop at itab_xcel.
    hang on to xcel line num
    l_tabix = sy-tabix.
    each line in the xcel file marks begining of new prod.version defn
    if num-of-trnas-in-session = 0, create new BDC session
    if v_trans_in_ssn is initial.
    perform bdc_session_open.
    endif.
    begin new bdc script for rtg create trans
    fill in bdc-data for prod.version maintenance screens
    perform bdc_build_script.
    insert the bdc script as a BDC transaction
    perform bdc_submit_transaction.
    keep track of how many BDC transactions were inserted in the BDC
    session
    add 1 to v_trans_in_ssn.
    if the user-specified num of trans in BDC session is reached OR
    if end of input file is reached, close the BDC session
    if v_trans_in_ssn = p_trnssn or
    l_tabix = v_lines_in_xcel.
    perform bdc_session_close.
    clear v_trans_in_ssn.
    endif.
    endloop.
    top-of-page.
    call function 'Z_HEADER'
    EXPORTING
    FLEX_TEXT1 =
    FLEX_TEXT2 =
    FLEX_TEXT3 =
    FORM TRANSFER_XCEL_TO_ITAB *
    Transfer Xcel Spreadsheet to SAP Internal Table *
    form transfer_xcel_to_itab.
    Read the tab-delimited file into itab
    call function 'WS_UPLOAD'
    exporting
    filename = p_name
    filetype = 'DAT'
    IMPORTING
    filelength = flength
    tables
    data_tab = itab_xcel
    exceptions
    conversion_error = 1
    file_open_error = 2
    file_read_error = 3
    invalid_table_width = 4
    invalid_type = 5
    no_batch = 6
    unknown_error = 7
    others = 8.
    if sy-subrc = 0.
    sort the data
    sort itab_xcel by matnr werks.
    clear v_lines_in_xcel.
    if no data in the file - error out
    describe table itab_xcel lines v_lines_in_xcel.
    if v_lines_in_xcel is initial.
    write: / 'No data in input file'.
    stop.
    endif.
    else.
    if file upload failed - error out
    write: / 'Error reading input file'.
    stop.
    endif.
    endform.
    FORM BDC_SESSION_OPEN *
    Open BDC Session *
    form bdc_session_open.
    create bdc session name = prefix-from-selectn-screen + nnnn
    add 1 to v_ssnnr.
    concatenate p_bdcpfx v_ssnnr into v_ssnname.
    open new bdc session
    call function 'BDC_OPEN_GROUP'
    exporting
    client = sy-mandt
    group = v_ssnname
    keep = p_keep
    user = p_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.
    endform.
    FORM BDC_BUILD_SCRIPT *
    Build BDC *
    form bdc_build_script.
    data: l_arbpl like crhd-arbpl,
    l_text1 like mkal-text1,
    l_mdv01 like mkal-mdv01,
    l_mapl like mapl.
    clear bdc-data itab - begin of new bdc transaction
    clear itab_bdc_tab.
    refresh itab_bdc_tab.
    read material cross reference tables to determine sap part#
    clear : v_matnr, v_plnnr, v_plnal.
    perform read_matnr_cross_ref using itab_xcel-matnr
    itab_xcel-werks
    changing v_matnr.
    determine the version description to use
    if itab_xcel-text1 is initial.
    l_text1 = itab_xcel-verid.
    else.
    l_text1 = itab_xcel-text1.
    endif.
    determine the routing group# and group ctr# to use
    perform read_routing .
    determine the production line to use
    if itab_xcel-mdv01 is initial.
    if not provided in the file then:
    prod line = work ctr on the last PP04 op of the rtg determined above
    perform read_wc_on_last_pp04 using v_plnnr v_plnal
    changing l_mdv01.
    NOTE: when executing the above form\routine, if v_plnnr is initial
    or v_plnal is initial, THEN l_mdv01 will automatically be
    returned blank (ie initial)
    else.
    l_mdv01 = itab_xcel-mdv01.
    endif.
    build bdc script
    perform bdc_build_script_record
    fill in initial screen
    using: 'X' 'SAPLCMFV' '1000',
    ' ' 'BDC_OKCODE' '=ENTE',
    ' ' 'MKAL-WERKS' itab_xcel-werks,
    ' ' 'MKAL-MATNR' v_matnr,
    ' ' 'MKAL_ADMIN-DISPO' space,
    ' ' 'MKAL-PLNNR' space,
    ' ' 'MKAL_ADMIN-STTAG' space,
    ' ' 'MKAL-PLNNG' space,
    ' ' 'MKAL-MDV01' space,
    ' ' 'MKAL-PLNNM' space,
    click create button on initial screen and go to detail screen
    'X' 'SAPLCMFV' '1000',
    ' ' 'BDC_OKCODE' '=CREA',
    fill in the detail screen and go back to initial screen
    'X' 'SAPLCMFV' '2000',
    ' ' 'BDC_OKCODE' '=CLOS',
    ' ' 'MKAL_EXPAND-MATNR' v_matnr,
    ' ' 'MKAL_EXPAND-VERID' itab_xcel-verid,
    ' ' 'MKAL_EXPAND-TEXT1' l_text1,
    ' ' 'MKAL_EXPAND-BSTMI' itab_xcel-bstmi,
    ' ' 'MKAL_EXPAND-BSTMA' itab_xcel-bstma,
    ' ' 'MKAL_EXPAND-ADATU' itab_xcel-adatu,
    ' ' 'MKAL_EXPAND-BDATU' itab_xcel-bdatu,
    ' ' 'MKAL_EXPAND-PLTYG' v_plnty,
    ' ' 'MKAL_EXPAND-PLNNG' v_plnnr,
    ' ' 'MKAL_EXPAND-ALNAG' v_plnal,
    ' ' 'MKAL_EXPAND-STLAL' itab_xcel-stlal,
    ' ' 'MKAL_EXPAND-STLAN' itab_xcel-stlan,
    ' ' 'MKAL_EXPAND-SERKZ' itab_xcel-serkz,
    ' ' 'MKAL_EXPAND-MDV01' l_mdv01,
    ' ' 'MKAL_EXPAND-ELPRO' itab_xcel-elpro,
    ' ' 'MKAL_EXPAND-ALORT' itab_xcel-alort,
    save the production version from initial screen
    'X' 'SAPLCMFV' '1000',
    ' ' 'BDC_OKCODE' '=SAVE'.
    endform.
    FORM BDC_SUBMIT_TRANSACTION *
    Submit BDC Session *
    form bdc_submit_transaction.
    Load BDC script as a trqansction in BDC session
    call function 'BDC_INSERT'
    exporting
    tcode = v_tcode
    tables
    dynprotab = itab_bdc_tab
    exceptions
    internal_error = 01
    not_open = 02
    queue_error = 03
    tcode_invalid = 04.
    endform.
    FORM BDC_BUILD_SCRIPT_RECORD *
    form bdc_build_script_record using dynbegin name value.
    clear itab_bdc_tab.
    if dynbegin = 'X'.
    move: name to itab_bdc_tab-program,
    value to itab_bdc_tab-dynpro,
    'X' to itab_bdc_tab-dynbegin.
    else.
    move: name to itab_bdc_tab-fnam,
    value to itab_bdc_tab-fval.
    shift itab_bdc_tab-fval left deleting leading space.
    endif.
    append itab_bdc_tab.
    endform.
    FORM BDC_SESSION_CLOSE *
    Close BDC Session *
    form bdc_session_close.
    close the session
    call function 'BDC_CLOSE_GROUP'
    exceptions
    not_open = 1
    queue_error = 2
    others = 3.
    skip 2.
    if sy-subrc ne 0.
    write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.
    else.
    write : / 'Session created:', v_ssnname,
    50 '# of transactions:', v_trans_in_ssn.
    endif.
    endform.
    *& Form read_routing_cache
    *FORM read_routing_cache USING pi_matnr
    pi_werks
    pi_alnag
    pi_verid
    pi_mdv01.
    DATA: BEGIN OF lt_plpo OCCURS 0,
    vornr LIKE plpo-vornr,
    objty LIKE crhd-objty,
    objid LIKE crhd-objid,
    arbpl LIKE crhd-arbpl,
    END OF lt_plpo,
    l_mapl_plnnr LIKE mapl-plnnr.
    determine the routing group#
    CLEAR lt_pp04_cache.
    chk if its in the cache first, if not then get it from MAPL table
    and put it in the cache
    READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    IF sy-subrc = 0.
    do nothing - lt_pp04_cache header line has rtg#
    ELSE.
    get the routing group # from MAPL
    SELECT plnnr INTO l_mapl_plnnr
    FROM mapl UP TO 1 ROWS
    WHERE matnr = pi_matnr AND
    werks = pi_werks AND
    plnty = 'R' AND
    plnal = pi_alnag AND
    loekz = space.
    ENDSELECT.
    put it in the cache internal table
    IF NOT l_mapl_plnnr IS INITIAL.
    lt_pp04_cache-matnr = pi_matnr.
    lt_pp04_cache-werks = pi_werks.
    lt_pp04_cache-alnag = pi_alnag.
    lt_pp04_cache-plnnr = l_mapl_plnnr.
    APPEND lt_pp04_cache.
    ENDIF.
    ENDIF.
    if the rtg# was determined AND
    -- the work center was not determined yet AND
    -- work center was really needed for this line in the input file
    then
    -- read the work center from last PP04 operation on the routing
    -- update the cache accordingly
    IF NOT lt_pp04_cache-plnnr IS INITIAL AND
    lt_pp04_cache-arbpl IS INITIAL AND
    ( pi_verid IS INITIAL OR
    pi_mdv01 IS INITIAL ).
    read the last PP04 operation
    CLEAR lt_plpo.
    REFRESH lt_plpo.
    SELECT vornr eobjty eobjid e~arbpl
    INTO CORRESPONDING FIELDS OF TABLE lt_plpo
    FROM plas AS b
    INNER JOIN plpo AS c
    ON bplnty = cplnty AND
    bplnnr = cplnnr AND
    bzaehl = czaehl
    INNER JOIN crhd AS e
    ON carbid = eobjid
    WHERE b~plnty = v_plnty AND
    b~plnnr = lt_pp04_cache-plnnr AND
    b~plnal = lt_pp04_cache-alnag AND
    c~loekz = space AND
    c~steus = v_plpo_steus AND
    e~objty = v_objty AND
    e~werks = lt_pp04_cache-werks AND
    e~verwe = v_verwe.
    SORT lt_plpo BY vornr DESCENDING.
    READ TABLE lt_plpo INDEX 1.
    IF NOT lt_plpo-arbpl IS INITIAL.
    lt_pp04_cache-arbpl = lt_plpo-arbpl.
    read work center description
    SELECT SINGLE ktext INTO lt_pp04_cache-ktext
    FROM crtx WHERE objty = lt_plpo-objty AND
    objid = lt_plpo-objid AND
    spras = sy-langu.
    the following read will get the index of the correct record to be
    updated in the cache
    READ TABLE lt_pp04_cache
    WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    MODIFY lt_pp04_cache
    INDEX sy-tabix
    TRANSPORTING arbpl ktext.
    ENDIF.
    ENDIF.
    *ENDFORM. " read_last_pp04_operation_cache
    *& Form read_routing
    form read_routing.
    data: begin of lt_mapl occurs 0,
    plnnr like mapl-plnnr,
    plnal like mapl-plnal,
    end of lt_mapl,
    l_arbpl like crhd-arbpl.
    get all the rtg# and grp ctr# from MAPL
    select plnnr plnal
    into corresponding fields of table lt_mapl
    from mapl
    where matnr = v_matnr and
    werks = itab_xcel-werks and
    plnty = v_plnty and "Rate Routing
    loekz = space. "with del flag = OFF
    sort lt_mapl by plnal.
    if not itab_xcel-verid is initial.
    if the verid=0001 then use the 1st good rtg-grp# and grp-ctr#
    if itab_xcel-verid = '0001'.
    read table lt_mapl index 1.
    v_plnnr = lt_mapl-plnnr.
    v_plnal = lt_mapl-plnal.
    else.
    if the verid<>0001 then use the rtg-grp# and grp-ctr# of the routing
    whose work center on the last PP04 operation matches the given verid
    loop at lt_mapl.
    clear l_arbpl.
    get the work center from the last PP04 operation
    perform read_wc_on_last_pp04 using lt_mapl-plnnr
    lt_mapl-plnal
    changing l_arbpl.
    if itab_xcel-verid = l_arbpl.
    v_plnnr = lt_mapl-plnnr.
    v_plnal = lt_mapl-plnal.
    exit.
    endif.
    endloop.
    endif.
    else.
    do nothing
    endif.
    For version IDs that are other then '0000' or 'ZWIP' :--
    if itab_xcel-verid NE '0000' and
    itab_xcel-verid NE 'ZWIP'.
    if routing group# or group counter was not determined, make the
    valid-to date 99/99/9999 so that the BDC, on execution, errors out.
    if v_plnnr is initial or
    v_plnal is initial.
    itab_xcel-bdatu = '99/99/9999'.
    endif.
    endif.
    determine the routing group#
    CLEAR lt_pp04_cache.
    chk if its in the cache first, if not then get it from MAPL table
    and put it in the cache
    READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    IF sy-subrc = 0.
    do nothing - lt_pp04_cache header line has rtg#
    ELSE.
    get the routing group # from MAPL
    put it in the cache internal table
    IF NOT l_mapl_plnnr IS INITIAL.
    lt_pp04_cache-matnr = pi_matnr.
    lt_pp04_cache-werks = pi_werks.
    lt_pp04_cache-alnag = pi_alnag.
    lt_pp04_cache-plnnr = l_mapl_plnnr.
    APPEND lt_pp04_cache.
    ENDIF.
    ENDIF.
    if the rtg# was determined AND
    -- the work center was not determined yet AND
    -- work center was really needed for this line in the input file
    then
    -- read the work center from last PP04 operation on the routing
    -- update the cache accordingly
    IF NOT lt_pp04_cache-plnnr IS INITIAL AND
    lt_pp04_cache-arbpl IS INITIAL AND
    ( pi_verid IS INITIAL OR
    pi_mdv01 IS INITIAL ).
    read the last PP04 operation
    CLEAR lt_plpo.
    REFRESH lt_plpo.
    SELECT vornr eobjty eobjid e~arbpl
    INTO CORRESPONDING FIELDS OF TABLE lt_plpo
    FROM plas AS b
    INNER JOIN plpo AS c
    ON bplnty = cplnty AND
    bplnnr = cplnnr AND
    bzaehl = czaehl
    INNER JOIN crhd AS e
    ON carbid = eobjid
    WHERE b~plnty = v_plnty AND
    b~plnnr = lt_pp04_cache-plnnr AND
    b~plnal = lt_pp04_cache-alnag AND
    c~loekz = space AND
    c~steus = v_plpo_steus AND
    e~objty = v_objty AND
    e~werks = lt_pp04_cache-werks AND
    e~verwe = v_verwe.
    SORT lt_plpo BY vornr DESCENDING.
    READ TABLE lt_plpo INDEX 1.
    IF NOT lt_plpo-arbpl IS INITIAL.
    lt_pp04_cache-arbpl = lt_plpo-arbpl.
    read work center description
    SELECT SINGLE ktext INTO lt_pp04_cache-ktext
    FROM crtx WHERE objty = lt_plpo-objty AND
    objid = lt_plpo-objid AND
    spras = sy-langu.
    the following read will get the index of the correct record to be
    updated in the cache
    READ TABLE lt_pp04_cache
    WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    MODIFY lt_pp04_cache
    INDEX sy-tabix
    TRANSPORTING arbpl ktext.
    ENDIF.
    ENDIF.
    endform. " read_last_pp04_operation_cache
    *& Form read_wc_on_last_pp04
    form read_wc_on_last_pp04 using pi_plnnr
    pi_plnal
    changing pe_arbpl.
    data: begin of lt_plpo occurs 0,
    vornr like plpo-vornr,
    objty like crhd-objty,
    objid like crhd-objid,
    arbpl like crhd-arbpl,
    end of lt_plpo.
    get all the PP04 operations for the given rtg# & grp-ctr#
    select vornr eobjty eobjid e~arbpl
    into corresponding fields of table lt_plpo
    from plas as b
    inner join plpo as c
    on bplnty = cplnty and
    bplnnr = cplnnr and
    bzaehl = czaehl
    inner join crhd as e
    on carbid = eobjid
    where b~plnty = v_plnty and "Rate Routing
    b~plnnr = pi_plnnr and
    b~plnal = pi_plnal and
    c~loekz = space and "Oper Del Flag = OFF
    c~steus = v_plpo_steus and "PP04
    e~objty = v_objty. "WC Obj Type = 'A'
    read the last operation
    sort lt_plpo by vornr descending.
    read table lt_plpo index 1.
    pe_arbpl = lt_plpo-arbpl.
    endform.
    Reward Points if useful
    Raghunath.S
    9986076729

  • Dif betwen BDC call transaction and session method

    Hi to all,
               This is my problem. I want to know, what is the difference between BDC call Transaction method and Session method. where the situation we can use these methods.
    I will be thankfull to all.

    Session Method :
       Asynchronous Processing.
       Transfers Data for Multiple Transactions
      Synchronous Database Update
      During Processing, No Transaction is started until the previous transction has been written to the database.
      A Batch Input Processing log is generated for each session
      Sessions can not be generated in Parallel.
      The Batch Input Porgram must not open a Session until it has closed the preceding Session.
    Call Transaction :
       Synchronous Processing.
       Transfers Data for a single transaction.
       Synchronous and Asynchronous Database updating both Possible.
       The Program Specifies which kind of updating is desired.
      Seperate LUW for the transaction.
      The System Performs a database commit immediately before and after the  CALL TRANSACTION Using Statement.
    No Batch Input Processing Log is generated.
    These are the differences between session and call transaction method.
    Call transaction is faster then session method. But usually we use session method in real time...because we can transfer large amount of data from internal table to database and if any errors in a session. Process will not complete until session get correct.

Maybe you are looking for

  • APEX_LDAP.AUTHENTICATE - using Microsoft Active Directory

    Application Express 4.1.1.00.23 Internet Explorer - 8 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production Hi very new to Apex and trying to get the authenticaqtion to work against our active directory. I have setup an authent

  • Material Migration per view

    Hi Friends, is it advisable to migrate Material Master Data per View? I mean, first the Basic view, then the Purchase View etc. If not, what problems can occur. Thank you very much in advance. Rg. Jimbob

  • Cannot integrate with Twitter

    Hi, I just installed Mountain Lion and wanted to integrate with Twitter but it doesn't work. I can add the account but after two seconds I get an error saying the password is wrong. However, OSX still pops up in the list of approved applications when

  • Can I change the colours in the Resize window?

    When resizing (either image size or canvas size) I can't tell which numbers I've highlit, as the highlight colour is dark blue on a dark grey background.  Is there any way of changing this to something more useful? PE10   Windows XP SP3

  • Value of variable  cannot be determined

    Hi Guys, We are using authorization values for the BPS planning template. The user gives the value for COSTCENTER, the background checks the authorization and fills the rest of the values. The variable is set with check on restrictions of values requ