Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

how to alv report in sap abap?

5 Answer(s) Available
Answer # 1 #

DATA : go_container TYPE REF TO cl_gui_custom_container. DATA : go_alv TYPE REF TO cl_gui_alv_grid.

DATA : gs_variant TYPE disvariant. DATA : gv_save TYPE c LENGTH 1.

SELECT-OPTIONS: so_car FOR gs_flight-carrid, so_con FOR gs_flight-connid.

PARAMETERS : pa_lv TYPE disvariant-variant.

START-OF-SELECTION.

SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_flights FROM sflight WHERE carrid IN so_car AND connid IN so_con.

END-OF-SELECTION.

CALL SCREEN 100.

*&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'G100'. SET TITLEBAR 'T100'. ENDMODULE. *&---------------------------------------------------------------------* *&      Module  USER_COMMAND_0100  INPUT *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT.

CASE ok_code. WHEN 'BACK'. PERFORM free_control. LEAVE TO SCREEN 0. WHEN 'EXIT'. PERFORM free_control. LEAVE PROGRAM.

ENDCASE. ENDMODULE. *&---------------------------------------------------------------------* *& Module CLEAR_CODE OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE clear_code OUTPUT.

CLEAR ok_code. ENDMODULE. *&---------------------------------------------------------------------* *& Module INIT_ALV OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE init_alv OUTPUT.

IF go_container IS INITIAL. CREATE OBJECT go_container EXPORTING container_name = 'CONTROL_AREA' EXCEPTIONS OTHERS         = 1. IF sy-subrc <> 0. MESSAGE 'Control error' TYPE 'E'. ENDIF.

CREATE OBJECT go_alv EXPORTING i_parent = go_container. IF sy-subrc <> 0. MESSAGE 'Control error' TYPE 'E'. ENDIF.

gs_variant-report = sy-cprog. gs_variant-variant = pa_lv.

gv_save = 'X'.

CALL METHOD go_alv->set_table_for_first_display EXPORTING *       i_buffer_active               = *       i_bypassing_buffer            = *       i_consistency_check           = i_structure_name              = 'SFLIGHT' is_variant                    = gs_variant i_save                        = gv_save *       i_default                     = 'X' *       is_layout                     = *       is_print                      = *       it_special_groups             = *       it_toolbar_excluding          = *       it_hyperlink                  = *       it_alv_graphics               = *       it_except_qinfo               = *       ir_salv_adapter               = CHANGING it_outtab                     = gt_flights *       it_fieldcatalog               = *       it_sort                       = *       it_filter                     = EXCEPTIONS invalid_parameter_combination = 1 program_error                 = 2 too_many_lines                = 3 OTHERS                        = 4. IF sy-subrc <> 0. *  Implement suitable error handling here ENDIF.

ENDIF. ENDMODULE. *&---------------------------------------------------------------------* *& Form FREE_CONTROL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& -->  p1        text *& <--  p2        text *&---------------------------------------------------------------------* FORM free_control . CALL METHOD go_container->free EXCEPTIONS cntl_error        = 1 cntl_system_error = 2 OTHERS            = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF.

CALL METHOD go_alv->free EXCEPTIONS cntl_error        = 1 cntl_system_error = 2 OTHERS            = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF.

[5]
Edit
Query
Report
Ann-Marie Cayla
Spotlight Operator
Answer # 2 #

Sap provides a set of ALV (ABAP LIST VIEWER) function modules, which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options. These reports are advanced than Normal Reports.

Function Modules in ALV Reports—>

SY-CPROG - CPROG is a standard field within SAP Structure that stores Calling Program information. ABAP system field. In externally called procedures, this is the name of the calling program; otherwise it is the name of the current program. If an externally called procedure calls another external procedure, sy-cprog keeps the name of the first master program and is not set to the name of the master program of the other caller.

CODING SCREEN (DISPLAYING ALL FIELDS OF TABLE MARA) — >

OUTPUT —>

For displaying particular fields in ALV Reports —>

FIELD CATALOG —> The field catalog is a table of type LVC_T_FCAT that contains information on the fields to be displayed. For example, the ALV uses this table to identify the type of a field.

Use — You can use fields of this catalog to determine the number format and column properties of the list to be output.

NOTE--> If there is ‘T’ in field catalog structure then it is for internal table only.

CODING SCREEN—>

OUTPUT —>

Field Catalog property to colour a particular field—> EMPHASIZE

OUTPUT—>

Field Catalog property to do a sum of a particular field—>

OUTPUT—>

It is used to display the multiple records on a single output screen.

Function modules to be used—>

CODING SCREEN —>

OUTPUT—>

CODING SCREEN—>

OUTPUT —>

CODING SCREEN —>

OUTPUT —>

AFTER DOUBLE CLICKING ON ANY PURCHASING DOCUMENT NUMBER

ISHNOOR SINGH SETHI

LINKEDIN- https://www.linkedin.com/in/ishnoorsingh/

