Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Table Controls using BDC

Former Member
0 Likes
496

Hi all,

I would like to know about "Table controls using BDC" & what are the major problems that occur while using table controls in BDC.I need a documentation of these.and also a code with step by step procedure .

Thanks in advance,

Sriram.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
472

2 major problems which you encounter are

1. Most of the cases there is no search for the exact row to which you would like to update the record value.

2. The number of rows for the table control in BDC mode is often different than the normal user mode . So to do a page down or page up you will need to know this in advance so that you can control the insertions/modifications from you internal table on to the BDC screen table control.

Cheers

Kareem

3 REPLIES 3
Read only

Former Member
0 Likes
472

Hi...

Table control in BDC

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

check the below link also u may find answers for all your q's

http://help.sap.com/saphelp_webas630/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/content.htm

ex----

*HANDLING TABLE CONTROL IN BDC

DATA : BEGIN OF IT_DUMMY OCCURS 0,

DUMMY(100) TYPE C,

END OF IT_DUMMY.

DATA : BEGIN OF IT_XK01 OCCURS 0,

LIFNR(10) TYPE C,

BUKRS(4) TYPE C,

EKORG(4) TYPE C,

KTOKK(4) TYPE C,

NAME1(30) TYPE C,

SORTL(10) TYPE C,

LAND1(3) TYPE C,

SPRAS(2) TYPE C,

AKONT(6) TYPE C,

FDGRV(2) TYPE C,

WAERS(3) TYPE C,

END OF IT_XK01,

BEGIN OF IT_BANK OCCURS 0,

BANKS(3) TYPE C,

BANKL(10) TYPE C,

BANKN(10) TYPE C,

KOINH(30) TYPE C,

LIFNR(10) TYPE C,

END OF IT_BANK.

DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'C:\VENDOR.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = IT_DUMMY.

LOOP AT IT_DUMMY.

IF IT_DUMMY-DUMMY+0(2) = '11'.

IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).

IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).

IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).

IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).

IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).

IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).

IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).

IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).

IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).

IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).

IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).

APPEND IT_XK01.

ELSE.

IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).

IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).

IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).

IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).

IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).

APPEND IT_BANK.

ENDIF.

ENDLOOP.

LOOP AT IT_XK01.

REFRESH IT_BDCDATA.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-REF_LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

IT_XK01-LIFNR.

perform bdc_field using 'RF02K-BUKRS'

IT_XK01-BUKRS.

perform bdc_field using 'RF02K-EKORG'

IT_XK01-EKORG.

perform bdc_field using 'RF02K-KTOKK'

IT_XK01-KTOKK.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-TELX1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-NAME1'

IT_XK01-NAME1.

perform bdc_field using 'LFA1-SORTL'

IT_XK01-SORTL.

perform bdc_field using 'LFA1-LAND1'

IT_XK01-LAND1.

perform bdc_field using 'LFA1-SPRAS'

IT_XK01-SPRAS.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR'

'LFBK-KOINH(02)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

DATA : FNAM(20) TYPE C,

IDX TYPE C.

MOVE 1 TO IDX.

LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.

CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-BANKS.

CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-BANKL.

CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-BANKN.

CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-KOINH.

IDX = IDX + 1.

ENDLOOP.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR'

'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02K' '0210'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-FDGRV'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFB1-AKONT'

IT_XK01-AKONT.

perform bdc_field using 'LFB1-FDGRV'

IT_XK01-FDGRV.

perform bdc_dynpro using 'SAPMF02K' '0215'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-ZTERM'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0220'.

perform bdc_field using 'BDC_CURSOR'

'LFB5-MAHNA'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFM1-WAERS'

IT_XK01-WAERS.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR'

'WYT3-PARVW(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

CALL TRANSACTION 'XK01' USING IT_BDCDATA

MODE 'A'

UPDATE 'S'

MESSAGES INTO IT_BDCMSGCOLL.

ENDLOOP.

FORM BDC_DYNPRO USING PROG SCR.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROG.

