Application Development 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: 

how to create table control without wizard....???

Former Member
0 Kudos

Hello experts !!

Plz tell me how to create table control without wizard.

for sflight table.

Scenario 1

-


I have one screen like 1000.

There i have taken carrid, connid, fldate as criteria and one Button.

Now i want to display Planetype, Price, Seatsmax in the table control when i will click the button.

Scenario 2

-


i have two screens 1001, 1002.

in the screen 1001 i have taken carrid, connid, fldate as criteria and there is a Button.

when i will click the button it will show the price, planetype and seatsmax in the table control in the next screen, i.e 1002

plz help me out...

and how to save new record in the dictionary table from that table control....

3 REPLIES 3

Former Member
0 Kudos

Hi Soumya,

Have a look at this .

Step 1 (Create new structure for table control)

Type is name of structure (ZTC_EKKO) and press create

Enter the fields that you want to display in the table control. Example uses fields from EKKO.

Now save and activate it!

· Step 2 (Create Program)

Goto transaction SE80(Object Navigator) -> Repository Browser -> Program.

Enter your program name, please ensure that is begins with SAPMZ…… as this is a module pool (dialog program).

Press enter to create, and press yes!

Ensure that you create a top include, and press Enter.

Accept the name created for the top include.

Press Enter.

Press Save

· Step 3 (Create TOP include)

Double click on the top include and enter following ABAP code:

Tables: ZTC_EKKO.

controls: tc100 type tableview using screen 100.

data: ok_code type sy-ucomm.

data: it_ekko type standard

table of ZTC_EKKO initial size 0,

wa_ekko type ZTC_EKKO.

data: ok_code type sy-ucomm.

Press Save and Activate

· Step 4 (Create screen)

Right click the program to create a screen 100 for the dialog. Enter Short description, set screen type to Normal and enter 0 or blank into Next screen. Then move to Element List tab and enter the OK code as OK_CODE (i.e. the same as what you declared in the top include with data: ok_code type sy-ucomm).

· Step 5 (Create table control)

Press the Layout button to bring up the screen painter editor.

Press table control button and drag it on to the screen, enter the name of table control created in TOP include (TC100). Now press the yellow button for attributes and set the table control as below options

· Step 6 (Populate table control )

Press the orange button (Fields). On the next screen enter ZTC_EKKO and press the ‘Get from Dict’ button. Select the fields you want (all) and press enter. Now drag them onto your Table Control.

Below is the result, there will been syntax errors if we check now! So Save and go back into the flow logic tab.

· Step 7 (Create flow control )

Within the flow logic of screen 100 and create two modules, one to select the data from the database and the other to move the selected fields into the table control. Also insert the two loop statements to populate and retrieve the lines of the table control.

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_0100.

module data_retrieval.

loop at it_ekko into wa_ekko with control TC100.

module populate_screen.

endloop.

*

PROCESS AFTER INPUT.

loop at it_ekko.

endloop.

  • MODULE USER_COMMAND_0100.

Double click the module data_retrieval to create and click yes to get past the popup. Ensure that a new include is created to hold all the PBO modules (default). Press enter.

Select 10 rows of data from the EKKO table and load into the internal table it_ekko. Go back to the flow logic to load this data into the Table Control.

*----


*

***INCLUDE MZ_TCONTROL_DATA_RETRIEVALO01 .

*----


*

*&----


*

*& Module data_retrieval OUTPUT

*&----


*

  • text

*----


*

MODULE data_retrieval OUTPUT.

  • select data from ekko table

SELECT ebeln bukrs bstyp bsart

bsakz loekz statu aedat

UP TO 10 ROWS

FROM ekko

INTO CORRESPONDING FIELDS OF TABLE it_ekko.

ENDMODULE. " data_retrieval OUTPUT

Double click the module populate_screen to create. Now move the values in this loop from the wa_ekko into the Table Control with the move-corresponding statement.

MODULE populate_screen OUTPUT.

