Skip to Content
author's profile photo
Former Member

BDC

Hi all,

How we upload data from flat file using call transaction and session method when the fields are in table control.

regards,

vijay.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    author's profile photo
    Former Member
    Sep 26, 2005 at 06:48 PM

    Hello Vijaya,

    Since you are uploading values froma table control...you have to do it by building the line number dynamically. One way of doing it is by declaring the fields like below which you want to upload.

    DATA: BEGIN OF i_epstp,

    field1(11) TYPE c VALUE 'RM06E-EPSTP',

    field2(1) TYPE c VALUE '(',

    field3(3) TYPE n VALUE 000,

    field4(1) TYPE c VALUE ')',

    END OF i_epstp.

    DATA: BEGIN OF i_knttp,

    field1(10) TYPE c VALUE 'EKPO-KNTTP',

    field2(1) TYPE c VALUE '(',

    field3(3) TYPE n VALUE 000,

    field4(1) TYPE c VALUE ')',

    END OF i_knttp.

    ................................

    PERFORM create_bdc_session.

    ...................................

    FORM create_bdc_session.

    PERFORM open_group.

    i_xleg[] = i_leg[].

    LOOP AT i_leg.

    IF i_leg-po_nm = i_xleg-po_nm.

    SKIP.

    ELSE.

    PERFORM read_xref_tables.

    *-- First screen

    CLEAR w_insert_line.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0100'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'RM06E-BSART'.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

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

    PERFORM bdc_field USING 'RM06E-BSART' c_yb.

    PERFORM bdc_field USING 'EKKO-EKORG' p_ekorg.

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

    PERFORM vendor_address.

    IF w_address EQ '3'.

    PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' '04/02'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=SELV'.

    PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' '04/02'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=SELV'.

    PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' '04/02'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=SELV'.

    ENDIF.

    IF w_address EQ '2'.

    PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' '04/02'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=SELV'.

    PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' '04/02'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=SELV'.

    ENDIF.

    IF w_address EQ '1'.

    PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' '04/02'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=SELV'.

    ENDIF.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'RM06E-EBELP'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=KOPF'.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0101'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'EKKO-VERKF'.

    PERFORM bdc_field USING 'BDC_OKCODE' 'AB'.

    PERFORM bdc_field USING 'EKKO-VERKF' i_leg-po_nm.

    PERFORM bdc_field USING 'EKKO-ZTERM' i_sap-zterm.

    PERFORM bdc_field USING 'EKKO-SPRAS' 'EN'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLXM06'.

    PERFORM record_counter.

    LOOP AT i_xleg WHERE po_nm EQ i_leg-po_nm.

    • w_count = w_count + 1.

    WRITE: i_leg-del_date TO w_del_date YYMMDD.

    CONCATENATE '20' w_del_date INTO w_del_date.

    MOVE w_del_date(4) TO w_year.

    MOVE w_del_date+4(2) TO w_date.

    MOVE w_del_date+6(2) TO w_mon.

    CONCATENATE w_date '/' w_mon '/' w_year INTO w_del_date.

    PERFORM item_xref_tables.

    IF w_insert_line EQ space.

    *-- Second Screen Line # 1

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' i_eeind.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

    • PERFORM bdc_field USING i_bstpo w_item.

    PERFORM bdc_field USING i_epstp 'D'.

    PERFORM bdc_field USING i_knttp 'K'.

    PERFORM bdc_field USING i_txz01 i_sap-txz01.

    PERFORM bdc_field USING i_eeind w_del_date.

    PERFORM bdc_field USING i_netpr i_sap-netprice.

    PERFORM bdc_field USING i_matkl '25080400'.

    PERFORM bdc_field USING i_werks i_sap-werks.

    **-- Second Screen Line # 2 Onwards.

    ELSE.

    *--- Call Insert Line.

    PERFORM line_item_data.

    IF i_epstp-field3 GT c_loop.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'RM06E-EBELP'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=NP'.

    PERFORM record_counter.

    PERFORM line_item_data.

    ENDIF.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR' i_eeind.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

    • PERFORM bdc_field USING i_bstpo w_item.

    PERFORM bdc_field USING i_epstp 'D'.

    PERFORM bdc_field USING i_knttp 'K'.

    PERFORM bdc_field USING i_txz01 i_sap-txz01.

    PERFORM bdc_field USING i_eeind w_del_date.

    PERFORM bdc_field USING i_netpr i_sap-netprice.

    PERFORM bdc_field USING i_matkl '25080400'.

    PERFORM bdc_field USING i_werks i_sap-werks.

    ENDIF.

    w_insert_line = 'X'.

    *-- Third Screen.

    PERFORM bdc_dynpro USING 'SAPLMLSP' '0200'.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSP'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSL'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSL'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSP'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'ESLL-TBTWR(01)'.

    PERFORM bdc_field USING i_ktext1 i_sap-txz01.

    PERFORM bdc_field USING i_menge i_xleg-quant.

    PERFORM bdc_field USING i_meins 'PU'.

    PERFORM bdc_field USING i_tbtwr i_sap-netprice.

    PERFORM bdc_dynpro USING 'SAPLMLSK' '0200'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'ESKN-SAKTO(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

    PERFORM bdc_field USING i_mkntm w_quant.

    PERFORM bdc_field USING i_kostl w_costcenter.

    PERFORM bdc_field USING i_sakto w_glaccount.

    PERFORM bdc_dynpro USING 'SAPLMLSK' '0200'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'ESLL-INTROW'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.

    PERFORM bdc_dynpro USING 'SAPLMLSP' '0200'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=ESB'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSP'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSL'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSL'.

    PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLMLSP'.

    PERFORM bdc_field USING 'BDC_CURSOR' 'ESLL-KTEXT1(01)'.

    ENDLOOP.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.

    PERFORM bdc_transaction USING 'ME21'.

    ENDIF.

    ENDLOOP.

    PERFORM close_group.

    ENDFORM. " CREATE_BDC_SESSION

    -


    &----


    *& Form BDC_DYNPRO

    &----


    FORM bdc_dynpro USING program dynpro.

    CLEAR bdcdata.

    bdcdata-program = program.

    bdcdata-dynpro = dynpro.

    bdcdata-dynbegin = w_flg.

    APPEND bdcdata.

    CLEAR bdcdata.

    ENDFORM. " BDC_DYNPRO

    &----


    *& Form BDC_FIELD

    &----


    FORM bdc_field USING fnam fval.

    CLEAR bdcdata.

    bdcdata-fnam = fnam.

    bdcdata-fval = fval.

    APPEND bdcdata.

    CLEAR bdcdata.

    ENDFORM. " BDC_FIELD

    -


    Should you require the complete code I can mail you the whole code as an attachment.

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 26, 2005 at 05:00 PM

    Hi

    Do you want to update the data of fields in table control?

    In this case you have to create a field name like this:

    BDC_FIELD_NAME = <FIELD_SCREEN_NAME>(N).

    N is the number of th row of table control you want to update.

    You should try to work always on the first row of table control, but you can do it if there's a function to place in a certain position.

    LOOP AT T_FILE.

    IF SY-TABIX = 1.

    BDC-FIELD_NAME = <FIELD_SCREEN_NAME>(1).

    BDC-FIELD_VALUE = T_FILE-VALUE.

    APPEND BDC.

    else.

    • Here you should simulate to place in the first

    • position, so you have always the second row to insert

    • a new data:

    .....

    BDC-FIELD_NAME = <FIELD_SCREEN_NAME>(2).

    BDC-FIELD_VALUE = T_FILE-VALUE.

    APPEND BDC.

    ENDIF.

    ENDLOOP.

    Max

    Message was edited by: max bianchi

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      In this case:

      Insert first row:

      LOOP AT T_FILE.

      count_posnr = count_posnr + 10.

      if sy-tabix = 1.

      BDC_FIELD_NAME = 'EKPO-EMATN(01)'.

      ......

      ......

      ......

      append bdc.

      else.

      • Place in the first row the last position you have

      created

      BDC_FIELD_NAME = 'RM06E-EBELP'.

      BDC_FIELD_VALUE = count_posnr.

      • Insert ok-code enter /00 (I think)...

      • Now insert the new position

      BDC_FIELD_NAME = 'EKPO-EMATN(02)'.

      ......

      ......

      ......

      endif.

      count_posnr = count_posnr + 10.

      In you do in this way you always work on second (except first position), and so you aren't care how many position you have to insert

      Max

  • author's profile photo
    Former Member
    Sep 26, 2005 at 05:32 PM

    Hi vijay,

    welcome to SDN.

    below links might help you.

    http://help.sap.com/saphelp_erp2004/helpdata/en/fa/097126543b11d1898e0000e8322d00/frameset.htm

    http://www.sap-img.com/abap/learning-bdc-programming.htm

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

    reward points for helpfull answers by clicking top left side radio buttons and close the thread if your question is solved.

    regards,

    venu.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 26, 2005 at 06:33 PM

    Create a new recording in transaction SHDB for ME21 or ME22 or whichever tcode you want to do the BDC for.

    Later there in an option to create program . You can leverage the code generated in the program or put your logic of reading from file and passing data into this program.

    Try putting more that one line items in PO and in the code you will see how it done for a table control.

    However you can also use BAPI_PO_CREATE to create the POs without going into the hassle of writing a BDC.

    Cheers

    Add comment
    10|10000 characters needed characters exceeded