IT_BDCDATA-DYNPRO = SCR.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.

CLEAR IT_BDCDATA.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

ENDFORM.

Hope it helps you...

Let me know if u have any more doubt...

Reward points if useful......

Suresh.......

Read only

Former Member
0 Likes
473

2 major problems which you encounter are

1. Most of the cases there is no search for the exact row to which you would like to update the record value.

2. The number of rows for the table control in BDC mode is often different than the normal user mode . So to do a page down or page up you will need to know this in advance so that you can control the insertions/modifications from you internal table on to the BDC screen table control.

Cheers

Kareem

Read only

Former Member
0 Likes
472

Hi Tangirala.

This is hr-module program. Go through this code and impliment as for the requirement.

TYPES: BEGIN OF ty_comm,

pernr TYPE p0105-pernr,

email TYPE p0105-usrid_long,

END OF ty_comm.

DATA: it_comm TYPE STANDARD TABLE OF ty_comm WITH HEADER LINE,

it_bdcdata TYPE STANDARD TABLE OF bdcdata WITH HEADER LINE,

it_msgtab TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE.

DATA: v_file TYPE string,v_rc.

PARAMETERS: p_file TYPE rlgrap-filename,

p_mode TYPE ctu_params-dismode,

p_update TYPE ctu_params-updmode.

*INCLUDE zbt_call_tran_forms.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM f4_help.

START-OF-SELECTION.

v_file = p_file.

PERFORM upload_data.

LOOP AT it_comm.

REFRESH it_bdcdata.

PERFORM mapping.

CALL TRANSACTION 'PA30' USING it_bdcdata

MODE p_mode

UPDATE p_update

MESSAGES INTO it_msgtab.

ENDLOOP.

END-OF-SELECTION.

LOOP AT it_msgtab.

IF it_msgtab-msgtyp = 'A' OR

it_msgtab-msgtyp = 'E'.

write:/ it_msgtab.

ENDIF.

ENDLOOP.

FORM f4_help .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

  • DYNPRO_NUMBER = SYST-DYNNR

field_name = 'P_FILE'

IMPORTING

file_name = p_file.

.

ENDFORM. " f4_help

&----


*& Form upload_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_data .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

read_by_line = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = it_comm

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " upload_data

&----


*& Form mapping

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM mapping .

DATA: lv_date TYPE char10.

WRITE sy-datum TO lv_date.

PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=INS'.

PERFORM bdc_field USING 'RP50G-PERNR'

it_comm-pernr.

*perform bdc_field using 'RP50G-TIMR6'

  • 'X'.

*perform bdc_field using 'BDC_CURSOR'

  • 'RP50G-SUBTY'.

PERFORM bdc_field USING 'RP50G-CHOIC'

'0105'.

PERFORM bdc_field USING 'RP50G-SUBTY'

'0010'.

PERFORM bdc_dynpro USING 'MP010500' '2000'.

*perform bdc_field using 'BDC_CURSOR'

  • 'P0105-USRID_LONG'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

PERFORM bdc_field USING 'P0105-BEGDA'

lv_date.

PERFORM bdc_field USING 'P0105-ENDDA'

'31.12.9999'.

PERFORM bdc_field USING 'P0105-USRID_LONG'

it_comm-email.

ENDFORM. " mapping

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0115 text

  • -->P_0116 text

----


FORM bdc_dynpro USING program

dynpro.

CLEAR it_bdcdata.

it_bdcdata-program = program.

it_bdcdata-dynpro = dynpro.

it_bdcdata-dynbegin = 'X'.

APPEND it_bdcdata.

ENDFORM. " bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->P_0130 text

  • -->P_0131 text

----


FORM bdc_field USING fnam fval.

*IF FVAL <> NODATA.

CLEAR it_bdcdata.

it_bdcdata-fnam = fnam.

it_bdcdata-fval = fval.

APPEND it_bdcdata.

  • ENDIF.

endform.

Rewards some points if it is helpful.

Rgds,

P.Nag