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

reg table control

Former Member
0 Likes
990

what is table control. what is pai and pbo events.

when these event are trigger.

what is describe in table control.

can u give some examples

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
950

Hi,

TABLE CONTROL COMPONENTS:

-


Table Control component is used to view the table records and if needed, we can directly modify table records and update the database table using table control.

Here, the records can be viewed in rows and columns format separated by horizontal and vertical lines.

SYNTAX:

-


CONTROLS <table_Control_name> TYPE TABLEVIEW USING SCREEN <MPP_screen_number>

CONTROLS statement is used to create a memory space area for table control component in AS.

TABLEVIEW is a data type for table control component.

SCREEN NUMBER should be specified to make the system know where the table control was physically created.

Navigations to create TABLE CONTROL COMPONENT:

-


Create MPP program -> In TOP INCLUDE FILE, write the following code:

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

CONTROLS TABCTRL TYPE TABLEVIEW USING SCREEN '123'.

DATA CUR TYPE I.

Save -> Activate.

Create a Normal screen (123) -> Drag and drop TABLE CONTROL component from application toolbar -> Specify its name in attributes box -> Specify title if necessary -> Select HORIZONTAL and VERTICAL SEPARATORS checkbox -> If needed, select COLUMN and ROW selection radiobuttons -> Click on Dictionary/Program Fields from Appn. Toolbar -> Specify internal table name specified in top include file -> Click on 'GET FROM PROGRAM' pushbutton -> Choose required fields -> Click on continue -> Place the fields in table control component -> Add labels for each fields -> Create two pushbuttons (FETCH, EXIT) -> Save -> Flow Logic.

In PAI module, write following code:

CASE SY-UCOMM.

WHEN 'FETCH'.

SELECT * FROM KNA1 INTO TABLE ITAB.

TABCTRL-LINES = SY-DBCNT.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

In Flow Logic editor, write following code:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0123.

LOOP AT ITAB CURSOR CUR WITH CONTROL TABCTRL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0123.

LOOP AT ITAB.

ENDLOOP.

Here, LOOP AT ITAB-ENDLOOP statement in PBO event is used to fetch the records and insert into table control component. CURSOR statement is used to make use of the cursor in table control component whenever we try to select a particular field and modify it.

LOOP AT ITAB-ENDLOOP statement in PAI event is used to make necessary modifications to the database table from table control component.

Create Tcode -> Execute.

Regards,

Priya.

8 REPLIES 8
Read only

Former Member
0 Likes
951

Hi,

TABLE CONTROL COMPONENTS:

-


Table Control component is used to view the table records and if needed, we can directly modify table records and update the database table using table control.

Here, the records can be viewed in rows and columns format separated by horizontal and vertical lines.

SYNTAX:

-


CONTROLS <table_Control_name> TYPE TABLEVIEW USING SCREEN <MPP_screen_number>

CONTROLS statement is used to create a memory space area for table control component in AS.

TABLEVIEW is a data type for table control component.

SCREEN NUMBER should be specified to make the system know where the table control was physically created.

Navigations to create TABLE CONTROL COMPONENT:

-


Create MPP program -> In TOP INCLUDE FILE, write the following code:

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

CONTROLS TABCTRL TYPE TABLEVIEW USING SCREEN '123'.

DATA CUR TYPE I.

Save -> Activate.

Create a Normal screen (123) -> Drag and drop TABLE CONTROL component from application toolbar -> Specify its name in attributes box -> Specify title if necessary -> Select HORIZONTAL and VERTICAL SEPARATORS checkbox -> If needed, select COLUMN and ROW selection radiobuttons -> Click on Dictionary/Program Fields from Appn. Toolbar -> Specify internal table name specified in top include file -> Click on 'GET FROM PROGRAM' pushbutton -> Choose required fields -> Click on continue -> Place the fields in table control component -> Add labels for each fields -> Create two pushbuttons (FETCH, EXIT) -> Save -> Flow Logic.

In PAI module, write following code:

CASE SY-UCOMM.

WHEN 'FETCH'.

SELECT * FROM KNA1 INTO TABLE ITAB.

TABCTRL-LINES = SY-DBCNT.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

In Flow Logic editor, write following code:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0123.

LOOP AT ITAB CURSOR CUR WITH CONTROL TABCTRL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0123.

LOOP AT ITAB.

ENDLOOP.

Here, LOOP AT ITAB-ENDLOOP statement in PBO event is used to fetch the records and insert into table control component. CURSOR statement is used to make use of the cursor in table control component whenever we try to select a particular field and modify it.

