BDC WITH ME51!!

HELLO
I HAVE CREATED A BDC WITH ME51,I AM FACING A PROBLEM WITH IT.IN THE ITEM DATA THE SECOND RECORD IS GETTING OVERWRITTEN BY THE 3RD RECORD DATA.PLEASE GIVE ME A SOLUTION.THE CODE GOES AS BELOW..........TELL ME WHERE I AM GOING WRONG.
REPORT Z_BDC_ME51_CALLTRANSACTION NO STANDARD PAGE HEADING LINE-SIZE 255.
TABLES: EBAN,RM06B.
*include bdcrecx1.
DATA:   T_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE .
DATA : BEGIN OF T_UPLOAD OCCURS 0 ,
        BSART LIKE EBAN-BSART ,
        EEIND LIKE RM06B-EEIND ,
        LPEIN LIKE RM06B-LPEIN ,
        WERKS LIKE EBAN-WERKS ,
        LGORT LIKE EBAN-LGORT ,
        EKGRP LIKE EBAN-EKGRP ,
        MATKL LIKE EBAN-MATKL ,
        MATNR LIKE EBAN-MATNR ,
        MENGE(10) ,
       END OF T_UPLOAD .
DATA : BEGIN OF T_HEADER OCCURS 0 ,
        BSART LIKE EBAN-BSART ,
        EEIND LIKE RM06B-EEIND ,
        LPEIN LIKE RM06B-LPEIN ,
        WERKS LIKE EBAN-WERKS ,
        LGORT LIKE EBAN-LGORT ,
        EKGRP LIKE EBAN-EKGRP ,
        MATKL LIKE EBAN-MATKL ,
       END OF T_HEADER ,
       BEGIN OF T_ITEM OCCURS 0 ,
        BSART LIKE EBAN-BSART ,
        MATNR LIKE EBAN-MATNR ,
        MENGE(10) ,
       END OF T_ITEM  ,
       V1 TYPE SY-TABIX .
DATA : P_FLNAME LIKE RLGRAP-FILENAME VALUE 'D:\TEST_ME51.TXT' .
CALL FUNCTION 'UPLOAD'
  EXPORTING
  CODEPAGE                      = ' '
    FILENAME                      = 'D:\TEST_ME51.txt'
    FILETYPE                      = 'DAT'
  ITEM                          = ' '
  FILEMASK_MASK                 = ' '
  FILEMASK_TEXT                 = ' '
  FILETYPE_NO_CHANGE            = ' '
  FILEMASK_ALL                  = ' '
  FILETYPE_NO_SHOW              = ' '
  LINE_EXIT                     = ' '
  USER_FORM                     = ' '
  USER_PROG                     = ' '
  SILENT                        = 'S'
IMPORTING
  FILESIZE                      =
  CANCEL                        =
  ACT_FILENAME                  =
  ACT_FILETYPE                  =
  TABLES
    DATA_TAB                      = T_UPLOAD
EXCEPTIONS
  CONVERSION_ERROR              = 1
  INVALID_TABLE_WIDTH           = 2
  INVALID_TYPE                  = 3
  NO_BATCH                      = 4
  UNKNOWN_ERROR                 = 5
  GUI_REFUSE_FILETRANSFER       = 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.
START-OF-SELECTION.
DATA : V_BSART LIKE EBAN-BSART .
LOOP AT T_UPLOAD.
   MOVE :
        T_UPLOAD-BSART TO T_HEADER-BSART,
        T_UPLOAD-EEIND TO T_HEADER-EEIND,
        T_UPLOAD-LPEIN TO T_HEADER-LPEIN,
        T_UPLOAD-WERKS TO T_HEADER-WERKS,
        T_UPLOAD-LGORT TO T_HEADER-LGORT,
        T_UPLOAD-EKGRP TO T_HEADER-EKGRP,
        T_UPLOAD-MATKL TO T_HEADER-MATKL.
   APPEND T_HEADER.
   V_BSART = T_UPLOAD-BSART.
   LOOP AT T_UPLOAD WHERE BSART = V_BSART.
     MOVE :
         T_UPLOAD-BSART TO T_ITEM-BSART ,
         T_UPLOAD-MENGE TO T_ITEM-MENGE,
         T_UPLOAD-MATNR TO T_ITEM-MATNR.
     APPEND T_ITEM.
     DELETE T_UPLOAD.
  ENDLOOP.
ENDLOOP.
LOOP AT T_HEADER .
CLEAR T_BDCDATA .
REFRESH T_BDCDATA .
PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0100'.
*PERFORM BDC_FIELD       USING 'BDC_CURSOR' 'RM06B-EEIND'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD       USING 'EBAN-BSART' T_HEADER-BSART.
PERFORM BDC_FIELD       USING 'RM06B-EEIND' T_HEADER-EEIND.
PERFORM BDC_FIELD       USING 'RM06B-LPEIN' T_HEADER-LPEIN.
PERFORM BDC_FIELD       USING 'EBAN-WERKS' T_HEADER-WERKS.
PERFORM BDC_FIELD       USING 'EBAN-LGORT' T_HEADER-LGORT.
PERFORM BDC_FIELD       USING 'EBAN-EKGRP' T_HEADER-EKGRP.
PERFORM BDC_FIELD       USING 'EBAN-MATKL' T_HEADER-MATKL.
*PERFORM BDC_FIELD       USING 'BDC_CURSOR' 'EBAN-MENGE(01)'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
LOOP AT T_ITEM WHERE BSART EQ T_HEADER-BSART .
  IF SY-TABIX EQ 1.
    PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0106'.
    PERFORM BDC_FIELD       USING 'EBAN-MATNR(01)' T_ITEM-MATNR.
   PERFORM BDC_FIELD       USING 'EBAN-TXZ01(01)' ''.
    PERFORM BDC_FIELD       USING 'EBAN-MENGE(01)' T_ITEM-MENGE.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
    PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0102'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
   PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0106'.
   PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
    ELSE .
    PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0106'.
    PERFORM BDC_FIELD       USING 'EBAN-MATNR(02)' T_ITEM-MATNR.
   PERFORM BDC_FIELD       USING 'EBAN-TXZ01(01)' ''.
    PERFORM BDC_FIELD       USING 'EBAN-MENGE(02)' T_ITEM-MENGE.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
    PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0102'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE' '/00'.
   PERFORM BDC_DYNPRO      USING 'SAPMM06B' '0106'.
   PERFORM BDC_FIELD       USING 'EBAN-MA
    ENDIF .
ENDLOOP .
PERFORM BDC_FIELD       USING 'BDC_OKCODE' '=BU'.
*PERFORM BDC_FIELD       USING 'RM06B-BNFPO' '10'.
CALL TRANSACTION 'ME51' USING T_BDCDATA
                              MODE 'A'
                              UPDATE 'S'
                              MESSAGES INTO MESSTAB.
