demo program on interactive alv

59
Demo program on interactive ALV By Swarna S, Tata Consultancy Services *&---------------------------------------------------------------------* *& Report z_tcoderefresh * *& Author : Swarna.S. * * Published at SAPTechnical.COM *&---------------------------------------------------------------------* *& AS : ALV report displaying all the transaction codes in SAP *& User can click any tcode on ALV and go to the same .The ALV displays *& first 25 records and on refreshing displays the next set *& of 25 records and so on *& * *&---------------------------------------------------------------------* REPORT zalv_tcoderefresh. *type pools for alv declarations TYPE-POOLS: slis. *structure declaration for tstc table TYPES : BEGIN OF ty_tstc, tcode TYPE tcode, pgmna TYPE program_id, dypno TYPE dynpronr, END OF ty_tstc. * Internal table and workarea declarations for tstc DATA: it_tstc TYPE STANDARD TABLE OF ty_tstc, wa_tstc TYPE ty_tstc. *data declarations for ALV DATA: it_layout TYPE slis_layout_alv, wa_fieldcat TYPE slis_fieldcat_alv, it_fieldcat TYPE slis_t_fieldcat_alv, it_eventexit TYPE slis_t_event_exit, wa_eventexit TYPE slis_event_exit. *initialisation event INITIALIZATION. *start of selection event START-OF-SELECTION. *subroutine to fetch data from the db table PERFORM fetch_data. *subroutine for output display PERFORM alv_output. *&---------------------------------------------------------------------* *& Form fetch_data *&---------------------------------------------------------------------* * *subroutine to fetch data from the db table *----------------------------------------------------------------------*

Upload: saranya-shanmugam

Post on 21-Jul-2016

78 views

Category:

Documents


1 download

DESCRIPTION

abap alv demo

TRANSCRIPT

Page 1: Demo Program on Interactive ALV

Demo program on interactive ALVBy Swarna S, Tata Consultancy Services

*&---------------------------------------------------------------------**& Report z_tcoderefresh **& Author : Swarna.S. ** Published at SAPTechnical.COM*&---------------------------------------------------------------------**& AS : ALV report displaying all the transaction codes in SAP*& User can click any tcode on ALV and go to the same .The ALV displays*& first 25 records and on refreshing displays the next set*& of 25 records and so on*& **&---------------------------------------------------------------------*REPORT zalv_tcoderefresh.*type pools for alv declarationsTYPE-POOLS: slis.*structure declaration for tstc tableTYPES : BEGIN OF ty_tstc, tcode TYPE tcode, pgmna TYPE program_id, dypno TYPE dynpronr, END OF ty_tstc.* Internal table and workarea declarations for tstcDATA: it_tstc TYPE STANDARD TABLE OF ty_tstc, wa_tstc TYPE ty_tstc.*data declarations for ALVDATA: it_layout TYPE slis_layout_alv, wa_fieldcat TYPE slis_fieldcat_alv, it_fieldcat TYPE slis_t_fieldcat_alv, it_eventexit TYPE slis_t_event_exit, wa_eventexit TYPE slis_event_exit.*initialisation eventINITIALIZATION.*start of selection eventSTART-OF-SELECTION.*subroutine to fetch data from the db table PERFORM fetch_data.*subroutine for output display PERFORM alv_output.*&---------------------------------------------------------------------**& Form fetch_data*&---------------------------------------------------------------------** *subroutine to fetch data from the db table*----------------------------------------------------------------------*FORM fetch_data.*Internal table and work area declaratin for TSTC (local tables) DATA : lt_tstc TYPE STANDARD TABLE OF ty_tstc, ls_tstc TYPE ty_tstc.*Static field definition*Reads the last tcode and stores it in l_tstc that on refresh further data*beyond this value is fetched STATICS l_tstc TYPE tcode.* Selection from the tstc table

Page 2: Demo Program on Interactive ALV

*we select till 25 rows and on further refresh next 25 are selected*we select transactions having screen numbers only SELECT tcode pgmna dypno FROM tstc INTO CORRESPONDING FIELDS OF TABLE lt_tstc UP TO 25 ROWS WHERE tcode GT l_tstc AND dypno NE '0000'.* Code for transferring the values of local table to output table* for 25 rows as sy-tfill is 25.*In case there are no records a message pops up. IF sy-subrc EQ 0. DESCRIBE TABLE it_tstc. READ TABLE lt_tstc INTO ls_tstc INDEX sy-tfill. l_tstc = ls_tstc-tcode. it_tstc[] = lt_tstc[]. ELSE. MESSAGE 'No Records found ' TYPE 'i'. ENDIF.ENDFORM. "read_data*&---------------------------------------------------------------------**& Form alv_output*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*FORM alv_output.*subroutine to refresh alv PERFORM event_exits.*field catalogue PERFORM build_fieldcat.*Layout for alv PERFORM build_layout.*output display PERFORM alv_display.ENDFORM. "alv_output*&---------------------------------------------------------------------**& Form event_exits*&---------------------------------------------------------------------** text*----------------------------------------------------------------------**subroutine to refresh alvFORM event_exits. CLEAR wa_eventexit. wa_eventexit-ucomm = '&REFRESH'. " Refresh wa_eventexit-after = 'X'. APPEND wa_eventexit TO it_eventexit.ENDFORM. "event_exits*&---------------------------------------------------------------------**& Form build_fieldcat*&---------------------------------------------------------------------** text*----------------------------------------------------------------------**Field catalogueFORM build_fieldcat. CLEAR wa_fieldcat.

Page 3: Demo Program on Interactive ALV

wa_fieldcat-row_pos = '1'. wa_fieldcat-col_pos = '1'. wa_fieldcat-fieldname = 'TCODE'. wa_fieldcat-tabname = 'it_tstc'. wa_fieldcat-seltext_m = 'TRANSACTION'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-row_pos = '1'. wa_fieldcat-col_pos = '2'. wa_fieldcat-fieldname = 'PGMNA'. wa_fieldcat-tabname = 'it_tstc'. wa_fieldcat-seltext_m = 'PROGRAM'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-row_pos = '1'. wa_fieldcat-col_pos = '3'. wa_fieldcat-fieldname = 'DYPNO'. wa_fieldcat-tabname = 'it_tstc'. wa_fieldcat-seltext_m = 'SCREEN'. APPEND wa_fieldcat TO it_fieldcat.ENDFORM. "build_fieldcat*&---------------------------------------------------------------------**& Form build_layout*&---------------------------------------------------------------------** text*----------------------------------------------------------------------**LayoutFORM build_layout. it_layout-zebra = 'X'. it_layout-colwidth_optimize = 'X'.ENDFORM. "build_layout*&---------------------------------------------------------------------**& Form alv_display*&---------------------------------------------------------------------** text*----------------------------------------------------------------------**ALV outputFORM alv_display. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND' i_callback_pf_status_set = 'PFSTATUS' it_fieldcat = it_fieldcat is_layout = it_layout it_event_exit = it_eventexit i_screen_start_column = 10 i_screen_start_line = 20 i_screen_end_column = 70 i_screen_end_line = 45 i_grid_title = 'Call Tcode Refresh ALV' TABLES t_outtab = it_tstc.ENDFORM. "alv_display*&---------------------------------------------------------------------**& Form user_command*&---------------------------------------------------------------------*