LOOP AT ITAB-ENDLOOP statement in PAI event is used to make necessary modifications to the database table from table control component.

Create Tcode -> Execute.

Regards,

Priya.

Read only

0 Likes
950

hi,

i have given u 10 points. its helped me.

but u have not told when to use pai and when pbo events.

plz reply

Read only

0 Likes
950

hi,

as u said i have included structure in top include file.

after activating that when i am putting itab name in app toolbar and click on get from prog it say itab is not in dictonary.

plz do me a fevor as soon as possible

regards,

sanjay

Read only

Former Member
0 Likes
950

Hi,

EVENTS IN MPP:

-


PROCESS BEFORE OUTPUT - This event gets triggered whenever the program is executed using Tcode. This event is used to assign initial default values to the screen components.

PROCESS AFTER INPUT - This event gets triggered after some user's action in the screen (for eg, after clicking pushbutton, subsequent event functionalities).

PROCESS ON VALUE REQUEST - This event is used to assign F1 functionality for the screen components.

PROCESS ON HELP REQUEST - This event is used to assign F4 functionality for the input field in the screen.

Eg. code to make field validations in MPP program:

-


Using screen painter, design a screen consisting of four input fields for client, username, password and language as we have in login screen of SAP.

Assign the first two input fields to one group called GR1, the third input field to a group GR2.

Create two pushbuttons and assign FCT codes.

In the TOP INCLUDE FILE, declare following variables:

PROGRAM SAPMYSCREENVALID.

DATA : IO1(3), IO2(8), IO3(8), IO4(2).

DATA A TYPE I.

Save -> Activate.

In Flow logic editor, decomment PAI MODULE, double click on module name, and inside the module, write the following code:

module USER_COMMAND_0200 input.

case sy-ucomm.

WHEN 'LOGIN'.

CALL TRANSACTION 'SE38'.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " USER_COMMAND_0200 INPUT

Save -> Activate.

In PBO module, write the following code to assign default input field attributes:

module STATUS_0200 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

IF A = 0.

MESSAGE S010(ZMSG).

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'GR1'.

SCREEN-REQUIRED = '1'.

ENDIF.

IF SCREEN-GROUP1 = 'GR2'.

SCREEN-INVISIBLE = '1'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

A = 1.

ENDIF.

endmodule. " STATUS_0200 OUTPUT

Save -> Activate.

Create a Transaction Code -> Execute the program.

i shall post u sample code regarding table control .. go through that..

Regards,

Priya.

Read only

0 Likes
950

hi,

i have asked u about tab control. u havent reply.

i think u r to busy. if yes just reply.

the code u have send for sap logon is not working properly. if i does not enter anything then also it calls se38.

plz help me

regards,

sanjay

Read only

Former Member
0 Likes
950

Hi,,

Normally we use wizard if we are working with table control. This document helps us how to create a table

control without using a wizard and how to manipulate the database based on the records in the table control.

All the fields in the screen should be disabled .After clicking that ‘Change’ button, we should be able to insert

new records and update existing records [Except primary key]. Save in the standard toolbar will be used to

save the changes made. ‘Delete’ button should be used to delete the rows selected from the database.

Table Control

Code:-

In the flow logic of the screen 9000, write the following code.

PROCESS BEFORE OUTPUT.

MODULE set_status.

MODULE get_t_ctrl_lines.

LOOP AT i_makt WITH CONTROL t_ctrl CURSOR t_ctrl-current_line.

  • Dynamic screen modifications

MODULE set_screen_fields.

ENDLOOP.

*

PROCESS AFTER INPUT.

LOOP AT i_makt.

FIELD i_makt-pick MODULE check.

FIELD i_makt-zmatnr MODULE zmatnr .

ENDLOOP.

MODULE user_command_9000.

In the program, write the following code.

PROGRAM SAPMZTC MESSAGE-ID zz.

***********************************************************************

  • Tables Declaration

***********************************************************************

TABLES: zzz_makt.

***********************************************************************

  • Internal table Declaration

***********************************************************************

DATA : i_makt TYPE STANDARD TABLE OF zzz_makt WITH HEADER LINE.

***********************************************************************

  • Table control Declaration

***********************************************************************

CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9000'.

***********************************************************************

  • Variable Declaration

***********************************************************************

DATA : flg, "Flag to set the change mode

ln TYPE i. "No. of records

&----


*& Module get_T_CTRL_lines OUTPUT

&----


  • Populating data

