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

Retriving datas into table control in module pool program.

Former Member
0 Likes
3,399

Hi,

I have created one screen it has one table control. Table control fields are material number, material name, quantity etc. material number is having one search help. It should show the material number's that are present in material master table. So when im selecting the material number in table control its details should come in the same line.

how can i write the code for that..

please help me.

Shyja

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,198

Dear Shyja,

Table Controls

Table controls are used to display large quantities of data in tables. Like all screen elements, they are defined in the Screen Painter. Within a table control, you can display input/output fields, radio buttons, checkboxes, radio button groups, and pushbuttons. You can have up to 255 columns and each column can have a heading. The first row is always the header row. Table controls offer users the following functions:

1.You can use the resizing attributes to specify whether the table control can resize the screen vertically or horizontally. If the control supports resizing, you can specify a minimum size for it.

2. You can define column headers that are also pushbuttons. You can use the pushbutton to select the column.

3. The width and position of columns can be changed by the user or by the program.

4.You can save the current settings as a default setting for a user.

5.Vertical scrolling with a scroll bar

6.Horizontal scrolling with a scroll bar

7.You can fix a number of lead columns that cannot be moved by the user.

8.A selection column enables you to select rows.

The only actions that trigger a PAI event are changes to the size of the screen (if the resizing attributes are selected), vertical scrolling, and saving settings. All other user actions are handled by the presentation server.

A table control displayed on a screen is a repeated series of table rows. Each row contains one or more screen elements, and all rows have the same structure. The step loop technique is used to pass data between the table controls and the ABAP program. To enable this, the screen flow logic and the ABAP program must be programmed accordingly

Table Controls on the Screen
Table controls are created on the screen using the tool Screen Painter. You can define as many table controls as you require for each screen.

First a table control area is created, into which the table control fields are then transferred.

Defining the Table Control Area
The table control area is created on the screen using the screen painter tool. The table control area is a multi-line screen element of a particular size, which must be assigned a name. The name identifies the table control and is used in screen flow logic and in ABAP programs to address it.

A table control has a few other special attributes apart from its name and size.

· Resize

The size of a table control can be fixed or changeable. The size of a table control changes when a user changes the size of a window, thereby cutting off a part of the table. The size change triggers the PAI event.

· Title

The top line of a table control can be reserved as a title line, into which a text field or an output field can be inserted.

· Column Headers

The second line of a table control can be reserved as a title line, where a text field or output field can be inserted in each column. At the same time the column titles function as buttons to select columns.

· Configure

The user can save the current settings of the attributes in a file. The system uses these settings every time the table control is displayed.

· Separators

Horizontal and vertical separators can be displayed between lines and columns.

· Line Selection

You can specify whether lines can be selected, and if so how many.

· Column Selection

You can specify whether columns can be selected, and if so how many.

· Selection Column

A column of the table control can be reserved as buttons for marking lines, it is treated internally as a checkbox. A selected line selection button contains ¢X¢ , an unselected one contains ¢ ¢. The selection column must be assigned a name. The state of the selection button can be transported into a character field, with length one and the same name, in an ABAP program and vice versa.

· Fixed Columns

A number of columns (from the left) can be excluded from the scrolling function. A fixed column cannot be moved.

The Table Control Field
After a table control area has been created on the screen, the following single line screen elements can be transferred into the area.

· Text Fields

· Input/Output Fields

· Checkbox Elements

· Radio Button Elements

Text fields and output fields can be transferred to the title lines.

The screen elements, frames, subscreens, tab strips, custom controls and status icons can not be transported to the table controls.

You can also transfer dictionary and program fields. During the transfer of fields from the ABAP Dictionary it is possible that column headers will be automatically assigned a text from the data element from the Dictionary.

Every screen element that is inserted makes up a column of the table control. In every free line available, under any title and column headers, the screen element is displayed repeatedly.

The screen elements of a column appear only once in the element list of the corresponding screen. Therefore, you only have to create fields with the same name once in ABAP programs.

Table Controls in ABAP Programs
To handle table controls in ABAP programs, you must declare a control in the declaration part of the program for each table control using the following statement:

CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.

