‎2008 Jul 12 6:28 AM
Hi experts,
Please give me information about table control programming.
explain it with example.
Thanks & Regards,
Rajesh Kumar
‎2008 Jul 12 6:33 AM
Hi Rajesh,
Please check this link
http://sap.niraj.tripod.com/id29.html
http://help.sap.com/saphelp_45b/helpdata/en/d1/801bdf454211d189710000e8322d00/content.htm
http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
http://hometown.aol.com/skarkada/sap/table_control/table_control.htm
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
Best regards,
raam
‎2008 Jul 12 6:33 AM
Hi Rajesh,
Please check this link
http://sap.niraj.tripod.com/id29.html
http://help.sap.com/saphelp_45b/helpdata/en/d1/801bdf454211d189710000e8322d00/content.htm
http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
http://hometown.aol.com/skarkada/sap/table_control/table_control.htm
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
Best regards,
raam
‎2008 Jul 12 7:40 AM
‎2008 Jul 12 7:56 AM
hi
*How to create a Table control *
To use table controls in ABAP program, declare a control statement in the declaration part of the type TABLEVIEW for every table control used in the program using the following syntax.
CONTROLS
Inside the module name, call the functional module F4IF_INT_TABLE_VALUE_REQUEST as similar as we used in F4 help for particular field. Import and export the required information to the functional module. In the screen painter for that field attributes set the Dropdown input field as u2018List boxu2019. See the snap shot for more details.
How to make lines and fields editable in table control?
In the screen painter you can set whether it is editable/non-editable by checking/uncheck the Input field check box. You can also change the settings dynamically in the PBO module. Inside the loop you have to loop at screen and change particular field screen-input = 0(non-editable) or 1(editable) and modify the screen depend on the conditions.
For example, in the table control you want to show some lines as editable & some of them as non editable. Those lines which need to be shown as non-editable are existing in database while those which are shown as editable are new entry from the users.
In order to achieve this you have to check Input field check box for all the fields in table control in the screen painter. Inside the loop in PBO check whether the table control line exist in the database table. If yes, then loop at screen and set the screen input = 0 and modify the screen. This will display the existing database records as non-editable even though we have checked the field as u2018Inputu2019 in the screen painter.
You can also group all the required fields to single group for example u2018GP1u2019 in the screen fields attribute and use in your program as below. It will change the field as non-editable only for those fields that are grouped as u2018GP1u2019.
LOOP AT SCREEN.
IF screen-group1 = 'GP1'. u201Cfor specific condition
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
You can also use screen name directly if you are going to modify the screen attributes for one or two fields. See the code below
LOOP AT SCREEN.
IF screen-name = 'WA_ALOC-EMPID' OR screen-name = 'WA_ALOC-NAME1'. u201CFor specific condition
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
How to use Radio button and check boxes in table control.
In the screen painter à control elements there is an option create elements. On clicking this it will gives you screen like below screen. From this option select Radio button or check box and assigned the declared name to the field.
While handling Radio buttons in TableControl, there might be a possibility of selecting two radio buttons in a group that leads to dump error. We have already seen that TableControl will only loop for the visible rows. For example if you have some 25 records in the internal table and your table control size is able to show only 8 records then in the PAI it will loop only for 8 records that are visible. If you are selecting 2nd line in the table control as radio button enabled then rest of the visible radio buttons in the TableControl would get grey out. Scroll down the table control to get out of the 2nd line (radio button selected line) from the visible lines in the table control. Once the 2nd line gone out of the table control visible rows then again the Radio button column will be enabled and it will be ready to accept Input though we already selected a Input for that. Here the Functionality of radio buttons fails.
In order to overcome this, If radio button field is selected, before modifying the internal table, read the internal table with radio button column = u2018Xu2019. If successful then clear the radio button selected field else donu2019t do anything.
IF wa_aloc-manager = 'X'. u201Cradio button field
READ TABLE it_aloc INTO lwa_aloc WITH KEY manager = 'X'.
IF sy-subrc = 0.
CLEAR lwa_aloc-manager.
MODIFY it_aloc FROM lwa_aloc TRANSPORTING manager
WHERE manager = 'X'.
ENDIF.
ENDIF.
How to use Table Controls in Tabstrips and Subscreens
Generally in SAP transactions, screens are structured using Tabstrip controls. Tabstrips are used to categorize the data. If the data is to be organized as a table, then table control is used. We have seen how to use Tablecontrols in a screen, under this heading I would like to give the overview of Tabstrips and Subcreens.
In Screen Layout create a Tabstrip Control and declare the TabStrip control in the program using following syntax.
Controls: tab1 TYPE TABSTRIP.
Name of the control should match the name given in the screen attribute.
Any number of tabs can be added to the Tabstrip control using Control elements.
FCODE is used to capture the Function code of the Tab clicked. This FCODE will be transferred to SY-UCOMM during execution.
Subscreen area has to be assigned to each tab in the Tabstrip control (Reference subscrn column) to hold the Subscreens. The concept of Subscreen here, is same as normal subscreens.
Tabstrip area can be controlled using control attributes
The Subscreen displayed on the mainscreen depends on the tab selected. This is controlled in the flow logic of the Mainscreen using the FCODE.
CASE FCODE.
WHEN 'EMP'.
v_dynnr = 1000.
tab1-activetab = 'EMP'.
v_tabflag = 'X'.
WHEN 'PROJ'.
v_dynnr = 2000.
tab1-activetab = 'PROJ'.
v_tabflag = 'X'. ENDCASE.
In the given example if tab1 is selected subscreen 1000 will be assigned to variable v_dynnr . This v_dynnr has the subscreen which has to be called in the PBO.
Flow logic of the mainscreen will be like this
PROCESS BEFORE OUTPUT.
MODULE status_3000.
MODULE set_tab_strip. "Set default tabstrip for the first time
CALL SUBSCREEN subarea INCLUDING sy-repid v_dynnr.
(Subscreen V_DYNNR is displayed in the subscreen area (subarea) of the tabstrip control)
PROCESS AFTER INPUT.
CALL SUBSCREEN subarea.
MODULE user_command_3000.
Subscreen can be designed as per the requirement like a normal screen, the only difference is the type of the screen should be 'Subscreen'. Keep in mind that subscreen do not have a 'okcode'. The function code of any action taken in subscreen is transferred to the 'okcode' of mainscreen.
‎2008 Jul 12 11:39 AM
‎2008 Jul 12 12:34 PM
Hi Rajesh,
Lets say the table has more than 20 fields and at first shot there are say 15 screen fields and to enter the 16th field you have to press page down so in this case you have to have a control on table..
The below example would help you to analyse..
check the example...
*"Selection screen elements............................................
parameters:
p_file like rlgrap-filename.
*" Data declarations...................................................
*"--------------------------------------------------------------------*
* Work variables *
*"--------------------------------------------------------------------*
data w_file type string.
data wa(80) type c.
data : w_fname(20),
w_tabix(2) type n,
w_table(20),
w_index,
w_fkey(20),
w_ftype(20),
w_flen(20),
w_fdesc(20).
*" Internal table declarations.........................................
*"--------------------------------------------------------------------*
* Internal table to hold *
*"--------------------------------------------------------------------*
data:
begin of itab_fields occurs 0,
count,
fname(20),
fkey,
ftype(10),
flen(10),
fdesc(30),
end of itab_fields.
data:
begin of itab_header occurs 0,
dbcheck,
tname(20),
tdesc(40),
devclass,
maintain,
end of itab_header.
data t_data like standard table of wa .
data:
t_bdcdata like
standard table of bdcdata with header line.
data w_count type i.
*"--------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST EVENT *
*"--------------------------------------------------------------------*
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
importing
file_name = p_file
.
w_file = p_file.
*"--------------------------------------------------------------------*
* START-OF-SELECTION EVENT *
*"--------------------------------------------------------------------*
start-of-selection.
call function 'GUI_UPLOAD'
exporting
filename = w_file
filetype = 'ASC'
* HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* IMPORTING
* FILELENGTH =
* HEADER =
tables
data_tab = t_data
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.
loop at t_data into wa.
if wa+0(1) eq 'H'.
shift wa by 2 places left.
split wa at ',' into itab_header-dbcheck
itab_header-tname
itab_header-tdesc
itab_header-devclass
itab_header-maintain.
append itab_header.
clear itab_header.
add 1 to w_count.
else.
shift wa by 2 places left.
split wa at ',' into itab_fields-fname
itab_fields-fkey
itab_fields-ftype
itab_fields-flen
itab_fields-fdesc.
write w_count to itab_fields-count.
append itab_fields.
clear itab_fields.
endif.
endloop.
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
* DEST = FILLER8
group = 'PADMA'
* HOLDDATE = FILLER8
* KEEP = FILLER1
user = sy-uname
* RECORD = FILLER1
* PROG = SY-CPROG
* IMPORTING
* QID =
exceptions
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
others = 11
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
loop at itab_header.
w_table = itab_header-tname.
w_index = sy-tabix.
refresh t_bdcdata.
perform populate_se11.
call function 'BDC_INSERT'
exporting
tcode = 'SE11'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
tables
dynprotab = t_bdcdata
exceptions
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 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.
refresh t_bdcdata.
perform populate_se13.
call function 'BDC_INSERT'
exporting
tcode = 'SE13'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
tables
dynprotab = t_bdcdata
exceptions
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 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.
refresh t_bdcdata.
perform activate.
call function 'BDC_INSERT'
exporting
tcode = 'SE11'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
tables
dynprotab = t_bdcdata
exceptions
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 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.
endloop.
call function 'BDC_CLOSE_GROUP'
exceptions
not_open = 1
queue_error = 2
others = 3.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*&---------------------------------------------------------------------*
*& Form POPULATE_SE11
*&---------------------------------------------------------------------*
* This subroutine is used to populate SE11 transaction data *
*----------------------------------------------------------------------*
* No interface parameters *
*----------------------------------------------------------------------*
form populate_se11 .
perform bdc_dynpro using 'SAPMSRD0' '0102'.
perform bdc_field using 'BDC_CURSOR'
'RSRD1-TBMA_VAL'.
perform bdc_field using 'BDC_OKCODE'
'=ADD'.
perform bdc_field using 'RSRD1-TBMA'
itab_header-dbcheck.
perform bdc_field using 'RSRD1-TBMA_VAL'
itab_header-tname.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_OKCODE'
'=CHANGE_MAINTFLAG'.
perform bdc_field using 'DD02D-DDTEXT'
itab_header-tdesc.
perform bdc_field using 'BDC_CURSOR'
'DD02D-MAINFLAG'.
perform bdc_field using 'DD02D-CONTFLAG'
itab_header-devclass.
perform bdc_field using 'DD02D-MAINFLAG'
itab_header-maintain.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_OKCODE'
'=DEF'.
perform bdc_field using 'DD02D-CONTFLAG'
'A'.
perform bdc_field using 'DD02D-MAINFLAG'
'X'.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_OKCODE'
'=FTYP'.
w_tabix = 0.
loop at itab_fields where count eq w_index.
add 1 to w_tabix.
if w_tabix gt 13.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_CURSOR'
w_fname.
perform bdc_field using 'BDC_OKCODE'
'=P+'.
w_tabix = 2.
endif.
concatenate 'DD03P-FIELDNAME(' w_tabix ')' into w_fname.
concatenate 'DD03P-KEYFLAG(' w_tabix ')' into w_fkey.
concatenate 'DD03D-DATATYPE(' w_tabix ')' into w_ftype.
concatenate 'DD03P-LENG(' w_tabix ')' into w_flen.
concatenate 'DD03P-DDTEXT(' w_tabix ')' into w_fdesc.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using w_fname
itab_fields-fname.
perform bdc_field using w_fkey
itab_fields-fkey.
perform bdc_field using w_ftype
itab_fields-ftype.
perform bdc_field using w_flen
itab_fields-flen.
perform bdc_field using w_fdesc
itab_fields-fdesc.
endloop.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_OKCODE'
'=WB_SAVE'.
perform bdc_dynpro using 'SAPLSTRD' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=ADD'.
perform bdc_field using 'KO007-L_DEVCLASS'
'Z1139'.
perform bdc_field using 'KO007-L_AUTHOR'
'SAPDEV02'.
perform bdc_dynpro using 'SAPLSTRD' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=LOCK'.
perform bdc_field using 'KO008-TRKORR'
'TR1K900085'.
perform bdc_dynpro using 'SAPLSD41' '2200'.
perform bdc_field using 'BDC_CURSOR'
'DD03P-DDTEXT(03)'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_dynpro using 'SAPMSRD0' '0102'.
perform bdc_field using 'BDC_CURSOR'
'RSRD1-TBMA_VAL'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
.
endform. " POPULATE_SE11
*&---------------------------------------------------------------------*
*& Form POPULATE_SE13
*&---------------------------------------------------------------------*
* This subroutine is used to populate SE13 data *
*----------------------------------------------------------------------*
* No interface parameters *
*----------------------------------------------------------------------*
form populate_se13 .
perform bdc_dynpro using 'SAPMSEDS' '0010'.
perform bdc_field using 'DD09V-TABNAME'
w_table.
perform bdc_field using 'BDC_OKCODE'
'PFLG'.
perform bdc_dynpro using 'SAPMSEDS' '0050'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_field using 'DD09V-TABART'
'APPL0'.
perform bdc_field using 'DD09V-TABKAT'
'0'.
perform bdc_field using 'ALLOWSTATE-NOT_ALLOWED'
'X'.
perform bdc_dynpro using 'SAPMSEDS' '0050'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_field using 'DD09V-TABART'
'APPL0'.
perform bdc_field using 'DD09V-TABKAT'
'0'.
perform bdc_field using 'ALLOWSTATE-NOT_ALLOWED'
'X'.
perform bdc_field using 'BDC_OKCODE'
'=WB_BACK'.
perform bdc_dynpro using 'SAPMSEDS' '0050'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_dynpro using 'SAPMSEDS' '0010'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
endform. " POPULATE_SE13
*&---------------------------------------------------------------------*
*& Form ACTIVATE
*&---------------------------------------------------------------------*
* This subroutine is used to activate the table from SE11 *
*----------------------------------------------------------------------*
* No interface parameters. *
*----------------------------------------------------------------------*
form activate .
perform bdc_dynpro using 'SAPMSRD0' '0102'.
perform bdc_field using 'RSRD1-TBMA'
'X'.
perform bdc_field using 'RSRD1-TBMA_VAL'
w_table.
perform bdc_field using 'BDC_OKCODE'
'ACT'.
perform bdc_dynpro using 'SAPLSEWORKINGAREA' '0205'.
perform bdc_field using 'BDC_OKCODE'
'=WEIT'.
perform bdc_dynpro using 'SAPMSRD0' '0102'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
endform. " ACTIVATE
*&---------------------------------------------------------------------*
*& Form bdc_dynpro
*&---------------------------------------------------------------------*
* This subroutine is used to populate the screen information *
*----------------------------------------------------------------------*
* -->prgname Program name
* -->screenno Screen number
*----------------------------------------------------------------------*
form bdc_dynpro using value(prgname)
value(screenno).
clear t_bdcdata.
t_bdcdata-program = prgname.
t_bdcdata-dynpro = screenno.
t_bdcdata-dynbegin = 'X'.
append t_bdcdata.
endform. " bdc_dynpro
*&---------------------------------------------------------------------*
*& Form bdc_field
*&---------------------------------------------------------------------*
* This subroutine is used to populate the field values *
*----------------------------------------------------------------------*
* -->fnam Field name *
* -->fval Field value *
*----------------------------------------------------------------------*
form bdc_field using value(fnam)
value(fval).
clear t_bdcdata.
t_bdcdata-fnam = fnam.
t_bdcdata-fval = fval.
append t_bdcdata.
endform. " bdc_field
******flat file ******
**H,X,Z1139_REC_30,Recorded Table,A,X*
**I,mandt,X,clnt,3,Client*
**I,ENO,X,char,6,Employee Number*
**I,ENAME, ,Char,20,Employee Name*
**I,deptno, ,char,10,Department Number*
**I,salary, ,int4, ,Salary*
**I,deptno,X,char,10,Department Number*
**I,dname, ,char,20,Department Name*
**I,Locate, ,char,20,Location*
**I,deptno,X,char,10,Department Number*
**I,dname, ,char,20,Department Name*
**I,Locate, ,char,20,Location*
**I,deptno,X,char,10,Department Number*
**I,dname, ,char,20,Department Name*
**I,Locate, ,char,20,Location*
**I,deptno,X,char,10,Department Number*
**I,dname, ,char,20,Department Name*
**I,Locate, ,char,20,Location*
**I,deptno,X,char,10,Department Number*
**I,dname, ,char,20,Department Name*
**I,Locate, ,char,20,Location*
**H,X,Z1139_REC_31,Recorded Table,A,X*
**I,mandt,X,clnt,3,Client*
**I,deptno,X,char,10,Department Number*
**I,dname, ,char,20,Department Name*
**I,Locate, ,char,20,Location*
hope the above example would help you and solve your issue.
Regards
Narin Nandivada