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.

Similar Messages

  • ALV run in background with oops

    Hi all,
    I created an ALV grid, which runs fine online. In the background however the spool is empty. The program does not dump though, it's just that the spool is empty.
    Here's the code for creating the grid in background:
    *.. create main grid
        create object g_grid1
       exporting
         i_parent          = g_dock
       exceptions
         error_cntl_create = 1
         error_cntl_init   = 2
         error_cntl_link   = 3
         error_dp_create   = 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.
    (and g_dock is declared as:  g_dock type ref to cl_gui_docking_container
                                       and:  g_grid1             type ref to cl_gui_alv_grid)
    Anyone got an idea what's going wrong here?
    Edited by: Ron Dijkstra on Jun 19, 2008 5:30 PM

    Hi,
    donno about the docking container, but surelly it works for the normal container with oops. I have worked on the similar requirement.
    we have to create the container based on the below condition
        IF cl_gui_alv_grid=>offline( ) IS INITIAL.
          CREATE OBJECT <CONTAINER>
                 EXPORTING container_name = <Name of the container specified in screen>
        endif.
    If you still have the doubt, copy the BCALV_EDIT_06 (this program is developed using OOPS and have the selection screen)  program to Z version, and add the above code while creating the container and execute in back ground.
    Thanks,
    Rajinikanth
    Edited by: Rajinikanth G on Jun 19, 2008 5:55 PM

  • Int-ALV with OOPS

    when i am going from 1st detail list to basic list and choosing another sales order number i am geting the previous data instead of data according to new sales order number.
    i have tried in ECC5.0 and also in 4.7EE.Plz Help me.
    The code is as follows
    *& Report  ZAP_OOPS_ALV_2
    *& Interactive alv with oops.
    REPORT  zap_oops_alv_2 MESSAGE-ID zapmsg.
    *& Structure Declaration
    Structure Declaration for sales order header data
    TYPES: BEGIN OF ty_vbak,
           vbeln TYPE vbeln_va, "Sales Ord Num
           vkorg TYPE vkorg,    "Sales Org
           vkgrp TYPE vkgrp,    "Sales Grp
           kunnr TYPE kunnr,    "Customer
           END OF ty_vbak,
    Structure Declaration for sales order item data
           BEGIN OF ty_vbap,
           vbeln TYPE vbeln_va, "Sales Ord Num
           posnr TYPE posnr,    "Sales item
           matnr TYPE matnr,    "Material Num
           matkl TYPE matkl,    "Material Grp
           netwr TYPE netwr,    "Net values
           END OF ty_vbap,
    Structure Declaration for customer data
           BEGIN OF ty_kna1,
           kunnr TYPE kunnr, "Customer
           name1 TYPE name1, "Name
           ort01 TYPE ort01, "City
           pstlz TYPE pstlz, "Postal code
           regio TYPE regio, "State
           END OF ty_kna1,
    Structure declaration for final output
          BEGIN OF ty_output,
           vbeln TYPE vbeln_va, "Sales Ord Num
           vkorg TYPE vkorg,    "Sales Org
           vkgrp TYPE vkgrp,    "Sales Grp
           kunnr TYPE kunnr,    "Customer
           name1 TYPE name1,    "Name
           ort01 TYPE ort01,    "City
           pstlz TYPE pstlz,    "Postal code
           regio TYPE regio,    "State
           posnr TYPE posnr,    "Sales item
           matnr TYPE matnr,    "Material Num
           matkl TYPE matkl,    "Material Grp
           netwr TYPE netwr,    "Net values
          END OF ty_output.
    *& Internal table Declaration
    DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak INITIAL SIZE 0,
          t_vbap TYPE STANDARD TABLE OF ty_vbap INITIAL SIZE 0,
          t_kna1 TYPE STANDARD TABLE OF ty_kna1 INITIAL SIZE 0,
          t_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
          t_vbep TYPE STANDARD TABLE OF vbep INITIAL SIZE 0,
    *& Work Area Declaration
      w_vbak TYPE ty_vbak,
      w_vbap TYPE ty_vbap,
      w_kna1 TYPE ty_kna1,
      w_output TYPE ty_output,
      w_vbep TYPE vbep,
      g_flag TYPE char1,
    g_vbeln TYPE vbak-vbeln.
    Alv Declarations
    DATA:g_custom_container1 TYPE REF TO cl_gui_custom_container,
         g_custom_container2 TYPE REF TO cl_gui_custom_container,
         g_grid1 TYPE REF TO cl_gui_alv_grid,
         g_grid2 TYPE REF TO cl_gui_alv_grid,
         w_fieldcat TYPE lvc_s_fcat,
         t_fieldcat TYPE lvc_t_fcat.
    *& Selection Screen Declaration
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:s_vbeln FOR g_vbeln.
    SELECTION-SCREEN END OF BLOCK b1.
          CLASS handle DEFINITION
    CLASS handle DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:click FOR EVENT double_click OF cl_gui_alv_grid
                                      IMPORTING e_row.
    ENDCLASS.                    "handle DEFINITION
          CLASS handle IMPLEMENTATION
    CLASS handle IMPLEMENTATION.
      METHOD click.
        CLEAR w_output.
        READ TABLE t_output INTO w_output INDEX e_row.
        CLEAR e_row.
        REFRESH t_vbep.
        SELECT *
         FROM vbep
         INTO TABLE t_vbep
         WHERE vbeln = w_output-vbeln.
        CREATE OBJECT g_custom_container2
                       EXPORTING
                        container_name = 'GRID2'.
        CREATE OBJECT g_grid2
                       EXPORTING
                        i_parent = g_custom_container2.
        CALL SCREEN 200.
      ENDMETHOD.                    "click
    ENDCLASS.                    "handle IMPLEMENTATION
    DATA:   g_handle TYPE REF TO handle.
          CLASS main DEFINITION
    CLASS main DEFINITION.
      PUBLIC SECTION.
        METHODS:get_vbak,
                get_vbap,
                get_kna1,
                disp_output,
                validate_vbeln,
                display_alv.
    ENDCLASS.                    "main DEFINITION
          CLASS main IMPLEMENTATION
    CLASS main IMPLEMENTATION.
    Method declaration for getting vbak data
      METHOD get_vbak.
        SELECT vbeln
               vkorg
               vkgrp
               kunnr
               FROM vbak
               INTO TABLE t_vbak
               WHERE vbeln IN s_vbeln.
      ENDMETHOD.                    "get_vbak
    Method Declaration for getting VBAP data
      METHOD get_vbap.
        SELECT vbeln
               posnr
               matnr
               matkl
               netwr
               FROM vbap
               INTO TABLE t_vbap
               FOR ALL ENTRIES IN t_vbak
               WHERE vbeln = t_vbak-vbeln.
      ENDMETHOD.                    "get_vbap
    Method Declaration for getting KNA1 data
      METHOD get_kna1.
        SELECT kunnr
               name1
               ort01
               pstlz
               regio
               FROM kna1
               INTO TABLE t_kna1
               FOR ALL ENTRIES IN t_vbak
               WHERE kunnr = t_vbak-kunnr.
      ENDMETHOD.                                                "get_kna1
    Method Declaration for displaying the output
      METHOD disp_output.
        LOOP AT t_vbap INTO w_vbap.
          w_output-vbeln = w_vbap-vbeln.
          w_output-posnr = w_vbap-posnr.
          w_output-matnr = w_vbap-matnr.
          w_output-matkl = w_vbap-matkl.
          w_output-netwr = w_vbap-netwr.
          CLEAR w_vbak.
          READ TABLE t_vbak INTO w_vbak WITH KEY vbeln = w_vbap-vbeln.
          IF sy-subrc = 0.
            w_output-vkorg = w_vbak-vkorg.
            w_output-vkgrp = w_vbak-vkgrp.
            w_output-kunnr = w_vbak-kunnr.
          ENDIF.
          CLEAR w_kna1.
          READ TABLE t_kna1 INTO w_kna1 WITH KEY kunnr = w_vbak-kunnr.
          IF sy-subrc = 0.
            w_output-name1 = w_kna1-name1.
            w_output-ort01 = w_kna1-ort01.
            w_output-pstlz = w_kna1-pstlz.
            w_output-regio = w_kna1-regio.
          ENDIF.
          APPEND w_output TO t_output.
          CLEAR w_output.
        ENDLOOP.
      ENDMETHOD.                    "disp_output
      METHOD validate_vbeln.
        DATA:l_vbeln TYPE vbeln_va.
        SELECT SINGLE vbeln
                FROM vbak
                INTO l_vbeln
                WHERE vbeln IN s_vbeln.
        IF sy-subrc <> 0.
          MESSAGE e001.
        ENDIF.
      ENDMETHOD.                    "validate_vbeln
      METHOD display_alv.
        CREATE OBJECT g_custom_container1
                       EXPORTING
                        container_name = 'GRID1'.
        CREATE OBJECT g_grid1
                       EXPORTING
                        i_parent = g_custom_container1.
        SET HANDLER g_handle->click  FOR g_grid1.
        w_fieldcat-col_pos = 1.
        w_fieldcat-fieldname = 'VBELN'.
        w_fieldcat-scrtext_m = 'Sales Ord'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 2.
        w_fieldcat-fieldname = 'POSNR'.
        w_fieldcat-scrtext_m = 'Sales Item'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 3.
        w_fieldcat-fieldname = 'MATNR'.
        w_fieldcat-scrtext_m = 'Material'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 4.
        w_fieldcat-fieldname = 'VKORG'.
        w_fieldcat-scrtext_m = 'Sale Org'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 5.
        w_fieldcat-fieldname = 'KUNNR'.
        w_fieldcat-scrtext_m = 'Customer'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        CALL SCREEN 100.
      ENDMETHOD.                    "display_alv
    ENDCLASS.                    "main IMPLEMENTATION
    DATA:g_main TYPE REF TO main.
    Selection SELECTION EVENT
    AT SELECTION-SCREEN.
    *Create the object
      CREATE OBJECT g_main.
      CALL METHOD g_main->validate_vbeln.
    Start of selection EVENT
    START-OF-SELECTION.
      CALL METHOD g_main->get_vbak .
      CALL METHOD g_main->get_vbap.
      CALL METHOD g_main->get_kna1.
      CALL METHOD g_main->disp_output.
      CALL METHOD g_main->display_alv.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MENU'.
    SET TITLEBAR 'xxx'.
      CALL METHOD g_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = t_output
          it_fieldcatalog = t_fieldcat.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  STATUS_0200  OUTPUT
          text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'MENU1'.
    SET TITLEBAR 'xxx'.
      CALL METHOD g_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name              = 'VBEP'
        CHANGING
          it_outtab                     = t_vbep.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    MODULE user_command_0200 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
         g_flag = 'X'.
         REFRESH t_vbep.
         SET HANDLER g_handle->click  FOR g_grid1.
         CALL METHOD g_main->display_alv.
         CALL SCREEN 100.
         LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 100.
          LEAVE TO SCREEN 0 .
         SET SCREEN 100. LEAVE SCREEN.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT

    Hi Srikar,
       In OOPS ALV, we first define screen then we define container on screen. Container means area on screen where you'll be placing your ALV.
      CREATE OBJECT r_cont
        EXPORTING
          container_name              = 'CONTAINER_1'  " Container name
        EXCEPTIONS
          OTHERS                      = 6
    Now you assign reference of container to your grid. grid defines structure of your ALV.
      CREATE OBJECT r_grid
        EXPORTING
          i_parent          = r_cont
        EXCEPTIONS
          OTHERS            = 5
    Now you call the method set_table_for_first_display of class cl_gui_alv_grid to define fieldcatalog, internal table etc. to display ALV. The reason behind using MODULE is that screen logic is always defined in MODULES. If the user is interacting with screen then screen logic will be defined in PAI of screen.
    One more thing is that in normal ALV you don't define screen and container. That means ALV will always be displayed at system defined place, but in OOP ALV, you define container(area) to define the place for your ALV.
    The advantage which I found in OOP ALV is that it is more flexible to use.
    Regards
    Abhijeet

  • Heirarchical ALV with OOPS

    Can anyone help me with the code of Heirarchical ALV with OOPS in module pool programming.

    hi,
    <i>link</i>
    http://www.sap-img.com/abap/how-to-use-alv-for-hierarchical-lists.htm
    <i>Check this example report :</i> BALVHD01
    <i>chk a sample code.</i>
    REPORT  ZTEST_HIER LINE-COUNT 65
                                 LINE-SIZE 200
                                 NO STANDARD PAGE HEADING
                                 MESSAGE-ID ZZ.
    TYPE-POOLS: SLIS.
    TYPES: BEGIN OF TY_HEAD,
          VBELN LIKE VBAK-VBELN,
          KUNNR LIKE VBAK-KUNNR,
          NAME  LIKE KNA1-NAME1,
          END OF TY_HEAD.
    TYPES: BEGIN OF TY_ITEM,
           VBELN LIKE VBAP-VBELN,
           POSNR LIKE VBAP-POSNR,
           MATNR LIKE VBAP-MATNR,
           MAKTX LIKE MAKT-MAKTX,
           CHECK(1),
           END OF TY_ITEM.
    DATA: IT_ITEM TYPE TABLE OF TY_ITEM.
    DATA: IT_HEADER TYPE TABLE OF TY_HEAD,
           IT_EVENTS TYPE SLIS_T_EVENT,          "Events.
           IT_FIELDCAT      TYPE SLIS_T_FIELDCAT_ALV.
    DATA: X_LAYOUT         TYPE SLIS_LAYOUT_ALV,
          X_FIELDCAT       TYPE SLIS_FIELDCAT_ALV,
          X_KEY           TYPE SLIS_KEYINFO_ALV,
          X_EVENTS TYPE SLIS_ALV_EVENT,      "Event
          X_VBELN LIKE VBAK-VBELN,
          X_ITEM TYPE TY_ITEM.
    CONSTANTS: C_S(1) VALUE '/'.
    DATA: V_FLAG.
    *                   SELECTION-SCREEN                                  *
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR X_VBELN.      "Sales order Number
    SELECTION-SCREEN END OF BLOCK BLK.
    AT SELECTION-SCREEN.
      IF NOT S_VBELN[] IS INITIAL.
        SELECT SINGLE VBELN
               INTO X_VBELN
               FROM VBAK
               WHERE VBELN IN S_VBELN.
        IF SY-SUBRC <> 0.
          MESSAGE E002 WITH 'Please enter valid Sales Order'(020).
        ENDIF.
      ENDIF.
    *       CLASS lcl_bill_complete DEFINITION
    CLASS LCL_BILL_COMPLETE DEFINITION.
      PUBLIC SECTION.
        METHODS:GET_HEADER_DATA,
                GET_ITEM_DATA,
                SHOW_DATA,
                FILL_FIELDCAT,
                FILL_EVENTS,
                TOP_OF_PAGE.
    ENDCLASS.                    "lcl_bill_complete DEFINITION
    *       CLASS lcl_bill_complete IMPLEMENTATION
    CLASS LCL_BILL_COMPLETE IMPLEMENTATION.
      METHOD GET_HEADER_DATA.
        DATA:X_HEADER LIKE LINE OF IT_HEADER.
        X_HEADER-VBELN = '12345'.
        X_HEADER-KUNNR = '1234'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
        X_HEADER-VBELN = '12346'.
        X_HEADER-KUNNR = '1236'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
        X_HEADER-VBELN = '12347'.
        X_HEADER-KUNNR = '1235'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
      ENDMETHOD.                    "get_header_data
      METHOD GET_ITEM_DATA.
        DATA:X_ITEM LIKE LINE OF IT_ITEM.
        X_ITEM-VBELN = '12345'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12345'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12346'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12346'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12347'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12347'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
      ENDMETHOD.                    "get_item_data
      METHOD SHOW_DATA.
        X_KEY-HEADER01 = 'VBELN'.
        X_KEY-ITEM01   = 'VBELN'.
        X_KEY-ITEM02   = 'POSNR'.
        CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = X_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT[]
            I_TABNAME_HEADER   = 'IT_HEADER'
            I_TABNAME_ITEM     = 'IT_ITEM'
            IS_KEYINFO         = X_KEY
            IT_EVENTS          = IT_EVENTS
          TABLES
            T_OUTTAB_HEADER    = IT_HEADER
            T_OUTTAB_ITEM      = IT_ITEM
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.
      ENDMETHOD.                    "show_data
      METHOD FILL_FIELDCAT.
        DATA: L_POS TYPE I.
        X_LAYOUT-HEADER_TEXT      = 'HEADER'.
        X_LAYOUT-ITEM_TEXT        = 'ITEM'.
        X_LAYOUT-DEFAULT_ITEM     = ' '.
        X_LAYOUT-NO_KEYFIX        = 'X'.
        X_LAYOUT-BOX_TABNAME      = 'IT_ITEM'.
        L_POS = L_POS + 1.
    *- Sales Order Number
        X_FIELDCAT-FIELDNAME   = 'VBELN'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-SELTEXT_M   = 'Sales Order'(017).
        X_FIELDCAT-OUTPUTLEN  = 11.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'KUNNR'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-SELTEXT_M   = 'Sold-to Party'(010).
        X_FIELDCAT-OUTPUTLEN  = 13.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'NAME'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-OUTPUTLEN  = 15.
        X_FIELDCAT-SELTEXT_M   = 'Sold-to name'(011).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'CHECK'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-CHECKBOX   = 'X'.
        X_FIELDCAT-INPUT  = 'X'.
        X_FIELDCAT-EDIT  = 'X'.
        X_FIELDCAT-SELTEXT_M   = ' '.
        X_FIELDCAT-OUTPUTLEN  = 2.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'VBELN'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-SELTEXT_M   = 'Sales Order'(017).
        X_FIELDCAT-OUTPUTLEN  = 11.
        X_FIELDCAT-TECH = 'X'.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
    *- Sales Order Item
        X_FIELDCAT-FIELDNAME   = 'POSNR'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-SELTEXT_M   = 'SO Item'(018).
        X_FIELDCAT-OUTPUTLEN  = 7.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'MATNR'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-OUTPUTLEN  = 18.
        X_FIELDCAT-SELTEXT_M   = 'Material number'(012).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'MAKTX'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-OUTPUTLEN  = 40.
        X_FIELDCAT-SELTEXT_M   = 'Material Description'(013).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
      ENDMETHOD.                    "fill_fieldcat
    *--Fill the events table
      METHOD FILL_EVENTS.
    *-  Top of page
        X_EVENTS-NAME =  'TOP_OF_PAGE'.
        X_EVENTS-FORM =  'TOP_OF_PAGE'.
        APPEND X_EVENTS TO IT_EVENTS.
      ENDMETHOD.                    "fill_events
      "fill_events
      METHOD TOP_OF_PAGE.
    *-  Call Steelcase Standard Header
        WRITE 'top_of_page here'.
      ENDMETHOD.                    "top_of_page
    ENDCLASS.                    "lcl_bill_complete IMPLEMENTATION
    START-OF-SELECTION.
      DATA: OBJ TYPE REF TO LCL_BILL_COMPLETE.
      CREATE OBJECT OBJ.
      CALL METHOD OBJ->GET_HEADER_DATA.
      CALL METHOD OBJ->GET_ITEM_DATA.
      CALL METHOD OBJ->FILL_FIELDCAT.
      CALL METHOD OBJ->FILL_EVENTS.
      CALL METHOD OBJ->SHOW_DATA.
    *&      Form  top_of_page
    *      TOP_OF_PAGE
    FORM TOP_OF_PAGE.
    *-To show the top of page
      CALL METHOD OBJ->TOP_OF_PAGE.
    ENDFORM.                    "top_of_page
    if hlped plsmark points.
    rgds
    Anver

  • 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!!!

  • Module pool program with OOPS

    Hi friends,
    am working on module pool program i want to use oops concept in moduel pool.can any body give me an example in
    module pool with oops .
    Thanks in advance,
    sai.

    Hello,
    we have uses ABAP OO and Classic Dypros in our current projekt a lot.
    It turned out to be the best way to it like this:
    1. Create your Dynpro
    2. Create an Interface that corresponds only to that Dynpro.
    3. In the Modules of the dynpro you only  call Methods from that interface created above, also all checks of Dynprofields etc should be handled in the Implelmentation of the methods. so you do like that:
    Module set_vbeln.
       gi_dynp_class->set_vbeln( gs_sd-vbeln ).
    endmodul.
    gi_dynp_class is from type of your interface.
    4. Create an application class that implements all the methods of the interface with the logic needed.  Using inheritance you can easily reuse the the Dynpro in different contexts with different Application classes behind it.
    5. In PBO of the dynpro you have to make sure that the the variable gi_dynp_class is bound. So you will cast your application class instance to it:
    gi_dynp_class ?= gi_app_class.
    The application class must be instanciates at the beginning of the program before the dynpro is used.
    As a class can implement several interface you can enable you application class for as many dynpros as you want to.
    Hope that helps a bit ...
    Greetings from Hamburg

  • 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

  • Can u explain me how to work with OOPs ABAP

    Hi,
    Can u explain me how to work with OOPS Abap,  If possible pls send me some sample programs regarding OOps concept used in Realtime.
    Thanks.

    hii,
    Please check this online document (starting page 1291).
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
    Also check this links as well.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.futureobjects.de/content/intro_oo_e.html
    http://www.sap-img.com/abap/business-add-in-you-need-to-understand-abap-oo-interface-concept.htm
    /people/ravikumar.allampallam/blog/2005/02/11/abap-oo-in-action
    What is Object Orientation?
    Object orientation (OO), or to be more precise, object-oriented programming, is a problem-solving method in which the software solution reflects objects in the real world.
    A comprehensive introduction to object orientation as a whole would go far beyond the limits of this introduction to ABAP Objects. This documentation introduces a selection of terms that are used universally in object orientation and also occur in ABAP Objects. In subsequent sections, it goes on to discuss in more detail how these terms are used in ABAP Objects. The end of this section contains a list of further reading, with a selection of titles about object orientation.
    Objects
    An object is a section of source code that contains data and provides services. The data forms the attributes of the object. The services are known as methods (also known as operations or functions). Typically, methods operate on private data (the attributes, or state of the object), which is only visible to the methods of the object. Thus the attributes of an object cannot be changed directly by the user, but only by the methods of the object. This guarantees the internal consistency of the object.
    Classes
    Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory, you can create any number of objects based on a single class. Each instance (object) of a class has a unique identity and its own set of values for its attributes.
    Object References
    In a program, you identify and address objects using unique object references. Object references allow you to access the attributes and methods of an object.
    In object-oriented programming, objects usually have the following properties:
    Encapsulation
    Objects restrict the visibility of their resources (attributes and methods) to other users. Every object has an interface, which determines how other objects can interact with it. The implementation of the object is encapsulated, that is, invisible outside the object itself.
    Polymorphism
    Identical (identically-named) methods behave differently in different classes. Object-oriented programming contains constructions called interfaces. They enable you to address methods with the same name in different objects. Although the form of address is always the same, the implementation of the method is specific to a particular class.
    Inheritance
    You can use an existing class to derive a new class. Derived classes inherit the data and methods of the superclass. However, they can overwrite existing methods, and also add new ones.
    Uses of Object Orientation
    Below are some of the advantages of object-oriented programming:
    Complex software systems become easier to understand, since object-oriented structuring provides a closer representation of reality than other programming techniques.
    In a well-designed object-oriented system, it should be possible to implement changes at class level, without having to make alterations at other points in the system. This reduces the overall amount of maintenance required.
    Through polymorphism and inheritance, object-oriented programming allows you to reuse individual components.
    In an object-oriented system, the amount of work involved in revising and maintaining the system is reduced, since many problems can be detected and corrected in the design phase.
    Achieving these goals requires:
    Object-oriented programming languages
    Object-oriented programming techniques do not necessarily depend on object-oriented programming languages. However, the efficiency of object-oriented programming depends directly on how object-oriented language techniques are implemented in the system kernel.
    Object-oriented tools
    Object-oriented tools allow you to create object-oriented programs in object-oriented languages. They allow you to model and store development objects and the relationships between them.
    Object-oriented modeling
    The object-orientation modeling of a software system is the most important, most time-consuming, and most difficult requirement for attaining the above goals. Object-oriented design involves more than just object-oriented programming, and provides logical advantages that are independent of the actual implementation
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/sap.user72/blog/2005/05/10/a-small-tip-for-the-beginners-in-oo-abap
    /people/ravikumar.allampallam/blog/2005/02/11/abap-oo-in-action
    /people/thomas.jung3/blog/2005/09/08/oo-abap-dynpro-programming
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For basic stuff......
    abap oops
    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/frameset.htm
    ABAP Business Development and Service Provisioning/ABAP Objects
    General information
    What is Object Orientation?
    some blogs
    A small tip for the beginners in OO ABAP
    Object Oriented ABAP (OO-ABAP)
    and others wiki OO Abap
    cheers,
    sharad
    Edited by: sharad narayan on Apr 29, 2008 12:19 PM

  • Printing Page numbers in ALV grid with oops

    Hi ,
    I have a ALV grid display with OOPS , there are also fields in top of page and end of page that go along with the print. I want to print the page numbers also . If I give a variable and increment it along with every call to top of page , then if a second print is issued, the variable can not be cleared out. Is there any other way.
    Thank you .

    Regarding  ALV Grid  Control using OOPs concepts
    Please give me reward point if it is useful.
    Thanks
    Murali Poli

  • 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>

  • BDC using oops

    hi,
    can any post me bdc using oops that is material creation.
    plz its urgent

    Hi Friend,
    Please do not use BDC to create material.
    Use BAPI BAPI_MATERIAL_SAVEDATA to create a material, it will tackle OOPS scenario also.
    Regards
    Krishnendu

  • .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.

Maybe you are looking for