05-30-2008 12:48 PM
Hi Experts,
In first screen i entered value if i click display then goes to second screen and diplayed all fields in disable mode. and i want to use table control how will do it .... please anyone send me code...
Thaks in Advance
Rajesh
05-30-2008 12:50 PM
Hi,
in SE38 search for DEMOTABLECONTROL you will find demo programs on Table control. Please go through the steps they are pretty simple.
Hope this helps.
Cheers
VJ
DEMO_DYNPRO_TABLE_CONTROL_1
DEMO_DYNPRO_TABLE_CONTROL_2
RSDEMO_TABLE_CONTROL
Edited by: Vijayendra Rao on May 30, 2008 7:52 AM
05-30-2008 12:53 PM
Hi rajesh,
Table control can be created in tow ways either by selecting the table control
icon from the elements toolbar or by using table control wizard in SE51 and drawing a table control area on the screen..
If we use table control wizard it takes mimimum of coding and effort to
create a workable table control.The wizard uses 7 dialogs .ABAP Code and screen flow logic statements are automatically generated for common functions like inserting new lines,selecting rows etc.
In table control attributes we check/uncheck
1) horizontal/vertical separators.
2) with title ,if with title the name of the field.
3) with column headers
4) We have to select from single/multiple/none selection for
rows and columns.
5) If Line selection column is to be used than the name of the Line Selection Column field is specified. This field is of type C(1) and can be used to determine which record(s) were selected by the user in PAI. A field of this name and type is generally the part of the internal table which will be used to display the data if multiple row selection has been checked in the attribute box,for a single line row selection a declaration in ABAP program with the same name and type is sufficient.
6) The number of fixed columns can be specified.They can be changed dynamically in ABAP program using tab_con-FIXED_COLS attribute.
Columns on Table Control
The columns on table control are generally taken from the structure which is of same type as internal table used for displaying values in the ABAP program.
see this link
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
thanks
karthik
reward me if usefull
05-30-2008 12:54 PM
HI Rajesh.
Please refer this code.
REPORT demo_dynpro_table_control_1 MESSAGE-ID sabapdocu.
DATA: BEGIN OF itab OCCURS 10,
mark,
col1 TYPE i,
col2 TYPE i,
END OF itab.
DATA ok_code TYPE sy-ucomm.
DATA ok_save TYPE sy-ucomm.
DATA tab_lines TYPE i.
DATA step_lines TYPE i.
DATA offset TYPE i.
CONTROLS table TYPE TABLEVIEW USING SCREEN 100.
CALL SCREEN 100.
MODULE init OUTPUT.
SET PF-STATUS 'BASIC'.
ENDMODULE.
MODULE fill_itab OUTPUT.
DESCRIBE TABLE itab LINES tab_lines.
IF tab_lines = 0.
DO 40 TIMES.
itab-col1 = sy-index.
itab-col2 = sy-index ** 2.
APPEND itab.
ENDDO.
DESCRIBE TABLE itab LINES tab_lines.
table-lines = tab_lines.
ENDIF.
ENDMODULE.
MODULE transp_itab OUTPUT.
READ TABLE itab INDEX table-current_line.
ENDMODULE.
MODULE lines OUTPUT.
step_lines = sy-loopc.
ENDMODULE.
MODULE exit INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE check_pai INPUT.
ok_save = ok_code. CLEAR ok_code.
MESSAGE s888 WITH 'TOP_LINE: ' table-top_line
', LINES: ' step_lines.
ENDMODULE.
MODULE check_table INPUT.
CASE ok_save.
WHEN 'MARK'.
IF itab-mark = 'X'.
MESSAGE i888 WITH 'Zeile' table-current_line 'markiert'.
ENDIF.
WHEN 'SETM'.
MODIFY itab INDEX table-current_line.
ENDCASE.
ENDMODULE.
MODULE check_all INPUT.
CASE ok_save.
WHEN 'ALLM'.
LOOP AT itab.
IF itab-mark = 'X'.
MESSAGE i888 WITH 'Zeile' sy-tabix 'markiert'.
ENDIF.
ENDLOOP.
WHEN 'DELE'.
LOOP AT itab.
IF itab-mark = 'X'.
itab-mark = ' '.
MODIFY itab.
ENDIF.
ENDLOOP.
ENDCASE.
ENDMODULE.
MODULE scroll INPUT.
CASE ok_save.
WHEN 'PGDO'.
offset = table-lines - step_lines.
IF table-top_line LT offset.
table-top_line = table-top_line + step_lines.
ENDIF.
WHEN 'PGUP'.
offset = step_lines.
IF table-top_line GT offset.
table-top_line = table-top_line - step_lines.
ELSE.
table-top_line = 1.
ENDIF.
WHEN 'PGLA'.
table-top_line = table-lines - step_lines + 1.
WHEN 'PGTO'.
table-top_line = 1.
ENDCASE.
ENDMODULE.
Reward all helpfull answers,
Regards.
Jay
05-30-2008 1:14 PM
hi,
in PAI use like this:
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'DISP'.
CALL SCREEN '200'.
SELECT kunnr land1 name1 FROM kna1
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE kunnr = kna1-kunnr.
WHEN'BACK'.
LEAVE PROGRAM.
ENDCASE.
thanks,
raji
05-30-2008 1:16 PM
Hi,
Here I am sending the sample code for table control.
MAIN PROGRAM :
INCLUDE mz50871_sd_tablecontroltop. " Global Data
INCLUDE mz50871_sd_tablecontrol_usei01. " PAI Modules
INCLUDE mz50871_sd_tablecontrol_popo01. " PBO Modules
&----
*& Module EXIT INPUT
&----
MODULE exit INPUT.
CASE okcode.
WHEN 'CANCEL' OR 'TOP' OR 'BACK'.
LEAVE PROGRAM.
CLEAR okcode.
ENDCASE.
ENDMODULE. " EXIT INPUT
&----
*& Module GUISTATUS2 OUTPUT
&----
MODULE guistatus2 OUTPUT.
SET PF-STATUS 'MENU1'.
ENDMODULE. " GUISTATUS2 OUTPUT
&----
*& Module GUISTATUS3 OUTPUT
&----
MODULE guistatus3 OUTPUT.
SET PF-STATUS 'MENU1'.
ENDMODULE. " GUISTATUS3 OUTPUT
TOP INCLUDE :
&----
*& Include MZ50871_SD_TABLECONTROLTOP
&----
PROGRAM sapmz50871_sd_tablecontrol.
----
Tables
----
TABLES : kna1, vbak, vbap.
----
Structure Declarations
Internaltable Table Declarations
----
TYPES : BEGIN OF st_vbak,
check TYPE c,
vbeln TYPE vbak-vbeln, "Sales Document Number
erdat TYPE vbak-erdat, "Date on which the record was created
ernam TYPE vbak-ernam, "Name of Person who Created the Object
vbtyp TYPE vbak-vbtyp, "SD document category
auart TYPE vbak-auart, "Sales Document Type
kunnr TYPE vbak-kunnr, "Customer Number
END OF st_vbak.
TYPES : BEGIN OF st_vbap,
posnr TYPE vbap-posnr, "Sales Document Item
matnr TYPE vbap-matnr, "Material Number
matkl TYPE vbap-matkl, "Material Group
posar TYPE vbap-posar, "Item Type
END OF st_vbap.
DATA : it_vbak TYPE STANDARD TABLE OF st_vbak WITH HEADER LINE,
it_vbap TYPE STANDARD TABLE OF st_vbap WITH HEADER LINE.
*global varible declarations
DATA : v_kunnr TYPE kna1-kunnr, "Customer Number
v_name1 TYPE kna1-name1, "Customer Name
v_kunnr1 TYPE kna1-kunnr, "Customer Number
v_vbeln TYPE vbak-vbeln, "Sales Document Number
okcode TYPE sy-ucomm.
----
Table Control Declarations
----
CONTROLS : tbc1 TYPE TABLEVIEW USING SCREEN '200',
tbc2 TYPE TABLEVIEW USING SCREEN '300'.
PAI MODULES :
----
INCLUDE MZ50871_SD_TABLECONTROL_USEI01 .
----
&----
*& Module USER_COMMAND_0100 INPUT
&----
MODULE user_command_0100 INPUT.
CASE okcode.
WHEN 'DISP'.
SELECT vbeln
erdat
ernam
vbtyp
auart
kunnr
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak
WHERE kunnr = v_kunnr.
IF sy-subrc NE 0.
MESSAGE i020(z50871msg) WITH 'Sales Header Data Is Not Available'.
ELSE.
tbc1-lines = sy-dbcnt.
CALL SCREEN '200'.
ENDIF.
CLEAR okcode.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module VALIDATE_KUNNR INPUT
&----
MODULE validate_kunnr INPUT.
SELECT SINGLE * FROM kna1 WHERE kunnr = v_kunnr.
IF sy-subrc = 0.
v_kunnr1 = kna1-kunnr.
v_name1 = kna1-name1.
ELSE.
MESSAGE i020(z50871msg) WITH 'Customer Does Not Exist'.
LEAVE TO SCREEN '100'.
ENDIF.
ENDMODULE. " VALIDATE_KUNNR INPUT
&----
*& Module MODIFY_ITAB INPUT
&----
MODULE modify_itab INPUT.
MODIFY it_vbak INDEX tbc1-current_line.
ENDMODULE. " MODIFY_ITAB INPUT
&----
*& Module user_command_0200 INPUT
&----
MODULE user_command_0200 INPUT.
CASE okcode.
WHEN 'ITEM'.
READ TABLE it_vbak WITH KEY check = 'X'.
IF sy-subrc = 0.
SELECT posnr
matnr
matkl
posar
FROM vbap
INTO TABLE it_vbap
WHERE vbeln = it_vbak-vbeln.
IF sy-subrc NE 0.
MESSAGE i020(z50871msg) WITH 'Sales Item Data Is not Available'.
ELSE.
v_vbeln = it_vbak-vbeln.
CALL SCREEN '300'.
ENDIF.
ELSE.
MESSAGE i020(z50871msg) WITH 'Please Select Sales Document Number'.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN '100'.
CLEAR okcode.
WHEN 'TOP' OR 'CANCEL'.
LEAVE PROGRAM.
CLEAR okcode.
ENDCASE.
ENDMODULE. " user_command_0200 INPUT
&----
*& Module user_command_0300 INPUT
&----
MODULE user_command_0300 INPUT.
CASE okcode.
WHEN 'BACK'.
LEAVE TO SCREEN '200'.
CLEAR it_vbap[].
CLEAR okcode.
WHEN 'CANCEL' OR 'TOP'.
CLEAR : it_vbak[] , it_vbap[].
LEAVE PROGRAM.
CLEAR okcode.
ENDCASE.
ENDMODULE. " user_command_0300 INPUT
PBO MODULES :
----
INCLUDE MZ50871_SD_TABLECONTROL_POPO01 .
----
&----
*& Module POPULATE_TBC1 OUTPUT
&----
MODULE populate_tbc1 OUTPUT.
vbak-vbeln = it_vbak-vbeln.
vbak-erdat = it_vbak-erdat.
vbak-ernam = it_vbak-ernam.
vbak-vbtyp = it_vbak-vbtyp.
vbak-auart = it_vbak-auart.
vbak-kunnr = it_vbak-kunnr.
ENDMODULE. " POPULATE_TBC1 OUTPUT
&----
*& Module GUISTATUS1 OUTPUT
&----
MODULE guistatus1 OUTPUT.
SET PF-STATUS 'MENU1'.
ENDMODULE. " GUISTATUS1 OUTPUT
&----
*& Module POPULATE_TBC2 OUTPUT
&----
MODULE populate_tbc2 OUTPUT.
vbap-posnr = it_vbap-posnr.
vbap-matnr = it_vbap-matnr.
vbap-matkl = it_vbap-matkl.
vbap-posar = it_vbap-posar.
ENDMODULE. " POPULATE_TBC2 OUTPUT
SCREEN 100 FLOW LOGIC :
process before output.
module guistatus1.
process after input.
field v_kunnr module validate_kunnr on input.
module user_command_0100.
module exit at exit-command.
SCREEN 200 FLOW LOGIC :
process before output.
loop at it_vbak into wa_vbak with control tbc1 cursor
tbc1-current_line.
module populate_tbc1.
endloop.
module guistatus2.
process after input.
loop at it_vbak .
module modify_itab.
endloop.
module user_command_0200.
SCREEN 300 FLOW LOGIC :
process before output.
module guistatus3.
loop at it_vbap into wa_vbap with control tbc2 cursor
tbc2-current_line.
module populate_tbc2.
endloop.
process after input.
module user_command_0300.
loop at it_vbap.
endloop.
FUNCTIONALITY
In the first screen it will ask for Customer Number . If you give customer number and predd DISPLAY button, then it will show Sales order header details in the next screen in TABLE CONTROL. There if you select any of sales order number and if u press display button, then it will dispaly Item details in the next screen in table control.
Regards
Sandeep REddy