Skip to Content
author's profile photo Former Member
Former Member

How to write simple reports!!

Hi all i am very new to ABAP.can anyone give me some docs/pdfs regarding report programing with some sample report programs.

thanks all

Note: i have serached ..but could not find any suitable one.!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 06:35 AM

    Hi Sam,

    I will develop a small code 4 u check it once.

    copy the below code and execute it ok..

    SAMPLE CODE:

    *Tables

    TABLES:vbap.

    *Internal Table

    DATA:BEGIN OF itab OCCURS 0,

    vbeln LIKE vbap-vbeln,

    posnr LIKE vbap-posnr,

    END OF itab.

    *select-options

    SELECT-OPTIONS:s_vbeln FOR vbap-vbeln.

    *Initilization

    INITIALIZATION.

    s_vbeln-sign = 'I'.

    s_vbeln-option = 'BT'.

    s_vbeln-low ='4969'.

    s_vbeln-high = '5000'.

    APPEND s_vbeln .

    *Start of selection

    START-OF-SELECTION.

    SELECT vbeln posnr FROM vbap INTO TABLE itab WHERE vbeln IN s_vbeln.

    *End of Selection

    END-OF-SELECTION.

    LOOP AT itab.

    WRITE:/ itab-vbeln, 20 itab-posnr.

    ENDLOOP.

    *Top of Page

    TOP-OF-PAGE.

    WRITE: / 'SALES ORDER REPORT'.

    ULINE.

    INITILIZATION: It is used to initilize the selection screen filed values.

    START-OF-SELECTION :It is used to fetch the data from the database.

    END-OF-SELECTION:For displaying the values.

    TOP-OF-PAGE: For Headings

    Award points if helpful

    Kiran Kumar.G.A

    Have a Nice Day..

    Edited by: KIRAN KUMAR on Jan 10, 2008 7:40 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 06:38 AM

    Hi Sam,

    this tells u about all various variable declarations in report programs, really helpful.

    hi,

    &----


    *& Report Z_OOABAP18 *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT Z_OOABAP18 .CLASS lcl_employee DEFINITION.

    PUBLIC SECTION.

    *----


    The public section is accesible from outside

    *----


    TYPES:

    BEGIN OF t_employee,

    no TYPE i,

    name TYPE string,

    END OF t_employee.

    METHODS:

    constructor

    IMPORTING im_employee_no TYPE i

    im_employee_name TYPE string,

    display_employee.

    Class methods are global for all instances

    CLASS-METHODS: display_no_of_employees.

    PROTECTED SECTION.

    *----


    The protecetd section is accesible from the class and its subclasses

    *----


    Class data are global for all instances

    CLASS-DATA: g_no_of_employees TYPE i.

    PRIVATE SECTION.

    *----


    The private section is only accesible from within the classs

    *----


    DATA: g_employee TYPE t_employee.

    ENDCLASS.

    LCL Employee - Implementation

    CLASS lcl_employee IMPLEMENTATION.

    METHOD constructor.

    g_employee-no = im_employee_no.

    g_employee-name = im_employee_name.

    g_no_of_employees = g_no_of_employees + 1.

    ENDMETHOD.

    METHOD display_employee.

    WRITE:/ 'Employee', g_employee-no, g_employee-name.

    ENDMETHOD.

    METHOD display_no_of_employees.

    WRITE: / 'Number of employees is:', g_no_of_employees.

    ENDMETHOD.

    ENDCLASS.

    ************************************************************************

    R E P O R T

    *********************************************************************

    DATA: g_employee1 TYPE REF TO lcl_employee,

    g_employee2 TYPE REF TO lcl_employee.

    START-OF-SELECTION.

    CREATE OBJECT g_employee1

    EXPORTING im_employee_no = 1

    im_employee_name = 'Vikram.C'.

    CREATE OBJECT g_employee2

    EXPORTING im_employee_no = 2

    im_employee_name = 'Raghava.V'.

    CALL METHOD g_employee1->display_employee.

    CALL METHOD g_employee2->display_employee.

    kindly reward if helpful.

    cheers,

    Hema.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 06:41 AM

    hi Sam, also check this sample report program.

    check this sample program using the BAPI to create sales order..

    code

    PARAMETERS: p_auart TYPE auart OBLIGATORY.

    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.

    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.

    PARAMETERS: p_spart TYPE vtweg OBLIGATORY.

    PARAMETERS: p_sold TYPE kunnr OBLIGATORY.

    PARAMETERS: p_ship TYPE kunnr OBLIGATORY.

    *ITEM

    PARAMETERS: p_matnr TYPE matnr OBLIGATORY.

    PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.

    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.

    PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.

    DATA DECLARATIONS.

    DATA: v_vbeln LIKE vbak-vbeln.

    DATA: header LIKE bapisdhead1.

    DATA: headerx LIKE bapisdhead1x.

    DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.

    DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.

    DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.

    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

    DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx

    WITH HEADER LINE.

    DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl

    WITH HEADER LINE.

    HEADER DATA

    header-doc_type = p_auart.

    headerx-doc_type = 'X'.

    header-sales_org = p_vkorg.

    headerx-sales_org = 'X'.

    header-distr_chan = p_vtweg.

    headerx-distr_chan = 'X'.

    header-division = p_spart.

    headerx-division = 'X'.

    headerx-updateflag = 'I'.

    PARTNER DATA

    partner-partn_role = 'AG'.

    partner-partn_numb = p_sold.

    APPEND partner.

    partner-partn_role = 'WE'.

    partner-partn_numb = p_ship.

    APPEND partner.

    ITEM DATA

    itemx-updateflag = 'I'.

    item-itm_number = '000010'.

    itemx-itm_number = 'X'.

    item-material = p_matnr.

    itemx-material = 'X'.

    item-plant = p_plant.

    itemx-plant = 'X'.

    item-target_qty = p_menge.

    itemx-target_qty = 'X'.

    item-target_qu = 'EA'.

    itemx-target_qu = 'X'.

    item-item_categ = p_itcat.

    itemx-item_categ = 'X'.

    APPEND item.

    APPEND itemx.

    Fill schedule lines

    lt_schedules_in-itm_number = '000010'.

    lt_schedules_in-sched_line = '0001'.

    lt_schedules_in-req_qty = p_menge.

    APPEND lt_schedules_in.

    Fill schedule line flags

    lt_schedules_inx-itm_number = '000010'.

    lt_schedules_inx-sched_line = '0001'.

    lt_schedules_inx-updateflag = 'X'.

    lt_schedules_inx-req_qty = 'X'.

    APPEND lt_schedules_inx.

    Call the BAPI

    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'

    EXPORTING

    sales_header_in = header

    sales_header_inx = headerx

    IMPORTING

    salesdocument_ex = v_vbeln

    TABLES

    return = return

    sales_items_in = item

    sales_items_inx = itemx

    sales_schedules_in = lt_schedules_in

    sales_schedules_inx = lt_schedules_inx

    sales_partners = partner.

    Check the return table.

    LOOP AT return WHERE type = 'E' OR type = 'A'.

    EXIT.

    ENDLOOP.

    IF sy-subrc = 0.

    WRITE: / 'Error in creating document'.

    ELSE.

    COMMIT WORK AND WAIT.

    WRITE: / 'Document ', v_vbeln, ' created'.

    ENDIF.

    [/code]

    cheers,

    Hema.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 06:42 AM

    Hi Sam, also check this.

    this program implements 'BAPI_SALESORDER_GETLIST' to get Sale Order Details.

    PARAMETER : p_kunnr TYPE bapi1007-customer,

    p_vkorg TYPE bapiorders-sales_org.

    DATA : t_order TYPE TABLE OF bapiorders," WITH HEADER LINE,

    wa_order TYPE bapiorders.

    START-OF-SELECTION.

    CALL FUNCTION 'BAPI_SALESORDER_GETLIST'

    EXPORTING

    customer_number = p_kunnr

    sales_organization = p_vkorg

    MATERIAL =

    DOCUMENT_DATE =

    DOCUMENT_DATE_TO =

    PURCHASE_ORDER =

    TRANSACTION_GROUP = 0

    PURCHASE_ORDER_NUMBER =

    IMPORTING

    RETURN =

    TABLES

    sales_orders = t_order

    .

    IF t_order[] IS NOT INITIAL.

    LOOP AT t_order INTO wa_order.

    WRITE : / wa_order-sd_doc,

    wa_order-itm_number,

    wa_order-material,

    wa_order-short_text,

    wa_order-doc_type.

    ENDLOOP.

    ELSE.

    WRITE : / 'No Data'.

    ENDIF.

    kindly reward if found helpful.

    cheers,

    Hema.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 06:42 AM

    Hi Sam,

    Follow the following report, it will useful for you.

    *&----


    *& Report ZPA_MM_ALBA_REPORT

    *&

    &----


    *&

    *&

    &----


    REPORT ZPA_MM_ALBA_REPORT.

    TABLES:MVER,MAPR,PROP,PROW.

    PARAMETERS: MATNR TYPE MVER-MATNR OBLIGATORY,

    WERKS TYPE MVER-WERKS OBLIGATORY.

    SELECT-OPTIONS GJAHR FOR MVER-GJAHR OBLIGATORY.

    TYPES: BEGIN OF TY_MVER,

    MATNR TYPE MVER-MATNR,

    WERKS TYPE MVER-WERKS,

    GJAHR TYPE MVER-GJAHR,

    GSV01 TYPE MVER-GSV01,

    GSV02 TYPE MVER-GSV02,

    GSV03 TYPE MVER-GSV03,

    GSV04 TYPE MVER-GSV04,

    GSV05 TYPE MVER-GSV05,

    GSV06 TYPE MVER-GSV06,

    GSV07 TYPE MVER-GSV07,

    GSV08 TYPE MVER-GSV08,

    GSV09 TYPE MVER-GSV09,

    GSV10 TYPE MVER-GSV10,

    GSV11 TYPE MVER-GSV11,

    GSV12 TYPE MVER-GSV12,

    GSV13 TYPE MVER-GSV13,

    MGV01 TYPE MVER-MGV01,

    MGV02 TYPE MVER-MGV02,

    MGV03 TYPE MVER-MGV03,

    MGV04 TYPE MVER-MGV04,

    MGV05 TYPE MVER-MGV05,

    MGV06 TYPE MVER-MGV06,

    MGV07 TYPE MVER-MGV07,

    MGV08 TYPE MVER-MGV08,

    MGV09 TYPE MVER-MGV09,

    MGV10 TYPE MVER-MGV10,

    MGV11 TYPE MVER-MGV11,

    MGV12 TYPE MVER-MGV12,

    MGV13 TYPE MVER-MGV13,

    END OF TY_MVER,

    BEGIN OF TY_MAPR,

    MATNR TYPE MAPR-MATNR,

    WERKS TYPE MAPR-WERKS,

    PNUM1 TYPE MAPR-PNUM1,

    END OF TY_MAPR,

    BEGIN OF TY_PROP,

    PNUM2 TYPE PROP-PNUM2,

    END OF TY_PROP,

    BEGIN OF TY_PROW,

    PNUM2 TYPE PROW-PNUM2,

    ERTAG TYPE PROW-ERTAG,

    PRWRT TYPE PROW-PRWRT,

    KOPRW TYPE PROW-KOPRW,

    FIXKZ TYPE PROW-FIXKZ,

    END OF TY_PROW.

    DATA:IT_MVER TYPE STANDARD TABLE OF TY_MVER WITH DEFAULT KEY WITH HEADER LINE,

    IT_MAPR TYPE STANDARD TABLE OF TY_MAPR WITH DEFAULT KEY WITH HEADER LINE,

    IT_PROP TYPE STANDARD TABLE OF TY_PROP WITH DEFAULT KEY WITH HEADER LINE,

    IT_PROW TYPE STANDARD TABLE OF TY_PROW WITH DEFAULT KEY WITH HEADER LINE,

    WA_PROP LIKE LINE OF IT_PROP,

    WA_PROW LIKE LINE OF IT_PROW.

    DATA: BEGIN OF IT_FORECAST OCCURS 0,

    YEAR LIKE PROW-ERTAG,

    MONTH LIKE T009B-POPER,

    PRWRT LIKE PROW-PRWRT,

    KOPRW LIKE PROW-KOPRW,

    END OF IT_FORECAST.

    DATA: BEGIN OF IT_SFINAL OCCURS 0,

    GJAHR LIKE MVER-GJAHR,

    MONTH LIKE T009B-POPER,

    GSVRR LIKE MVER-GSV01,

    MGVRR LIKE MVER-MGV01,

    END OF IT_SFINAL.

    DATA: BEGIN OF IT_FINAL OCCURS 0,

    YEAR LIKE MVER-GJAHR,

    MONTH LIKE T009B-POPER,

    GSVRR LIKE IT_MVER-GSV01,

    MGVRR LIKE IT_MVER-MGV01,

    PRWRT LIKE IT_PROW-PRWRT,

    KOPRW LIKE IT_PROW-KOPRW,

    END OF IT_FINAL,

    WA_FINAL LIKE LINE OF IT_FINAL.

    DATA : YEAR TYPE T009B-BDATJ,

    MONTH TYPE T009B-POPER,

    A TYPE I VALUE 2.

    PERFORM SELECTION_DATA.

    PERFORM OPERATION_DATA.

    PERFORM DISPLAY_DATA.

    ******************************************************************************************************************

    FORM SELECTION_DATA.

    SELECT MATNR WERKS GJAHR GSV01 GSV02 GSV03 GSV04

    GSV05 GSV06 GSV07 GSV08

    GSV09 GSV10 GSV11 GSV12

    GSV13 MGV01 MGV02 MGV03

    MGV04 MGV05 MGV06 MGV07

    MGV08 MGV09 MGV10 MGV11

    MGV12 MGV13

    FROM MVER INTO TABLE IT_MVER

    WHERE

    MATNR = MATNR AND

    WERKS = WERKS AND

    GJAHR IN GJAHR.

    IF SY-SUBRC 0.

    write:/ 'no record found'.

    endif.

    ******************************************************************************************************************

    SELECT MATNR WERKS PNUM1 FROM MAPR

    INTO TABLE IT_MAPR

    WHERE

    MATNR = MATNR AND

    WERKS = WERKS.

    IF SY-SUBRC 0.

    write:/ 'no record found'.

    endif.

    ******************************************************************************************************************

    SELECT PNUM2 FROM PROP

    INTO TABLE IT_PROP

    FOR ALL ENTRIES IN IT_MAPR

    WHERE

    PNUM1 = IT_MAPR-PNUM1.

    IF SY-SUBRC 0.

    write:/ 'no record found'.

    endif.

    ******************************************************************************************************************

    SELECT PNUM2 ERTAG PRWRT KOPRW FIXKZ FROM PROW

    INTO TABLE IT_PROW

    FOR ALL ENTRIES IN IT_PROP

    WHERE

    PNUM2 = IT_PROP-PNUM2.

    IF SY-SUBRC 0.

    write:/ 'no record found'.

    endif.

    ENDFORM.

    **************************************************************************************************************

    FORM OPERATION_DATA.

    LOOP AT IT_PROW.

    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

    EXPORTING

    I_DATE = IT_PROW-ERTAG

    I_PERIV = 'K4'

    IMPORTING

    E_BUPER = MONTH

    E_GJAHR = YEAR

    EXCEPTIONS

    INPUT_FALSE = 1

    T009_NOTFOUND = 2

    T009B_NOTFOUND = 3.

    IF SY-SUBRC 0.

    write:/ 'no record found'.

    ENDIF.

    IT_FORECAST-YEAR = YEAR.

    IT_FORECAST-MONTH = MONTH.

    IT_FORECAST-PRWRT = IT_PROW-PRWRT.

    IT_FORECAST-KOPRW = IT_PROW-KOPRW.

    APPEND IT_FORECAST.

    CLEAR IT_FORECAST.

    ENDLOOP.

    ******************************************************************************************************************

    LOOP AT IT_MVER.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 1.

    IT_SFINAL-GSVRR = IT_MVER-GSV01.

    IT_SFINAL-MGVRR = IT_MVER-MGV01.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 2.

    IT_SFINAL-GSVRR = IT_MVER-GSV02.

    IT_SFINAL-MGVRR = IT_MVER-MGV02.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 3.

    IT_SFINAL-GSVRR = IT_MVER-GSV03.

    IT_SFINAL-MGVRR = IT_MVER-MGV03.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 4.

    IT_SFINAL-GSVRR = IT_MVER-GSV04.

    IT_SFINAL-MGVRR = IT_MVER-MGV04.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 5.

    IT_SFINAL-GSVRR = IT_MVER-GSV05.

    IT_SFINAL-MGVRR = IT_MVER-MGV05.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 6.

    IT_SFINAL-GSVRR = IT_MVER-GSV06.

    IT_SFINAL-MGVRR = IT_MVER-MGV06.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 7.

    IT_SFINAL-GSVRR = IT_MVER-GSV07.

    IT_SFINAL-MGVRR = IT_MVER-MGV07.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 8.

    IT_SFINAL-GSVRR = IT_MVER-GSV08.

    IT_SFINAL-MGVRR = IT_MVER-MGV08.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 9.

    IT_SFINAL-GSVRR = IT_MVER-GSV09.

    IT_SFINAL-MGVRR = IT_MVER-MGV09.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 10.

    IT_SFINAL-GSVRR = IT_MVER-GSV10.

    IT_SFINAL-MGVRR = IT_MVER-MGV10.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 11.

    IT_SFINAL-GSVRR = IT_MVER-GSV11.

    IT_SFINAL-MGVRR = IT_MVER-MGV11.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 12.

    IT_SFINAL-GSVRR = IT_MVER-GSV12.

    IT_SFINAL-MGVRR = IT_MVER-MGV12.

    APPEND IT_SFINAL.

    IT_SFINAL-GJAHR = IT_MVER-GJAHR.

    IT_SFINAL-MONTH = 13.

    IT_SFINAL-GSVRR = IT_MVER-GSV13.

    IT_SFINAL-MGVRR = IT_MVER-MGV13.

    APPEND IT_SFINAL.

    ENDLOOP.

    ******************************************************************************************************************

    LOOP AT IT_SFINAL.

    IT_FINAL-YEAR = IT_SFINAL-GJAHR.

    IT_FINAL-MONTH = IT_SFINAL-MONTH.

    IT_FINAL-GSVRR = IT_SFINAL-GSVRR.

    IT_FINAL-MGVRR = IT_SFINAL-MGVRR.

    READ TABLE IT_FORECAST WITH KEY YEAR = IT_SFINAL-GJAHR MONTH = IT_SFINAL-MONTH.

    IT_FINAL-PRWRT = IT_FORECAST-PRWRT.

    IT_FINAL-KOPRW = IT_FORECAST-KOPRW.

    APPEND IT_FINAL.

    CLEAR IT_FINAL.

    CLEAR IT_FORECAST.

    ENDLOOP.

    ******************************************************************************************************************

    LOOP AT IT_FORECAST.

    READ TABLE IT_FINAL WITH KEY YEAR = IT_FORECAST-YEAR MONTH = IT_FORECAST-MONTH.

    IF SY-SUBRC 0.

    IT_FINAL-YEAR = IT_FORECAST-YEAR.

    IT_FINAL-MONTH = IT_FORECAST-MONTH.

    IT_FINAL-GSVRR = ' '.

    IT_FINAL-MGVRR = ' '.

    IT_FINAL-PRWRT = IT_FORECAST-PRWRT.

    IT_FINAL-KOPRW = IT_FORECAST-KOPRW.

    APPEND IT_FINAL.

    CLEAR IT_FORECAST.

    ENDIF.

    ENDLOOP.

    ENDFORM.

    ******************************************************************************************************************

    FORM DISPLAY_DATA.

    LOOP AT IT_FINAL INTO WA_FINAL.

    IF A = 1.

    FORMAT COLOR 4.

    ELSE.

    FORMAT COLOR 7.

    A = 0.

    ENDIF.

    AT NEW YEAR.

    WRITE: / sy-uline.

    endat.

    WRITE:/5 WA_FINAL-YEAR,

    SY-VLINE,

    25 WA_FINAL-MONTH,

    SY-VLINE,

    35 WA_FINAL-GSVRR,

    SY-VLINE,

    WA_FINAL-MGVRR,

    SY-VLINE,

    WA_FINAL-PRWRT,

    SY-VLINE,

    WA_FINAL-KOPRW,

    sy-vline.

    A = A + 1.

    ENDLOOP.

    ENDFORM.

    You can also chedk out the following links for sample codes.

    http://www.saptechies.com/functional-specs-for-some-payroll-report/

    http://www.sap-img.com/human/functional-specs-for-some-payroll-report.htm

    see example program t

    t_code abapdocu.

    Detail Lists

    When the system processes event blocks that are not assigned to interactive list events, and when processing dialog modules, the ABAP program writes its list output to the basic list.

    The ABAP system field SY-LSIND contains the index of the list currently being created. While the basic list is being created, SY-LSIND is zero.

    By default, the basic list has a standard list status and a standard page header. The TOP-OF-PAGE and END-OF-PAGE events can occur while the basic list is being created. All output in these events is placed in the page header or footer of the basic list. In executable programs, the basic list is automatically sent to the list processor and displayed at the end of the END-OF-SELECTION event. Otherwise, it is displayed after the PAI processing block on the screen from which the LEAVE TO LIST-PROCESSING statement occurred.

    Creating Detail Lists

    Each time the user executes an action on a list, the runtime environment checks whether there is an event block defined that corresponds to the function code. If there is, SY-LSIND is automatically increased by one, and the relevant event block is executed. Any list output arising during this event block places its data into a new list (list level) with the index SY-LSIND. In order to create a new list level, the GUI status of the basic list must allow user actions, and the relevant event blocks must be defined in the program.

    All lists created during an interactive list event are detail lists. Each interactive list event creates a new detail list. With one ABAP program, you can maintain one basic list and up to 20 detail 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. The user can interact with whichever list is currently displayed.

    The system displays this list after processing the entire processing block of the event keyword or after leaving the processing block due to EXIT or CHECK. By default, the new list overlays the previous list completely. However, you can display a list in a dialog box. If no other dialog status is set in the event block for the detail list, the system uses the status from the previous list level. However, there is no standard page header for detail lists (see below).

    Consequences of Event Control

    The fact that you program detail lists in event blocks has important consequences. You cannot nest processing blocks (see Structure of an ABAP Program). Therefore, you cannot process other events within the processing blocks of interactive lists.

    Especially, you cannot

    use separate processing blocks to process further interactive events. A certain user action always triggers the same processing block in your program. You must use control statements (IF, CASE) within the processing block to make sure that the system processes the desired statements. There is a range of system field that you can use for this.

    use the event TOP-OF-PAGE to influence the list structure of secondary lists. To layout the page headers of the secondary lists, you must use the event TOP-OF-PAGE DURING LINE-SELECTION (see below). However, the system does process the event END-OF-PAGE in secondary lists.

    use events such as GET and GET LATE to retrieve data for secondary lists, but must use SELECT statements. You can use the logical database assigned to the executable program (report) only for the basic list. If you want to use a logical database during interactive events, you must either call another executable program using SUMIT, or (better) call the logical database using a function module.

    Navigating in Lists

    To return from a high list level to the next-lower level (SY-LSIND), the user can choose Back from a detail list. The system releases the last list to have been displayed, and returns to the previous list level. The system deletes the contents of the released list.

    To determine the list level in which the output from an event block will be displayed, you can change the value of the system fields SY-LSIND. This is one of the few exceptions to the rule that states that you must never overwrite ABAP system fields. 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 you 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.

    When you change SY-LSIND, the change only takes effect at the end of the corresponding event. If you work with statements that access the list with index SY-LSIND (using the INDEX addition - for example, SCROLL), you should set the new value of SY-LISND after these statements. The best place to set it is in the last statement of the event block.

    System Fields for Details Lists

    After each user action on a list, the following ABAP system fields will be set in the corresponding event block:

    System field

    Information

    SY-LSIND

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

    SY-LISTI

    Index of the list level from which the event was triggered

    SY-LILLI

    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). This line may contain the page header.

    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 list currently being displayed.

    Page Headers for Detail Lists

    On detail 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 detail list, you must use a different TOP-OF-PAGE event:

    TOP-OF-PAGE DURING LINE-SELECTION.

    The system triggers this event for each detail 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).

    As on the basic list, the page header of a detail list remains displayed even when you scroll vertically.

    Messages on Detail Lists

    ABAP allows you to react to incorrect or possibly-incorrect user input by displaying messages. The seriousness of the error determines how program processing continues.

    In list processing, the message processing for the individual message types is as follows:

    A (=Abend): Termination

    The system displays the message in a dialog box. After the user confirms the message using ENTER , the system terminates the entire transaction (for example SA38).

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

    The system displays the message in the status bar. Once the user has confirmed the error by pressing ENTER, the current event block is terminated and the previous list level remains displayed. If you use an error or warning message while creating the basic list, the entire program is terminated.

    I (=Information):

    The system displays the message in a dialog box. Once the user has confirmed the message (ENTER), the program continues processing after the MESSAGE statement.

    S (= status)

    The system displays the message in the status bar of the current list.

    X (= Exit) Runtime error:

    This message type triggers a runtime error and generates a short dump.

    Using Detail Lists

    A classic report is a program that generates a single list, which must contain all of the required detail information. This procedure may result in extensive lists from which the user has to pick the relevant data. For background processing, this is the only possible method. After starting a background job, there is no way of influencing the program. The desired selections must be made beforehand and the list must provide detailed information.

    For dialog sessions, there are no such restrictions. The user is present during the execution of the program and can control and manipulate the program flow directly. To be able to use all advantages of the online environment, classical reporting was developed into interactive reporting.

    Interactive reporting allows the user to participate actively in retrieving and presenting data during the session. Instead of one extensive and detailed list, with interactive reporting you create a condensed 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. Detailed information is presented in detail lists.

    Apart from creating detail lists, interactive reporting also allows you to call transactions or other executable programs (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 to change the database table whose data is displayed in the list.

    Examples

    Creating Detail Lists

    REPORT demo_list_interactive_1.

    START-OF-SELECTION.

    WRITE: 'Basic List, SY-LSIND =', sy-lsind.

    AT LINE-SELECTION.

    WRITE: 'Secondary List, SY-LSIND =', sy-lsind.

    When you run the program, the basic list appears. The GUI status automatically permits the function Choose (F2). When you choose a list line, the system triggers the AT LINE-SELECTION event, and the first detail list overlays the basic list. This list has no standard page header. It also inherits the GUI status of the basic list. By choosing Choose, the user can now create up to 19 of these lists. Trying to produce more than 19 lists results in a runtime error. Using Back , the user can return to previous lists.

    Navigation in detail lists.

    REPORT demo_list_interactive_2.

    START-OF-SELECTION.

    WRITE: 'Basic List, SY-LSIND =', sy-lsind.

    AT LINE-SELECTION.

    IF sy-lsind = 3.

    sy-lsind = 0.

    ENDIF.

    WRITE: 'Secondary List, SY-LSIND =', sy-lsind.

    When you run the program, the basic list appears:

    Basic List, SY-LSIND = 0

    The GUI status automatically permits the function Choose (F2). If the user positions the cursor on the list line and chooses Choose to trigger the AT LINE-SELECTION event, the system displays a detail list that contains the following line:

    Secondary List, SY-LSIND = 1

    Choosing Choose again produces:

    Secondary List, SY-LSIND = 2

    Back leads to the previous list level. Choosing Choose for the third time produces a detail list that contains the following line (because of the IF condition):

    Secondary List, SY-LSIND = 0

    The system deletes list levels 1 and 2. Choosing Back returns to the point at which the list processing started. If you choose Choose, the system creates a detail list with index 1. However, the list on level 0 is no longer a basic list (no page header), but is itself a detail list.

    Page Headers for Detail Lists

    REPORT demo_list_interactive_3.

    START-OF-SELECTION.

    WRITE 'Basic List'.

    AT LINE-SELECTION.

    WRITE 'Secondary List'.

    TOP-OF-PAGE DURING LINE-SELECTION.

    CASE sy-lsind.

    WHEN 1.

    WRITE 'First Secondary List'.

    WHEN 2.

    WRITE 'Second Secondary List'.

    WHEN OTHERS.

    WRITE: 'Secondary List, Level:', sy-lsind.

    ENDCASE.

    ULINE.

    When you run the program, the basic list appears. The user can choose Choose to create detail lists. The detail lists have page headers that are set according to the value of SY-LSIND.

    Messages on Detail Lists

    REPORT demo_list_interactive_4 NO STANDARD PAGE HEADING.

    AT LINE-SELECTION.

    WRITE 'Basic List'.

    MESSAGE s888(sabapdocu) WITH text-001.

    AT LINE-SELECTION.

    IF sy-lsind = 1.

    MESSAGE i888(sabapdocu) WITH text-002.

    ENDIF.

    IF sy-lsind = 2.

    MESSAGE e888(sabapdocu) WITH text-003 sy-lsind text-004.

    ENDIF.

    WRITE: 'Secondary List, SY-LSIND:', sy-lsind.

    When the program runs, the system displays the basic list and the success message 100 in the status line. A single click triggers the AT-LINE-SELECTION event. When the system creates the first detail list, it displays a dialog box with the information message 100. You cannot create the second detail list, because the message 200 has message type E:

    Reward if useful.

    Edited by: Kaushik Vishnu Vardhan on Jan 10, 2008 7:44 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 06:44 AM

    REPORT /scl/rdfiapr_pri_vari.

    • Include for data declaration

    INCLUDE /scl/rdfiapr_pri_vari_top.

    • Include for form declaraion

    INCLUDE /scl/rdfiapr_pri_vari_form.

    ----


    • Event at selection-screen

    ----


    AT SELECTION-SCREEN.

    PERFORM field_validation USING s_bukrs-low

    s_monat-low

    s_monat-high

    p_gjahr.

    ----


    • EVENT TOP-OF-PAGE

    ----


    TOP-OF-PAGE.

    *PERFORM TOPOFPAGE

    PERFORM topofpage.

    ----


    • Event Start-of-Selection

    ----


    START-OF-SELECTION.

    • To retrive the values which we need dor output display

    PERFORM data_retrieval.

    • To move retrieve data into final internal table

    PERFORM move_data.

    • To move data into final internal table

    PERFORM build_fieldcat.

    • To display report

    IF NOT i_final IS INITIAL.

    PERFORM detail_alv_grid_display.

    ___________________________

    hi sam, this is the way we normally write the report.

    all the declaration we write within TOP include.

    all the form that we use we need to write in another form include.

    it is best practice to use intialization event to initialize all variables.

    at selectin screen we do the field validatinons for the selection parameters.

    modularisation technique is used to simplify the understanding of the report for that we write FORM ( subroutine) and call them using PEROFRM statement.

    logic for retriving a data and moving it into final internal table we use Stast-of-selection and end-of-selection event.

    To display classical report we use write statement.

    to display report in grid we use Function module "reuse_alv_grid_display" and there we pass the field catalof name that we have created for final internal table.

    _______________________________

    if u have some particular requirement then let me know so that i can help u in a better way.

    reward points if u find this information useful.

    Regards,

    Romanch

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 07:12 AM

    hi sam,

    how to create a simple report:

    1) in command field type se38

    2) type program name starts with Z or Y

    3) click create button

    after that u will get a report screen with ur progarm name.

    type below program

    "program for displaying parameters

    parameters: f_name(10) type c,

    l_name(10) type c.

    write:f_name,l_name.

    "program for assigning values to variables and displaying

    data: name1(20) type c value 'SAM',

    name2(20) type c value 'sam'.

    write:f_name,l_name.

    "program for numeric data types

    data:r_num type i value 123456789,

    r1_num type p value 123456789,

    r2_num type f value 123456789.

    write:r_num,r1_num,r2_num.

    after typing this program

    1)save (ctrl+s) it and

    2)Execute(F8) after that enter fields

    3)again press(F8)

    ok

    reawd if it is useful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 08:12 AM

    Hi Sam,

    ABAP/4

    Advanced Business Application Programming

    It is a 4th generation language

    ABAP is the only tool for developing applications in SAP

    Types of ABAP/4 Programs

    Report Programming

    Dialog Programming

    A Points worth Remembering

    All ABAP/4 programs should start with ‘Y’ or ‘Z’.

    Purpose

    Report Programs are used to display large amounts of data

    Used when data from a number of tables have to be selected and processed before presenting

    Used when reports have to have a special format

    Used when the report has to be downloaded from SAP to an Excel sheet to be distributed across.

    Used when the report has to be mailed to a particular person.

    Snippets

    Report Programs are always Executable Programs. Program Type is always 1.

    Every Report program corresponds to a particular Application Type i.e. either with Sales & Distribution, FI – CO etc. It can also be Cross

    Application i.e. type ‘*’.

    Report Programming is an Event-driven programming.

    How to create a program!

    Transaction SE38

    Small Demo

    1.The first line of a report program is always Report <report-name>.

    2. In order to suppress the list heading or the name of the program the addition No Standard Page Heading is used.

    3.The line size for a particular report can be set by using the addition

    line-size <size>.

    4.The line count for a particular page can be set by using the addition line-count n(n1). N is the number of lines for the page and N1 is the number

    of lines reserved for the page footer.

    5.To display any information or error message we add a message class to the program using the addition: Message-id .

    Message classes are maintained in SE91.

    6.Therefore an ideal report program should start with:

    Report <report name> no standard page heading

    line-size <size>

    line-count <n(n1)>

    message-id <message class>.

    Selection Screen

    Definition

    It is the screen where one specifies the input values for which the program should run.

    You use it to design the selection screen in the program or logical database access routine.

    The selection screen is normally generated from the

    Parameters

    Select-Options

    Syntax

    Selection-screen begin of screen <screen #>

    selection-screen begin of block <#> with frame title <text>

    ………

    ………

    selection-screen end of block <#>

    selection-screen end of screen <screen #>

    Parameters

    Parameters helps one to do dynamic selection

    Parameters can accommodate only one value for one cycle of execution of the program

    Syntax

    Defining parameters as a data type

    Parameters p_id(30) type c.

    Defining parameters like a table field.

    Parameter p_id like <table name>-<field name>.

    Parameters can be Checkboxes as well as Radiobuttons.

    Parameters p_id as checkbox.

    Parameters p_id1 radiobutton group <group name>.

    Parameters p_id2 radiobutton group <group name>.

    Parameters can be listbox.

    Parameter p_id like <table name>-<field name> as listbox.

    Select-Option

    A Select-Option is used to input a range of values or a set of values to a program

    Syntax

    Defining Select-Option like a field of a table.

    Select-Options s_vbeln for vbak-vbeln.

    A select-option can be made to look like a parameter. Following is the syntax

    select-options s_vbeln for vbak-vbeln no intervals no-extension

    1.Internally a select-option behaves like an internal table.

    2.The different fields of the internal table are

    SIGN Possible Values: I, E

    OPTION Possible values: EQ,NE,CP,NP,GE,LT,LE,GT, BT

    LOW

    HIGH

    3.One might want to make it necessary to input some values for the execution of the program. In such a case the following addition is used

    Obligatory

    e.g Parameters p_id like vbak-vbeln obligatory

    Select-options s_vbeln for vbak-vbeln obligatory

    4.You can specify a default value to both a Parameter and a Select-Option with the following addition

    Default <value>

    E.g. Parameters : p_date TYPE sy-datum DEFAULT sy-datum.

    Select-options s_date for sy-datum default sy-datum.

    You can hide a parameter , select-option with NO-DISPLAY addition

    E.g. PARAMETERS d TYPE spfli-carrid no-display.

    Select-options s_vbeln for vbak-vbeln no-display .

    Text Elements: Three components (Path: Goto &#61664;Text Elements)

    List Headings

    Selection Texts

    Text Symbols

    List Headings:

    Used to make Dynamic List Headings

    Selection Texts:

    Used to give a name to the select-options and parameters which will be displayed in the selection screen.

    Text Symbols:

    Used for printing texts either on the selection screen or in the report output.

    Importance

    Text Elements enjoy multi-lingual support.

    Hard Coding can be avoided using text symbols.

    Events in an ABAP/4 Report Program

    ABAP/4 report programs are event driven programs

    The different events in a report Program are:

    1.Load-of-program

    Triggers the associated event in an internal session after loading a program of type 1, M, F, or S. Also runs the associated processing block once

    and once only for each program and internal session.

    The processing block LOAD-OF-PROGRAM has roughly the same function for an ABAP

    program of type 1, M, F or S as a constructor has for classes in ABAP Objects

    2.Initialization.

    This event is executed before the selection screen is displayed .

    Initialization of all the values.

    You can assign different values other than the values defaulted on the selection screen .

    You can fill your selection screen with some values at runtime.

    3.At Selection-Screen.

    The event is processed when the selection screen has been processed (at the end of PAI ).

    Validation & Checks of inputted values happen here

    Extras :

    …ON VALUE-REQUEST FOR psel_low_high .

    The pushbutton for F4 (Possible entries) appears beside the appropriate field.

    ... ON HELP-REQUEST FOR psel_low_high

    . ... OUTPUT

    This event is executed at PBO of the selection screen every time the user presses ENTER

    4.Start-of-Selection.

    Here the program starts selecting values from tables.

    5.End-of-selection.

    After all the data has been selected this event writes the data to the screen.

    6.Interactive Events

    Used for interactive reporting. It is used to create a detailed list from a basic list.

    Start-Of-Selection

    Processing block is executed after processing the selection screen

    All the data is selected in this block.

    All the main processing on the data except for interactive reporting is handled in this block.

    End-Of-Selection

    Data which is selected and has been processed is printed to the screen in this block.

    List Processing happens in this block

    Top-of-Page.

    New-Page.

    End-of-Page.

    Events during List Processing

    1.Top-of-Page.

    Triggered by the first write statement in the program

    It is used to have a standard header in the program for all the pages.

    TOP-OF-PAGE is only executed before outputting the first line on a new page

    2.New-Page.

    Can be used when one wants to display different data on different pages

    Terminates the current page and continues output on a new page.

    Will not trigger the Top-of-Page or End-of-Page.

    3.End-of-Page.

    It is used to have a standard footer for all the pages.

    Triggered by the program if the number of records exceed the line-count of the program.

    Formatting the report

    ABAP/4 allows the reports to be formatted as the user wants it to be.

    e.g Alternate Lines must appear in different colors and the Totals line should appear in Yellow.

    Syntax

    Format Color n. Or Format Color n Intensified On.

    n may correspond to various numbers

    Please note that there are other additions along with format as well.

    FORMAT COLOR OFF INTENSIFIED OFF INVERSE OFF HOTSPOT OFF INPUT Off.

    Interactive Reporting

    Purpose

    User can actively control the data retrieval and display of data

    To create a detailed list from a very basic list

    To make a report interactive with another transaction.

    Snippets

    The detailed data is written on a secondary list.

    The secondary list may either completely overlay the first screen or one can display it in a new screen

    The secondary lists can be themselves interactive.

    The first list may also call a transaction.

    There are different events associated with interactive programming. (Again!)

    Interactive Reporting

    Some commands used for Interactive Reporting.

    1.Hotspot

    If one drags the mouse over the data displayed in the report using the FORMAT statement then the cursor changes to a Hand with an Outstretched

    Index finger

    Syntax: Format Hotspot On (Off).

    2.Hide

    This command helps you to store the field names based on which one will be doing further processing to get a detailed list. It is written directly

    after the WRITE statement for a field. When a row is selected the values get automatically filled in the variables for further use.

    Syntax: Hide <field-name>.

    3.Get Cursor Command

    Like Hide this is also used for getting the values after selection of a row.

    Syntax:

    1. GET CURSOR FIELD f.

    2. GET CURSOR LINE lin.

    Calling an executable program

    1.Using Transaction code

    a.Transaction codes are created using se93.

    b.Give the report name for which tcode has to be created and choose program and selection screen (Report transaction)

    2.Using Submit

    SUBMIT rep.

    Calls report rep.

    The system leaves the active program and starts the new report rep.

    Additions :.

    .. VIA SELECTION-SCREEN

    ... AND RETURN

    . ... EXPORTING LIST TO MEMORY

    ... USING SELECTION-SETS OF PROGRAM prog

    Debugging of report

    To Activate the Debugger before executing your ABAP program

    System -> Utilities -> Debug ABAP/4

    or use /H

    The purpose of the debugger is to allow you to execute your program line by line. It also allow you display the data as you execute the program.

    Hard coded break-points can be created in the program using

    BREAK-POINT.

    BREAK-POINT f.

    SAMPLE REPORT1---

    TABLES:vbak.

    SELECT-OPTIONS: SALE_DOC FOR vbak-vbeln OBLIGATORY,

    DATE_CRE FOR vbak-erdat OBLIGATORY,

    DIS_CHAN FOR vbak-vtweg,

    SDOC_TYP FOR vbak-auart OBLIGATORY NO INTERVALS

    NO-EXTENSION DEFAULT 'qt'.

    data : t_vbak type standard table of vbak.

    data : wa type vbak.

    *DATA: BEGIN OF t_vbak OCCURS 0,

    • mandt TYPE vbak-mandt,

    • vbeln TYPE vbak-vbeln,

    • erdat TYPE vbak-erdat,

    • erzet TYPE vbak-erzet,

    • ernam TYPE vbak-ernam,

    • auart TYPE vbak-auart,

    • vkorg TYPE vbak-vkorg,

    • vtweg TYPE vbak-vtweg,

    *END OF t_vbak.

    *SELECT mandt vbeln erdat erzet ernam auart vkorg vtweg FROM

    • vbak INTO TABLE t_vbak WHERE erdat IN DATE_CRE.

    *

    *sort t_vbak by vbeln erdat.

    *

    *LOOP AT t_vbak.

    • WRITE: / t_vbak-mandt, t_vbak-vbeln, t_vbak-erdat,

    • t_vbak-erzet,

    • t_vbak-ernam, t_vbak-auart, t_vbak-vkorg, t_vbak-vtweg.

    *ENDLOOP.

    select * from vbak into

    table t_vbak WHERE ERDAT GT '20060910'.

    sort t_vbak by vbeln erdat.

    loop at t_vbak into wa.

    write :/ wa-MANDT, WA-VBELN, WA-ERDAT, wa-erzet, wa-auart, wa-vkorg,

    wa-vtweg.

    endloop.

    SAMPLE REPORT2---

    Data: Begin of line,

    col1 type I,

    col2 type I,

    End of line.

    Data itab like line occurs 10.

    Do 2 times.

    Line-col1 = sy-index.

    Line-col2 = sy-index ** 2.

    Append line to itab.

    Enddo

    .

    Line-col1 = 11.

    Line-col2 = 22.

    Insert line into itab index 2.

    Insert initial line into itab index 1.

    Loop at itab into line.

    Write: / sy-tabix, Line-col1, Line-col2.

    Endloop.

    HOPE THIS MATERIAL HELPS U

    reward if useful

    thanks and regards

    suma sailaja

    Edited by: suma sailaja pvn on Jan 10, 2008 9:13 AM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.