[4]
Edit
Query
Report
Create wpjl
ASSEMBLER METAL BONDING
Answer # 3 #
  • FACTORY You instantiate the main ALV class: You define the internal data table that provides the structure and content of the ALV output, as needed. You define which display type you want to use for the ALV output.
  • DISPLAY To display the ALV output on the screen, call up the method DISPLAY afterwards.
[4]
Edit
Query
Report
Mohamed Tracey
Taxidermist
Answer # 4 #

ALV reports include below in-built functions:

Main advantage of these functions is, we can avoid implementing these all the way from scratch. You can use these functions because the mechanism we are using to develop an ALV report is standard function modules provided by SAP.

Below are the three types of ALV Reports in SAP ABAP:

At the early stages of SAP, we used the REUSE_ALV_LIST_DISPLAY function module to display an ALV list. With the rise of object-oriented programming now we can use the REUSE_ALV_GRID_DISPLAY function module to display an ALV grid. Though performance wise ALV grid display is below par from the ALV list display, developers tend to use ALV grid display mostly.

We can use the REUSE_ALV_FIELDCATALOG_MERGE function module to create a field catalog from an internal table or dictionary structure. By the way you don’t need to use this function module if you are selecting all the fields from one table.

Let’s assume that the user needs to view two or more reports in a single screen. How do you do that? Well, the solution is to benefit from Blocked ALV reports. Below function modules can be used to develop Blocked ALV reports.

Then there is another type of ALV Report called Sequential ALV Reports. You can use these sequential reports to output header and item table details of a certain process. As an example, to process purchase orders, we can output the main header and item tables called EKKO and EKPO in a single report. With these kinds of reports users can analyze hierarchical breakdown of a process. The REUSE_ALV_HIERSEQ_LIST_DISPLAY function module can be used for this purpose.

Moving on to the limitations of ALV reports in SAP there are some. Below are those limitations:

So far, we identified types of SAP ALV reports, pros, and cons of them. Let’s check on how to create a simple ALV report in SAP ABAP.

First, you need to create a program to develop the ALV report. You need to go to the transaction code SE38 called ABAP Editor and type a program name starting with ‘Z’ since this is a customizing program. Then you can click the create button. Check whether the Source Code option is already selected from the sub objects box before clicking on the create button.

In the Program Attributes window, type a descriptive name for the report in the Title text box. Select Executable program from Attributes box. Then click on the Save button. You will direct to the Object Directory Entry window after that. Here you can type the Package name in the Package text box in the Attributes box. After that you can click the Save button with the save icon.

Then, there is a window for a Transportable Workbench Request. Select the Transport Request from there and click on Okay button with green tick icon. Now, you will direct to ABAP Editor and let’s develop an ALV report using SAP standard function modules.

Requirement is to display records in the VBAP table in the ALV report.

First, you need to define VBAP as a table since you need to define a type using VBAP table fields after that. Then you can define a type called ty_vbap and include the fields in the VBAP table. Let’s include table fields vbeln, posnr, matnr, matkl, arktx, netwr, waerk, klmeng and vrkme. Table declaration and type declaration is done. Then we’ll move to the data declaration part.

For this part you need to define an internal table called lt_vbap using the type ty_vbap. With internal tables always comes a work area. Define ls_vbap work area using the type ty_vbap. Then we’ll define the field catalog of the ALV report. You need to define an internal table called lt_fieldcat using SAP standard type slis_t_fieldcat_alv and a work area called ls_fieldcat using SAP standard type slis_fieldcat_alv.

Data declaration part is also over now. You can name the definitions as you wish. But we are following the general coding standards. It will be very easy to identify definitions if you follow them.

Moving on to the selection screen. You can create a selection screen block called b1 and include select options as you wish. We’ll define two select options called so_vbeln and so_matnr for vbeln and matnr table fields in the VBAP table.

Now, we can fetch data from the VBAP table selecting relevant fields in the internal table. Don’t forget to filter out the select options using where clause. Here comes the filling out field catalog for ALV report in SAP. Since there are nine table fields that need to fill column position, field name, table name, and selection text one by one using ls_fieldcat. There are some important things to note when filling out a field catalog.

Now comes the most important part. Calling the SAP standard function module called REUSE_ALV_GRID_DISPLAY. Pass i_callback_program exporting parameter sy-repid system variable value and it_fieldcat exporting parameter lt_fieldcat to field catalog. Pass table lt_vbap to tables and pass exceptions too in case of a failure.

If sy-subrc value is not equal to zero, you can implement suitable error handling. Better to add an error message with the relevant exception.

You can check out the sample ABAP code for your reference.

[3]
Edit
Query
Report
Karanvir Sethi
SHAKER REPAIRER
Answer # 5 #

Create ALV Report in SAP ABAP. First, you need to create a program to develop the ALV report. You need to go to the transaction code SE38 called ABAP Editor and type a program name starting with 'Z' since this is a customizing program. Then you can click the create button.

[3]
Edit
Query
Report
Abbe Christman
Quality Improvement