cancel
Showing results for 
Search instead for 
Did you mean: 

Table Control

Former Member
0 Kudos

Dear friends,

What is Table table control how to control & configure pls explain step by step

Thanking you

Reddy

<REMOVED>

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi,

<b>TABLE CONTROL</b>

These are the screen elements used to display tabular data they can be called

as screen tables( like STEP LOOP).To use table control we have to create it on the screen using SCREEN PAINTER(SE51) and declare a control variable of TYPE TABLEVIEW using CONTROLS statement in the ABAP program. We have to use LOOP .. ENDLOOP statement in both PBO and PAI with or without AT int_table parameter. IF AT int_table parameter is not used than we have to place a MODULE call between the LOOP...ENDLOOP statement to fill the screen table rows from the ABAP program in PBO and program our own scrolling functions

using OK_CODE field.

Having a parallel loop(at screen table rows & int table rows) by using parameter

AT int_table makes the ABAP code simple.

A special structure of type CXTAB_CONTROL is used to set/get various

attributes of table control at runtime like CURRENT_LINE ,TOP_LINE.

ABAP declaration

CONTROLS: tab_con TYPE TABLEVIEW USING SCREEN nnnn

Here tab_con is the same name we used in screen for the table control.

This ABAP statement will declare a control variable that will be used to access

the table control , and set it's various attributes like number of fixed columns(tab_con-FIXED_COLS) ,total number of records it will display(tab_con-LINES).It is of type CXTAB_CONTROL and is a deep structure(structure containing structures).

REFRESH CONTROL tab_con FROM SCREEN nnnn

This ABAP statement will initialize the table control on the screen nnnn to its initial values.

PBO processing

In PBO we have to use the screen LOOP ...ENDLOOP statement , with or without

intenal table.

LOOP WITH CONTROL tab_con.

MODULE fill_tab_con.

ENDLOOP.

Here a module should be called between the loop endloop statement to transfer

data from th ABAP program to the screen table through a structure.This module

should use the CURRENT_LINE attribute of the table control variable to get the

current screen table record index to read the data from the internal table into a work area.

e.g.

READ TABLE int_table INDEX tab_con-CURRENT_LINE

The record read will be placed in the header line of the internal table and will be available to the similarly named screen fields or if these are different it can be written explicitly. e.g.

screen_field_name = int_table-field_name

...

.

LOOP AT int_table INTO workarea WITH CONTROL tab_con CURSOR i FROM

n1 TO n2.

ENDLOOP.

Here the module call is not required to fill the screen table.The CURSOR parameter is a integer of type I indicating which absolute internal table line

should be the first to display on the table control .FROM n1 TO n2 can be used

to restrict the starting line and ending line number of the internal table , they are of type SY-TABIX.

In both cases before the LOOP statement a module should be called which

is generally for setting of status ,in which we should fill the LINES attribute

(tab_con-LINES ) of the control with the total number of internal table records,doing this ensures correct and automatic scrolling.

The ABAP statement DESCRIBE TABLE int_table LINES lines can be used

to get the total lines in an int table.

PAI Processing

We have to use LOOP ... ENDLOOP in PAI so that data can transfer fro table control to ABAP program. If we want to write changes to the data we should

call a module between the LOOP ... ENDLOOP. The MODULE call to process user commands (SY-UCOM) should be called after the ENDLOOP statement.

e.g.

PROCESS AFTER INPUT

MODULE mod AT EXIT-COMMAND.

LOOP AT itab_table or LOOP "depending on whether we are using AT int_table

MODULE modify_int_table.

ENDLOOP.

MODULE user_command.

In the MODULE call modify_int_table we can use

MODIFY int_table FROM workarea INDEX tab_con-CURRENT_LINE

or we can use

int_table-field_name = screen_field_name.

Thanks

sadhu kishore

Lakshmipathi
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Reddy,

Refer below

BDC Example: Using Table Control in BDC

Among beginners, using table control in BDC is always a puzzle.

Following is a sample code of handling table control in BDC.

REPORT Y730_BDC5 .

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

Refer to the links below... can get useful info

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

http://www.sap-img.com/abap/question-about-bdc-program.htm

Handling Table Control in BDC

http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm

How to use Table Control in BDC

http://www.allinterview.com/showanswers/29144.html

==========

http://sap.niraj.tripod.com/id29.html

==========

Please Reward If Really Helpful,

Thanks and Regards,

Sateesh.Kandula