ENDLOOP .
       Start new screen                                              *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR T_BDCDATA.
  T_BDCDATA-PROGRAM  = PROGRAM.
  T_BDCDATA-DYNPRO   = DYNPRO.
  T_BDCDATA-DYNBEGIN = 'X'.
  APPEND T_BDCDATA.
ENDFORM.
       Insert field                                                  *
FORM BDC_FIELD USING FNAM FVAL.
  IF FVAL <> SPACE.
    CLEAR T_BDCDATA.
    T_BDCDATA-FNAM = FNAM.
    T_BDCDATA-FVAL = FVAL.
    APPEND T_BDCDATA.
  ENDIF.
ENDFORM.
I AM USING BSART,EEIND,LPEIN, WERKS,LGORT,EKGRP,MATKL,MATNR,MENGE IN THE FLAT FILE.

The number in the brackets indicate the number of the line item, right?
So, if you are not incrementing that number, you are always overwriting your 2nd line item with the next line item.
So, as the loop goes, you should increment that number also so that when the BDC runs the materials are attached to different line numbers.
Outside the loop
DATA : counter(2) type n value '01'.
Inside the loop
counter = counter + 1.
concatenate 'EBAN-MATNR(' counter ')' into fieldmatnr.
PERFORM BDC_FIELD USING fieldmatnr = T_ITEM-MATNR.
concatenate 'EBAN-MENGE(' counter ')' into fieldmenge.
PERFORM BDC_FIELD USING fieldmenge T_ITEM-MENGE.
The above changes should solve your problem.
Regards,
Ravi
Note - Pleas emark all the helpful answes
Message was edited by:
        Ravikumar Allampallam
Message was edited by:
        Ravikumar Allampallam