Page 4: Demo Program on Interactive ALV

* text*----------------------------------------------------------------------**User actions on ALVFORM user_command USING r_ucomm TYPE sy-ucomm rs_selfield TYPE slis_selfield. CASE r_ucomm.*User clicks a transaction code and that tcode is called from ALV WHEN '&IC1'. READ TABLE it_tstc INDEX rs_selfield-tabindex INTO wa_tstc. IF sy-subrc = 0. CALL TRANSACTION wa_tstc-tcode. ENDIF.*user clicks the refresh button and the next 25 records are displayed WHEN '&REFRESH'. PERFORM fetch_data. rs_selfield-refresh = 'X'. rs_selfield-col_stable = 'X' . rs_selfield-row_stable = 'X' . ENDCASE.ENDFORM. "user_command*---------------------------------------------------------------------** FORM PFSTATUS **---------------------------------------------------------------------**Form for settings the pf status to the alvFORM pfstatus USING ut_extab TYPE slis_t_extab. SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'.ENDFORM. " PF_STATUS_SET

Output

Page 5: Demo Program on Interactive ALV

 

Click on this Refresh button, the next set of 25 records are displayed  

Click on any transaction, and it takes you to that particular transaction.

Page 6: Demo Program on Interactive ALV

Tutorial on Interactive Reports in ALV List/Grid

Here is the Interactive Report for ALV's.

Below code contains few Function Modules related to ALV's.Just go through the below code where i have mentioned proper comments. Which helps you to make your work easy.

REPORT ZALV_INTERACTIVE_REPORT2.

*//TABLES DECLARATIONTABLES: MARA.

*// FUNCTION GROUP TO HOLD ALV EVENTSTYPE-POOLS: SLIS.

*//TYPES DECLARATION FOR MARA TABLETYPES: BEGIN OF TY_MARA, MATNR TYPE MARA-MATNR,"MATERIAL NUMBER ERSDA TYPE MARA-ERSDA,"CREATED ON ERNAM TYPE MARA-ERNAM,"CREATED BY END OF TY_MARA.

DATA: IT_MARA TYPE STANDARD TABLE OF TY_MARA, WA_MARA TYPE TY_MARA.

*//TYPES DECLARATION FOR MARC TABLETYPES: BEGIN OF TY_MARC, MATNR TYPE MARC-MATNR,"MATERIAL NUMBER WERKS TYPE MARC-WERKS,"PLANT PSTAT TYPE MARC-PSTAT,"STATUS END OF TY_MARC.

DATA: IT_MARC TYPE STANDARD TABLE OF TY_MARC, WA_MARC TYPE TY_MARC.

*//DECLARATIONS FOR FIELDCATALOGSDATA: IT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,

Page 7: Demo Program on Interactive ALV

WA_FCAT1 TYPE SLIS_FIELDCAT_ALV.

DATA: IT_FCAT2 TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT2 TYPE SLIS_FIELDCAT_ALV.

*//VARIABLE TO HOLD REPORT NAME*//USED IN FUNCTION MODULE REUSE_ALV_GRID_DISPLAYDATA: V_REPID TYPE SY-REPID VALUE 'ZALV_INTERACTIVE_REPORT2'.

*//TABLE AND WORKAREA FOR CATCHING EVENTS*//USED IN FUNCTION MODULE REUSE_ALV_EVENTS_GETDATA: IT_EVENTS TYPE SLIS_T_EVENT, WA_EVENTS TYPE SLIS_ALV_EVENT.

*//ALV LIST HEADER*//USED IN FUNCTION MODULE REUSE_ALV_COMMENTRY_WRITEDATA: IT_LISTHEADER1 TYPE SLIS_T_LISTHEADER, IT_LISTHEADER2 TYPE SLIS_T_LISTHEADER.

*//VARIABLES FOR READING DOUBLE CLICK EVENTSDATA: R_UCOMM TYPE SY-UCOMM, RS_SELFIELD TYPE SLIS_SELFIELD.

*//VARIABLES FOR DISPLAYING ALV GRID TITLEDATA: I_TITLE_MARA TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.DATA: I_TITLE_MARC TYPE LVC_TITLE VALUE 'SECONDARY LIST DISPLAYED'.DATA: v_layout TYPE slis_layout_alv.DATA: MATNR_VAL TYPE MARA-MATNR.

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

START-OF-SELECTION.V_REPID = SY-REPID.PERFORM BUILD_VALUES. "RETRIEVING DATAPERFORM BUILD_FCAT. "FILLING FIELD CATALOGPERFORM TOP_OF_PAGE. "TOP OF PAGEPERFORM GET_EVENTS. "RETRIEVING EVENTS IN OUR REPORTPERFORM POPULATE_EVENTS. "POPULATING THE REQUIRED EVENTSPERFORM DISPLAY_FCAT. "DISPLAYING FIELDCATALOGPERFORM USER_COMMAND USING R_UCOMM RS_SELFIELD. "FOR LINE SELECTION

Page 8: Demo Program on Interactive ALV

*&---------------------------------------------------------------------**& Form BUILD_VALUES*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form BUILD_VALUES .SELECT MATNR ERSDA ERNAM FROM MARA INTO TABLE IT_MARA WHERE MATNR IN S_MATNR.endform. " BUILD_VALUES*&---------------------------------------------------------------------**& Form BUILD_FCAT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form BUILD_FCAT . WA_FCAT1-TABNAME = 'IT_MARA'. WA_FCAT1-FIELDNAME = 'MATNR'. WA_FCAT1-SELTEXT_M = 'MATERIAL NO'. APPEND WA_FCAT1 TO IT_FCAT1. CLEAR WA_FCAT1. WA_FCAT1-TABNAME = 'IT_MARA'. WA_FCAT1-FIELDNAME = 'ERSDA'. WA_FCAT1-SELTEXT_M = 'CREATED ON'. APPEND WA_FCAT1 TO IT_FCAT1. CLEAR WA_FCAT1. WA_FCAT1-TABNAME = 'IT_MARA'. WA_FCAT1-FIELDNAME = 'ERNAM'. WA_FCAT1-SELTEXT_M = 'CREATED BY'. APPEND WA_FCAT1 TO IT_FCAT1. CLEAR WA_FCAT1.endform. " BUILD_FCAT

