Online Tutorials & Training Materials | STechies.com
Register Login

Create Table Control

|| || 0

Create Table Control
Stechies

Steps to create table control

The values specified for the size category and data class are mapped to database-specific values via control tables.

1. Declare the table control

As well as drawing the table control on the screen it is necessary to declare the table
control as a data item (in the TOP include program for the transaction).

CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.

• is the name of the table control on a screen in the ABAP program
• corresponds to a complex type – (CXTAB_CONTROL defined in the ABAP dictionary)
• is the screen from which the table control will get its initial values

2. Adding table control to a screen

In the graphical screen editor choose the table control element button. Use the left mouse button to position and size the control on the screen.

Then input the name of the table control.

3. Adding Field to a table control

To add field to table control, we can retrieve from table or internal table. Click on icon “dictionary/program field window” or function key F6.

There two option while retrieve field, i.e. based on database table or internal table. If want to retrieve from database table, input the name of table then click push button “Get from Dictionary”.If want to retrieve from internal table, input the internal table name then click push button “Get from program”.’

Read more about SAP R3 systems

 Mark the field to be added to table control, and then click on push button OK.

Drag selected fields into table then release the mouse button.

Here the fields we selected will be displayed in reversed order. I do not exactly why it happens. I have tried some ways and tricks to display in correct order, but the fields still displayed in reversed order. Finally, to get the correct order I selected the fields one by one.

4. Adding label for each column

Label column is text field. To add it, just click on the text field icon, drag it onto header of the column and then type the label.

Table Control Principle

There are a set of programming principles that should be adhered to when using table controls and step loops. Data from the database should be initially loaded into an internal table. This means that the database is accessed for read purposes only once in the transaction. Next the rows of the internal table are loaded into the table control. Any changes that are made to the data are then saved back to the internal table. At the end of the transaction, the contents of the internal table can be written back to the database, again to minimize database I/O.

PAI logic for screen 1 (see screen below) loads the internal table with data from the database according to the entries supplied by the user.

PBO logic for screen 2 (see screen below) populates the table control from the internal table (buffer).

User action in screen 2 triggers the PAI logic. PAI logic updates the internal table with new values entered (into the table control screen fields) by the user.

PAI logic is triggered by actions such as scrolling down a single row as well as actions such as BACK, EXIT, etc.

Unless the user action causes the transaction to leave the current screen, after the PAI modules have been executed, the PBO modules for the screen are executed again. Thus the table control fields are updated or refreshed after every user action.

Get more information on ABAP Transaction Codes

PBO (Process Before Output)

In PBO processing fields are transported from the module pool to the screen in a predefined order.

  • The table control step loop is processed row by row. Fields with corresponding names are transported from the module pool to the screen.
  • After the step loop has been processed all remaining module pool fields are transported to the screen.

PAI (Process After Input)

  • All screen fields that do not belong to a table control and are not specified in a FIELD statement are transported to module pool fields
  • Table control fields are transported row by row to module pool fields
  • Fields specified in FIELD statements are transported immediately before the FIELD statement is executed

Updating data in table control

The ABAP language provides two mechanisms for loading the table control with data from the internal table and then storing the altered rows of the table control back to theinternal table.

 

1) Method 1: Read the internal table into the Table Control in the screen’s flow logic. Used when the names of the Table Control fields are based on fields of the
internal table.

2) Method 2: Read the internal table into the Table Control in the module pool code. Used when the names of the Table Control fields are based on fields of the
database table.

Method 1 (table control fields = itab fields)
In the flow logic we can read an internal table using the LOOP statement. Define thereference to the relevant able control by specifying WITH CONTROL

Determine which table entry is to be read by specifying CURSOR -CURRENT_LINE.

After the read operation the field contents are placed in the header line of the internal table. If the fields in the table control have the same name as the internal they will be filled automatically. Otherwise we need to write a module to transfer the internal table fields to the screen fields.

We must reflect any changes the user makes to the fields of the table control in the internal table otherwise they will not appear when the screen is redisplayed after PBO processing, (eg, after the user presses Enter or scrolls) However, this processing should be performed only if changes have actually been made to the screen fields of the table control (hence the use of the ON REQUEST)

PROCESS BEFORE OUTPUT.
LOOP AT ITAB_REG WITH CONTROL TCREG
CURSOR TCREG-CURRENT_LINE.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT ITAB_REG.
MODULE MODIFY_ITAB_REG.
ENDLOOP.
MODULE MODIFY_ITAB_REG INPUT.
MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
ENDMODULE.
Method 2 (table control fields = dict. fields)

If using a LOOP statement without an internal table in the flow logic, we must read the data in a PBO module which is called each time the loop is processed.

Since, in this case, the system cannot determine the number of internal table entries itself, we must use the EXIT FROM STEP-LOOP statement to ensure that no blank lines are displayed in the table control if there are no more corresponding entries in the internal table.

PROCESS BEFORE OUTPUT.
LOOP WITH CONTROL TCREG.
MODULE READ_ITAB_REG.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP WITH CONTROL TCREG.
CHAIN.
FIELD: ITAB_REG-REG,
ITAB_REG-DESC.
MODULE MODIFY_ITAB_REG
ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE READ_ITAB_REG OUTPUT.
READ TABLE ITAB_REG INDEX TCREG-CURRENT_LINE.
I IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING ITAB_REREG TO TCREG.
ELSE.
EXIT FROM STEP-LOOP.
ENDIF.
ENDMODULE.
MODULE MODIFY_ITAB_REG INPUT.
MOVE-CORRESPONDING TCREG TO ITAB_REG.
MODIFY ITAB_REG INDEX
TCREG-CURRENT_LINE.
ENDMODULE.
Updating the internal table