Similar Messages

  • How can we handle dateformat from diff countries into india in bdc with out

    hi
    experts can u help me pz
    how can we handle dateformat from diff countries into india in bdc with out chnaging system parameters while uploading.
    i.e flatfile date is germanformat
         target date is indianformat.
    thanks and regords.

    use WRITE statement to format date.. along with extension ...
    DD/MM/YY
    or
    DD/MM/YYYY

  • BDC with MM01/ MM02 from MARA table

    Can anybody suggest me for the following problem.
    I want to construct a BDC with MM01/ MM02 from MARA table.
    And I want the source file to be a notepad or Excel sheet. But i am not
    getting, that how to write the data in Notepad/Excel sheet, to feed to the
    master table according to the MM01/MM02 fields .

    This is the sample code for creation of flatfile for MM01 this will be definetly helping you to create a flatfile.
    REPORT  ZBDC_FF MESSAGE-ID BCTRAIN .
    TYPES: BEGIN OF STU,
           MATNR LIKE RMMG1-MATNR,
           MBRSH LIKE RMMG1-MBRSH,
           MTART LIKE RMMG1-MTART,
           MAKTX LIKE MAKT-MAKTX,
           MEINS LIKE MARA-MEINS,
           END OF STU.
    DATA WA_ITAB TYPE STU.
    DATA ITAB TYPE TABLE OF STU.
    WA_ITAB-MATNR = 'T1'.              "MATERIAL NUMBER"
    WA_ITAB-MBRSH = 'K'.                 "INDUSTRY SECTOR"
    WA_ITAB-MTART = 'VKHM'.              "MATERIAL TYPE"
    WA_ITAB-MAKTX = 'TOOLEMATERIAL'.     "MATERIAL DESCRIPTION"
    WA_ITAB-MEINS = 'EE'.                "BASE UNIT OF MEASURE"
    APPEND WA_ITAB TO ITAB.
    CLEAR WA_ITAB.
    *WA_ITAB-MATNR = 'TOL2'.              "MATERIAL NUMBER"
    *WA_ITAB-MBRSH = 'M'.                 "INDUSTRY SECTOR"
    *WA_ITAB-MTART = 'VKHM'.              "MATERIAL TYPE"
    *WA_ITAB-MAKTX = 'TOOLEMATERIAL'.     "MATERIAL DESCRIPTION"
    *WA_ITAB-MEINS = 'EA'.                "BASE UNIT OF MEASURE"
    *APPEND WA_ITAB TO ITAB.
    *CLEAR WA_ITAB.
    *WA_ITAB-MATNR = 'TOL3'.              "MATERIAL NUMBER"
    *WA_ITAB-MBRSH = 'M'.                 "INDUSTRY SECTOR"
    *WA_ITAB-MTART = 'VKHM'.              "MATERIAL TYPE"
    *WA_ITAB-MAKTX = 'TOOLEMATERIAL'.     "MATERIAL DESCRIPTION"
    *WA_ITAB-MEINS = 'EA'.                "BASE UNIT OF MEASURE"
    *APPEND WA_ITAB TO ITAB.
    *CLEAR WA_ITAB.
    *WA_ITAB-MATNR = 'TOL4'.              "MATERIAL NUMBER"
    *WA_ITAB-MBRSH = 'M'.                 "INDUSTRY SECTOR"
    *WA_ITAB-MTART = 'VKHM'.              "MATERIAL TYPE"
    *WA_ITAB-MAKTX = 'TOOLEMATERIAL'.     "MATERIAL DESCRIPTION"
    *WA_ITAB-MEINS = 'EA'.                "BASE UNIT OF MEASURE"
    *APPEND WA_ITAB TO ITAB.
    *CLEAR WA_ITAB.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    FILENAME     = 'C:\Documents and Settings\chiranjeevi\Desktop\BDC.TXT'
      TABLES
        DATA_TAB     = ITAB
    IF SY-SUBRC <> 0.
    MESSAGE S999 WITH 'EXECUTED'.
    ENDIF.
    Cheers!!!

  • Bdc with oops

    Hi iam new to abap objects. I was interested in bdc with oops. If any one knows the procedure send me, if possible with any sample code.................

    this can be helpful.
    OOPs ABAP uses Classes and Interfaces which uses Methods and events.
    If you have Java skills it is advantage for you.
    There are Local classes as well as Global Classes.
    Local classes we can work in SE38 straight away.
    But mostly it is better to use the Global classes.
    Global Classes or Interfaces are to be created in SE24.
    SAP already given some predefined classes and Interfaces.
    This OOPS concepts very useful for writing BADI's also.
    So first create a class in SE 24.
    Define attributes, Methods for that class.
    Define parameters for that Method.
    You can define event handlers also to handle the messages.
    After creation in each method write the code.
    Methods are similar to ABAP PERFORM -FORM statements.
    After the creation of CLass and methods come to SE38 and create the program.
    In the program create a object type ref to that class and with the help of that Object call the methods of that Class and display the data.
    Example:
    REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L I N T E R N A L T A B L E S
    *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
    TYPES: BEGIN OF st_sflight.
    INCLUDE STRUCTURE zsflight.
    Field for traffic light
    TYPES: traffic_light TYPE c.
    Field for line color
    types: line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    G L O B A L D A T A
    DATA: ok_code LIKE sy-ucomm,
    Work area for internal table
    g_wa_sflight TYPE st_sflight,
    ALV control: Layout structure
    gs_layout TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
    DATA:
    go_grid TYPE REF TO cl_gui_alv_grid,
    go_custom_container TYPE REF TO cl_gui_custom_container,
    o_event_receiver TYPE REF TO lcl_event_receiver.
    DATA:
    Work area for screen 200
    g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
    DATA:
    Internal table
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    C L A S S E S
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
    e_object e_interactive,
    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Event handler method for event toolbar.
    CONSTANTS:
    Constants for button type
    c_button_normal TYPE i VALUE 0,
    c_menu_and_default_button TYPE i VALUE 1,
    c_menu TYPE i VALUE 2,
    c_separator TYPE i VALUE 3,
    c_radio_button TYPE i VALUE 4,
    c_checkbox TYPE i VALUE 5,
    c_menu_entry TYPE i VALUE 6.
    DATA:
    ls_toolbar TYPE stb_button.
    Append seperator to the normal toolbar
    CLEAR ls_toolbar.
    MOVE c_separator TO ls_toolbar-butn_type..
    APPEND ls_toolbar TO e_object->mt_toolbar.
    Append a new button that to the toolbar. Use E_OBJECT of
    event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
    This class has one attribute MT_TOOLBAR which is of table type
    TTB_BUTTON. The structure is STB_BUTTON
    CLEAR ls_toolbar.
    MOVE 'CHANGE' TO ls_toolbar-function.
    MOVE icon_change TO ls_toolbar-icon.
    MOVE 'Change flight' TO ls_toolbar-quickinfo.
    MOVE 'Change' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
    Handle own functions defined in the toolbar
    CASE e_ucomm.
    WHEN 'CHANGE'.
    PERFORM change_flight.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
    SET SCREEN '100'.
    *& Module USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    CASE ok_code.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Module STATUS_0100 OUTPUT
    MODULE status_0100 OUTPUT.
    DATA:
    For parameter IS_VARIANT that is sued to set up options for storing
    the grid layout as a variant in method set_table_for_first_display
    l_layout TYPE disvariant,
    Utillity field
    l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines > 0.
    CALL METHOD go_grid->set_selected_rows
    EXPORTING
    it_index_rows = gi_index_rows.
    CALL METHOD cl_gui_cfw=>flush.
    REFRESH gi_index_rows.
    ENDIF.
    Read data and create objects
    IF go_custom_container IS INITIAL.
    Read data from datbase table
    PERFORM get_data.
    Create objects for container and ALV grid
    CREATE OBJECT go_custom_container
    EXPORTING container_name = 'ALV_CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
    i_parent = go_custom_container.
    Create object for event_receiver class
    and set handlers
    CREATE OBJECT o_event_receiver.
    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
    Layout (Variant) for ALV grid
    l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
    Set grid title
    gs_layout-grid_title = 'Flights'.
    Selection mode - Single row without buttons
    (This is the default mode
    gs_layout-sel_mode = 'B'.
    Name of the exception field (Traffic light field) and the color
    field + set the exception and color field of the table
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
    gs_layout-info_fname = 'LINE_COLOR'.
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    Value of traffic light field
    g_wa_sflight-traffic_light = '1'.
    Value of color field:
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
    Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
    is_variant = l_layout
    i_save = 'A'
    is_layout = gs_layout
    CHANGING it_outtab = gi_sflight.
    *-- End of grid setup -
    Raise event toolbar to show the modified toolbar
    CALL METHOD go_grid->set_toolbar_interactive.
    Set focus to the grid. This is not necessary in this
    example as there is only one control on the screen
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
    ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0200 INPUT
    MODULE user_command_0200 INPUT.
    CASE ok_code.
    WHEN 'EXIT200'.
    LEAVE TO SCREEN 100.
    WHEN'SAVE'.
    PERFORM save_changes.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    *& Form get_data
    FORM get_data.
    Read data from table SFLIGHT
    SELECT *
    FROM zsflight
    INTO TABLE gi_sflight.
    ENDFORM. " load_data_into_grid
    *& Form change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
    FORM change_flight.
    DATA:l_lines TYPE i.
    REFRESH gi_index_rows.
    CLEAR g_selected_row.
    Read index of selected rows
    CALL METHOD go_grid->get_selected_rows
    IMPORTING
    et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table gi_index_rows will be empty
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines = 0.
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
    EXPORTING
    textline1 = 'You must choose a line'.
    EXIT.
    ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
    LOOP AT gi_index_rows INTO g_selected_row.
    IF sy-tabix = 1.
    READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
    ENDIF.
    ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
    CLEAR g_screen200.
    MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
    LEAVE TO SCREEN '200'.
    ENDFORM. " change_flight
    *& Form save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
    FORM save_changes.
    DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
    MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
    MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-traffic_light = '1'.
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    clear g_wa_sflight-line_color.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    clear g_wa_sflight-line_color.
    ENDIF.
    MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
    CALL METHOD go_grid->refresh_table_display.
    CALL METHOD cl_gui_cfw=>flush.
    LEAVE TO SCREEN '100'.
    ENDFORM. " save_changes
    chk this blog
    /people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid
    with regards,
    Hema SUndara.

  • BDC With table Control

    Dear All .
    can you give me some idea how to do BDC with tbale Control . Any documentation on the same or some simple example .

    Handling Table Control in BDC
    An example abap program of handling Table Control during bdc programming.
    REPORT zmm_bdcp_purchaseorderkb02
           NO STANDARD PAGE HEADING LINE-SIZE 255.
                    Declaring internal tables                            *
    *-----Declaring line structure
    DATA : BEGIN OF it_dummy OCCURS 0,
             dummy(255) TYPE c,
           END OF it_dummy.
    *-----Internal table for line items
    DATA :  BEGIN OF it_idata OCCURS 0,
              ematn(18),      "Material Number.
              menge(13),      "Qyantity.
              netpr(11),      "Net Price.
              werks(4),       "Plant.
              ebelp(5),       "Item Number.
            END OF it_idata.
    *-----Deep structure for header data and line items
    DATA  :  BEGIN OF it_me21 OCCURS 0,
               lifnr(10),      "Vendor A/c No.
               bsart(4),       "A/c Type.
               bedat(8),       "Date of creation of PO.
               ekorg(4),       "Purchasing Organisation.
               ekgrp(3),       "Purchasing Group.
               x_data LIKE TABLE OF it_idata,
             END OF it_me21.
    DATA  :  x_idata LIKE LINE OF it_idata.
    DATA  :  v_delimit VALUE ','.
    DATA  :  v_indx(3) TYPE n.
    DATA  :  v_fnam(30) TYPE c.
    DATA  :  v_count TYPE n.
    DATA  :  v_ne TYPE i.
    DATA  :  v_ns TYPE i.
    *include bdcrecx1.
    INCLUDE zmm_incl_purchaseorderkb01.
                    Search help for file                                 *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_file.
    START-OF-SELECTION.
           To upload the data into line structure                        *
      CALL FUNCTION 'WS_UPLOAD'
        EXPORTING
          filename = p_file
          filetype = 'DAT'
        TABLES
          data_tab = it_dummy.
        Processing the data from line structure to internal tables       *
      REFRESH:it_me21.
      CLEAR  :it_me21.
      LOOP AT it_dummy.
        IF it_dummy-dummy+0(01) = 'H'.
          v_indx = v_indx + 1.
          CLEAR   it_idata.
          REFRESH it_idata.
          CLEAR   it_me21-x_data.
          REFRESH it_me21-x_data.
          SHIFT it_dummy.
          SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
                                           it_me21-bsart
                                           it_me21-bedat
                                           it_me21-ekorg
                                           it_me21-ekgrp.
          APPEND it_me21.
        ELSEIF it_dummy-dummy+0(01) = 'L'.
          SHIFT it_dummy.
          SPLIT it_dummy AT v_delimit INTO it_idata-ematn
                                           it_idata-menge
                                           it_idata-netpr
                                           it_idata-werks
                                           it_idata-ebelp.
          APPEND it_idata TO it_me21-x_data.
          MODIFY it_me21 INDEX v_indx.
        ENDIF.
      ENDLOOP.
                    To open the group                                    *
      PERFORM open_group.
            To populate the bdcdata table for header data                *
      LOOP AT it_me21.
        v_count = v_count + 1.
        REFRESH it_bdcdata.
        PERFORM subr_bdc_table USING:   'X' 'SAPMM06E'    '0100',
                                        ' ' 'BDC_CURSOR'  'EKKO-LIFNR',
                                        ' ' 'BDC_OKCODE'  '/00',
                                        ' ' 'EKKO-LIFNR'  it_me21-lifnr,
                                        ' ' 'RM06E-BSART' it_me21-bsart,
                                        ' ' 'RM06E-BEDAT' it_me21-bedat,
                                        ' ' 'EKKO-EKORG'  it_me21-ekorg,
                                        ' ' 'EKKO-EKGRP'  it_me21-ekgrp,
                                        ' ' 'RM06E-LPEIN' 'T'.
        PERFORM subr_bdc_table USING:   'X' 'SAPMM06E'    '0120',
                                        ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                        ' ' 'BDC_OKCODE'  '/00'.
        MOVE 1 TO v_indx.
    *-----To populate the bdcdata table for line item data
        LOOP AT it_me21-x_data INTO x_idata.
          CONCATENATE 'EKPO-EMATN(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-ematn.
          CONCATENATE 'EKPO-MENGE(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-menge.
          CONCATENATE 'EKPO-NETPR(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-netpr.
          CONCATENATE 'EKPO-WERKS(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-werks.
          v_indx = v_indx + 1.
          PERFORM subr_bdc_table USING:  'X' 'SAPMM06E'    '0120',
                                         ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                         ' ' 'BDC_OKCODE'  '/00'.
        ENDLOOP.
        PERFORM subr_bdc_table USING:    'X' 'SAPMM06E'    '0120',
                                         ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                         ' ' 'BDC_OKCODE'  '=BU'.
        PERFORM bdc_transaction USING 'ME21'.
      ENDLOOP.
      PERFORM close_group.
                      End of selection event                             *
    END-OF-SELECTION.
      IF session NE 'X'.
    *-----To display the successful records
        WRITE :/10  text-001.          "Sucess records
        WRITE :/10  SY-ULINE(20).
        SKIP.
        IF it_sucess IS INITIAL.
          WRITE :/  text-002.
        ELSE.
          WRITE :/   text-008,          "Total number of Succesful records
                  35 v_ns.
          SKIP.
          WRITE:/   text-003,          "Vendor Number
                 17 text-004,          "Record number
                 30 text-005.          "Message
        ENDIF.
        LOOP AT it_sucess.
          WRITE:/4  it_sucess-lifnr,
                 17 it_sucess-tabix CENTERED,
                 30 it_sucess-sucess_rec.
        ENDLOOP.
        SKIP.
    *-----To display the erroneous records
        WRITE:/10   text-006.          "Error Records
        WRITE:/10   SY-ULINE(17).
        SKIP.
        IF it_error IS INITIAL.
          WRITE:/   text-007.          "No error records
        ELSE.
          WRITE:/   text-009,          "Total number of erroneous records
                 35 v_ne.
          SKIP.
          WRITE:/   text-003,          "Vendor Number
                 17 text-004,          "Record number
                 30 text-005.          "Message
        ENDIF.
        LOOP AT it_error.
          WRITE:/4  it_error-lifnr,
                 17 it_error-tabix CENTERED,
                 30 it_error-error_rec.
        ENDLOOP.
        REFRESH it_sucess.
        REFRESH it_error.
      ENDIF.
    CODE IN INCLUDE.
    Include           ZMM_INCL_PURCHASEORDERKB01
    DATA:   it_BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
    DATA:   it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA:   E_GROUP_OPENED.
    *-----Internal table to store sucess records
    DATA:BEGIN OF it_sucess OCCURS 0,
           msgtyp(1)   TYPE c,
           lifnr  LIKE  ekko-lifnr,
           tabix  LIKE  sy-tabix,
           sucess_rec(125),
         END OF it_sucess.
    DATA: g_mess(125) type c.
    *-----Internal table to store error records
    DATA:BEGIN OF it_error OCCURS 0,
           msgtyp(1)   TYPE c,
           lifnr  LIKE  ekko-lifnr,
           tabix  LIKE  sy-tabix,
           error_rec(125),
         END OF it_error.
           Selection screen
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS session RADIOBUTTON GROUP ctu.  "create session
    SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
    SELECTION-SCREEN POSITION 45.
    PARAMETERS ctu RADIOBUTTON GROUP ctu.     "call transaction
    SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS group(12).                      "group name of session
    SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS: keep AS CHECKBOX.       "' ' = delete session if finished
    "'X' = keep   session if finished
    SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS e_group(12).             "group name of error-session
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS: e_keep AS CHECKBOX.     "' ' = delete session if finished
    "'X' = keep   session if finished
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:p_file LIKE rlgrap-filename.
      at selection screen                                                *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
      IF SESSION = 'X' AND
         GROUP = SPACE. "OR USER = SPACE.
        MESSAGE E613(MS).
      ENDIF.
      create batchinput session                                          *
    FORM OPEN_GROUP.
      IF SESSION = 'X'.
        SKIP.
        WRITE: /(20) 'Create group'(I01), GROUP.
        SKIP.
    *----open batchinput group
        CALL FUNCTION 'BDC_OPEN_GROUP'
          EXPORTING
            CLIENT = SY-MANDT
            GROUP  = GROUP
            USER   = sy-uname.
        WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ENDIF.
    ENDFORM.                    "OPEN_GROUP
      end batchinput session                                             *
    FORM CLOSE_GROUP.
      IF SESSION = 'X'.
    *------close batchinput group
        CALL FUNCTION 'BDC_CLOSE_GROUP'.
        WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ELSE.
        IF E_GROUP_OPENED = 'X'.
          CALL FUNCTION 'BDC_CLOSE_GROUP'.
          WRITE: /.
          WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
        ENDIF.
      ENDIF.
    ENDFORM.                    "CLOSE_GROUP
           Start new transaction according to parameters                 *
    FORM BDC_TRANSACTION USING TCODE TYPE ANY.
      DATA: L_SUBRC LIKE SY-SUBRC.
    *------batch input session
      IF SESSION = 'X'.
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = TCODE
          TABLES
            DYNPROTAB = it_BDCDATA.
        WRITE: / 'BDC_INSERT'(I03),
                 TCODE,
                 'returncode:'(I05),
                 SY-SUBRC,
                 'RECORD:',
                 SY-INDEX.
      ELSE.
        REFRESH it_MESSTAB.
        CALL TRANSACTION TCODE USING it_BDCDATA
                         MODE   CTUMODE
                         UPDATE CUPDATE
                         MESSAGES INTO it_MESSTAB.
        L_SUBRC = SY-SUBRC.
        WRITE: / 'CALL_TRANSACTION',
                 TCODE,
                 'returncode:'(I05),
                 L_SUBRC,
                 'RECORD:',
                 SY-INDEX.
      ENDIF.
      Message handling for Call Transaction                              *
      perform subr_mess_hand using g_mess.
    *-----Erzeugen fehlermappe
      IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
        IF E_GROUP_OPENED = ' '.
          CALL FUNCTION 'BDC_OPEN_GROUP'
            EXPORTING
              CLIENT = SY-MANDT
              GROUP  = E_GROUP
              USER   = sy-uname
              KEEP   = E_KEEP.
          E_GROUP_OPENED = 'X'.
        ENDIF.
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = TCODE
          TABLES
            DYNPROTAB = it_BDCDATA.
      ENDIF.
      REFRESH it_BDCDATA.
    ENDFORM.                    "BDC_TRANSACTION
         Form  subr_bdc_table                                            *
          text
         -->P_0220   text                                                *
         -->P_0221   text                                                *
         -->P_0222   text                                                *
    FORM subr_bdc_table  USING      VALUE(P_0220) TYPE ANY
                                    VALUE(P_0221) TYPE ANY
                                    VALUE(P_0222) TYPE ANY.
      CLEAR it_bdcdata.
      IF P_0220 = ' '.
        CLEAR it_bdcdata.
        it_bdcdata-fnam     = P_0221.
        it_bdcdata-fval     = P_0222.
        APPEND it_bdcdata.
      ELSE.
        it_bdcdata-dynbegin = P_0220.
        it_bdcdata-program  = P_0221.
        it_bdcdata-dynpro   = P_0222.
        APPEND it_bdcdata.
      ENDIF.
    ENDFORM.                    " subr_bdc_table
         Form  subr_mess_hand                                            *
          text                                                           *
         -->P_G_MESS  text                                               *
    FORM subr_mess_hand USING  P_G_MESS TYPE ANY.
      LOOP AT IT_MESSTAB.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            ID     = it_messtab-msgid
            LANG   = it_messtab-msgspra
            NO     = it_messtab-msgnr
            v1     = it_messtab-msgv1
            v2     = it_messtab-msgv2
          IMPORTING
            MSG    = P_G_MESS
          EXCEPTIONS
            OTHERS = 0.
        CASE it_messtab-msgtyp.
          when 'E'.
            it_error-error_rec   =  P_G_MESS.
            it_error-lifnr       =  it_me21-lifnr.
            it_error-tabix       =  v_count.
            APPEND IT_ERROR.
          when 'S'.
            it_sucess-sucess_rec =  P_G_MESS.
            it_sucess-lifnr      =  it_me21-lifnr.
            it_sucess-tabix      =  v_count.
            APPEND IT_SUCESS.
        endcase.
      ENDLOOP.
      Describe table it_sucess lines v_ns.
      Describe table it_error  lines v_ne.
    ENDFORM.                    " subr_mess_hand

  • Regarding BDC with RFC Enabled FM

    Hi,
    When we run BDC with function module, I believe its the session method, but after the program is run I do not see any session in SM35, even if I KEEP THE SESSION ('X'). I am using the following function mod. however the data is being updated.
    CALL FUNCTION 'Z_FM_Z1_REC'
       EXPORTING
         mode                 = 'N'
       UPDATE               = 'A'
         group                = s_name
       USER                 = sy-uname
       KEEP                 = 'X'
       HOLDDATE             = h_date
      NODATA               = '/'
       MATNR_001            = i_tab-matnr
       MBRSH_002            = i_tab-mbrsh
       MTART_003            = i_tab-mtart
       KZSEL_01_004         = 'X'
       MAKTX_005            = i_tab-maktx
       MEINS_006            = i_tab-meins
       MTPOS_MARA_007       = 'NORM'
    IMPORTING
       SUBRC                = subrc
    TABLES
       MESSTAB              = messtab  .
    Also, this FM is RFC enabled but does not work, any idea why ?
    Thirdly, where is this session data stored (database table).
    Thanks!
    "Max Points Are Assured for Most Appropriate Answers"

    Hi,
    Answer to Q1) You need to check the content of your custom FM... Check if you have used BDC_OPEN_GROUP, BDC_INSERT and BDC_CLOSE_GROUP to generate the session... it is NOT the question with the FM that you are using...
    First, try using the above mentioned FMs to generate session... if it works (and it should), then put them into your custom FM.
    Answer to Q2) The table for storing all the BDC sessions is APQI.
    Regards, Tapas
    <Allot points pls if it solves your problem>

  • .can anybody explain the bdc with help of an example

    i am new to bdc .can anybody explain the bdc with help of an example

    Hi,
    BDC is method to transfer legacy data into R3 system.
    Data transfer can be done in any one method below:
    BDC
    LSMW
    Direct Input method
    BAPI
    Of these BDC is subdivided into 2 types,
    Call Transaction and Session method (TCode: SM35)
    Let me give the sample prg for Call Transaction method.
    tables ZMATMASTER.
    DATA : itab like TABLE OF  ZMATMASTER WITH KEY DESCRIPTION with header line.
    DATA : IT_BDC LIKE TABLE OF BDCDATA WITH HEADER LINE.
    DATA : IT_MSG LIKE TABLE OF BDCMSGCOLL WITH HEADER LINE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'C:\Material.txt'
        FILETYPE                      = 'ASC'
        HAS_FIELD_SEPARATOR           = '#'
      TABLES
        DATA_TAB                      = itab.
    LOOP AT ITAB.
        PERFORM BDC_HEADER USING 'ZFILE_DOWNLOAD' 9001.
        PERFORM BDC_DATA   USING 'BDC_OKCODE' 'SAVE'.
        PERFORM BDC_DATA   USING 'ZMATMASTER-MNO' ITAB-MNO.
        PERFORM BDC_DATA   USING 'ZMATMASTER-DESCRIPTION' ITAB-DESCRIPTION.
        PERFORM BDC_DATA   USING 'ZMATMASTER-PLANT' ITAB-PLANT.
        PERFORM BDC_DATA   USING 'ZMATMASTER-SLOC' ITAB-SLOC.
        PERFORM BDC_DATA   USING 'ZMATMASTER-ROL' ITAB-ROL.
        PERFORM BDC_DATA   USING 'ZMATMASTER-UOM' ITAB-UOM.
        PERFORM BDC_DATA   USING 'ZMATMASTER-PRICE' ITAB-PRICE.
        PERFORM BDC_DATA   USING 'ZMATMASTER-DDAYS' ITAB-DDAYS.
        PERFORM BDC_DATA   USING 'ZMATMASTER-FLOT' ITAB-FLOT.
    ENDLOOP.
    CALL TRANSACTION 'ZTRANSCODES'
                     USING IT_BDC
                     MODE 'A'
                     UPDATE 'S'
                     MESSAGES INTO IT_MSG.
    FORM BDC_HEADER USING PROGRAMNAME SCREENNO.
         IT_BDC-PROGRAM = PROGRAMNAME.
         IT_BDC-DYNPRO = SCREENNO.
         IT_BDC-DYNBEGIN = 'X'.
         APPEND IT_BDC.
    ENDFORM.
    FORM BDC_DATA USING FNAME FVALUE.
         CLEAR IT_BDC.
         IT_BDC-FNAM = FNAME.
         IT_BDC-FVAL = FVALUE.
         APPEND IT_BDC.
    ENDFORM.
    In session method, log file can be viewed.
    Foll. is the example for session method.
    REPORT ZBDC_BATCH1                                                 .
    TABLES: ZEMPREC.
    DATA : BEGIN OF STR1,
           EMPNO(3),
           EMPNAME(15),
           SALARY(9),
           DOJ(10),
           END OF STR1.
    DATA: FNAME(100) TYPE C VALUE 'C:\EMPLOYEE.TXT.,
    DATA : BDCITAB LIKE TABLE OF BDCDATA WITH  HEADER LINE,
           MSGITAB LIKE TABLE OF BDCMSGCOLL WITH HEADER LINE.
    OPEN DATASET: FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    perform open_group.
    DO .
      READ DATASET FNAME INTO  STR1.
      IF SY-SUBRC <> 0 .
        EXIT.
      ENDIF.
      perform bdc_dynpro      using 'ZBDC_BATCH' '9000'.
      perform bdc_field       using 'ZEMPREC-EMPNO'
                                    STR1-EMPNO.
      perform bdc_field       using 'ZEMPREC-EMPNAME'
                                    STR1-EMPNAME.
      perform bdc_field       using 'ZEMPREC-SALARY'
                                    STR1-SALARY.
      perform bdc_field       using 'ZEMPREC-DOJ'
                                    STR1-DOJ.
    ENDDO.
    CLOSE DATASET FNAME.
    perform bdc_transaction using 'ZTCODE'.
    perform close_group.
    CLOSE DATASET FNAME1.
    CALL TRANSACTION 'SM35'.
      FORM open_group
    FORM open_group .
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          CLIENT   = SY-MANDT
          GROUP    = 'sample'
          HOLDDATE = SY-DATUM
          KEEP     = 'X'
          USER     = SY-UNAME.
    ENDFORM.                    "open_group
      FORM bdc_transaction
      -->  TCODE
    form bdc_transaction USING TCODE.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE     = 'ZTCODE'
        TABLES
          DYNPROTAB = BDCITAB.
    ENDFORM.                    "bdc_transaction
      FORM close_group
    FORM close_group.
      CALL FUNCTION 'BDC_CLOSE_GROUP'.
    ENDFORM.                    "close_group
      FORM BDC_DYNPRO
      -->  PROGRAM
      -->  SCREEN
    FORM BDC_DYNPRO USING PROGRAM SCREEN.
      CLEAR BDCITAB.
      BDCITAB-PROGRAM = PROGRAM.
      BDCITAB-DYNPRO = SCREEN.
      BDCITAB-DYNBEGIN = 'X'.
      APPEND BDCITAB.
    ENDFORM.                    "BDC_DYNPRO
      FORM BDC_FIELD
      -->  FNAM
      -->  FVAL
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR BDCITAB.
      BDCITAB-FNAM = FNAM.
      BDCITAB-FVAL = FVAL.
      APPEND BDCITAB.
    ENDFORM.                    "BDC_FIELD
    Hope now u get an idea abt BDC.
    Regards,
    Router

  • How to create bdc with table control

    hi all.
    please some body tell me how to create bdc with table control
    or suggest any www with screen shots
    thanks in advance ,
    aparna

    Hi AParna,
    Its very Simple.
    ALl you have to do is set up a counter based on the number of lines in the tabke. when the counter reaches the number of lines in the table hit the next page button which is at the top of every screen in SAP.
    Please refer to the following BDC program I had developed using Table control,
    this is for ME01 transaction.
      LOOP AT T_EORD_HED.
        SELECT SINGLE * FROM MARA WHERE MATNR = T_EORD_HED-MATNR.
        IF SY-SUBRC = 0.
          PERFORM BDC_DYNPRO      USING 'SAPLMEOR' '0200'.
          PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                        'EORD-MATNR'.
          PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                        '/00'.
          PERFORM BDC_FIELD       USING 'EORD-MATNR'
                                        T_EORD_HED-MATNR.       "'58335'.
          PERFORM BDC_FIELD       USING 'EORD-WERKS'
                                        T_EORD_HED-WERKS.       "'0253'.
          L_COUNT = 1.
          LOOP AT T_EORD WHERE MATNR = T_EORD_HED-MATNR
                           AND WERKS = T_EORD_HED-WERKS.
            SELECT SINGLE * FROM LFA1 WHERE LIFNR = T_EORD-LIFNR.
            IF SY-SUBRC = 0.
    * Look into the if condition below
              IF L_COUNT = 010.
                L_COUNT = 1.
                PERFORM BDC_DYNPRO      USING 'SAPLMEOR' '0205'.
                PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'EORD-MATNR'.
                PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                       '=NS'.
                L_COUNT = L_COUNT + 1.
              ENDIF.
              PERFORM BDC_DYNPRO      USING 'SAPLMEOR' '0205'.
              PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                            'EORD-AUTET(01)'.
              PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                            '/00'.
              CONCATENATE 'EORD-VDATU' '(' L_COUNT ')' INTO OPR_FIELD.
              WRITE SY-DATUM TO T_EORD-VDATU.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-VDATU.
              CONCATENATE 'EORD-BDATU' '(' L_COUNT ')' INTO OPR_FIELD.
              WRITE T_EORD-BDATU TO V_BDATU.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            V_BDATU.
              CONCATENATE 'EORD-LIFNR' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-LIFNR.
              CONCATENATE 'EORD-EKORG' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            '0001'.
              CONCATENATE 'EORD-RESWK' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-RESWK.
              WRITE T_EORD-MEINS TO V_MEINS.
              CONCATENATE 'EORD-MEINS' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            V_MEINS.
    *          CONCATENATE 'EORD-EBELN' '(' L_COUNT ')' INTO OPR_FIELD.
    *          PERFORM BDC_FIELD       USING 'OPR_FIELD'
    *                                        T_EORD-EBELN.
              CONCATENATE 'EORD-EBELP' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-EBELP.
              IF T_EORD-FLIFN NE SPACE OR T_EORD-FRESW NE SPACE OR
                 T_EORD-FEBEL NE SPACE.
                CONCATENATE 'RM06W-FESKZ' '(' L_COUNT ')' INTO OPR1_FIELD.
                PERFORM BDC_FIELD       USING OPR1_FIELD
                                              'X'.
              ENDIF.
              IF T_EORD-NOTKZ <> ''.
                CONCATENATE 'EORD-NOTKZ' '(' L_COUNT ')' INTO OPR_FIELD.
                PERFORM BDC_FIELD       USING OPR_FIELD
                                              'X'.
              ENDIF.
              CONCATENATE 'EORD-AUTET' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-AUTET.
              L_COUNT = L_COUNT + 1.
            ENDIF.
          ENDLOOP.
          PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                        'EORD-MATNR'.
          PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                        '=BU'.
          CALL TRANSACTION 'ME01' USING I_BDCDATA
                        MODE UP_MODE
    *                     optIONS  FROM l_opt
                        MESSAGES INTO I_BDCMSGCOLL.
          PERFORM FORMAT_OUTPUT.
        ENDIF.
      ENDLOOP.

  • Can u send me the link which describes me in about bdc with direct method

    Can u send me the link which describes me in about bdc with direct method with examples in detail

    Hi,
    http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm
    and
    http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm
    For BDC:
    http://myweb.dal.ca/hchinni/sap/bdc_home.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    http://www.sapdevelopment.co.uk/bdc/bdchome.htm
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
    http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
    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
    reward if useful
    regards,
    Anji

  • Problem in BDC with ( MM01-Dynamic views )

    HI
    I am working with BDC on material Mater(mm01).
    Now while Creating Material,there is option of selecting different views based on MaterialType.
    But while recording a BDC i can record it for a particular Material Type.and can select view associated to that particular Material Type.
    Is there any solution to create a bdc progarm which can accept a new material based on
    any material type and having views on user's choice that are given by user in Input file.
    FOr that i think i need to create dynamic views and screen elements for input associated to those views.
    After scanning some sites and forums for this particular problem,i got some help on this:-----
    <b>SELECTION_VIEWS_FIND</b> should be very useful in this case.
    There are three FModules totally involved:
    a) <b>T130M_SINGLE_READ</b>
    Pass TCODE = MM01, and get T130M values
    b) <b>BILDSEQUENZ_IDENTIFY</b>
    Pass KZRFB = 'X',TCODE_REF=T130M-TRREF and get
    BILDSEQUENZ values
    c) <b>SELECTION_VIEWS_FIND</b>
    Pass BILDSEQUENZ and T130M-PSTAT
    Now, this function module holds the values of all the views and the next screen numbers
    But i am unable to interpret the solution..Can somebody Elaborate on this.or provide me some other solution for this.
    Thanks in Advance
    Help Will be appreciated.

    Yes, I agree with Christian.  You are gonna want to use the BAPI or the underlying function module.  It works good and isn't really that complex.  Here is sample program.  Here the function module is being used to change data,  it can also be used to create,  you will have to change the Tcode from MM02 to MM01.
    report zrich_0001.
    data: i_mara type table of mara_ueb with header line.
    data: i_marc type table of marc_ueb with header line.
    data: i_marcx type table of marc with header line.
    parameters: p_matnr type mara-matnr,
                p_plifz type marc-plifz.
    start-of-selection.
    * Get all plants for that material
      select * into corresponding fields of table i_marcx
            from marc where matnr = p_matnr.
    * Now maintain data for each plant
      loop at i_marcx.
    * Reset I_Mara to new material number
        clear i_mara. refresh i_mara.
        select * into corresponding fields of table i_mara
              from mara where matnr = p_matnr.
        read table i_mara index 1.
        i_mara-tcode = 'MM02'.
        i_mara-tranc = '0000000001'.
        modify i_mara index 1.
    * Get Plant Data
        clear i_marc. refresh i_marc.
        select * into corresponding fields of table i_marc
              from marc where matnr = i_marcx-matnr
                          and werks = i_marcx-werks.
        read table i_marc index 1.
        i_marc-plifz  = p_plifz.        " Plan Del time
        i_marc-tranc = '0000000001'.
        modify i_marc index 1.
    * Maintain material
        perform MATERIAL_MAINTAIN_DARK'.
      endloop.
    *  MATERIAL_MAINTAIN_DARK
    form MATERIAL_MAINTAIN_DARK.
    * Variable for "Maintain_Material_Dark" Function Module
      data: numerror like tbist-numerror.
      data: last_matnr type mara-matnr.
      data: i_delfields type table of mfieldres with header line.
      data: i_errors    type table of merrdat   with header line.
      call function 'MATERIAL_MAINTAIN_DARK'
             exporting
                  sperrmodus                = ' '
                  kz_prf                    = 'W'
                  max_errors                = ' '
                  p_kz_no_warn              = 'X'
                  kz_verw                   = 'X'
                  kz_aend                   = 'X'
                  kz_dispo                  = 'X'
                  kz_test                   = ' '
                  flag_muss_pruefen         = ' '
                  call_mode                 = 'ACT'
             importing
                  number_errors_transaction = numerror
                  matnr_last     = last_matnr
             tables
                 amara_ueb      = i_mara    "Basic Data
    *             amakt_ueb      = i_makt    "Descriptions
                 amarc_ueb      = i_marc    "Plant
    *             amard_ueb      = i_mard    "Storage Location
    *            AMFHM_UEB      = I_MFHM    "Production Tools
    *             amarm_ueb      = i_marm    "Units of Measure
    *            AMEA1_UEB      = I_MEA1    "Internal Mangagement -  EANs
    *             ambew_ueb      = i_mbew    "Accounting/Costing
    *             asteu_ueb      = i_steu    "Tax Data
    *             astmm_ueb      = i_steumm  "Tax Data
    *            AMLGN_UEB      = I_MLGN    "Warehouse Data
    *            AMLGT_UEB      = I_MLGT    "Storage Type Data
    *            AMPGD_UEB      = I_MPGD    "Change Documents
    *            AMPOP_UEB      = I_MPOP    "Forcast Parameters
    *            AMVEG_UEB      = I_MVEG    "Total Consumption Data
    *            AMVEU_UEB      = I_MVEU    "Unplanned Consumption Data
    *             amvke_ueb      = i_mvke    "Sales Data
    *             altx1_ueb      = i_ltx1    "Sales Text
    *            AMPRW_UEB      = I_MPRW    "Forcast Values
                 amfieldres     = i_delfields
                 amerrdat       = i_errors
             exceptions
                  kstatus_empty             = 01
                  tkstatus_empty            = 02
                  t130m_error               = 03
                  internal_error            = 04
                  update_error              = 05
                  too_many_errors           = 06.
      if sy-subrc <> 0.
        rollback work.
        call function 'DEQUEUE_ALL'.
      else.
        commit work and wait.
        call function 'DEQUEUE_ALL'.
      endif.
      clear: i_mara, i_marc.
      refresh: i_mara, i_marc.
    endform.
    Regards,
    Rich Heilman

  • BDC  with ALV grid

    Hi everybody,
       I´m working with transaction SHDB to record a "Z" transaction. This one has an ALV grid with a toolbar. The problem is that when i´m recording this transaction, i cannot capture the events of the ALV toolbar and the selected lines of the grid. 
    Hope you can help me,
    Pablo.

    Hi Pablo,
    Another thought. If it is Z report, why dont you just submit the report/call routines in this report directly to perform the required actions?
    When you a do BDC on a Z report, you gotta be a little careful. There is every chance that tomorrow there might be a need to change selection screen parameters, show one more popup, insert one more screen and so on. And this might cause the BDC to fail.
    And as for the reason of why you are not able to capture the events, these events are not defined in the Status of the screen menu (SE41). Hence, it is not possible to captue these events.
    /Sagar

  • How to obtain PERNR during BDC with PA40

    Greetings!
    I recorded a PA40 session and am using the code in my program with success.  However, now I must make a call during the BDC code to a FM which requires the PERNR.  I'm not sure how to obtain the PERNR while the BDC code is executing.  I'm sure if I was doing it manually via PA40 I would be able to "see" the PERNR on the screens but I'm not sure how to obtain it while the BDC code is running.
    Thanks in advance.
    Snippet of code:
        PERFORM bdc_dynpro      USING 'MP000200'                '2010'.
        PERFORM bdc_field       USING 'BDC_CURSOR'              'Q0002-FATXT'.
        PERFORM bdc_field       USING 'BDC_OKCODE'              '=UPD'.
        PERFORM bdc_field       USING 'P0002-BEGDA'             lv_begda.
        PERFORM bdc_field       USING 'P0002-ENDDA'             '12319999'.
        PERFORM bdc_field       USING 'P0002-NACHN'             gt_enrollment-lname.
        PERFORM bdc_field       USING 'P0002-VORNA'             gt_enrollment-fname.
        PERFORM bdc_field       USING 'P0002-MIDNM'             gt_enrollment-mname.
        PERFORM bdc_field       USING 'Q0002-PERID'             gt_enrollment-ph_ssn.
        PERFORM bdc_field       USING 'P0002-GBDAT'             gt_enrollment-dob.

    Rob:
    Thanks for the reply.
    The following two lines are the ones that my functional guy is telling me I need to change from hard-coded values to those from HR_BEN_GET_FROM_FEATURE_XXXX; however, this FM requires the PERNR.  It looks like the only option I have is to wait until the BDC is finished and then do a "MOD" operation via HR_INFOTYPE_OPERATION.  Suggestions?
        PERFORM bdc_field     USING 'P0171-BENGR'            '0002'.
        PERFORM bdc_field     USING 'P0171-BSTAT'            '0002'.

  • BDC with call transaction VD02 works fin in A mode but not in N mode

    Hi All,
        I have BDC program developed in 4.6c using call transaction VD02 works fine with mode A but not with mode N.
    Now we upgraded to ECC 6.0.Do I need to change anything?

    No, you don't have to change anything for ECC. BTW, I wonder why VD02 is not working in the background for you?

  • BDC with many records ?

    Hello,
    I am having 10000 records material mater records to be uploaded by BDC i did the coding part and all its working fine i have checked it with sample 2 records it is working fine. Same code i got the instructions to upload the 10000 records use SM35 in this case what i have to do. I want to know how to configure SM35 so that i can trigger at the time which i got the instructions to run the program.
    Thks

    Hi balu,
    You can use transaction code SM35 to run and manage batch input sessions.
    You can schedule SAP standard program: RSBDCSUB to execute your session
    see this link
    http://e-mory.blogspot.com/2007/06/sap-batch-input-session-sm35.html
    thanks
    karthik

  • Bdc with session method

    hi all,
            i need to upload these transactions(MB1A, MB31,MB1A )one after the other.i have  the data in flat file(excel). I need to use BDC for this. I am prefering SESSION method for this.Can any one help me to acieve this. shall i record the transactions one after the othet and keep BDC_INSERT after the perform statements. will achieve this. Help me with a sample code for this

    Hi Kiran,
    Upload data into internal table (itab) using the below function modules.And then by using session method populate that in the BDCDATA internal table as you generally do session method.
    PARAMETERS: filename LIKE rlgrap-filename .
    PARAMETERS: kzheader AS CHECKBOX.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                mask      = '*.xls'
                static    = 'X'
           CHANGING
                file_name = filename.
    START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = filename
                i_begin_col             = begcol
                i_begin_row             = begrow
                i_end_col               = endcol
                i_end_row               = endrow
           TABLES
                intern                  = itab
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
      IF sy-subrc <> 0.
        WRITE:/ 'Upload Error ', SY-SUBRC.
      ENDIF.
    Reward points if useful.
    Thanks & Regards,
    khan.
    Edited by: Ahmed Khan on Apr 29, 2008 8:01 AM

Maybe you are looking for