where ctrl is the name of the table control on a screen in the ABAP program. The control allows the ABAP program to read the attributes of the table control and to influence the control. The statement also declares a deep structure of name ctrl. The data type of the structure corresponds to the type CXTAB_CONTROL defined in the type group CXTAB in the ABAP Dictionary.

At runtime the components of the structure contain the attributes of the table control. Several of the initial values are determined in the Screen Painter. The initial value for the control ctrl is taken from the screen which is determined using the addition USING.

You can start a screen sequence from an ABAP program using

REFRESH CONTROL ctrl FROM SCREEN scr.

you can initialize a table control at any time with the initial value of a screen scr. Values that are not taken from the settings in the Screen Painter, are set to the current status of the table control at PAI.

Structure CXTAB_CONTROL
The deep structure CXTAB_CONTROL contains the general attributes of the table control on the highest level. The component CXTAB_CONTROL is a table of the structure CXTAB_COLUMN and contains the attributes of a column. The component CXTAB_CONTROL-COLS-SCREEN is a flat structure of the same type as system table screen and contains the attributes of the individual screen elements.

Up to component CURRENT_LINE, all attributes of the structure CXTAB_CONTROL in the ABAP program can be set to change the table control display on the screen

Components of SCREEN
The component SCREEN-NAME is the name of the screen element that creates the column. The initial values of the remaining components correspond to the attributes of the screen elements in the Screen Painter. The attributes are transferred from here with initial values. They can be changed directly in the ABAP program. Note that directly set values can be overwritten by modifying these attributes using MODIFY SCREEN within the loop LOOP AT SCREEN.

Furthermore, note that the attributes of the structure screen are not set with blank characters and X, but are set with 0 and 1 as in the normal processing of screen.

Scrolling in Table Controls

Scrolling with scroll bars is automatically implemented with table controls, and managed by the system. However, the component ctrl-LINES must be set to the required row number before editing the table control. This is the case for table controls with or without parallel loops using an internal table. The component LINES is set implicitly for table controls with parallel loops using an internal table, although the correct value is not guaranteed (see table above). It is therefore recommended that in both instances you set the component LINES explicitly to the number of rows in the internal table of the ABAP program. You can determine this number from the statement DESCRIBE TABLE (see the following example).

The event PAI with an empty function code is triggered when scrolling using scroll bars. When the loops at PAI and PBO are executed, the system sets the component TOP_LINE of the structure CXTAB_CONTROL before PBO, so that the correct row is edited at the loop pass.

You can easily implement program-controlled vertical scrolling (line by line, page by page, or goto page) by using the component of the structure CXTAB_CONTROL. Essentially the component TOP_LINE must be provided with a value. For page by page scrolling, the number of rows to be scrolled during the loop pass can be taken from the system field sy-loopc. sy-loopccontains the number of rows currently display, whereas the component LINES of structure CXTAB_CONTROL contains the number of all rows in the table control.

Cursor Position on Table Controls

At PBO you can set the cursor on a specific field of a specific row of a table control.

SET CURSOR FIELD f LINE lin .

Using the optional addition OFFSET, you can enter the offset of the cursor in the field as described under Setting the Cursor Position .

At PAI you can read the current cursor position.

GET CURSOR FIELD f LINE lin ...

In addition to the information given under Finding Out the Cursor Position , field lin contains information on which row of the table control the cursor is currently on. You can also use

GET CURSOR LINE lin.

. sy-subrc allows you to check if the cursor is placed in a row of a table control.

Regards,

Rajesh K Soman

Please reward points if found helpful.

3 REPLIES 3
Read only

Former Member
0 Likes
1,198

write the code in Process on value request module(POV).

Read only

Former Member
0 Likes
1,198

<b><u>Input Help in Dialog Modules</u></b>

You can call dialog modules in the POV event using the event keyword PROCESS ON VALUE-REQUEST.

PROCESS ON VALUE-REQUEST.

...

FIELD <f> MODULE <mod>.

...