Method 1

PROCESS AFTER INPUT.
LOOP AT ITAB_REG.
CHAIN.
FIELD: ITAB_REG-REG,
ITAB_REG-DESC.
MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE MODIFY_ITAB_REG INPUT.
ITAB_REG-MARK = 'X'.
MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
ENDMODULE.

Method 2

PROCESS AFTER INPUT.
LOOP WITH CONTROL TCREG.
CHAIN.
FIELD: TCREG-REG,
TCREG-DESC.
MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE MODIFY_ITAB_REG INPUT.
MOVE-CORRESPONDING TCREG TO ITAB_REG.
I TAB_REG-MARK = 'X'.
MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
ENDMODULE.

Updating the database

MODULE USER_COMMAND_100.
CASE OK_CODE.
WHEN ‘SAVE’.
LOOP AT ITAB-REG.
CHECK ITAB_REG-MARK = ‘X’.
MOVE-CORRESPONDING ITAB_REG TO TCREG.
UPDATE TCREG.
ENDLOOP.
WHEN ...
...
ENDCASE.
ENDMODULE.

Those are the simple steps how to create table control. What I have learned this week only the beginning. Actually there are more areas in SAP Table Control with ABAP Programming that can be explored deeper, but may be next time.

ABAP Introduction

What is ABAP/4
Logon to SAP R/3
Transaction Codes
multitasking Commands
ABAP/4 Editor (SE38)
Steps for Creating a program
Elements in R/3 Screen

ABAP Dictionary

Introduction
Data Dictionary Functions
Data Dictionary Objects
Domains
Data Elements
Data Base Tables
Structures
Views
Type Groups
Search helps
Lock Objects
Primary key and Foreign Key relations
Table Maintenance Generator

Packages, variants and message classes

Difference between Local Objects and packages
Transferring local objects to Packages
variants Introduction
Creating variants in ABAPEditor and Data Dictionary
Message Class introduction
Message Types
Calling message class in Report
Dialog programs

Selection Screens & Open SQL Statements

Selection screens
Parameter Statement
Select options Statement
Selection Screen Statement
Screen table and its fields
Dynamic screen modifications
Select
Insert
Modify
Update
Delete operations

Internal tables

Internal tables Introduction
Declaring Internal table
Populating Internal Table
Processing Internal Table
Initializing Internal Tables
Inner joins and for all entries
Control Break Statements

Debugging techniques

Introduction
Break-points (Static and Dynamic)
Watch points
Dynamically changing internal tables contents in Debugging Editor
Program in Debugging Editor

Modularization Techniques

Introduction
Includes
Sub routines
Passing Parameters to subroutines
Passing Tables to Sub routines
Function Groups
Function Modules

Reports

Introduction
Types of Reports
Classical Reports
Events in classical reports
Interactive Reports
Events in interactive reports
Techniques fro Interactive Reports
Hotspot
hide
Get Cursor
ALV

Dialog/Module Pool Programming / Transactions

MPP Introduction
Flow logic Events
Process Before Output (PBO)
Process After Input (PAI)
Process on Value Request (POV)
Process On Help Request (POH)
Include Programs in MPP
Dynamic Screens
Call Screen
Set Screen
Processing of List from Transaction and Vice Versa
Elements in Screen Layout
Table Controls
Step Loops
Tab Strop Controls
Sub Screens

Batch Data Communication

BDC Introduction
Methods in BDC
Flat file creation
Uploading data
BDC methods
Session Method
Call Transaction Method
Recording
Handling Table controls in BDC
Legacy system migration workbench
File handling
Application Server
Presentation Server

SAP Scripts

SAP Scripts Introductions
Components of SAP Scripts
Layout Set
Standard Text
Output Program
Modifying Standard SAP Script layouts
SAP Scripts utilities - upload/download

Smart Forms

Smart Forms introduction
Graphic Management
Style Maintenance
Paragraph Formats
Character Formats
Writing print program and designing layouts

ABAP Queries

Quick Viewer
SAP ABAP Query
User Groups
Info Sets
Query Reports
List Creation

Performance Tuning & Cross applications

Types of Program Analysis
Static, Dynamic Checks
Short Dump Analysis
Performance Tools
Runtime Analysis and SQL Trace
Introduction to Cross Applications
Introduction to Distributed Environment

RFC & ALE

Introduction
Define logical systems
Creating RFC Destinationbetween 2 systems
Creating program using Remote Enabled Function
ALE basics
Overview of Outbound & Inbound Process
Config Steps
Assign client to logical system
model View
Creating Ports

IDOCs (Intermediate Document)

Introductions
Types of iDocs
Basic iDocs
Extension Idocs
Creating iDocs
Message Types
Assigning iDoc type to Messgae type

Enhancements

Enhancement Concepts
Types of Exits
Implementing various type of user exits for enhancements
Field exits
Screen exit
Function Exit
Menu Exit

BAPI's (Business Application Programming)

BAPI Overview
Creation of BAPI
EDI (Electronic Data Interchange)
Difference ALE & EDI
Overview of Outbound & Inbound Process
Configuration Steps
Port Creation
Partner Profile Creation

 


Related Articles

0.0123 seconds.