banner



How To Display Output In Sap Abap

ALV Report in SAP ABAPALV Report is one of the many ways of displaying SAP table data in a reporting mode. Acronym ALV stands for ABAP List Viewer. ALV Report in SAP ABAP are very commonly used in many standard and custom SAP transaction across unlike SAP modules.

ALV reports include below in-built functions:

  • Sorting of records.
  • Filtering of records.
  • Totaling of records when at that place is a quantity cavalcade.
  • Sub totaling of records when there is a quantity cavalcade.
  • Hiding columns.
  • Irresolute guild of columns.
  • Downloading report in Excel or HTML format.

Main advantage of these functions is, we tin avoid implementing these all the manner from scratch. Yous tin use these functions because the mechanism we are using to develop an ALV report is standard function modules provided past SAP.

Types of ALV Reports in SAP

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

  • Uncomplicated ALV Report.
  • Blocked ALV Report.
  • Hierarchical ALV Report.

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

We can apply the REUSE_ALV_FIELDCATALOG_MERGE function module to create a field catalog from an internal table or dictionary construction. By the manner you don't need to use this role module if y'all are selecting all the fields from one table.

Let's assume that the user needs to view two or more than 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.

  • REUSE_ALV_BLOCK_LIST_INIT
  • REUSE_ALV_BLOCK_LIST_APPEND
  • REUSE_ALV_BLOCK_LIST_DISPLAY

Then there is some other type of ALV Report called Sequential ALV Reports. You lot 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 written report. With these kinds of reports users tin can analyze hierarchical breakdown of a process. The REUSE_ALV_HIERSEQ_LIST_DISPLAY function module can be used for this purpose.

Limitations of ALV Reports

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

  • Maximum of 255 characters can be shown on a cavalcade of a study.
  • Maximum of ninety columns tin can be displayed on a single report.
  • ALV listing display is more efficient than ALV filigree display because the number of records can exist shown on one become.

And so far, nosotros identified types of SAP ALV reports, pros, and cons of them. Permit'southward check on how to create a simple ALV report in SAP ABAP.

Create ALV Report in SAP ABAP

Showtime, you lot need to create a program to develop the ALV report. Y'all need to get to the transaction lawmaking SE38 chosen ABAP Editor and blazon a plan name starting with 'Z' since this is a customizing program. Then yous can click the create push. Bank check whether the Source Code option is already selected from the sub objects box before clicking on the create button.

In the Programme Attributes window, type a descriptive name for the written report in the Championship text box. Select Executable program from Attributes box. Then click on the Save button. You will direct to the Object Directory Entry window afterwards that. Here yous can type the Packet proper name in the Packet text box in the Attributes box. Later that yous can click the Salve push with the save icon.

Then, at that place is a window for a Transportable Workbench Request. Select the Transport Request from there and click on Okay push with green tick icon. At present, you will direct to ABAP Editor and let's develop an ALV report using SAP standard part modules.

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

First, y'all demand to define VBAP as a tabular array since y'all need to define a blazon using VBAP table fields after that. Then you tin can ascertain a blazon 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 proclamation is done. Then we'll move to the data declaration office.

For this part yous demand to define an internal table called lt_vbap using the type ty_vbap. With internal tables ever comes a work area. Ascertain ls_vbap work area using the blazon ty_vbap. And then we'll define the field catalog of the ALV written report. You need to ascertain an internal table chosen 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 proclamation part is also over now. You tin name the definitions as you lot wish. Just we are following the general coding standards. Information technology will be very easy to identify definitions if y'all follow them.

Moving on to the option screen. You can create a option screen cake called b1 and include select options as you wish. We'll define ii select options chosen so_vbeln and so_matnr for vbeln and matnr table fields in the VBAP table.

Now, nosotros 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. Hither comes the filling out field catalog for ALV report in SAP. Since there are 9 tabular array fields that demand to fill cavalcade position, field name, table name, and selection text one past one using ls_fieldcat. There are some important things to note when filling out a field catalog.

  • Make full field name using majuscule letters.
  • Tabular array name should be the internal tabular array name.
  • Keep in heed to fill the key attribute for the key field as Ten.
  • Append ls_fieldcat to lt_fieldcat later filling for one field.
  • Clear ls_fieldcat once it appended to lt_fieldcat.