After the PROCESS ON VALUE-REQUEST statement, you can only use the MODULE statement together with the FIELD statement. When the user chooses F4 for a field <f>, the system calls the module <mod> belonging to the FIELD <f> statement. If there is more than one FIELD statement for the same field <f>, only the first is executed. The module <mod> is defined in the ABAP program like a normal PAI module. However, the contents of the screen field <f> are not available, since it is not transported by the FIELD statement during the PROCESS ON HELP-REQUEST event. You can now program your own value lists in the module. However, this procedure is only recommended if it really is not possible to use a search help. Defining search helps is much easier than PROCESS ON VALUE-REQUEST, since the system takes over some of the standard operations, such as getting field contents from the screen. It also ensures that the F4 help has a uniform look and feel throughout the system. Furthermore, it means that you do not have to reassign input help to fields on each screen.

Despite the introduction of search helps (and search help exits), there are still cases in which you need to use parts of the standard F4 functions directly. In this case, there are some standard function modules that you can use in the POV event. They support search helps, as well as all other kinds of input help, and are responsible for data transport between the screen and the input help. These all have the prefix F4IF_. The most important are:

F4IF_FIELD_VALUE_REQUEST

Calls the input help of the ABAP Dictionary dynamically. You can pass the component names of a structure or database table of the ABAP Dictionary to the function module in the import parameters TABNAME and FIELDNAME. The function module starts the ABAP Dictionary input help for this component. All of the relevant screen fields are read. If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the user’s selection is returned to the corresponding field on the screen. If you specify the table parameter RETURN_TAB, the selection is returned into the table instead.

F4IF_INT_TABLE_VALUE_REQUEST

This function module displays a value list that you created in an ABAP program. The value list is passed to the function module as the table parameter VALUE_TAB. If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the user’s selection is returned to the corresponding field on the screen. If you specify the table parameter RETURN_TAB, the selection is returned into the table instead.

There are also two function modules - DYNP_VALUES_READ and DYNP_VALUES_UPDATE - that can read the values of screen fields and return values to them during the POV event. For further information, refer to the relevant function module documentation.

Input help in dialog modules

REPORT DEMO_DYNPRO_F4_HELP_MODULE.

TYPES: BEGIN OF VALUES,

CARRID TYPE SPFLI-CARRID,

CONNID TYPE SPFLI-CONNID,

END OF VALUES.

DATA: CARRIER(3) TYPE C,

CONNECTION(4) TYPE C.

DATA: PROGNAME LIKE SY-REPID,

DYNNUM LIKE SY-DYNNR,

DYNPRO_VALUES TYPE TABLE OF DYNPREAD,

FIELD_VALUE LIKE LINE OF DYNPRO_VALUES,

VALUES_TAB TYPE TABLE OF VALUES.

CALL SCREEN 100.

MODULE INIT OUTPUT.

PROGNAME = SY-REPID.

DYNNUM = SY-DYNNR.

CLEAR: FIELD_VALUE, DYNPRO_VALUES.

FIELD_VALUE-FIELDNAME = 'CARRIER'.

APPEND FIELD_VALUE TO DYNPRO_VALUES.

ENDMODULE.

MODULE CANCEL INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE VALUE_CARRIER INPUT.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

TABNAME = 'DEMOF4HELP'

FIELDNAME = 'CARRIER1'

DYNPPROG = PROGNAME

DYNPNR = DYNNUM

DYNPROFIELD = 'CARRIER'.

ENDMODULE.

MODULE VALUE_CONNECTION INPUT.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = PROGNAME

DYNUMB = DYNNUM

TRANSLATE_TO_UPPER = 'X'

TABLES

DYNPFIELDS = DYNPRO_VALUES.

READ TABLE DYNPRO_VALUES INDEX 1 INTO FIELD_VALUE.

SELECT CARRID CONNID

FROM SPFLI

INTO CORRESPONDING FIELDS OF TABLE VALUES_TAB

WHERE CARRID = FIELD_VALUE-FIELDVALUE.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'CONNID'

DYNPPROG = PROGNAME

DYNPNR = DYNNUM

DYNPROFIELD = 'CONNECTION'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = VALUES_TAB.

ENDMODULE.

The next screen (statically defined) for screen 100 is itself. It has the following layout:

The input fields have been adopted from the program fields CARRIER and CONNECTION. The pushbutton has the function code CANCEL with function type E.

The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.

MODULE INIT.

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

