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

how populate the data in table control in BDC?

pls urgent?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Oct 17, 2006 at 04:42 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 04:42 AM

    hi,

    Check

    <b>Table control in BDC</b>

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

    <b>Reward points by marking helpful answers..</b>

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2006 at 04:43 AM

    Hi,

    Check this link.This contains very good example.

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

    Regards

    - Gopi

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2006 at 04:45 AM

    hi,

    see the below code .

    FORM create_bdc_session .

    DATA : w_saved_tx.

    DATA g_r_itab TYPE typ_itab_rec.

    CLEAR g_t_itab.

    CLEAR g_r_itab.

    LOOP AT g_t_itab INTO g_r_itab.

    • skip error lines

    IF g_r_itab-ebeln = 'ERROR'.

    CONTINUE.

    ENDIF.

    • open Bdc session

    AT FIRST.

    PERFORM bdc_open_group.

    ENDAT.

    g_t_itab = g_r_itab.

    • On change in agreement number

    AT NEW ebeln.

    PERFORM bdc_header.

    CLEAR: w_dtl_cnt_i, w_line_i.

    ENDAT.

    • save at full page

    IF w_line_i > 11.

    PERFORM bdc_save.

    PERFORM bdc_header_change.

    w_line_i = 1.

    ENDIF.

    • detail material processing

    PERFORM bdc_detail.

    CLEAR w_saved_tx .

    • save at end of agreement

    AT END OF ebeln.

    IF w_saved_tx NE 'Y' AND w_dtl_cnt_i > 0.

    PERFORM bdc_save.

    ENDIF.

    w_saved_tx = 'Y'.

    ENDAT.

    ENDLOOP.

    PERFORM bdc_close_group.

    ENDFORM. " CREATE_BDC_SESSION

    &----


    *& Form BDC_OPEN_GROUP

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM bdc_open_group .

    DATA w_user_tx LIKE apqi-userid.

    w_user_tx = sy-uname.

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    client = sy-mandt

    group = p_bdc

    keep = 'X'

    user = w_user_tx

    EXCEPTIONS

    client_invalid = 01

    destination_invalid = 02

    group_invalid = 03

    holddate_invalid = 04

    internal_error = 05

    queue_error = 06

    running = 07

    user_invalid = 08.

    CASE sy-subrc.

    WHEN 0.

    WHEN OTHERS.

    WRITE: / 'BDC OPEN ERROR', sy-subrc.

    ENDCASE.

    ENDFORM. " BDC_OPEN_GROUP

    &----


    *& Form BDC_HEADER

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM bdc_header .

    REFRESH bdcdata.

    CLEAR bdcdata.

    *

    • determine now if text exists

    CLEAR w_text_lines_i.

    *----


    • Transaction ME31K.

    *----


    PERFORM bdc_dynpro USING 'SAPMM06E' '0200'.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

    PERFORM bdc_field USING 'EKKO-LIFNR' g_t_itab-lifnr.

    PERFORM bdc_field USING 'RM06E-EVART' 'MK'.

    PERFORM bdc_field USING 'RM06E-EVRTN' g_t_itab-ebeln.

    PERFORM bdc_field USING 'EKKO-EKORG' g_t_itab-ekorg.

    PERFORM bdc_field USING 'EKKO-EKGRP' g_t_itab-ekgrp.

    • Item category is on a detail line, but is entered on the entry screen

    IF g_t_itab-pstyp = '3'.

    g_t_itab-pstyp = 'L'.

    ELSE.

    CLEAR g_t_itab-pstyp.

    ENDIF.

    PERFORM bdc_field USING 'RM06E-EPSTP' g_t_itab-pstyp.

    PERFORM bdc_field USING 'RM06E-WERKS' p_nwerks.

    PERFORM bdc_field USING 'RM06E-LGORT' g_t_itab-lgort.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0201'.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

    PERFORM bdc_field USING 'EKKO-WAERS' g_t_itab-waers.

    WRITE sy-datum TO w_date_tx DD/MM/YYYY.

    PERFORM bdc_field USING 'EKKO-KDATB' '01.06.2004'.

    PERFORM bdc_field USING 'EKKO-KDATE' '31.12.2999'.

    w_tcode = 'ME31K'.

    ENDFORM. " BDC_HEADER

    &----


    *& Form BDC_SAVE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM bdc_save .

    • final save

    PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.

      • needed for some boxes (save anyway message)

    • PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.

    • PERFORM bdc_field USING 'BDC_OKCODE' '=YES'.

      • Insert the transaction into the BDC session.

      PERFORM bdc_insert USING w_tcode.

      REFRESH bdcdata.

      CLEAR bdcdata.

      ENDFORM. " BDC_SAVE

      &----


      *& Form BDC_HEADER_change

      &----


      • text

      ----


      • --> p1 text

      • <-- p2 text

      ----


      FORM bdc_header_change .

      DATA: w_pos LIKE rm06e-ebelp.

      REFRESH bdcdata.

      CLEAR bdcdata.

      • determine now if text exists

      CLEAR w_text_lines_i.

      *----


      • Transaction ME32K.

      *----


      PERFORM bdc_dynpro USING 'SAPMM06E' '0205'.

      PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

      PERFORM bdc_field USING 'RM06E-EVRTN' g_t_itab-ebeln.

      PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.

      PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

      w_pos = g_t_itab-ebelp - 10.

      PERFORM bdc_field USING 'RM06E-EBELP' w_pos.

      w_tcode = 'ME32K'.

      ENDFORM. " BDC_HEADER_change

      &----


      *& Form BDC_INSERT

      &----


      • text

      ----


      • -->P_W_TCODE text

      ----


      FORM bdc_insert USING p_w_tcode.

      CALL FUNCTION 'BDC_INSERT'

      EXPORTING

      tcode = w_tcode

      TABLES

      dynprotab = bdcdata

      EXCEPTIONS

      internal_error = 01

      not_open = 02

      queue_error = 03

      tcode_invalid = 04.

      CASE sy-subrc.

      WHEN 0.

      WHEN OTHERS.

      WRITE: / 'BDC INSERT ERROR', sy-subrc.

      ENDCASE.

      ENDFORM. " BDC_INSERT

      &----


      *& Form BDC_CLOSE_GROUP

      &----


      • text

      ----


      • --> p1 text

      • <-- p2 text

      ----


      FORM bdc_close_group .

      CALL FUNCTION 'BDC_CLOSE_GROUP'

      EXCEPTIONS

      not_open = 1

      queue_error = 2

      OTHERS = 3.

      CASE sy-subrc.

      WHEN 0.

      WHEN OTHERS.

      WRITE: / 'BDC CLOSE ERROR', sy-subrc.

      ENDCASE.

      ENDFORM. " BDC_CLOSE_GROUP

      &----


      *& Form bdc_dynpro

      &----


      • text

      ----


      • -->P_0658 text

      • -->P_0659 text

      ----


      FORM bdc_dynpro USING program dynpro.

      CLEAR bdcdata.

      bdcdata-program = program.

      bdcdata-dynpro = dynpro.

      bdcdata-dynbegin = 'X'.

      APPEND bdcdata.

      ENDFORM. "BDC_DYNPRO

      &----


      *& Form BDC_FIELD

      &----


      • text

      ----


      • -->P_0688 text

      • -->P_W_POS text

      ----


      FORM bdc_field USING field value.

      CLEAR bdcdata.

      bdcdata-fnam = field.

      bdcdata-fval = value.

      APPEND bdcdata.

      ENDFORM. "BDC_FIELD

      &----


      *& Form load_dataset

      &----


      • text

      ----


      • --> p1 text

      • <-- p2 text

      ----


      FORM load_dataset .

      • load dataset

      LOOP AT g_t_itab INTO g_r_itab.

      • Load dataset with records needed for direct input

      MOVE-CORRESPONDING g_r_itab TO g_t_itab.

      AT NEW ebeln.

      PERFORM load_dataset_mbepoh USING w_phys_outfil1_tx.

      ENDAT.

      PERFORM load_dataset_mbepoi USING w_phys_outfil1_tx.

      ENDLOOP.

      ENDFORM. " load_dataset

      &----


      *& Form load_dataset_mbepoh

      &----


      • text

      ----


      • -->P_W_PHYS_OUTFIL1_TX text

      ----


      FORM load_dataset_mbepoh USING p_dataset.

      CLEAR rec1.

      MOVE-CORRESPONDING g_t_itab TO rec1.

      rec1-stype = '1'.

      rec1-ernam = sy-uname.

      TRANSFER rec1 TO p_dataset.

      ENDFORM. " load_dataset_mbepoh

      &----


      *& Form load_dataset_mbepoi

      &----


      • text

      ----


      • -->P_W_PHYS_OUTFIL1_TX text

      ----


      FORM load_dataset_mbepoi USING p_dataset.

      CLEAR rec2.

      • fields for MBEPOH

      ADD 1 TO w_good_i.

      MOVE-CORRESPONDING g_t_itab TO rec2.

      rec2-stype = '2'.

      rec2-werks = p_nwerks.

      rec2-ematn = g_t_itab-matnr.

      TRANSFER rec2 TO p_dataset.

      ENDFORM. " load_dataset_mbepoi

      &----


      *& Form BDC_DETAIL

      &----


      • text

      ----


      • --> p1 text

      • <-- p2 text

      ----


      FORM bdc_detail .

      DATA: w_ktmng_tx(11),

      w_peinh_tx(5) TYPE c,

      w_price_p(13) TYPE p DECIMALS 6,

      w_price2_p(13) TYPE p DECIMALS 2,

      w_price3_p(13) TYPE p DECIMALS 3,

      w_price0_p(13) TYPE p DECIMALS 0,

      w_cent_p TYPE p DECIMALS 2,

      w_peinh_n(5) TYPE n,

      w_price_tx(14).

      • accumulate lines to determine if page_down required

      ADD 1 TO w_addit_i.

      ADD 1 TO w_dtl_cnt_i.

      ADD 1 TO w_line_i.

      IF w_line_i > 12.

      w_line_i = 2.

      PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.

      PERFORM bdc_field USING 'BDC_OKCODE' '=NP'.

      ENDIF.

      • get material unit of measure

      CLEAR mara-meins.

      SELECT SINGLE * FROM mara WHERE matnr = g_t_itab-matnr.

      w_price_tx = g_t_itab-netpr.

      w_peinh_tx = g_t_itab-peinh.

      IF g_t_itab-ktmng = 0.

      g_t_itab-ktmng = 1.

      ENDIF.

      w_ktmng_tx = g_t_itab-ktmng.

      • get decimal places of currency

      TCURX-CURRDEC = 2.

      SELECT SINGLE * FROM TCURX WHERE CURRKEY = g_t_itab-waers.

      • multiply Price

      W_PRICE_P = g_t_itab-netpr.

      CASE TCURX-CURRDEC.

      WHEN 0.

      W_PRICE_P = g_t_itab-netpr * 100.

      W_PRICE0_P = W_PRICE_P.

      W_PRICE_TX = W_PRICE0_P.

      WHEN 2.

      W_PRICE2_P = W_PRICE_P.

      W_PRICE_TX = W_PRICE2_P.

      WHEN 3.

      W_PRICE3_P = W_PRICE_P.

      W_PRICE_TX = W_PRICE3_P.

      ENDCASE.

      • material overview screen (with enter)

      PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.

      PERFORM bdc_field USING 'BDC_OKCODE' '=DETA'.

      PERFORM bdc_field_idx USING 'RM06E-TCSELFLAG' 'X' w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-EMATN' g_t_itab-matnr w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-KTMNG' w_ktmng_tx w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-NETPR' w_price_tx w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-PEINH' w_peinh_tx w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-BPRME' mara-meins w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-WERKS' p_nwerks w_line_i.

      PERFORM bdc_field_idx USING 'EKPO-LGORT' g_t_itab-lgort w_line_i.

      • IF g_t_itab-pstyp = '3'.

      • g_t_itab-pstyp = 'L'.

      • ELSE.

      • CLEAR g_t_itab-pstyp.

      • ENDIF.

      • PERFORM bdc_field_idx USING 'RM06E-EPSTP' g_t_itab-pstyp w_line_i.

      *

      • item details screen

      PERFORM bdc_dynpro USING 'SAPMM06E' '0211'.

      PERFORM bdc_field USING 'BDC_OKCODE' '=OR'.

      PERFORM bdc_field USING 'EKPO-SPINF' 'B'.

      PERFORM bdc_field USING 'EKPO-BSTAE' '0001'.

      PERFORM bdc_field USING 'EKPO-MWSKZ' g_t_itab-mwskz.

      PERFORM bdc_field USING 'EKPO-IDNLF' g_t_itab-idnlf.

      PERFORM bdc_field USING 'EKPO-REPOS' 'X'.

      PERFORM bdc_field USING 'EKPO-EVERS' g_t_itab-evers.

      PERFORM bdc_field USING 'EKPO-KZABS' 'X'.

      PERFORM bdc_field USING 'EKPO-NETPR' w_price_tx. "deliberate

      PERFORM bdc_field USING 'EKPO-PEINH' w_peinh_tx . "Overwriting

      • Source list

      PERFORM bdc_dynpro USING 'SAPLMEOR' '0220'.

      PERFORM bdc_field USING 'BDC_OKCODE' 'EN'.

      PERFORM bdc_field USING 'BDC_CURSOR' 'EORD-AUTET(01)'.

      PERFORM bdc_field USING 'EORD-VDATU(01)' '01062004'.

      PERFORM bdc_field USING 'EORD-BDATU(01)' '31122999'.

      PERFORM bdc_field USING 'EORD-FEBEL(01)' ' '.

      PERFORM bdc_field USING 'EORD-AUTET(01)' '1'.

      • GOTO Conditions

      PERFORM bdc_dynpro USING 'SAPMM06E' '0211'.

      PERFORM bdc_field USING 'BDC_OKCODE' '=KO'.

      PERFORM bdc_dynpro USING 'SAPMV13A' '0201'.

      PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.

      ENDFORM. " BDC_DETAIL

      &----


      *& Form BDC_FIELD_IDX

      &----


      • text

      ----


      • -->P_1390 text

      • -->P_G_T_ITAB_PSTYP text

      • -->P_W_LINE_I text

      ----


      FORM bdc_field_idx USING field LIKE bdcdata-fnam

      value p_index TYPE i.

      DATA: w_index_tx(2).

      UNPACK p_index TO w_index_tx.

      CLEAR bdcdata.

      CONCATENATE field '(' w_index_tx ')' INTO field.

      bdcdata-fnam = field.

      bdcdata-fval = value.

      APPEND bdcdata.

      ENDFORM. " BDC_FIELD_IDX

      regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 04:56 AM

    Populating data into table control is moving data from internal table to table control.Follow the code it may help u.

    *********************************

    PROCESS BEFORE OUTPUT.

    MODULE status_9010.

    LOOP WITH CONTROL tab_control.

    MODULE move_data_to_table.

    ENDLOOP.

    PROCESS AFTER INPUT.

    LOOP WITH CONTROL tab_control.

    MODULE move_data_from_table.

    ENDLOOP.

    ****************************

    &----


    *& Module move_data_to_table OUTPUT

    &----


    • This is to move the data from the internal table to the table control

    ----


    MODULE move_data_to_table OUTPUT.

    • This is to move the data from the internal table to the table control

    zmpets_mode-modecode,zmpets_range-rangeid,zmpets_servfacto-factor are column name if *table control

    *

    READ TABLE int_factor INDEX tab_control-current_line.

    IF sy-subrc = 0.

    zmpets_mode-modecode = int_factor-modecode.

    zmpets_range-rangeid = int_factor-rangeid.

    zmpets_servfacto-factor = int_factor-factor.

    ENDIF.

    ENDMODULE. " move_data_to_table OUTPUT

    **********************

    &----


    *& Module move_data_from_table INPUT

    &----


    • Date is moved from the table control to the Internal Table

    ----


    MODULE move_data_from_table INPUT.

    • To move the data from the table control to internal table 'INT_FACTOR.

    int_factor-modecode = zmpets_mode-modecode.

    int_factor-rangeid = zmpets_range-rangeid.

    int_factor-factor = zmpets_servfacto-factor.

    MODIFY int_factor INDEX tab_control-current_line.

    IF sy-subrc NE 0.

    APPEND int_factor.

    CLEAR int_factor.

    ENDIF.

    ENDIF.

    ENDMODULE. " move_data_from_table INPUT

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Before answering

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

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