Вы находитесь на странице: 1из 16

ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid

Posted on January 3, 2012 by Stedie

ALV Grid Part 1 consists of a very detailed step by step on how to create a very simple OO ALV Grid. TL;DR: Click here to jump to the coding. ALV Grid Part 2: Enabling buttons

Tcode: SE80 Choose program from the first dropdown list and put in a Z program name that makes sense at the second input box.

SE80 object navigator

Upon hitting ENTER. Pop up appears, select Yes to create the object.

Yes please, create the object

We would want to keep this simple for now, uncheck the With TOP INCL.checkbox.

Uncheck the checkboxPut in a title

Put in a titleselect Executable Program and leave everything else by default, hit SAVE.

Put in a title

Put in $TMP and click SAVE, alternately, just click Local Object.

Put in $TMP and click SAVE

Now..time to put in some codes! Obviously, we would need some data to be displayed.
DATA: BEGIN OF gt_data. INCLUDE STRUCTURE sflight. DATA: END OF gt_data. DATA: t_data LIKE STANDARD TABLE OF gt_data.

* Retrieve 20 rows data from table SFLIGHT SELECT * FROM sflight INTO TABLE t_data UP TO 20 ROWS.

Next, we will need a container to hold our ALV grid to be displayed on the screen. Back to the object navigator frame, right click on the program name -> Create -> Screen.

Creating a screen

Key in a screen number 1001 .

Key in screen number

Key in a short description of your choice and hit the Layout button where we will create the container on the screen we just created.

Key in short description

Tada..! This is known as the screen painter. Click the Custom Controlicon as indicate in the screenshot below, drag and draw on the frame on the right. Key in a name for the container, GRID_CONTAINER in this case. Activate and go back.

Create container for the newly created screen

Now we put in some coding to initialize and create the container.


DATA: g_grid_container TYPE REF TO cl_gui_custom_container. CREATE OBJECT g_grid_container EXPORTING container_name = 'GRID_CONTAINER' EXCEPTIONS cntl_error = 1

cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5.

After which, we create the ALV Grid object and making the container we have created to host it.
DATA: g_alv_grid TYPE REF TO cl_gui_alv_grid. CREATE OBJECT g_alv_grid EXPORTING i_parent = g_grid_container.

After that, we call method set_table_for_first_display to display the ALV Grid. CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab EXCEPTIONS invalid_parameter_combination = 1 program_error too_many_lines OTHERS = 2 = 3 = 4. = t_data[]

Finally, we call the screen.

CALL SELECTION-SCREEN 1001.

Coding all together: REPORT ZTEST_STED_ALVGRID.

DATA: BEGIN OF gt_data. INCLUDE STRUCTURE sflight. DATA: END OF gt_data. DATA: t_data LIKE STANDARD TABLE OF gt_data.

DATA: g_alv_grid

TYPE REF TO cl_gui_alv_grid,

g_grid_container TYPE REF TO cl_gui_custom_container.

data selection

SELECT * FROM sflight INTO TABLE t_data UP TO 20 ROWS.

CREATE OBJECT g_grid_container EXPORTING container_name EXCEPTIONS cntl_error = 1 = 'GRID_CONTAINER'

cntl_system_error create_error lifetime_error

= 2 = 3 = 4

lifetime_dynpro_dynpro_link = 5.

CREATE OBJECT g_alv_grid EXPORTING i_parent = g_grid_container.

CALL METHOD g_alv_grid->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab EXCEPTIONS invalid_parameter_combination = 1 program_error too_many_lines OTHERS = 2 = 3 = 4. = t_data[]

CALL SELECTION-SCREEN 1001.

This entry was posted in ABAP, ALV Grid, SAP. Bookmark the permalink. Hide Title and Notification bar ALV Grid Part 1.5: Enabling buttons

One Response to ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid
1. Pingback: ALV Grid Part 1.5: Enabling buttons | Android / ABAP Blog