PROCESS ON VALUE-REQUEST.

FIELD CARRIER MODULE VALUE_CARRIER.

FIELD CONNECTION MODULE VALUE_CONNECTION.

When the user chooses input help for the individual fields, the following is displayed:

For the Airline field, the POV module VALUE_CARRIER is called. The function module F4IF_FIELD_VALUE_REQUEST displays the input help for the component CARRIER1 of the structure DEMOF4HELP from the ABAP Dictionary, namely the search help DEMOF4DE. The user’s selection is returned to the screen field CARRIER.

For the Flight number field, the POV module VALUE_CONNECTION is called. The function module DYNP_VALUE_READ transports the value of the screen field CARRIER into the program. The program then reads the corresponding values from the database table SPFLI into the internal table VALUES_TAB using a SELECT statement, and passes the internal table to F4IF_INT_TABLE_VALUE_REQUEST. This displays the internal table as input help, and places the user’s selection into the screen field CONNECTION.

<i>Reward if useful.</i>

Read only

Former Member
0 Likes
1,199

Dear Shyja,

Table Controls

Table controls are used to display large quantities of data in tables. Like all screen elements, they are defined in the Screen Painter. Within a table control, you can display input/output fields, radio buttons, checkboxes, radio button groups, and pushbuttons. You can have up to 255 columns and each column can have a heading. The first row is always the header row. Table controls offer users the following functions:

1.You can use the resizing attributes to specify whether the table control can resize the screen vertically or horizontally. If the control supports resizing, you can specify a minimum size for it.

2. You can define column headers that are also pushbuttons. You can use the pushbutton to select the column.

3. The width and position of columns can be changed by the user or by the program.

4.You can save the current settings as a default setting for a user.

5.Vertical scrolling with a scroll bar

6.Horizontal scrolling with a scroll bar

7.You can fix a number of lead columns that cannot be moved by the user.

8.A selection column enables you to select rows.

The only actions that trigger a PAI event are changes to the size of the screen (if the resizing attributes are selected), vertical scrolling, and saving settings. All other user actions are handled by the presentation server.

A table control displayed on a screen is a repeated series of table rows. Each row contains one or more screen elements, and all rows have the same structure. The step loop technique is used to pass data between the table controls and the ABAP program. To enable this, the screen flow logic and the ABAP program must be programmed accordingly

Table Controls on the Screen
Table controls are created on the screen using the tool Screen Painter. You can define as many table controls as you require for each screen.

First a table control area is created, into which the table control fields are then transferred.

Defining the Table Control Area
The table control area is created on the screen using the screen painter tool. The table control area is a multi-line screen element of a particular size, which must be assigned a name. The name identifies the table control and is used in screen flow logic and in ABAP programs to address it.

A table control has a few other special attributes apart from its name and size.

· Resize

The size of a table control can be fixed or changeable. The size of a table control changes when a user changes the size of a window, thereby cutting off a part of the table. The size change triggers the PAI event.

· Title

The top line of a table control can be reserved as a title line, into which a text field or an output field can be inserted.

· Column Headers

The second line of a table control can be reserved as a title line, where a text field or output field can be inserted in each column. At the same time the column titles function as buttons to select columns.

· Configure

The user can save the current settings of the attributes in a file. The system uses these settings every time the table control is displayed.

· Separators

Horizontal and vertical separators can be displayed between lines and columns.

· Line Selection

You can specify whether lines can be selected, and if so how many.

· Column Selection

You can specify whether columns can be selected, and if so how many.

· Selection Column

A column of the table control can be reserved as buttons for marking lines, it is treated internally as a checkbox. A selected line selection button contains ¢X¢ , an unselected one contains ¢ ¢. The selection column must be assigned a name. The state of the selection button can be transported into a character field, with length one and the same name, in an ABAP program and vice versa.

· Fixed Columns

A number of columns (from the left) can be excluded from the scrolling function. A fixed column cannot be moved.

The Table Control Field
After a table control area has been created on the screen, the following single line screen elements can be transferred into the area.

· Text Fields

· Input/Output Fields

· Checkbox Elements

· Radio Button Elements

Text fields and output fields can be transferred to the title lines.

