Friday, May 2, 2014

How to Create ALV Interactive Report Using OOABAP

How to Create ALV Interactive Report Using OOABAP Tutorial, welcome to SAP ABAP Interview Questions. 

Creating ALV Interactive Report Using OOABAP


Let's find the tutorial on creating ALV interactive report by using object oriented advanced business applications programming source code.


OOABAP Tutorial How to Create ALV Interactive Report

Here in this post sapabapiq.com, presenting a ALV report program on how to create ALV Interactive Report using Object Oriented ABAP programming language. Just copy this below code and paste it in ABAP Editor, and debug the source code to understand functionality of this ABAP report clearly.


OOABAP ALV Interactive Report Source Code:


TYPES:

    BEGIN OF TW_XRESULT,
            TEXT      TYPE ZSDTYPE,
            VBELN    TYPE VBELN,
            ERNAM   TYPE ERNAM,
            PERSRB   TYPE ZPERS_RESP,
            ERDAT     TYPE ERDAT,
            VKORG     TYPE VKORG,
            VTWEG    TYPE VTWEG,
            SPART      TYPE SPART,
            VKBUR     TYPE VKBUR,
            VKGRP     TYPE VKGRP,
            VBTYP     TYPE VBTYP,
            FEHLER     TYPE ZNUMBER,
            NETWR     TYPE NETWR_AK,
            UVALL       TYPE UVALL,
            UVVLK      TYPE UVVLK,
            UVFAK     TYPE UVFAK,
            UVPRS     TYPE UVPRS,
            T_COLOR  TYPE LVC_T_SCOL,     "For row color
          END OF TW_XRESULT .


TYPES:

  TT_RESULT  TYPE STANDARD TABLE OF TW_XRESULT .


2. REGISTER THE EVENTS FOR WHICH YOU NEED TO ACT UPON.

METHOD ALV_SET_EVENTS.

  DATA: LR_EVENTS TYPE REF TO CL_SALV_EVENTS_TABLE.
  LR_EVENTS = MCN_ALV-> GET_EVENT().

*- Register the event Double click
  SET HANDLER ME->MT_ON_DOUBLE_CLICK FOR LR_EVENTS.


*- Register the event User command
  SET HANDLER ME->MT_ON_USER_COMMAND FOR LR_EVENTS.
ENDMETHOD.                    "ALV_SET_EVENTS

*3. ONCE THE REQUIRED DATA IS FETCHED INTO THE INTERNAL TABLE (SAY, INTO INTERNAL TABLE MT_RESULT), WE USE THE FOLLOWING CODE, TO DISPLAY THE RECORDS WITH PROVISION TO SELECT MULTIPLE RECORDS (THROUGH THE SELECTION PUSHBUTTON ON THE LEFT FOR EACH RECORD)
METHOD ALV_SHOW .
  DATA : LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
  FIELD-SYMBOLS: <FS_DATA> TYPE STANDARD TABLE.


*- Show ALV on the screen
  ASSIGN ME->MN_DATA->* TO <FS_DATA>.
  CHECK <FS_DATA> IS ASSIGNED.
  TRY.
      CL_SALV_TABLE=>FACTORY( EXPORTING LIST_DISPLAY = ABAP_FALSE
                              IMPORTING R_SALV_TABLE = MCN_ALV
                               CHANGING T_TABLE = <FS_DATA> ).
    CATCH CX_SALV_MSG INTO MCN_ALV_EXCEPTION.
      MESSAGE MCN_ALV_EXCEPTION TYPE 'E'.
      EXIT.
  ENDTRY.

  ME->ALV_SET_FUNCTIONS( ).
  ME->ALV_SET_COLUMNS( ).
  ME->ALV_SET_LAYOUT( MF_VARIANTNAME ).
  ME->ALV_SET_EVENTS( ).
  ME->ALV_SET_HEADERS( ).

  CALL METHOD ALV_MODIFY_SETTINGS( ).
  LR_SELECTIONS = MCN_ALV->GET_SELECTIONS( ).
  LT_ROWS = LR_SELECTIONS->GET_SELECTED_ROWS().      " This will get the selected record numbers, in lt_rows.


*- Set selection mode

  LR_SELECTIONS->SET_SELECTION_MODE( IF_SALV_C_SELECTION_MODE=>ROW_COLUMN ).
  MCN_ALV->SET_SCREEN_STATUS(
  PFSTATUS      =  'ZREPINCOMP'
  REPORT        =  MF_REPID
  SET_FUNCTIONS = MCN_ALV->C_FUNCTIONS_ALL ).
  MCN_ALV->DISPLAY( ).
ENDMETHOD.                    "ALV_SET_EVENTS


*4. WITH THE ABOVE CODE, YOU WILL BE ABLE TO SELECT MULTIPLE RECORDS, AND THEN THE FOLLOWING CODE WILL PROCESS THE SELECTED RECORDS, AND SET A COLOR FOR THE PROCESSED RECORDS.
DATA:   LW_ROW        TYPE I,
     LT_COLOR TYPE LVC_T_SCOL ,
     LS_COLOR TYPE LVC_S_SCOL .