----


MODULE get_t_ctrl_lines OUTPUT.

SELECT zmatnr zmaktx

INTO CORRESPONDING FIELDS OF TABLE i_makt

FROM zzz_makt.

DESCRIBE TABLE i_makt LINES ln.

  • To make the vertical scroll bar to come on runtime

t_ctrl-lines = ln + 100.

ENDMODULE. " get_T_CTRL_lines OUTPUT

&----


*& Module USER_COMMAND_9000 INPUT

&----


  • Triggering event according to the user command

----


MODULE user_command_9000 INPUT.

DATA :lv_fcode LIKE sy-ucomm, "Function Code

lv_answer(1) type c. "Storing the answer

lv_fcode = sy-ucomm.

CASE lv_fcode.

WHEN 'CHANGE'.

  • Setting the flag to make the table control in editable mode[excluding

  • primary key].

flg = 'Y'.

WHEN 'DELETE'.

  • Setting the flag to make the table control in editable mode after

  • deleting the selected line

flg = 'Y'.

  • Confirmation of delete

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

TITLEBAR = 'Confirm'

text_question = 'Are you sure to delete from database?'

TEXT_BUTTON_1 = 'Yes'(001)

TEXT_BUTTON_2 = 'No'(002)

IMPORTING

ANSWER = lv_answer.

if lv_answer eq '1'.

  • Updating the database table from the internal table

UPDATE zzz_makt FROM TABLE i_makt.

  • Deleting the selected row from the internal table

DELETE i_makt WHERE pick = 'X'.

  • Deleting the selected row from the database table

DELETE FROM zzz_makt WHERE pick = 'X'.

MESSAGE s005 WITH 'Deleted Successfully'.

ENDIF.

WHEN 'SAVE'.

  • Inserting new record or updating existing record in database table

  • from the internal table

MODIFY zzz_makt FROM TABLE i_makt.

MESSAGE s005 WITH 'Saved Successfully'.

WHEN 'BACK'.

SET SCREEN '0'.

WHEN 'EXIT' OR 'CANCEL'.

  • Leaving the program

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

&----


*& Module set_screen_fields OUTPUT

&----


  • Setting the screen fields

----


MODULE set_screen_fields OUTPUT.

LOOP AT SCREEN.

IF flg IS INITIAL.

screen-input = 0.

ELSEIF ( flg EQ 'Y' ).

IF ( ( screen-name = 'I_MAKT-ZMAKTX'

OR screen-name = 'I_MAKT-CHECK1' )

AND t_ctrl-current_line LE ln ) .

  • Making the screen fields as editable

screen-input = 1.

ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )

AND t_ctrl-current_line LE ln ).

  • Making the screen field as uneditable

screen-input = 0.

ENDIF.

ENDIF.

  • Modifying the screen after making changes

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " set_screen_fields OUTPUT

&----


*& Module zmatnr INPUT

&----


  • Appending records to the internal table

----


MODULE zmatnr INPUT.

MODIFY i_makt INDEX t_ctrl-current_line.

IF t_ctrl-current_line GT ln.

READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.

IF sy-subrc NE 0.

  • Inserting record if it does not exist in database

APPEND i_makt.

ELSE.

MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.

ENDIF.

ENDIF.

ENDMODULE. " zmatnr INPUT

&----


*& Module set_status OUTPUT

&----


  • Setting the GUI status

----


MODULE set_status OUTPUT.

SET PF-STATUS 'ZSTATUS'.

SET TITLEBAR 'ZTITLE'.

ENDMODULE. " set_status OUTPUT

*&----


*& Module CHECK INPUT

*&----


  • Modify the internal table using the current line in table control

*----


MODULE check INPUT.

MODIFY i_makt INDEX t_ctrl-current_line.

ENDMODULE. " CHECK INPUT

Regards,

Priya.

Read only

Former Member
0 Likes
950

Hi,

Declare ur table name in the topinclude.

Read only

0 Likes
950

hi,

very very thanks for yr support.with yr help i have done it.

but when i am writing the code written under pai into pbo

it is working but after the second click i will getting the data.

but with pai just 1 click is enough. why is it so.

secondly

CASE SY-UCOMM.

WHEN 'FETCH'.

SELECT * FROM KNA1 INTO TABLE ITAB.

*TbcL-LINES = SY-DBCNT.

when i am commenting the TbcL-LINES = SY-DBCNT

still i am getting the data. then what is its use?

once again from my heart i am thanking u.

can i reword u more points if yes then how