steps to create table control in sap abap

23
Here steps to create table control 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.

Upload: manish-shankar

Post on 27-Oct-2014

553 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Steps to Create Table Control in SAP ABAP

Here steps to create table control

1. Declare the table control

As well as drawing the table control on the screen it is necessary to declare the tablecontrol 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_CONTROLdefined 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 mousebutton to position and size the control on the screen.

 

Page 2: Steps to Create Table Control in SAP ABAP

 

Then input the name of table control.

 

 

Page 3: Steps to Create Table Control in SAP ABAP

 

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.

 

Page 4: Steps to Create Table Control in SAP ABAP

 

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

 

Page 5: Steps to Create Table Control in SAP ABAP

 

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

 

Page 6: Steps to Create Table Control in SAP ABAP

 

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 ithappens. I have tried some ways and tricks to display in correct order, but the fields stilldisplayed in reversed order. Finally, to get the correct order I selected the fields one byone.

 

Page 7: Steps to Create Table Control in SAP ABAP

 

4. Adding label for each column

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

 

Page 8: Steps to Create Table Control in SAP ABAP

 

Table Control Principle

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

 

Page 9: Steps to Create Table Control in SAP ABAP

 

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

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

User action in screen 2 triggers the PAI logic. PAI logic updates the internal table withnew 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 actionssuch as BACK, EXIT, etc.

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

 

Page 10: Steps to Create Table Control in SAP ABAP

 

PBO (Process Before Output)

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

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

 

Page 12: Steps to Create Table Control in SAP ABAP

PAI (Process After Input)

• All screen fields that do not belong to a table control and are not specified in aFIELD 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 theFIELD statement is executed

 

Page 13: Steps to Create Table Control in SAP ABAP

 

Updating data in table control

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

Page 14: Steps to Create Table Control in SAP ABAP

internal table.

1. Method 1: Read the internal table into the Table Control in the screen’s flowlogic. Used when the names of the Table Control fields are based on fields of theinternal 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 thedatabase 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 internaltable. If the fields in the table control have the same name as the internal they will befilled automatically. Otherwise we need to write a module to transfer the internal tablefields to the screen fields.

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

PROCESS BEFORE OUTPUT.LOOP AT ITAB_REG WITH CONTROL TCREGCURSOR 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 thedata 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

Page 15: Steps to Create Table Control in SAP ABAP

in the table control if there are no more corresponding entries in the internaltable.

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_REGON 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 INDEXTCREG-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.

Page 16: Steps to Create Table Control in SAP ABAP

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 weekonly the beginning. Actually there are more areas in SAP Table Control with abapprogramming that can be explored deeper, but may be next time

ABAP IntroductionWhat is ABAP/4Logon to SAP R/3Transaction Codesmultitasking CommandsABAP/4 Editor (SE38)Steps for Creating a programElements in R/3 Screen

ABAP DictionaryIntroduction

Page 17: Steps to Create Table Control in SAP ABAP

Data Dictionary FunctionsData Dictionary ObjectsDomainsData ElementsData Base TablesStructuresViewsType GroupsSearch helpsLock ObjectsPrimary key and Foreign Key relationsTable Maintenance Generator

Packages, variants and message classesDifference between Local Objects and packagesTransferring local objects to Packagesvariants IntroductionCreating variants in ABAPEditor and Data DictionaryMessage Class introductionMessage TypesCalling message class in ReportDialog programs

Selection Screens & Open SQL StatementsSelection screensParameter StatementSelect options StatementSelection Screen StatementScreen table and its fieldsDynamic screen modificationsSelectInsertModifyUpdateDelete operations

Internal tablesInternal tables IntroductionDeclaring Internal tablePopulating Internal TableProcessing Internal TableInitializing Internal TablesInner joins and for all entriesControl Break Statements

Debugging techniques

Page 18: Steps to Create Table Control in SAP ABAP

IntroductionBreak-points (Static and Dynamic)Watch pointsDynamically changing internal tables contents in Debugging EditorProgram in Debugging Editor

Modularization TechniquesIntroductionIncludesSub routinesPassing Parameters to subroutinesPassing Tables to Sub routinesFunction GroupsFunction Modules

ReportsIntroductionTypes of ReportsClassical ReportsEvents in classical reportsInteractive ReportsEvents in interactive reportsTechniques fro Interactive ReportsHotspothideGet CursorALV

Dialog/Module Pool Programming / TransactionsMPP IntroductionFlow logic EventsProcess Before Output (PBO)Process After Input (PAI)Process on Value Request (POV)Process On Help Request (POH)Include Programs in MPPDynamic ScreensCall ScreenSet ScreenProcessing of List from Transaction and Vice VersaElements in Screen LayoutTable ControlsStep LoopsTab Strop ControlsSub Screens

Page 19: Steps to Create Table Control in SAP ABAP

Batch Data CommunicationBDC IntroductionMethods in BDCFlat file creationUploading dataBDC methodsSession MethodCall Transaction MethodRecordingHandling Table controls in BDCLegacy system migration workbenchFile handlingApplication ServerPresentation Server

SAP ScriptsSAP Scripts IntroductionsComponents of SAP ScriptsLayout SetStandard TextOutput ProgramModifying Standard SAP Script layoutsSAP Scripts utilities - upload/download

Smart FormsSmart Forms introductionGraphic ManagementStyle MaintenanceParagraph FormatsCharacter FormatsWriting print program and designing layouts

ABAP QueriesQuick ViewerSAP ABAP QueryUser GroupsInfo SetsQuery ReportsList Creation

Performance Tuning & Cross applicationsTypes of Program AnalysisStatic, Dynamic ChecksShort Dump AnalysisPerformance ToolsRuntime Analysis and SQL Trace

Page 20: Steps to Create Table Control in SAP ABAP

Introduction to Cross ApplicationsIntroduction to Distributed Environment

RFC & ALEIntroductionDefine logical systemsCreating RFC Destinationbetween 2 systemsCreating program using Remote Enabled FunctionALE basicsOverview of Outbound & Inbound ProcessConfig StepsAssign client to logical systemmodel ViewCreating Ports

IDOCs (Intermediate Document)IntroductionsTypes of iDocsBasic iDocsExtension IdocsCreating iDocsMessage TypesAssigning iDoc type to Messgae type

EnhancementsEnhancement ConceptsTypes of ExitsImplementing various type of user exits for enhancementsField exitsScreen exitFunction ExitMenu Exit

BAPI's (Business Application Programming)BAPI OverviewCreation of BAPIEDI (Electronic Data Interchange)Difference ALE & EDIOverview of Outbound & Inbound ProcessConfiguration StepsPort CreationPartner Profile Creation