DATA: ld_line TYPE i.

  • Set which line of table is a top of displayed table control

IF sy-stepl = 1.

tc100-lines =

tc100-top_line + sy-loopc - 1.

ENDIF.

  • move fields from work area to scrren fields

MOVE-CORRESPONDING wa_ekko TO ztc_ekko.

ENDMODULE. " populate_screen OUTPUT

· Step 8 (Create transaction )

Now create a transaction to test the table control program. Right click the Program and select create-> transaction.

· Step 9 (Execute transaction )

Execute transaction ZTC

refer http://www.sapdev.co.uk/dialog/tabcontrol/tc_basic.htm for the screen shots

Reward If Useful.

Regards,

Chitra

Former Member
0 Kudos

Hi Soumya,

Please consider the scenario-1:

Step 1: Navigate to transaction code SE80.

Step 2: Create a program with name SAPMZ(prg name).

Step 3: Right Click on this program and go for the option create screen. Enter the screen number and select it as normal screen.

Step 4: Expand the screen folder and double click on the screen number. Then click the layout button on the application toolbar to open the screen painter.

Step 5: In the screen painter press F6 to open the datadictionary window. Enter the table name as SFLIGHT. Pull in the required fields on the screen. i.e carrid, connid and fldate.

Step 6: On the left side you will find a button called "Table Control". Click on that and place the table with desired width on the screen. Double click on the table anf in the pop up which appears, enter the table name, //this is mandatory//.

Step 7: Now press F6 and enter table name as SFLIGHT. and pull in the required fields on the table. i.e planetype, price and seatsmax. Double click on the table and check the option Seperators - vertical and horizontal.

Step 7: Enter the below mentioned program..

Screen (Flow Logic Tab)

PROCESS BEFORE OUTPUT.

LOOP AT ITAB

INTO WA

WITH CONTROL TABLE //TABLE INDICATES TABLE NAME ASSSIGNED IN SCREEN//

CURSOR TABLE-CURRENT_LINE.

MODULE STATUS_0100.

*

MODULE TABLE_MOVE. //coding will be in PBO module//

MODULE TABLE_GET_LINES. //coding will be in PBO module//

ENDLOOP.

PROCESS AFTER INPUT.

LOOP AT ITAB.

ENDLOOP.

MODULE USER_COMMAND_0100.

-


PAI Module

MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'DISPLAY'. //button placed on application toolbar//

SELECT * FROM SFLIGHT INTO TABLE ITAB WHERE CARRID EQ SFLIGHT-CARRID CONNID EQ SFLIGHT-CONNID AND FLDATE EQ SFLIGHT-FLDATE.

ENDCASE.

ENDMODULE.

-


PBO Module STATUS:

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MENU'.

  • SET TITLEBAR 'TITLE'.

ENDMODULE.

TABLE-GET-LINE

MODULE TABLE_GET_LINES OUTPUT.

G_TABLE_LINES = SY-LOOPC.

ENDMODULE.

TABLE-MOVE

MODULE TABLE_MOVE OUTPUT.

MOVE-CORRESPONDING WA TO SFLIGHT.

ENDMODULE.

-


TOP Include

PROGRAM SAPMZTABLE10.

TABLES: SFLIGHT.

DATA: ITAB TYPE STANDARD TABLE OF SFLIGHT,

WA LIKE SFLIGHT.

DATA: OK_CODE LIKE SY-UCOMM.

DATA: G_TABLE_LINES LIKE SY-LOOPC.

DATA: G_TABLE_COPIED.

CONTROLS: TABLE TYPE TABLEVIEW USING SCREEN 0001.

-


Under Screen- Element list tab.. dont forget to enter OK_CODE as the last element.

-


Last step: Create a transaction code. and execute the screen using this transaction code..

-


If found helpful please reward..

Thanks

Sumit Shenoy

Former Member
0 Kudos

Hi,

For learning, pls refer to the standard program RSDEMO02.

Hope this helps.

Regards,

Renjith Michael.