FIELD-SYMBOLS: <FS_RESULT> TYPE TW_XRESULT.                 "#EC NEEDED
LOOP AT LT_ROWS INTO LW_ROW.
  READ TABLE MT_RESULT ASSIGNING <FS_RESULT> INDEX LW_ROW.
  IF SY_SUBRC EQ 0.

*    <CODE FOR PROCESSING YOUR SELECTED RECORD>

*- For setting the color to the record

    CLEAR LT_COLOR.
    CLEAR LS_COLOR.
    LS_COLOR-COLOR-COL = CO_COLOR.
    LS_COLOR-COLOR-INT = 0.
    LS_COLOR-COLOR-INV = 0.
    APPEND LS_COLOR TO LT_COLOR.
    <FS_RESULT>-T_COLOR =  LT_COLOR.
  ENDIF.
ENDLOOP.






"You found the information helpful and want to say thanks? Your donation is enough to inspire us to do more. Thanks a bunch!"

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Categories

ABAP (1) ABAP Interview Questions (112) ABAP Open SQL Statements (1) ABAP Syntax Rules (6) ABAP WORKBENCH (2) ABAP-Interview-Questions (52) ALE IDOC (6) ALE IDOC Interview Questions (6) ale-idoc (6) ALE-IDOC-Interview-Questions (19) ALV Interview Questions (5) ALV-Interview-Questions (22) BADI (2) BAPI (1) BAPI Interview Questions (1) BAPI-Interview-Questions (14) BDC (6) BDC Interview Questions (6) BDC-Interview-Questions (9) big data (2) big data interview questions (1) Classical Reports Interview Question (3) Classical-Reports-Interview-Questions (22) Conditional Statements (1) Cross Applications (3) Cross-Applications (14) Data Dictionary (22) Data Type Questins (1) Data types (1) Data-Dictionary (48) Data-Type-Questins (6) Dialog programming (5) Dialog Programming Interview Questions (4) Dialog-Programming (30) DOMAIN Interview Questions (1) Domain-Interview-Questions (8) Function Module (2) hadoop (2) hadoop interview questions (2) hdfs (1) IDoc Tutorials (6) Interactive Report Interview Questions (4) Interactive-Reports-Interview-Questions (22) Internal Tables (1) interview questions (1) Lock Object Interview Questions (1) Lock-Objects-Interview-Questions (10) Logical Database (1) Modularization Interview Questions (4) Modularization-Interview-Questions (25) Module Pool Programming (5) Module-Pool-Programming (39) modules in sap (1) Object Oriented ABAP (19) Object Oriented ABAP Interview Questions (15) object-oriented-abap (2) Object-Oriented-ABAP-Interview-Questions (34) OOABAP (9) Reports (14) Reports Interview Questions (9) Reports-Interview-Questions (19) RFC (1) RFC Interview Questions (1) RFC-Interview-Questions (14) RICEF (1) RICEF Objects (1) SAP (4) SAP ABAP (4) SAP ABAP Interview Questions (42) SAP ABAP Introduction (46) SAP ABAP Message Types (2) SAP BADI Interview Questions (2) SAP Basics (71) SAP Books (2) SAP Certification (1) SAP CONSULTANTS (5) SAP CRM (1) SAP ENHANCEMENTS (3) SAP EXITS (2) SAP EXITS ( SAP ENHANCEMENTS ) Interview Questions (1) SAP Free Books (1) SAP HR (2) SAP Lock Object (1) sap modules (2) SAP Open SQL Statements (1) SAP R/3 Architecture (4) SAP Search help (1) SAP Smartforms (1) SAP Smartforms Interview Questions (2) SAP Tables (5) SAP Tcodes (10) SAP Views (1) SAP Webdynpro ABAP (12) SAP Work Processors (2) SAP Workflow (3) SAP-BADI-Interview-Questions (11) SAP-Enhancements (39) SAP-Exits (39) SAP-Exits-Enhancements-Interview Questions (3) SAP-HANA (1) SAP-HANA-Interview-Questions (1) SAP-Smartforms-Interview-Questions (2) SAP-Workflow (3) Scripts (3) Scripts Interview Questions (2) Scripts-Interview-Questions (32) Search Help Interview Questions (1) Search-Help-Interview-Questions (9) Smartforms (1) Table Maintenance Generator (1) Table-Maintenance-Generator (4) Tables in SAP (2) Tables Interview Questions (3) Tables-Interview-Questions (3) Type Group Interview Questions (1) Type-Group-Interview-Questions (7) Variable Declaration (1) Views Interview Questions (1) Views-Interview-Questions (5) Webdynpro (12) what is big data (1)

Protected Blog

 
This blog is not affiliated to SAP AG |SAP is trademark of SAP AG |The information collected from various sources use information with your own risk.