The screen elements, frames, subscreens, tab strips, custom controls and status icons can not be transported to the table controls.

You can also transfer dictionary and program fields. During the transfer of fields from the ABAP Dictionary it is possible that column headers will be automatically assigned a text from the data element from the Dictionary.

Every screen element that is inserted makes up a column of the table control. In every free line available, under any title and column headers, the screen element is displayed repeatedly.

The screen elements of a column appear only once in the element list of the corresponding screen. Therefore, you only have to create fields with the same name once in ABAP programs.

Table Controls in ABAP Programs
To handle table controls in ABAP programs, you must declare a control in the declaration part of the program for each table control using the following statement:

CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.

where ctrl is the name of the table control on a screen in the ABAP program. The control allows the ABAP program to read the attributes of the table control and to influence the control. The statement also declares a deep structure of name ctrl. The data type of the structure corresponds to the type CXTAB_CONTROL defined in the type group CXTAB in the ABAP Dictionary.

At runtime the components of the structure contain the attributes of the table control. Several of the initial values are determined in the Screen Painter. The initial value for the control ctrl is taken from the screen which is determined using the addition USING.

You can start a screen sequence from an ABAP program using

REFRESH CONTROL ctrl FROM SCREEN scr.

you can initialize a table control at any time with the initial value of a screen scr. Values that are not taken from the settings in the Screen Painter, are set to the current status of the table control at PAI.

Structure CXTAB_CONTROL
The deep structure CXTAB_CONTROL contains the general attributes of the table control on the highest level. The component CXTAB_CONTROL is a table of the structure CXTAB_COLUMN and contains the attributes of a column. The component CXTAB_CONTROL-COLS-SCREEN is a flat structure of the same type as system table screen and contains the attributes of the individual screen elements.

Up to component CURRENT_LINE, all attributes of the structure CXTAB_CONTROL in the ABAP program can be set to change the table control display on the screen

Components of SCREEN
The component SCREEN-NAME is the name of the screen element that creates the column. The initial values of the remaining components correspond to the attributes of the screen elements in the Screen Painter. The attributes are transferred from here with initial values. They can be changed directly in the ABAP program. Note that directly set values can be overwritten by modifying these attributes using MODIFY SCREEN within the loop LOOP AT SCREEN.

Furthermore, note that the attributes of the structure screen are not set with blank characters and X, but are set with 0 and 1 as in the normal processing of screen.

Scrolling in Table Controls

Scrolling with scroll bars is automatically implemented with table controls, and managed by the system. However, the component ctrl-LINES must be set to the required row number before editing the table control. This is the case for table controls with or without parallel loops using an internal table. The component LINES is set implicitly for table controls with parallel loops using an internal table, although the correct value is not guaranteed (see table above). It is therefore recommended that in both instances you set the component LINES explicitly to the number of rows in the internal table of the ABAP program. You can determine this number from the statement DESCRIBE TABLE (see the following example).

The event PAI with an empty function code is triggered when scrolling using scroll bars. When the loops at PAI and PBO are executed, the system sets the component TOP_LINE of the structure CXTAB_CONTROL before PBO, so that the correct row is edited at the loop pass.

You can easily implement program-controlled vertical scrolling (line by line, page by page, or goto page) by using the component of the structure CXTAB_CONTROL. Essentially the component TOP_LINE must be provided with a value. For page by page scrolling, the number of rows to be scrolled during the loop pass can be taken from the system field sy-loopc. sy-loopccontains the number of rows currently display, whereas the component LINES of structure CXTAB_CONTROL contains the number of all rows in the table control.

Cursor Position on Table Controls

At PBO you can set the cursor on a specific field of a specific row of a table control.

SET CURSOR FIELD f LINE lin .

Using the optional addition OFFSET, you can enter the offset of the cursor in the field as described under Setting the Cursor Position .

At PAI you can read the current cursor position.

GET CURSOR FIELD f LINE lin ...

In addition to the information given under Finding Out the Cursor Position , field lin contains information on which row of the table control the cursor is currently on. You can also use

GET CURSOR LINE lin.

. sy-subrc allows you to check if the cursor is placed in a row of a table control.

Regards,

Rajesh K Soman

Please reward points if found helpful.