ALVGrid Control
ALVGrid Control
Dynpro or Modulpool
A dynpro (Dynamic Program) consists of a screen and its flow logic and controls exactly one dialog steps. Each screen contains
fields used to display or request information. Fields can be text strings, input or output fields, radio buttons, checkboxes, or
pushbuttons. See the screen of program ZSHAD6 (Transaction TZ10).
You create and edit all components of a dynpro in the Screen Painter. To call the Screen Painter, create a dynpro in the Object
Browser or double-click on an existing dynpro. The Object Browser then calls the Screen Painter. There, you can enter the flow
logic of the new dynpro. By pressing the corresponding pushbutton you can maintain the Screen attributes, branch to the Full
Screen-Editor or you choose the pushbutton Field list and change the attributes of fields.
Screen Attributes
From the user's point of view, a transaction is a sequence of screens, displayed one after another. How do I determine this
sequence? The transaction's attributes determine the first screen to be displayed. The attributes of the individual dynpros
determine which screen to display after the current screen. You can also set the number of the subsequent screen dynamically
from within the ABAP/4 program.
For the sample transaction, the screen attributes need not be changed, since no subsequent screen is called.
Layout
Field Attributes
To display and modify the attributes of the individual fields (input/output fields, input required, possible entries button,
invisible, and so on), use the Field list.
The fields can be defined as input/output fields. Other fields can be used only for outputting the data. See Transaction TZ10
Flow Logic
The flow control code of a dynpro consists of a few statements that syntactically resemble ABAP/4 statements. However, you
cannot use flow control keywords in ABAP/4 and vice versa. You enter the flow control code in the Screen Painter as one
component of the dynpro.
The flow control for the dynpro of Transaction ZSHAD6 looks like this:
To display information on the statement syntax in the flow logic, choose Utilities --> Help on... in the flow logic editor. In the
subsequent dialog window, mark Flow logic keyword, enter the name of the desired keyword, and press ENTER.
CASE SY-UCOMM.
WHEN 'INSERT'.
INSERT ZSHAD.
WHEN 'DISPLAY'.
SELECT SINGLE * FROM ZSHAD INTO ZSHAD WHERE PLANETYPE = ZSHAD-PLANETYPE.
WHEN 'CLEAR'.
CLEAR ZSHAD.
WHEN 'EXIT'.
LEAVE TO SCREEN 0 .
ENDCASE.
*************
PROCESS BEFORE OUTPUT.
MODULE STATUS_0001.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0001.
**********************
See ZSHAD6_dynpro.txt
The following graphic shows a list displayed with the ALV Grid Control in a dialog box:
The ALV Grid Control consists of a toolbar, a title and the output table displayed in a grid control. If required, the user can hide
the title and the standard functions of the toolbar.
With Functions
REUSE_ALV_GRID_DISPLAY is a function module which is used to display the output in grid format.
The input for this function module are two internal tables: one internal table for data and another for internal table for about
the fields. Example:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_grid_title = 'titulo'
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = i_valores
EXCEPTIONS
program_error = 1
OTHERS = 2.
i_valores must correspond with field description and type o each field in i_fieldcat.
REPORT ZTX2202_ALV_2.
TYPE-POOLS: SLIS.
END OF w_sflight,
* Parameters
PARAMETERS: p_carrid TYPE sflight-carrid.
*SELECT-OPTIONS: s_carrid FOR sflight-carrid.
START-OF-SELECTION.
Perform f_alv.
END-OF-SELECTION.
*********************************************
*&---------------------------------------------------------------------*
*& Form f_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM f_alv.
DATA: lv_tabname(10) VALUE 'sflight'.
CONSTANTS: lc_CARRID(5) VALUE 'CARRID',
lc_CONNID(10) VALUE 'CONNID',
lc_FLDATE(10) VALUE 'FLDATE',
lc_PRICE(10) VALUE 'PRICE'.
ADD 1 TO lv_pos.
lw_fieldcat-col_pos = lv_pos.
lw_fieldcat-fieldname = lc_carrid.
lw_fieldcat-tabname = lv_tabname.
lw_fieldcat-seltext_l = 'text-010'.
lw_fieldcat-seltext_m = 'text-010'.
lw_fieldcat-seltext_s = 'text-010'.
APPEND lw_fieldcat TO li_fieldcat.
CLEAR lw_fieldcat.
ADD 1 TO lv_pos.
lw_fieldcat-col_pos = lv_pos.
lw_fieldcat-fieldname = lc_connid.
lw_fieldcat-tabname = lv_tabname.
lw_fieldcat-seltext_l = 'text-011'.
lw_fieldcat-seltext_m = 'text-011'.
lw_fieldcat-seltext_s = 'text-011'.
APPEND lw_fieldcat TO li_fieldcat.
CLEAR lw_fieldcat.
ADD 1 TO lv_pos.
lw_fieldcat-col_pos = lv_pos.
lw_fieldcat-fieldname = lc_fldate.
lw_fieldcat-tabname = lv_tabname.
lw_fieldcat-seltext_l = 'text-012'.
lw_fieldcat-seltext_m = 'text-012'.
lw_fieldcat-seltext_s = 'text-012'.
APPEND lw_fieldcat TO li_fieldcat.
CLEAR lw_fieldcat.
ADD 1 TO lv_pos.
lw_fieldcat-col_pos = lv_pos.
lw_fieldcat-fieldname = lc_price.
lw_fieldcat-tabname = lv_tabname.
lw_fieldcat-seltext_l = 'text-013'.
lw_fieldcat-seltext_m = 'text-013'.
lw_fieldcat-seltext_s = 'text-013'.
APPEND lw_fieldcat TO li_fieldcat.
CLEAR lw_fieldcat.
With Objects
This instance is defined with reference to class cl_gui_alv_grid:
An instance for the ALV Grid Control manages all information pertaining to a list on your screen. You can call methods on this
instance with which you can define and change the properties of this control.
First Steps
1. Create an instance of the ALV Grid Control and integrate it into a screen.
2. Select the data to be displayed and pass it together with a description of the fields to the instance.
In order to integrate a control into a screen, you can use four different container controls (in this example, we use the custom
container control).
2. Create a standard screen and mark an area for the custom container control in the graphical
Screen Painter (icon identified by letter 'C'). Assign name CCCONTAINER to this area.
3. In the PBO module of the screen, you must now instantiate the container control and the ALV Grid Control. By doing this,
you create a link between the container control and the screen, using the container created in the Screen Painter. Using
parameter parent, you define the container control as the parent of the ALV Grid Control:
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
CONTAINER_NAME = 'CCCONTAINER'.
CREATE OBJECT GRID1
EXPORTING
I_PARENT = g_custom_container.
ENDIF.
2. Pass the output table and the structure data to the ALV Grid Control. Again, ensure to call this method only once after the
ALV Grid Control is created:
In this case, the structure data is provided through the Data Dictionary. The ALV Grid Control gets the field information from
table SFLIGHT and displays all fields of the table.
See sample report BCALV_GRID_DEMO in development class SLIS.
Batch input
Batch input processing brings large amounts of data into an SAP system using the same types of data entry commands and
processes as manual data input. The difference is that batch input transfers data from an electronic storage medium to the SAP
database and then inputs data automatically rather than relying on a human end user to input data by hand. Transfer speed
and adherence to data integrity rules that ensure data accuracy makes advantages to using batch processing rise in direct
proportion to the amount or size of input data.
Process
Batch input is a two-step process that starts with exporting or transferring data from the source system according to the
transfer method you choose -- Classical Batch Input or Call Transaction using Call Dialog -- and instructions you provide in a
special data transfer computer program. Although each completes the transfer process differently, both transfer data to a
common structure called a Batch Data Input Structure or BDCDATA. Depending on the transfer method, the BDCDATA holds
data for input later or input to your SAP database takes place immediately.
Classical Batch Input
Classical Batch Input, or CBI, allows you to run a data transfer program multiple times and store the results -- called transactions
-- within the BDCDATA in “sessions” for later processing. Updating can take place in the foreground but most often occurs
behind the scenes while other programs are running. Although slower, CBI is more appropriate for transferring large amounts
of data and because CBI generates a batch input process log for each input session and offers support for finding and correcting
process errors.
Call Transaction
Call Transaction Using Call Dialog transfers and processes data for single transactions or each time you run the data transfer
application program. As data arrives at the BDCDATA, processing -- committing the data and updating an SAP database -- takes
place immediately. Because of this, Call Transaction is appropriate for transferring small amounts of data. In addition, Call
Transaction does not generate batch input process logs, meaning there is no support for finding and correcting process errors
and you must provide explicit error detection and handling instructions within the data transfer program.
*&---------------------------------------------------------------------*
*& Report ZTX2203_BATCHI
report ZTX2203_BATCHI
END OF IT_TAB.
EXPORTING
FILENAME = 'C:\FLIGHT.TXT'
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_TAB.
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT IT_TAB.
REFRESH BDCDATA.
PERFORM MAPPING.
ENDLOOP.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM MAPPING.
'=INSERT'.
'ZSHAD-PAYEMENT'.
'AA'.
'28.01.2012'.
'SH21'.
'1000'.
ENDFORM. "MAPPING
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. "BDC_FIELD