*&---------------------------------------------------------------------**& Form TOP_OF_PAGE

Page 9: Demo Program on Interactive ALV

*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form TOP_OF_PAGE .DATA: WA_LISTHEADER TYPE SLIS_LISTHEADER.

*//HEADER TEXTWA_LISTHEADER-INFO = 'ALV REPORT FOR MATERIALS'.WA_LISTHEADER-TYP = 'H'.APPEND WA_LISTHEADER TO IT_LISTHEADER1.CLEAR WA_LISTHEADER.

*//SUB-ITEMSWA_LISTHEADER-TYP = 'S'.WA_LISTHEADER-KEY = 'DATE: '.WA_LISTHEADER-INFO = SY-DATUM.APPEND WA_LISTHEADER TO IT_LISTHEADER1.CLEAR WA_LISTHEADER.

WA_LISTHEADER-TYP = 'S'.WA_LISTHEADER-KEY = 'TIME: '.WA_LISTHEADER-INFO = SY-UZEIT.APPEND WA_LISTHEADER TO IT_LISTHEADER1.CLEAR WA_LISTHEADER.

WA_LISTHEADER-TYP = 'S'.WA_LISTHEADER-KEY = 'EXECUTED BY: '.WA_LISTHEADER-INFO = SY-UNAME.APPEND WA_LISTHEADER TO IT_LISTHEADER1.CLEAR WA_LISTHEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = IT_LISTHEADER1 I_LOGO = 'VENKAT_LOGO'* I_END_OF_LIST_GRID =* I_ALV_FORM = . REFRESH IT_LISTHEADER1.

Page 10: Demo Program on Interactive ALV

endform. " TOP_OF_PAGE

*&---------------------------------------------------------------------**& Form DISPLAY_FCAT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form DISPLAY_FCAT .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = v_repid i_callback_user_command = 'USER_COMMAND' i_callback_top_of_page = 'TOP_OF_PAGE' I_GRID_TITLE = I_TITLE_MARA is_layout = v_layout it_fieldcat = it_fcat1* IS_VARIANT = VARIANT* I_SAVE = 'U' IT_EVENTS = IT_EVENTS TABLES t_outtab = IT_MARA EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.endform. " DISPLAY_FCAT*&---------------------------------------------------------------------**& Form GET_EVENTS*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form GET_EVENTS .

Page 11: Demo Program on Interactive ALV

CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING I_LIST_TYPE = 0 IMPORTING ET_EVENTS = IT_EVENTS EXCEPTIONS LIST_TYPE_WRONG = 1 OTHERS = 2 .IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.

endform. " GET_EVENTS*&---------------------------------------------------------------------**& Form POPULATE_EVENTS*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form POPULATE_EVENTS .READ TABLE IT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'TOP_OF_PAGE'.IF SY-SUBRC EQ 0. WA_EVENTS-FORM = 'TOP_OF_PAGE'. MODIFY IT_EVENTS FROM WA_EVENTS TRANSPORTING FORM WHERE NAME = WA_EVENTS-NAME. CLEAR WA_EVENTS.ENDIF.

READ TABLE IT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'USER_COMMAND'.IF SY-SUBRC EQ 0. WA_EVENTS-FORM = 'USER_COMMAND'. MODIFY IT_EVENTS FROM WA_EVENTS TRANSPORTING FORM WHERE NAME = WA_EVENTS-NAME. CLEAR WA_EVENTS.ENDIF.endform. " POPULATE_EVENTS*&---------------------------------------------------------------------**& Form USER_COMMAND

Page 12: Demo Program on Interactive ALV

*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_R_UCOMM text* -->P_TYPE text* -->P_SY_UCOMM text* -->P_RS_SELFIELD text* -->P_TYPE text* -->P_SLIS_SELFIELD text*----------------------------------------------------------------------*form USER_COMMAND using R_UCOMM RS_SELFIELD TYPE SLIS_SELFIELD .CASE R_UCOMM. WHEN '&IC1'. IF RS_selfield-FIELDNAME = 'MATNR'. READ TABLE IT_MARA INTO WA_MARA INDEX RS_selfield-tabindex. MOVE RS_SELFIELD-VALUE TO MATNR_VAL. ENDIF. PERFORM BUILD_VALUES_MARC. PERFORM BUILD_FCAT_MARC. PERFORM TOP_OF_PAGE_MARC. PERFORM GET_EVENTS_MARC. PERFORM POPULATE_EVENTS_MARC. PERFORM DISPLAY_FCAT_MARC.ENDCASE.REFRESH IT_FCAT2.endform. " USER_COMMAND*&---------------------------------------------------------------------**& Form BUILD_FCAT_MARC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form BUILD_FCAT_MARC . WA_FCAT1-TABNAME = 'IT_MARC'. WA_FCAT1-FIELDNAME = 'MATNR'. WA_FCAT1-SELTEXT_M = 'MATERIAL NUMBER'. APPEND WA_FCAT1 TO IT_FCAT2. CLEAR WA_FCAT1. WA_FCAT1-TABNAME = 'IT_MARC'. WA_FCAT1-FIELDNAME = 'WERKS'.

Page 13: Demo Program on Interactive ALV

WA_FCAT1-SELTEXT_M = 'PLANT'. APPEND WA_FCAT1 TO IT_FCAT2. CLEAR WA_FCAT1. WA_FCAT1-TABNAME = 'IT_MARC'. WA_FCAT1-FIELDNAME = 'PSTAT'. WA_FCAT1-SELTEXT_M = 'STATUS'. APPEND WA_FCAT1 TO IT_FCAT2. CLEAR WA_FCAT1.

endform. " BUILD_FCAT_MARC*&---------------------------------------------------------------------**& Form BUILD_VALUES_MARC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form BUILD_VALUES_MARC .REFRESH IT_MARC. SELECT SINGLE MATNR WERKS PSTAT FROM MARC INTO WA_MARC WHERE MATNR = MATNR_VAL.APPEND WA_MARC TO IT_MARC.CLEAR WA_MARC.endform. " BUILD_VALUES_MARC*&---------------------------------------------------------------------**& Form TOP_OF_PAGE_MARC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form TOP_OF_PAGE_MARC .DATA: WA_LISTHEADER1 TYPE SLIS_LISTHEADER.REFRESH IT_LISTHEADER1.WA_LISTHEADER1-INFO = 'ALV REPORT FOR PLANTS'.WA_LISTHEADER1-TYP = 'H'.APPEND WA_LISTHEADER1 TO IT_LISTHEADER2.CLEAR WA_LISTHEADER1.

Page 14: Demo Program on Interactive ALV

WA_LISTHEADER1-TYP = 'S'.WA_LISTHEADER1-KEY = 'DATE: '.WA_LISTHEADER1-INFO = SY-DATUM.APPEND WA_LISTHEADER1 TO IT_LISTHEADER2.CLEAR WA_LISTHEADER1.

WA_LISTHEADER1-TYP = 'S'.WA_LISTHEADER1-KEY = 'TIME: '.WA_LISTHEADER1-INFO = SY-UZEIT.APPEND WA_LISTHEADER1 TO IT_LISTHEADER2.CLEAR WA_LISTHEADER1.

WA_LISTHEADER1-TYP = 'S'.WA_LISTHEADER1-KEY = 'EXECUTED BY: '.WA_LISTHEADER1-INFO = SY-UNAME.APPEND WA_LISTHEADER1 TO IT_LISTHEADER2.CLEAR WA_LISTHEADER1.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = IT_LISTHEADER2 I_LOGO = 'VENKAT_LOGO'* I_END_OF_LIST_GRID =* I_ALV_FORM = . REFRESH IT_LISTHEADER2.endform. " TOP_OF_PAGE_MARC*&---------------------------------------------------------------------**& Form GET_EVENTS_MARC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form GET_EVENTS_MARC .CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING I_LIST_TYPE = 0 IMPORTING ET_EVENTS = IT_EVENTS

Page 15: Demo Program on Interactive ALV

EXCEPTIONS LIST_TYPE_WRONG = 1 OTHERS = 2 .IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.endform. " GET_EVENTS_MARC*&---------------------------------------------------------------------**& Form POPULATE_EVENTS_MARC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form POPULATE_EVENTS_MARC .READ TABLE IT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'TOP_OF_PAGE'.IF SY-SUBRC EQ 0. WA_EVENTS-FORM = 'TOP_OF_PAGE_MARC'. MODIFY IT_EVENTS FROM WA_EVENTS TRANSPORTING FORM WHERE NAME = WA_EVENTS-NAME. CLEAR WA_EVENTS.ENDIF.

endform. " POPULATE_EVENTS_MARC*&---------------------------------------------------------------------**& Form DISPLAY_FCAT_MARC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form DISPLAY_FCAT_MARC .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = v_repid i_callback_top_of_page = 'TOP_OF_PAGE_MARC' I_GRID_TITLE = I_TITLE_MARC is_layout = v_layout

Page 16: Demo Program on Interactive ALV

it_fieldcat = it_fcat2 TABLES t_outtab = IT_MARC EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.endform. " DISPLAY_FCAT_MARC

------------------------------------------------------------------------------------------------------------ NOTE: If you have any queries, leave comments so that i acn get back to you. Thanks.

“In this scenario, we would take an example of a material and develop an interactive report. Once you click on require “material no” on the basic list, the corresponding material information on the secondary list.”

Following is a sample interactive report developed for our demo purpose:

 REPORT  zintractive                             .

TYPES : BEGIN OF str_mard, matnr TYPE mard-matnr, lgort TYPE mard-lgort, werks TYPE mard-werks, END OF str_mard.DATA : wa_mard TYPE str_mard, it_mard TYPE TABLE OF str_mard.TYPES : BEGIN OF str_makt, matnr TYPE makt-matnr, maktg TYPE makt-maktg, END OF str_makt.DATA : wa_makt TYPE str_makt, it_makt TYPE TABLE OF str_makt.TYPES : BEGIN OF str_mara, matnr TYPE mara-matnr, ersda TYPE mara-ersda, ernam TYPE mara-ernam, laeda TYPE mara-laeda, mtart TYPE mara-mtart, matkl TYPE mara-matkl, meins TYPE mara-meins,

Page 17: Demo Program on Interactive ALV

END OF str_mara.DATA : wa_mara TYPE str_mara, it_mara TYPE TABLE OF str_mara.TYPES : BEGIN OF str_final, matnr TYPE mara-matnr, ersda TYPE mara-ersda, ernam TYPE mara-ernam, laeda TYPE mara-laeda, mtart TYPE mara-mtart, matkl TYPE mara-matkl, meins TYPE mara-meins, lgort TYPE mard-lgort, werks TYPE mard-werks, END OF str_final.DATA: wa_final TYPE str_final, it_final TYPE TABLE OF str_final.PARAMETERS : plant TYPE mard-werks, stor LIKE mard-lgort.SELECT matnr lgort werksFROM mardINTO TABLE it_mardWHERE lgort = stor AND werks = plant..SELECT matnr maktgFROM maktINTO TABLE it_makt FOR ALL ENTRIES IN it_mardWHERE matnr = it_mard-matnr AND spras = 'E'.SELECT matnr ersda ernam laeda mtart matkl meinsFROM maraINTO TABLE it_mara FOR ALL ENTRIES IN it_maktWHERE matnr = it_makt-matnr.LOOP AT it_makt INTO wa_makt. WRITE : /1 wa_makt-matnr COLOR 1, 40 wa_makt-maktg COLOR 2. HIDE wa_makt-matnr.ENDLOOP.CLEAR wa_mard-matnr.AT LINE-SELECTION. REFRESH it_final. CLEAR wa_final. ULINE. IF sy-lsind = 1. WRITE : /1 'MATERIAL NO' COLOR 2, 20 'CREATION DATE' COLOR 3, 32 'PERSON CREATED', 50 'DATE OF LIST' , 65 'MATERIALTYPE', 80 'MATGROUP' , 90 'UNITOFMEASURE', 110 'STORLOCATION' COLOR 4, 130 'PLANT' COLOR 5. ULINE. ENDIF. LOOP AT it_mara INTO wa_mara WHERE matnr = wa_makt-matnr. wa_final-matnr = wa_mara-matnr. wa_final-ersda = wa_mara-ersda. wa_final-ernam = wa_mara-ernam.

Page 18: Demo Program on Interactive ALV

wa_final-laeda = wa_mara-laeda. wa_final-mtart = wa_mara-mtart. wa_final-matkl = wa_mara-matkl. wa_final-meins = wa_mara-meins. READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_makt-matnr. wa_final-lgort = wa_mard-lgort. wa_final-werks = wa_mard-werks. APPEND wa_final TO it_final. ENDLOOP. LOOP AT it_final INTO wa_final. WRITE : /1 wa_final-matnr COLOR 2, 20 wa_final-ersda COLOR 3, 37 wa_final-ernam, 50 wa_final-laeda , 70 wa_final-mtart , 85 wa_final-matkl , 95 wa_final-meins, 115 wa_final-lgort COLOR 4, 130 wa_final-werks COLOR 5. ENDLOOP.TOP-OF-PAGE. WRITE : /1 'MATERIAL NO' COLOR 1, 40 'DISCRIPTION' COLOR 2. ULINE .

Result  

Enter the “Plant” and “Storage Location”

Press the Execute Button. 

Page 19: Demo Program on Interactive ALV

 

Double Click on require “Material No” which displays secondary list to corresponding material information. 

The result shown below 

Hi,

1.Double_click is used for Interactive reports.Eg: FORM_USER_COMMAND USING UCOMM TYPE SY-UCOMMSELFIELD TYPE SLIS_SELFIELD.

In this stmt UCOM stores FCT code where u Double click on field.

2.EDIT - It is used to Edit the Perticular field in The grid.3. Hotspot = 'x' means it will show Hand Symbol when u put cursor on that Field. By: Sateesh | 15 Mar 2012 1. DOUBLE_CLICK it is an Event.it is used for to print Interactive Report.this is mainly used in ooalv report.ex:Dc event for double_click for e_row. (e_row is parameter)

2. EDIT field is used to edit data at output screenthis is declare in Feildcat Level only.ex : EDIT = 'X'.3.Hotspot is used for Single click at Basic list.it shows Hand symbol ,it is also Declared in Fieldcat leavelHotspot = 'X'. By: nagarajut | 23 May 2012

Page 20: Demo Program on Interactive ALV

can validate input values in selection screen and which event was fired?

Answer1:We can Validate Selection Screen With the Help of the Following Events, the Event Follows the Same hierachy.

AT SELECTION-SCREEN ONAT SELECTION-SCREEN ON BLOCKAT SELECTION-SCREEN OUTPUTAT SELECTION-SCREEN.Answer2:

At selection-screen onselect stmt ------------------ where = .if sy-subrc = 0.validation success for LOw value in selection screenAt selection-screen onselect stmt-------------------- where =if sy-subrc <> 0.validation failure on high value in the selection field.elsesuccess.endif

BDC Transaction code?

Transaction code for bdc :SHDB

How to navigate basic list to secondary list?

Page 21: Demo Program on Interactive ALV

We can Navigate from basic list to secondary list with the help the event called AT LINE-SELECTION. for every Secondary List the System Field SY-LSIND increases by 1. So there will be Totally 21 list possible in SAP.

One Basic List 20 Secondary List.

Which is the First character of creating LockObject?

LockObjects always starts with character 'E'.

What is the Difference between Data Element and Domain?

Answer1:Domain: Defines the attributes such as length,type and possible value range.Data element; An intermediate object between domain and table typeAnswer2:Domain : technical attributes of dataelement is called domain.Dataelement : Symantic attributes are called dataelement.

How many types of standard SAP Internal Tables?

1)standered table

Page 22: Demo Program on Interactive ALV

2)index table3)hashed table4)sorted table

What is the Difference Between Tablecontrols and Step Loops?

Table controls have both horizontal and vertical scrollers and cursor control logic is designed implicitly.Step loops have only horizontal scrollers and cursor control logic is to be designed by the user explicitly.

What are the Events in Dialog Programs?

Events in Dialog Programming are:PBO-Process Before OutputPAI-Process AFter InputPOH-Process on Help RequestPOV-Process on Value Request

How many ways you can create Table?

User can create a Database table in two ways.

1.Top-to-bottom approach: In this approach, first fields are defined and later domain and data element are defined.2.Bottom-to-top approach: In this approach, first domain and data element are defined and later fields are defined.

Page 23: Demo Program on Interactive ALV

What are the Cluster Tables?

Cluster tables contain continuous text, for example, documentation. Several cluster tables can be combined to form a table cluster. Several logical lines of different tables are combined to form a physical record in this table type. This permits object-by-object storage or object-by-object access. In order to combine tables in clusters, at least parts of the keys must agree. Several cluster tables are stored in one corresponding table on the database.

What are function modules in LDB?

Function modules in LDB's are

getputget lateWhat are Difference Between Classical Batch Input and Call Transaction?

Answer1:

In Batch input many transactions can be executed, where as in Call transcation only one transactioin can be executed.BI is a background process, Ct can be either background or foreground .BI is Synchronous process, Ct is both Asynchronous &

Page 24: Demo Program on Interactive ALV

Synchronous.BI Sessions cannot be runed parallel.Log file is generated automaticly in BI, errors can be found through BDCMSGCOLL.Answer2:1.batch input works for multiple applications where as call transactions doen't work2.batch input has an implicit log file with it. where as call transaction doesn't have3.batch input has sy-subrc check with the database where as call transaction doesn't have so call transaction is fast.

How can you call the Sessions?

using transaction code SM35

Can you call Report in SAP Script?

Yes, we can.Just write in Line editor:/:perform f_display_report----------------------------------/:endperformTHIS PERFORM WOULD BE DECLARED IN THE PRINT PROGRAMME IN WHICH YOU CAN ALWAYS WRITE STATEMENTSUBMIT REPORT...

Page 25: Demo Program on Interactive ALV

How to Upload Logo to Layout Set and what is Program Name?

You can also upload a Logo in BMP format - it has to be saved as "%^ Colours if it is a colour Bitmap.If you don't save a colour Bitmap as 256 Colours then it will be uploaded in Black.This can be done in Smart Forms, SAPScript or Transaction SE78

es, we can generate both classical and Interactive reportS in ALV..

For classical report in ALV..Type-pools : slis.

DATA : it_Fcat type slis_T_fieldcat_Alvwa_fcat type slis_fieldcat_Alv.

Data : itab type standard table of (SOme Structure)wa like line ot itab.

Start-of-selection.Select.....

after readig data from database....

we use FM REUSE_ALV_FIELDCATALOG_MERGE

After that We display the Output

We use FM : REUSE_ALV_GRID_DISPLAY ( for Grid Format)OR

Page 26: Demo Program on Interactive ALV

REUSE_ALV_LIST_DISPLAY(for list format)******&----INTERACITVE ALV*******We take two Internal tables ...Data : itab type standard table of ty_marc (Type structure)itab1 type standard table of ty_mara(TYPE structure)

data : it_fcat type slis_t_fieldcat_alv,t_Event type slis_t_event,t_listheader type slis_t_listheader.

we use FM : REUSE_ALV_GET_EVENTThis is function Module is used to catch the EVENTs like TOP-OF-PAGE and END-OF-PAGE, USER_COMMAND....etc

For interactive Report:we will give form like

Form User_Command Using ucomm like Sy-ucommselfld type SLIS_SELFIELD,

*& we'll call this Subroutine in the FM GRID DISPLAY..

case ucomm.

when '&IC1'. " this is FunctionCode which catchs when user do some actions.READ TABLE Itab INTO WA_tab INDEX RS_SELFIELD-TABINDEX.perform buildcatlog.perform DataRetrieval.lPerform Listdisplay.Perfrom Dispaly.

endcase.

THIS IS HOW WE DO INTERACTIVE ALV...I THINK THIS WIIL U IN DOING CLASSICAL AND INTERACTIVE ALV..

Page 27: Demo Program on Interactive ALV

Classical Report : It is nothing but getting data from one or more tables and displays it on LPS formated or unformated. It is having only one screens for the output. It has not any sub list.Events like that.InitilizationsAt selection-screenStart-of-selectionsTop-of-pageEnd-of-pageEnd-of-selections

Interactive Report : Is nothing but communications between one report data to another. its having one primary list and 20 secondary list for the outputs.Events like thatAt line selectionsAt user-commandAt pt Top-of-page-during line-selections.

ALV Report : Its stands for Application line viewer, it is used for analysis purpose, it has no limitations characters for the printing. These are two types list and grid.

hi bhushan,

 

1. What is the difference b/w classical report and ALV report and in classical report can we produce output more than 255 characters?

Ans. Classical report ---Consist of one program that create a single list.This means that when list is displayed,it has to contain all data

requested,regardless of the number of details the user wants to see.This procdeure may result in extensive and cluttered list from which the user has to pick the relvent data.(desired selection much be made before hand).

 

Mian thing in classical report is it is not interactive(you will have cluttered information).

 

Page 28: Demo Program on Interactive ALV

Alv report _ IS interactive reporting (it is a set of function modules).(in alv we use both classical and interactive).

in classical report we can't produce output more than 255 characters(but in ALV we can have the report contains columns more than 255 characters in length).

 

ALV is very efficient tool for dynamically sorting and arranging the columns from a report output.

 

 

 

 

 

 

2. Did you used classes to create ALV reports and how is superior over using function modules in ALV report generation?

 

Ans. its upto you(did you use classes in ALV then say yes)

3. If we don't know the exact number of blocks to be generated then Can we generate the output with different number of blocks in

ALV reports?

4. In report if we have write statements in initialization, top of page and in start of selection then which event is first excuted and what

is the output?

ANS. TOP_OF_PAGE is triggered.

 

this event is triggered with the first WRITE statement or whenever new page is triggered. if you donts have any write statement before top-of-page or

Page 29: Demo Program on Interactive ALV

in start-of-selection then this event is not triggered.

 

 

 

5. In interactive report what is the use of exit key word?

Ans.

 

6. what are nested structures and deep structures?

7. how can we write BDC program to upload data from CSV, XL, TAB delimeter type flat files?

 

Ans use FM 'GUI_UPLOAD'(CSV/TAB is .XLS)

 

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'D:PERSONALF1.XLS'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ' ' HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

Page 30: Demo Program on Interactive ALV

VIRUS_SCAN_PROFILE =

NO_AUTH_CHECK = ' '

IMPORTING

FILELENGTH =

HEADER =

tables

data_tab = itab[]

EXCEPTIONS FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

Page 31: Demo Program on Interactive ALV

OTHERS = 17

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

 

You can also use.

 

Use GUI_UPLOAD FM with exporting parameter

has_field_separator = 'X'

8. In BDC if the flat file consist of header and multiple line items then how to upload the load, does we create a single internal table for

both header and body or different internal tables?

 

ans. To know more- /people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

 

/people/william.li/blog/2006/03/21/minimize-memory-usage-during-message-mapping-when-replicating-an-element

 

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f59730fa-0901-0010-df97-c12f071f7d3b

 

No Documentation for Mapping Function useOneAsMany (Mapping Problem)

Page 32: Demo Program on Interactive ALV

 

/people/claus.wallacher/blog/2006/04/17/replication-of-nodes-using-the-graphical-mapping-tool

 

/people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi

 

/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

 

  Re: BDC - Header with multiple line items.   

Posted: Sep 18, 2006 6:53 PM    in response to: sap innova       Reply      E-mail this post 

 

 

 

 

http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

 

 

 

When you have enter multiple line in BDC for a table control use call transaction tcode using i_bdcdata options from opt message into i_messages.

 

Check the below example.

data: lws_cnt type char2,

Page 33: Demo Program on Interactive ALV

lws_field type char15.

 

LOOP AT i_invoicing_plan INTO wa_invoicing_plan.

lws_cnt = sy-tabix.

 

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = lws_cnt

IMPORTING

output = lws_cnt .

 

CONCATENATE 'FPLT-AFDAT(' lws_cnt ')' INTO lws_field.

CONCATENATE wa_invoicing_plan-date+6(2)

wa_invoicing_plan-date+4(2)

wa_invoicing_plan-date+0(4) INTO lws_date

SEPARATED BY '.'.

PERFORM bdc_field USING lws_field lws_date.

CONCATENATE 'FPLT-FPROZ(' lws_cnt ')' INTO lws_field.

lws_perct = wa_invoicing_plan-percentage.

CONDENSE lws_perct.

PERFORM bdc_field USING lws_field lws_perct.

ENDLOOP.

 

Page 34: Demo Program on Interactive ALV

 

While calling the transaction give like this:

 

DATA: opt TYPE ctu_params.

opt-dismode = 'N'.

opt-updmode = 'A'.

opt-defsize = 'X'.

 

CALL TRANSACTION tcode

USING i_bdcdata OPTIONS FROM opt MESSAGES INTO i_messages.

 

LOOP AT i_messages.

ENDLOOP.

 

 

 

 

 

9. In call transaction and session method which method is prefered one?

Ans. it depends on data if data is small then go for call transaction method.

 

10. why can't we use call transaction method to upload large amount of data?

Ans.there are chances of many errors.

Page 35: Demo Program on Interactive ALV

 

11.what is the use of standard text in sap scripts, why can't we hard code the same information in form itself?

Ans.Assume ur company has stored some text which will printed on sapscript based on certain conditions and not taken thru driver program .

 

For eg .for a plant 1000

You have to print 'Plant is 1000 and stock is 1000'.

for plant 1010

You have to print 'Plant is 4000 and stock is 3000'.

 

Then you will create a standard text thru SO10 create a text name and id would be ST and language as EN .

 

AND YOU PLace the text You have to print 'Plant is 1000 and stock is 1000'.

and this will create one standard text and another standard text for another .

 

then in the sapscript you will check the plant

use the command in the sapscript and write

Include text name 'zzz' id ST lanuage en.

 

When you execute

Sapscript will read the include and bring the text from SO10 and print on the screen .

 

Check T-Code NACE

Page 36: Demo Program on Interactive ALV

 

Check link for more on SAP Scripts.

http://www.sap-img.com/sapscripts.htm

 

 

 

 

12.what are user exits and how can we create them?

User exits -> They are the provisions given by the sap standard program to add some extra functionality to their program .

Which will be present till there is any version change .

 

1. User exits were nothing but

subroutines

FORM/PERFORM

called from standard programs.

 

2. The FORM defintion was placed inside

an empty include file.

 

3. So It was called EVERYTIME.

and we need to MODIFY/REPAIR the

standard include .

 

Page 37: Demo Program on Interactive ALV

 

 

USER EXITS

1. Introduction:

 

User exits (Function module exits) are exits developed by SAP.

The exit is implementerd as a call to a functionmodule.

The code for the function module is writeen by the developer.

You are not writing the code directly in the function module,

but in the include that is implemented in the function module.

 

The naming standard of function modules for functionmodule exits is:

EXIT_<program name><3 digit suffix>

 

The call to a functionmodule exit is implemented as:

CALL CUSTOMER.-FUNCTION <3 digit suffix>

http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

 

For information on Exits, check these links

 

http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

http://www.sapgenie.com/abap/code/abap26.htm

http://www.sap-img.com/abap/what-is-user-exits.htm

Page 38: Demo Program on Interactive ALV

http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction

http://www.easymarketplace.de/userexit.php

http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

http://www.sappoint.com/abap/userexit.pdfUser-Exit

 

 

13. can we modify the sap provided code?

Ans. Yes,but you need to have access key and i thing you need to have permission also.

14. what are oss notes?

ans.SAP provides support in the form of Notes also and this is called OSS. Can check the link Sree provided.

 

Just for an example if you face any error in your system. Then there is error number associated with the error. Then you can search for the OSS not for the error number, and the note will give you possible solution to your problem.

 

You do have notes for any details for every thng and any thing related to SAP.

 

 

ans.YES! It is Online Suppor System from SAP. It is official.

 

Search in http://service.sap.com support portal link with keywork 'OSS' / 'OSS User Guide' to get more info and 'how to' guides.

 

Page 39: Demo Program on Interactive ALV

OSS (online support system) .You can get this support from WWW.SAP.COM site..SAP will issue OSS userid and password to the customers with each licence to their packages..Here you will get all suppost packages information and how to use the things..These kind of info you will get it..Ask your Project customer about this id.. OSS1 is the transaction code to check the oss notes from SAP...

 

 

15. what are the different types of performance techniques?

Ans. Use se30--- simply gives you an over view of the time spent on the application processing against the time spend selecting from the database.

     use sto5 _SQL trace tool ---Overview of exactly how the prog is hitting against the database and shows you the individual SQL statements used with which index was used.

16. can we do modifications on output of ALV reports, how?

ans.

 

17. what are the classes that are used in ALV reporting?

ans.Check out this tutorial

 

An Easy Reference for ALV Grid Control.pdf

 

and also demo programs in your system.

 

BCALV_GRID_*.

Check these out:

Check this for basic concepts of OOPS

ABAP Interactive Reports, here we are providing real time SAP Interactive Reports interview questions and answers. These

Page 40: Demo Program on Interactive ALV

questions are helpful in facing the interviews. These interactive reporting questions are collected from various sources, refer this post for more details and interview questions on Interactive Reporting. Click on read more to read this article.

SAP ABAP INTERACTIVE REPORTING 

ABAP Interactive Reports, here we are providing real time SAP Interactive Reports interview questions and answers. These questions are helpful in facing the interviews. These interactive reporting questions are collected from various sources, refer this post for more details and interview questions on Interactive Reporting.

1.   What is interactive reporting?

It helps you to create easy-to-read lists.  You can display an overview list first that contains general information and provide the user with the possibility of choosing detailed information that you display on further lists.

2.   What are the uses of interactive reporting?

The user can actively control data retrieval and display during the session.  Instead of an extensive and detailed list, you create a basic list with condensed information from which the user can switch to detailed displays by positioning the cursor and entering commands.  The detailed information appears in secondary lists.

3.   What are the event key words in interactive reporting?

        Event Keyword                                              Event

AT LINE-SELECTION                     Moment at which the user selects a line by double clicking on it or by positioning the cursor on it and pressing F2.

AT USER-COMMAND                    Moment at which the user presses a function key.

TOP-OF-PAGE DURING                 Moment during list processing of a                           secondary list at which a new page starts.

Page 41: Demo Program on Interactive ALV

4.   What is secondary list?

It allows you to enhance the information presented in the basic list.  The user can, for example, select a line of the basic list for which he wants to see more detailed information.  

You display these details on a secondary list.  Secondary lists may either overlay the basic list completely or you can display them in an extra window on the screen.  The secondary lists can themselves be interactive again.

5.   How to select valid lines for secondary list?

To prevent the user from selecting invalid lines, ABAP/4 offers several possibilities.  At the end of the processing block END-OF-SELECTION, delete the contents of one or more fields you previously stored for valid lines using the HIDE statement.  

At the event AT LINE-SELECTION, check whether the work area is initial or whether the HIDE statement stored field contents there.  

After processing the secondary list, clear the work area again.  This prevents the user from trying to create further secondary lists from the secondary list displayed.

6.   How to create user interfaces for lists?

The R/3 system automatically, generates a graphical user interface (GUI) for your lists that offers the basic functions for list processing, such as saving or printing the list.  If you want to include additional functionality, such as push buttons, you must define your own interface status.  

To create a new status, the Development Workbench offers the Menu Painter.  With the Menu Painter, you can create menus and application tool bars.  And you can assign Function Keys to certain functions.  At the beginning of the statement block of AT END-OF-SELECTION, active the status of the basic list using the statement: SET PF-STATUS ‘STATUS’.

7.   What is interactive reporting?

A classical non-interactive report consists of one program that creates a single list.  Instead of one extensive and detailed list, with interactive reporting you create basic list from which the user can call detailed information by positioning the cursor and entering commands.  Interactive reporting thus reduces information retrieval to the data actually required.

8.   Can we call reports and transactions from interactive reporting lists?

Page 42: Demo Program on Interactive ALV

Yes.  It also allows you to call transactions or other reports from lists.  These programs then use values displayed in the list as input values.  

The user can, for example, call a transaction from within a list of change the database table whose data is displayed in the list.

9.   What are system fields for secondary lists?

SY-LSIND           Index of the list created during the current event (basic list = 0)

SY-LIST1             Index of the list level from which the event was triggered.

SY-LILL1             Absolute number of the line from which the event was triggered.

SY-LISEL                        Contents of the line from which the event was triggered.

SY-CUROW        Position of the line in the window from which the event was triggered   (counting starts with 1)

SY-CUCOL          Position of the column in the window from which the event was triggered             (counting starts with 2).

SY-CPAGE          Page number of the first displayed page of the list from which the event was triggered.

SY-STARO          Number of the first line of the first page displayed of the list from which the event was triggered (counting starts with 1).  Possibly, a page header occupies this line.

SY-STACO          Number of the first column displayed in the list from which the event was triggered (counting starts with 1).

SY-UCOMM        Function code that triggered the event.

SY-PFKEY           Status of the displayed list.

10. How to maintain lists?

To return from a high list level to the next-lower level (SY-LSIND), the user chooses Back on a secondary list. 

The system then releases the currently displayed list and activates the list created one step earlier.  The system deletes the contents of the released list.  

Page 43: Demo Program on Interactive ALV

To explicitly specify the list level, into which you want to place output, set the SY-lsind field.  The system accepts only index values, which correspond to existing list levels. 

It then deletes all existing list levels whose index is greater or equal to the index specify.  For example, if you set SY-LSIND to 0, the system deletes all secondary lists and overwrites the basic list with the current secondary list.

11. What are the page headers for secondary lists?

On secondary lists, the system does not display a standard page header and it does not trigger the event. TOP-OF-PAGE.  To create page headers for secondary list, you must enhance TOP-OF-PAGE: Syntax TOP-OF-PAGE DURING LINE-SELECTION.  

The system triggers this event for each secondary list.  If you want to create different page headers for different list levels, you must program the processing block of this event accordingly, for example by using system fields such as SY-LSIND or SY-PFKEY in control statements (IF, CASE).

12. How to use messages in lists?

ABAP/4  allows you to react to incorrect or doubtful user input by displaying messages that influence the program flow depending on how serious the error was. 

Handling messages is mainly a topic of dialog programming.  You store and maintain messages in Table T100.  Messages are sorted by language, by a two-character ID, and by a three-digit number.  

You can assign different message types to each message you output.  The influence of a message on the program flow depends on the message type.  In our program, use the MESSAGE statement to output messages statically or dynamically and to determine the message type.

Syntax:REPORT <rep> MESSAGE-ID <id>.

13. What are the types of messages?

A message can have five different types.  These message types have the following effects during list processing:

.A (=Abend):

.E (=Error) or W (=Warning):

Page 44: Demo Program on Interactive ALV

.I (=Information):

.S (=Success):

14. What are the user interfaces of interactive lists?

If you want the user to communicate with the system during list display, the list must be interactive.  You can define specific interactive possibilities in the status of the list’s user interface (GUI).  

To define the statuses of interfaces in the R/3 system, use the Menu Painter tool.  In the Menu Painter, assign function codes to certain interactive functions.  After an user action occurs on the completed interface, the ABAP/4 processor checks the function code and, if valid, triggers the corresponding event.

15. What are the drill-down features provided by ABAP/4 in interactive lists?

ABAP/4 provides some interactive events on lists such as AT LINE-SELECTION (double click) or AT USER-COMMAND (pressing a button). 

You can use these events to move through layers of information about individual items in a list.

16. What is meant by stacked list?

A stacked list is nothing but secondary list and is displayed on a full-size screen unless you have specified its coordinates using the window command.

17. Is the basic list deleted when the new list is created?

No.  It is not deleted and you can return back to it using one of the standard navigation functions like clicking on the back button or the cancel button.

Page 45: Demo Program on Interactive ALV

18. What is meant by hotspots?

A Hotspot is a list area where the mouse pointer appears as an upright hand symbol. When a user points to that area (and the hand cursor is active), a single click does the same thing as a double-click.  Hotspots are supported from R/3 release 3.0c.

19. What is the length of function code at user-command?

Each menu function, push button, or function key has an associated function code of length FOUR (for example, FREE), which is available in the system field SYUCOMM after the user action.

20. Can we create a gui status in a program from the object browser?

Yes.  You can create a GUI STATUS in a program using SET PF-STATUS.

21. In which system field does the name of current gui status is there?

The name of the current GUI STATUS is available in the system field SY-PFKEY.

22. Can we display a list in a pop-up screen other than full-size stacked list?

Yes, we can display a list in a pop-up screen using the command WINDOW with the additions starting at X1 Y1 and ending at X2 Y2 to set the upper-left and the lower-right corners where x1 y1 and x2 y2 are the coordinates.

23. What is meant by hide area?

Page 46: Demo Program on Interactive ALV

The hide command temporarily stores the contents of the field at the current line in a system-controlled memory called the HIDE AREA.  At an interactive event, the contents of the field are restored from the HIDE AREA.

24. When the get cursor command used in interactive lists?

If the hidden information is not sufficient to uniquely identify the selected line, the command GET CURSOR is used.  

The GET CURSOR command returns the name of the field at the cursor position in a field specified after the addition field, and the value of the selected field in a field specified after value.

25. How can you display frames (horizontal and vertical lines) in lists?

You can display tabular lists with horizontal and vertical lines (FRAMES) using the ULINE command and the system field SY-VLINE.  

The corners arising at the intersection of horizontal and vertical lines are automatically drawn by the system.

26. What are the events used for page headers and footers?

The events TOP-OF-PAGE and END-OF-PAGE are used for pager headers and footers.

27. How can you access the function code from menu painter?

From within the program, you can use the SY-UCOMM system field to access the function code.  You can define individual interfaces for your report and assign them in the report to any list level.  

If you do not specify self-defined interfaces in the report but use at least one of the three interactive event keywords.  AT LINE-SELECTION, AT PF<nn>, OR AT USER-COMMAND in the program, the system automatically uses appropriate predefined standard interfaces.  These standard interfaces provide the same functions as the standard list described under the standard list.

Page 47: Demo Program on Interactive ALV

28. How the at-user command serves mainly in lists?

The AT USER-COMMAND event serves mainly to handle own function codes.  In this case, you should create an individual interface with the Menu Painter and define such function codes.

29. How to pass data from list to report?

ABAP/4 provides three ways of passing data:

---Passing data automatically using system fields

---Using statements in the program to fetch data

---Passing list attributes

30. How can you manipulate the presentation and attributes of interactive lists?

---Scrolling through Interactive Lists.

---Setting the Cursor from within the Program.

---Modifying List Lines.

31. How to call other programs?

Report                                                 Transaction

Call and return          SUBMIT AND RETURN              CALL TRANSACTION

Call without return   SUBMIT                                         LEAVE TO TRANSACTION

You can use these statements in any ABAP/4 program.

32. What will exactly the hide statement do?

Page 48: Demo Program on Interactive ALV

For displaying the details on secondary lists requires that you have previously stored the contents of the selected line from within the program.  

To do this, ABAP/4 provides the HIDE statement.  This statement stores the current field contents for the current list line.  

When calling a secondary list from a list line for which the HIDE fields are stored, the system fills the stored values back into the variables in the program. 

In the program code, insert the HIDE statement directly after the WRITE statement for the current line.  

Interactive lists provide the user with the so-called ‘INTERACTIVE REPORTING’ facility.  For background processing the only possible method of picking the relevant data is through ‘NON INTERACTIVE REPORT’ .  

After starting a background job, there is no way of influencing the program.  But whereas for dialog sessions there are no such restrictions.

33. How many lists can a program can produce?

Each program can produce up to 21 lists: one basic list and 20 secondary lists.  If the user creates a list on the next level (that is, SY-LSIND increases), the system stores the previous list and displays the new one.  Only one list is active, and that is always the most recently created list.

"You found the information helpful and wa