Leave a Reply
Your email address will not be published. Required fields are marked * Name * Email * Website

Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title="">
<b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Post Comment

Search

Recent Posts

Function module to retrieve Fiscal year and duration ALV Grid Part 1.5: Enabling buttons ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid Hide Title and Notification bar Debug certificate expired error Alice on Hide Title and Notification bar ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid | Android / ABAP Blog on ALV Grid Part 1.5: Enabling buttons ALV Grid Part 1.5: Enabling buttons | Android / ABAP Blogon ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid

Recent Comments

Archives

April 2012 January 2012 July 2011 ABAP Activity

Categories

ALV Grid Android androidManifest.xml debug certificate SAP Screen

ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid Function module to retrieve Fiscal year and duration

ALV Grid Part 1.5: Enabling buttons


Posted on January 3, 2012 by Stedie

This post doesnt really talk about ALV Grid, but more about screen in general. If you have followed through ALV Grid Part 1, you will notice the standard toolbar has been disabled. This post, we will look into how to enable the standard toolbar.

Disabled buttons

Continuing from ALV Grid Part 1, if you execute the program, theres no way to go back or exit besides doing a /n in the Command field. Double click on screen 1001 and click on the Flow Logic tab.

Double click on screen 1001

You will notice that 2 modules have been commented out. PROCESS BEFORE OUTPUT The event PROCESS BEFORE OUTPUT (PBO) is triggered by the runtime environment before the screen of a dynpro is sent to the presentation layer. PROCESS AFTER INPUT The event PROCESS AFTER INPUT (PAI) is triggered by a user action on the user interface

So the basic thing one needs to understand is the flow logic, its always called like this. PROCESS BEFORE OUTPUT (PBO) -> Display on screen -> PROCESS AFTER INPUT (PAI) Lets uncomment the 2 modules. Double click on MODULE status_1001, you should see a pop up box saying that object does not exist, proceed to create it.

Uncomment the 2 modules

Lets keep things simple by creating it in the main program for now.

Create module in MAIN program

You will get something similiar as below in the main program.


*&--------------------------------------------------------------* *& Module STATUS_1001 OUTPUT

*&--------------------------------------------------------------* * text

*---------------------------------------------------------------*

MODULE STATUS_1001 output. * * SET PF-STATUS 'xxxxxxxx'. SET TITLEBAR 'xxx'.

ENDMODULE.

" STATUS_1001

OUTPUT

Proceed to uncomment SET PF-STATUS 'xxxxxx' , and replace the xxxxx with something meaningful, e.g. STATUS_1001(needs to be all uppercase). Double click on the STATUS_1001.

PBO Status Creation

Expand the Function keys, you will see something familiar. Lets assign BACK , activate and go back to flow logic of Screen 1001.

Assign BACK button

All buttons and users interactions will be handled in the PAI (Process after Input). Double click on the MODULE USER_COMMAND_1001 and it should prompt you to create the missing object like you did for the PBO module. Put in the coding to tell the program what should be done in the event of user clicking theBACK button: Leave. After youre done, you should have something like this in the main program.
*&--------------------------------------------------------------* *& Module USER_COMMAND_1001 INPUT

*&--------------------------------------------------------------* * text

*---------------------------------------------------------------* MODULE USER_COMMAND_1001 input. CASE sy-ucomm. WHEN 'BACK'. LEAVE. ENDCASE. ENDMODULE. " USER_COMMAND_1001 INPUT

Activate and execute the program. Now your Back button should be working.
This entry was posted in ABAP, ALV Grid, SAP, Screen. Bookmark the permalink. ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid Function module to retrieve Fiscal year and duration

One Response to ALV Grid Part 1.5: Enabling buttons


1. Pingback: ALV Grid Part 1: Detailed step by step on how to create a simple ALV Grid | Android /

ABAP Blog

Вам также может понравиться