Now comes the most important part. Calling the SAP standard role module chosen 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 laissez passer exceptions too in instance of a failure.

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

Sample Lawmaking of ALV Report in SAP ABAP

Yous can bank check out the sample ABAP code for your reference.

REPORT ztesting.          *Tabular array Announcement          TABLES: vbap.          *Type Annunciation          TYPES : Brainstorm OF ty_vbap,  vbeln TYPE vbap-vbeln, posnr TYPE vbap-posnr, matnr Type vbap-matnr, matkl TYPE vbap-matkl, arktx TYPE vbap-arktx, netwr Blazon vbap-netwr, waerk Blazon vbap-waerk, klmeng Type vbap-klmeng, vrkme TYPE vbap-vrkme,  END OF ty_vbap.          *Data Announcement          DATA : lt_vbap TYPE STANDARD TABLE OF ty_vbap, ls_vbap Blazon ty_vbap.  DATA : lt_fieldcat TYPE slis_t_fieldcat_alv, ls_fieldcat Type slis_fieldcat_alv, v_repid Like sy-repid.          *Selection Screen          Choice-SCREEN Brainstorm OF BLOCK b1 WITH FRAME Championship TEXT-002. SELECT-OPTIONS: so_vbeln FOR vbap-vbeln, so_matnr FOR vbap-matnr. Selection-SCREEN END OF Block b1.  Beginning-OF-Option.          *Data Fetching          SELECT vbeln  posnr matnr matkl arktx netwr waerk kimeng vrkme  FROM vbap INTO Tabular array lt_vbap WHERE vbeln IN so_vbeln AND matnr IN so_matnr.          *Field Catalog          Clear ls_fieldcat. ls_fieldcat-col_pos = 1. ls_fieldcat-fieldname = 'VBELN'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'SD NO.'. ls_fieldcat-key = 'X'. APPEND ls_fieldcat TO lt_fieldcat.  Clear ls_fieldcat. ls_fieldcat-col_pos = 2. ls_fieldcat-fieldname = 'POSNR'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'ITEM NO.'. Append ls_fieldcat TO lt_fieldcat.  CLEAR ls_fieldcat. ls_fieldcat-col_pos = 3. ls_fieldcat-fieldname = 'MATNR'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'MATERIAL NO.'. Suspend ls_fieldcat TO lt_fieldcat.  Articulate ls_fieldcat. ls_fieldcat-col_pos = iv. ls_fieldcat-fieldname = 'MATKL'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'Material Group'. APPEND ls_fieldcat TO lt_fieldcat.  CLEAR ls_fieldcat. ls_fieldcat-col_pos = 5. ls_fieldcat-fieldname = 'ARKTX'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'Description'. Suspend ls_fieldcat TO lt_fieldcat.  CLEAR ls_fieldcat. ls_fieldcat-col_pos = half-dozen. ls_fieldcat-fieldname = 'NETWR'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'Amount'. APPEND ls_fieldcat TO lt_fieldcat.  CLEAR ls_fieldcat. ls_fieldcat-col_pos = vii. ls_fieldcat-fieldname = 'WAERK'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'CURRENCY'. APPEND ls_fieldcat TO lt_fieldcat.  Clear ls_fieldcat. ls_fieldcat-col_pos = 8. ls_fieldcat-fieldname = 'KLMENG'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'QUANTITY'. APPEND ls_fieldcat TO lt_fieldcat.  Articulate ls_fieldcat. ls_fieldcat-col_pos = nine. ls_fieldcat-fieldname = 'VRKME'. ls_fieldcat-tabname = 'IT_VBAP'. ls_fieldcat-seltext_m = 'SALES UNIT'. Suspend ls_fieldcat TO lt_fieldcat.  Phone call FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid it_fieldcat = lt_fieldcat TABLES t_outtab = lt_vbap EXCEPTIONS program_error = 1 OTHERS = 2.  IF sy-subrc <> 0.          * Implement suitable error handling here          ENDIF.

Did you like this tutorial? Have any questions or comments? We would love to hear your feedback in the comments section beneath. It'd exist a large help for us, and hopefully it's something we can address for you in improvement of our free SAP ABAP tutorials.

Source: https://erproof.com/abap/sap-abap-training/alv-report-in-sap-abap/

0 Response to "How To Display Output In Sap Abap"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel