Count of items in ALV report

Hi I have created an ALV report  on which i need  a count of number of lines after the sorting  and a grand total count .
I dont need a total value of the fields but instead a count of number of lines .
I have sorted by state ALV and then by the facility.I need a count of the number of lines for each facility and then for each region and then a grand count .
I am using the function  REUSE_ALV_GRID_DISPLAY to display the ALV I am using the is_sort paramater to sort the ALV by the State and facility .
What parameter do i use to give a count and a grabd count of all items

Hi Anjali,
Use this code, while defining the field catalog to hide the individual entries:-
wa_field-no_out = 'X'.
append wa_field to it_field.
And pass this it_field in the FM for ALV Display.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir

Similar Messages

  • Count of rows in ALv report

    Hi!
    I would like to get the count of rows in my ALV report . How to get the count of the rows ? Can anyone guide me in getting it dome please.
    Thanks

    Hi Gaddemmedi!
    I am attaching the report as you had asked for. I have added the things you asked me to do and now I am getting the count on the top of the page. The problem is that though it shows me the count of the lines from the LAV report on top but when I try to filter the records in the report that count first of all dosent change and remain the same as the initial number of record though after filtering records reduce and over that the count lines keep on increasing I mean the count is shown in repeated lines afet lines. Kindly help please.
    Thanks
    *& Report  ZSD_BILLING_HDR_TEXT_sum                                       *
    *&         billing doc. and associated header text report              *
    *&                            CHANGE LOG                               *
    *& jpoon 2007.08.03                  Change request: DEVK905095        *
    *& Move request: SD_1451_01          Requestor: Mona Fox               *
    *& FP14134 - original code.                                            *
    REPORT  zsd_billing_hdr_text_sum MESSAGE-ID zsd NO STANDARD PAGE HEADING.
    * For ALV usage
    TYPE-POOLS: slis.
    DATA: gs_layout   TYPE slis_layout_alv,
          tp_print    TYPE slis_print_alv,
          gt_sort     TYPE slis_t_sortinfo_alv,
          gt_events   TYPE slis_t_event,
          t_fieldcat  TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          repid       TYPE syrepid,               " ABAP Program.
          gt_list_top_of_page TYPE slis_t_listheader,     " Top of page text.
          alv_variant   TYPE disvariant," Customize Disp. Variant
          w_event type slis_alv_event.
    DATA: w_field    TYPE slis_fieldcat_alv.
    TABLES: vbrk, vbrp, vbpa.
    DATA  SLIS_EV_AFTER_OUTPUT.
    data: gs_list_top_of_page type slis_listheader.
    *data: gt_list_top_of_page type slis_t_listheader.
    * Definition of selection screen                                       *
    *   By plant, storage location, sold-to customers, material and        *
    *   posting date of the sales orders                                   *
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_vbeln  FOR  vbrk-vbeln,      " billing doc.
                    s_kunnr  FOR  vbpa-kunnr,      " bill-to customer number.
                    s_werks  FOR  vbrp-werks,      " line item plant.
                    s_fkdat  FOR  vbrk-fkdat,      " billing date.
                    s_fkart  FOR  vbrk-fkart,      " billing type.
                    s_vkorg  FOR  vbrk-vkorg.      " sales org.
    PARAMETERS:     p_hold   AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK one.
    * ALV display layout
    SELECTION-SCREEN BEGIN OF BLOCK layout WITH FRAME TITLE text-003.
    PARAMETERS: pa_vari TYPE slis_vari DEFAULT ' '. " Display variant.
    SELECTION-SCREEN END OF BLOCK layout.
    * Data Definitions                                                     *
    * Storing Extracted Info.
    TYPES: BEGIN OF t_extract,
             vbeln        TYPE vbeln_vf,   " Sales order number.
             posnr        TYPE posnr,      " line item
             fkart        TYPE fkart,      " billing type.
             vtext        TYPE BEZEI20,    " billing type description.
             fkdat        TYPE fkdat,      " billing date.
             werks        TYPE werks_d,    " line item plant.
             werks_name1  TYPE name1,      " plant description.
             kunnr        TYPE kunnr,      " bill-to customer.
             kunnr_name1  TYPE name1_gp,   " bill-to description.
             netwr        TYPE netwr,      " net value,invoice total $
             zzflag       TYPE boolean,    " hold indicator
             zzreason     TYPE char30,     " header text2 (reason)
             zzuser       TYPE ernam,      " last changed by
             zz_changed_date TYPE dats,    " last changed date
             zz_changed_time TYPE tims,    " last changed time
            END OF t_extract.
    DATA: it_extract  TYPE TABLE OF t_extract WITH HEADER LINE,
          it_extract2 TYPE TABLE OF t_extract WITH HEADER LINE.
    DATA: it_text TYPE TABLE OF tline WITH HEADER LINE.
    DATA: wa_thead type thead.
    DATA: w_tdname type TDOBNAME.
    DATA: L_COUNT TYPE I.
    * initialization
    INITIALIZATION.
      gs_layout-colwidth_optimize = 'X'.
      tp_print-no_print_listinfos = 'X'.
      tp_print-no_coverpage = 'X'.
      PERFORM set_fieldcat.
      PERFORM alv_eventtab_build USING:
    **    Event name     Form to execute     Event internal table
       'TOP_OF_PAGE'  'TOP_OF_PAGE'       gt_events[].
    * Dropdown list for all created ALV layouts, global or user-specific
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.
      PERFORM alv_variant_f4 CHANGING pa_vari.
    * Main BODY of processing logic
    START-OF-SELECTION.
      IF s_vbeln IS INITIAL
      AND s_kunnr IS INITIAL
      AND s_werks IS INITIAL
      AND s_fkdat IS INITIAL
      AND s_fkart IS INITIAL
      AND s_vkorg IS INITIAL.
         MESSAGE i000 WITH text-037 ' ' ' ' ' '.
      ELSE.
        PERFORM extract_data.
      ENDIF.
    END-OF-SELECTION.
      IF it_extract2[] IS INITIAL.
        MESSAGE i000 WITH text-002 ' ' ' ' ' '.
      ELSE.
    * Build headings for report.
    *    PERFORM build_top_of_page  USING gt_list_top_of_page[].
    * describe table it_extract2 lines l_count.
    *write :/ 'TOTAL NO OF ENTRIES', SY-VLINE, 32 L_COUNT.
          PERFORM call_alv.
    *write :/ 'TOTAL NO OF ENTRIES', SY-VLINE, 32 L_COUNT.
      ENDIF.
    *&      Form  EXTRACT_KEY_DATA
    * Retreive the data for the report.
    FORM extract_data.
      CLEAR: it_extract.  REFRESH: it_extract.
    * read and select billing documents
      IF p_hold IS INITIAL.
        SELECT vbrk~vbeln vbrk~fkart vbrk~fkdat vbrk~netwr
               vbrk~zzflag vbrk~zzreason vbrk~zzuser
               vbrk~zz_changed_date vbrk~zz_changed_time
               vbrp~posnr vbrp~werks
          INTO CORRESPONDING FIELDS OF TABLE it_extract
          FROM vbrk INNER JOIN vbrp ON
               vbrk~vbeln = vbrp~vbeln
         WHERE vbrk~vbeln IN s_vbeln
           AND vbrk~fkart IN s_fkart
           AND vbrk~fkdat IN s_fkdat
           AND vbrk~vkorg IN s_vkorg
           AND vbrk~fksto NE 'X'
           AND vbrp~werks IN s_werks.
      ELSE.
    * read 'held' documents only as per selection
        SELECT vbrk~vbeln vbrk~fkart vbrk~fkdat vbrk~netwr
               vbrk~zzflag vbrk~zzreason vbrk~zzuser
               vbrk~zz_changed_date vbrk~zz_changed_time
               vbrp~posnr vbrp~werks
          INTO CORRESPONDING FIELDS OF TABLE it_extract
          FROM vbrk INNER JOIN vbrp ON
               vbrk~vbeln = vbrp~vbeln
         WHERE vbrk~vbeln IN s_vbeln
           AND vbrk~fkart IN s_fkart
           AND vbrk~fkdat IN s_fkdat
           AND vbrk~vkorg IN s_vkorg
           AND vbrk~fksto NE 'X'
           AND vbrk~zzflag = 'X'
           AND vbrp~werks IN s_werks.
      ENDIF.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-002 ' ' ' ' ' '.
      ENDIF.
      CHECK sy-subrc = 0.
    * only need first line item for this report.
      SORT it_extract BY vbeln posnr.
      DELETE ADJACENT DUPLICATES FROM it_extract COMPARING vbeln.
      LOOP AT it_extract.
    * Retrieve and select by sales order bill-to on header level
    * as well as lookup bill-to customer name/description
        SELECT SINGLE kunnr FROM vbpa INTO it_extract-kunnr
         WHERE vbeln = it_extract-vbeln
           AND posnr = '000000'
           AND parvw = 'RE'.
        IF it_extract-kunnr IN s_kunnr.
          it_extract-kunnr_name1 = zcl_kna1=>get_name1( it_extract-kunnr ).
        ELSE.
          DELETE it_extract.
          CONTINUE.
        ENDIF.
    * lookup billing type description
        SELECT SINGLE vtext FROM tvfkt
          INTO it_extract-vtext
         WHERE spras = sy-langu
           AND fkart = it_extract-fkart.
        IF sy-subrc <> 0.
          clear it_extract-vtext.
        ENDIF.
    * lookup plant description
        SELECT SINGLE name1 FROM t001w
          INTO it_extract-werks_name1
         WHERE werks = it_extract-werks.
        IF sy-subrc <> 0.
          clear it_extract-werks_name1.
        ENDIF.
        MOVE-CORRESPONDING it_extract TO it_extract2.
        APPEND it_extract2.
       ENDLOOP.
    describe table it_extract2 lines l_count.
    ENDFORM.                    " EXTRACT_DATA
    *&      Form  SET_FIELDCAT
    * Create the field catalogue.
    FORM set_fieldcat .
    *CLEAR W_EVENT.
    *W_EVENT-FORM = SLIS_EV_AFTER_OUTPUT.
    *W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.
    *APPEND W_EVENT TO GT_EVENTS.
      CLEAR w_field.
      CLEAR t_fieldcat.  REFRESH t_fieldcat.
      w_field-col_pos = 1.
      w_field-fieldname = 'ZZFLAG'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Hold Printing'(005).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 2.
      w_field-fieldname = 'ZZREASON'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Reason'(036).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 3 .
      w_field-fieldname = 'VBELN'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Billing Doc'(028).
      w_field-emphasize = 'X'.
      w_field-hotspot   = 'X'.
      APPEND w_field TO t_fieldcat.
      CLEAR w_field.
      w_field-col_pos = 4 .
      w_field-fieldname = 'VTEXT'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Type Description'(030).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 5 .
      w_field-fieldname = 'FKDAT'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Billing Date'(031).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 6 .
      w_field-fieldname = 'WERKS'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Plant'(012).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 7 .
      w_field-fieldname = 'WERKS_NAME1'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Plant Description'(032).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 8.
      w_field-fieldname = 'KUNNR'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Bill-to Customer'(033).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 9 .
      w_field-fieldname = 'KUNNR_NAME1'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Bill-to Description'(034).
      w_field-emphasize = 'X'.
      w_field-hotspot   = 'X'.
      APPEND w_field TO t_fieldcat.
      CLEAR w_field.
      w_field-col_pos = 10 .
      w_field-fieldname = 'NETWR'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Invoice Amount'(035).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 11 .
      w_field-fieldname = 'ZZUSER'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Changed By'.
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 12 .
      w_field-fieldname = 'ZZ_CHANGED_DATE'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Last Changed Date'(006).
      APPEND w_field TO t_fieldcat.
      w_field-col_pos = 13 .
      w_field-fieldname = 'ZZ_CHANGED_TIME'.
      w_field-tabname = 'IT_EXTRACT2'.
      w_field-seltext_l = 'Last Changed Time'(007).
      APPEND w_field TO t_fieldcat.
    *  W_event-NAME = slis_ev_end_of_list.
    *  W_event-FORM = 'END_OF_LIST'.
    *  APPEND W_event  TO GT_EVENTS.
    *  CLEAR W_event .
    *  w_field-col_pos = 14 .
    *  w_field-fieldname = 'COUNT'.
    *  w_field-tabname = 'IT_EXTRACT2'.
    *  w_field-seltext_l = 'COUNT'.
    *  APPEND w_field TO t_fieldcat.
    ENDFORM.                    " SET_FIELDCAT
    *&      Form  CALL_ALV
    * Call the ALV Grid function.
    FORM call_alv .
      SORT it_extract BY vbeln.
    * repid is necessary since the ALV F.M. does not work properly with
    * sy-repid.
      repid = sy-repid.
      alv_variant-variant  = pa_vari.
      alv_variant-report   = sy-repid.
      alv_variant-username = sy-uname.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = repid
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = gs_layout
          it_fieldcat             = t_fieldcat[]
          it_sort                 = gt_sort[]
          i_default               = 'X'
          i_save                  = 'A'
          is_variant              = alv_variant
          it_events               = gt_events[]
          is_print                = tp_print
        TABLES
          t_outtab                = it_extract2
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
    write :/ 'TOTAL NO OF ENTRIES', SY-VLINE, 32 L_COUNT.
      IF sy-subrc NE 0.
        MESSAGE w000 WITH text-004 ' ' ' ' ' '.
      ENDIF.
    ENDFORM.                    " CALL_ALV
    *&      Form  alv_eventtab_build
    *     Pass list of events to be triggered by the ALV function module
    FORM alv_eventtab_build USING  u_name  TYPE slis_alv_event-name
                                   u_form  TYPE slis_alv_event-form
                                   alv_lt_events  TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.   " structure for event handling
      ls_event-name = u_name.
      ls_event-form = u_form.
      APPEND ls_event TO alv_lt_events.
    ENDFORM.                    " alv_eventtab_build
    *       FORM TOP_OF_PAGE                                              *
    FORM top_of_page.
    *gs_list_top_of_page-type = 'H'.
    GS_LIST_TOP_OF_PAGE-INFO = L_COUNT.
    APPEND GS_LIST_TOP_OF_PAGE TO GT_LIST_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'NEWALTA_LOGO'
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    " TOP_OF_PAGE
    *&      Form  user_command
    * Process the user command.
    *      -->R_UCOMM      User command
    *      -->RS_SELFIELD  Field selected
    FORM user_command USING r_ucomm     LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      DATA: ltp_vbeln TYPE vbeln.  " Sales document number.
      CASE  r_ucomm.
        WHEN '&IC1'.
          IF ( rs_selfield-fieldname = 'VBELN'
            OR rs_selfield-fieldname = 'BILL_VBELN' )
           AND rs_selfield-value IS NOT INITIAL.        " Display sales document.
            ltp_vbeln = rs_selfield-value.
            zcl_sales_doc=>display( ltp_vbeln ).
          ENDIF.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  alv_v-ariant_f4
    * Get the display variant.
    *      <--CTP_VARI  Variant name
    FORM alv_variant_f4 CHANGING ctp_vari TYPE slis_vari.
      alv_variant-report   = sy-repid.             " Report ID
      alv_variant-username = sy-uname.             " User ID
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = alv_variant
          i_save     = 'A'
        IMPORTING
          es_variant = alv_variant
        EXCEPTIONS
          OTHERS     = 1.
      IF sy-subrc = 0.
        ctp_vari = alv_variant-variant.
      ENDIF.
    ENDFORM.                    " alv_variant_f4

  • Count of Items in BEx Report

    Dear Experts,
    We have a report that contains item level data (multiple records for same item in the report). We would like to see the count of records for these items based on aggregation levels.
    Since the data is on item level, we have same items available in multiple lines that gives me wrong results.
    For e.g, I'd like to see the report that shows the count of items based on some fields like below.
    Region
    Count of Items
    ELAT
    20
    AMEA
    40
    NAM
    38
    So, if I drill down on Sub-region level, I should get the proper count of items as below.
    Region
    Sub region
    Count of Items
    ELAT
    ER1
    10
    ELAT
    ER2
    5
    ELAT
    ER3
    5
    AMEA
    AR1
    40
    NAM
    NR1
    10
    MAN
    NR2
    28
    So, the count is same for the above report with additional drill down on Sub region.
    When I use Exception Aggregation based on reference characteristic, I'm getting results, but, it varies on different aggregation levels (drill downs of other characteristics).
    When I use formula to show '1' for each record, the aggregation shows wrong values, because of multiple records with same item numbers in the report.
    I'm not sure Constant Selection would help me because, these are item level data.
    Any idea on how to achieve this is much appreciated.
    Let me know for any clarifications.
    Br, Harish

    Hi Yasemin ULUTURK,
    I have a similar requirement in which I need to get a count of RKFs in the report.
    This RKF is a subset of items count that was formulated earlier using your approach.
    Since the count is a formula, I cannot use this for creating an RKF based on it.
    Any idea on how to achieve this is highly helpful.
    Br, Harish

  • How to add field to the header for FBL5N ALV report

    Hi,
       I need to add fields to the customer line item display ALV report(FBL5N) header part.Right now there are four fields in the header like customer, company code, name and city, after that I need to add first name last name and phone no. Can any one tell me where exactly I need to add and populate there fields to be appear in ALV output list.
    Thanks in Advance
    Swapna

    Yes I have tried, I have place a break point in that perform but it does not stop. I think that is not the correct place to added and populate fields. That routine is for populate selection screen ranges single and multiple values and parameters only.
    Thanks
    Swapna

  • How can we assign different colours to different records(line items) in alv

    how can we assign different colours to different records(line items) in alv reporting?

    Hi Friend,
    Please see this SDN Wiki  for setting the color in ALV :[http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP-DevelopingInteractiveALVReportusing+OOABAP]
    There are so many SDN Wiki's on this  just try with search  Alv Color display in SDN,
    Regards,

  • Count of Sales documenst in a ALV report

    Hi Gurus!
    I have an ALv report that gives me a list of sales document number with other data associated with it like the material number , status , date , iem ect ect. Each docum,ent can have several line items associated with it and it shows on teh report . I have used a count column in my report which gives me the count of line items in the report . Now what I want is the count of documnet numbers in the report rather than the count of line items , which will enable to know how many sales document are ther in the report for therie r report purpose. Is ot possible to get a count of teh document numbers in the ALV report output apart from teh count of the line items . Will I ahve to make changes in my report or it can be acheived in the layout itself. Kindly advice please.
    Thanks

    I ahve done as said
    report  zztest message-id zsd no standard page heading.
    * For ALV usage
    type-pools: slis.
    data: gs_layout   type slis_layout_alv,
          tp_print    type slis_print_alv,
          gt_sort     type slis_t_sortinfo_alv,
          gt_events   type slis_t_event,
          t_fieldcat  type slis_t_fieldcat_alv with header line,
          repid       type syrepid,               " ABAP Program.
          gt_list_top_of_page type slis_t_listheader,     " Top of page text.
          alv_variant   type disvariant.           " Customize Disp. Variant
    data: w_field    type slis_fieldcat_alv.
    data: gs_list_top_of_page type slis_listheader.
    data: l_count type I.
    data: l_vbeln type I.
    tables: vbak, vbap, vbpa, knvv.
    *DATA : v_count type N.
    DATA :  count1 type N.
    * Definition of selection screen                                       *
    *   By plant, storage location, sold-to customers, material and        *
    *   posting date of the sales orders                                   *
    selection-screen begin of block one with frame title text-001.
    parameters:     p_vkorg  type vkorg obligatory memory id vko,"DEVK906677
                    p_vtweg  type vtweg obligatory default '01',
                    p_spart  type spart obligatory default '01'.
    select-options: s_vkbur  for  vbak-vkbur,      " Sales Office     "DEVK906677
                    s_kunnr  for  vbak-kunnr.      " Sold-to customer number.
    select-options: s_shipto for  vbap-oid_ship,   " Ship-to customer number.
                    s_billto for  vbpa-kunnr,      " bill-to from S.O. header.
                    s_load   for  vbpa-kunnr,      " Load confirmation contact.
                    s_truck  for  vbap-oid_extbol. " Trucking ticket number.
    select-options: s_werks for vbap-werks obligatory no intervals. " Plant.
    select-options: s_lgort for vbap-lgort.        " Storage location.
    select-options: s_matnr for vbap-matnr.        " Material number.
    select-options: s_konda for knvv-konda.        " price group
    selection-screen skip 1.
    select-options: s_vdatu for vbak-vdatu default sy-datum.
    selection-screen end of block one.
    * ALV display layout
    selection-screen begin of block layout with frame title text-003.
    parameters: pa_vari type slis_vari default ' '. " Display variant.
    selection-screen end of block layout.
    selection-screen begin of block two with frame title text-028.
    selection-screen comment: /1(79) text-029.
    selection-screen comment: /1(79) text-030.
    selection-screen comment: /1(79) text-031.
    selection-screen comment: /1(79) text-032.
    selection-screen comment: /1(79) text-033.
    selection-screen comment: /1(79) text-034.
    selection-screen comment: /1(79) text-035.
    selection-screen comment: /1(79) text-036.
    selection-screen end of block two.
    * Data Definitions                                                     *
    * Storing Extracted Info.
    types: begin of t_extract,
             vbeln        type vbeln_va,   " Sales order number.
             augru        type augru,      " order reason
             vdatu        type edatu_vbak, " Requested delivery date.
             kunnr        type kunag,      " Sold-to customer number.
             posnr        type posnr_va,   " Item number.
             matnr        type matnr,      " Material number.
             vrkme        type vrkme,      " Sales UoM.
             mseh3        type mseh3,      " UoM text.
             netwr        type netwr_ap,   " Net value of the order item.
             kwmeng       type p length 13 decimals 1, " Quantity.
             werks        type werks_d,    " Plant.
             lgort        type lgort_d,    " Storage location.
             oid_extbol   type oid_extbol, " External BOL or truck ticker header.
             maktx        type maktx,      " Material description.
             soldto_name  type name1_gp,   " Sold-to name.
             oid_ship     type kunwe,      " Ship-to customer number.
             shipto_name  type name1_gp,   " Ship-to name.
             billto       type kunre,      " Bill-to customer number.
             billto_name  type name1_gp,   " Bill-to name.
             load_contact type kunnr,      " Load confirmation contact.
             load_name    type name1_gp,   " Load confirmation contact name.
             truck        type kunnr,      " Truck company number.
             truck_name   type name1_gp,   " Truck company name.
             bstkd        type bstkd,      " PO number.
             ihrez        type ihrez,      " AFE number per the contract/sales order.
             delivery     type vbeln_vl,   " Delivery number.
             posnr_vl     type posnr_vl,   " Delivery item number.
             bill_vbeln   type vbeln_vf,   " Invoice number.
             bill_posnr   type posnr_vf,   " Invoice item number.
             bill_netwr   type netwr_fp,   " Invoice net value.
             statu        type stats,      " Document status.
             auart        type auart,      " order type
             vkorg        type vkorg,      " sales org.
             vtweg        type vtweg,      " distrbtn channel
             spart        type spart,      " division
             vkbur        like vbak-vkbur, " Sales Office DEVK906677
             konda        type konda,      " price group
             tdline       type tdline,     " text for customer account reference
             count        type I ,
           end of t_extract.
    data :
      it_extract  type table of t_extract with header line,
      it_extract2 type table of t_extract with header line.
    data: it_text type table of tline with header line.
    data: w_index type sy-index,
          w_tdname type tdobname.
    constants: c_minus1       type netwr_ap value '1.00-'.
    *RANGES: r_auart FOR vbak-auart.
    data: r_auart type range of t_extract-auart,
          r_auart_line like line of r_auart.
    * initialization
    initialization.
      gs_layout-colwidth_optimize = 'X'.
      tp_print-no_print_listinfos = 'X'.
      tp_print-no_coverpage = 'X'.
      perform set_fieldcat.
      perform alv_eventtab_build using:
    **    Event name     Form to execute     Event internal table
       'TOP_OF_PAGE'  'TOP_OF_PAGE'       gt_events[].
    * changed to exclude following order types
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZEQ'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * credit memo
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZPRC'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * debit memo
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZPRD'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZDR'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * Industry sales order correction
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZSOC'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * oilfield FF correction
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZOCF'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * oilfield WP correction
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZOCW'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * Dropdown list for all created ALV layouts, global or user-specific
    at selection-screen on value-request for pa_vari.
      perform alv_variant_f4 changing pa_vari.
    * Main BODY of processing logic
    start-of-selection.
      perform extract_data.
    end-of-selection.
      if not it_extract[] is initial.
    * Build headings for report.
        perform build_top_of_page  using gt_list_top_of_page[].
        perform call_alv.
      endif.
    *&      Form  EXTRACT_KEY_DATA
    * Retreive the data for the report.
    form extract_data.
      clear: it_extract.  refresh: it_extract.
    * orders
      select vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
             vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
             vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
             vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
        into corresponding fields of table it_extract
        from vbak inner join vbap
             on  vbak~mandt = vbap~mandt
             and vbak~vbeln = vbap~vbeln where
        vbak~auart not in r_auart and
        vbak~vkorg eq p_vkorg and
        vbak~vtweg eq p_vtweg and
        vbak~spart eq p_spart and
        vbak~vkbur in s_vkbur and                               "DEVK906677
        vbak~vdatu in s_vdatu and
        vbak~kunnr in s_kunnr and
        vbap~matnr in s_matnr and
        vbap~werks in s_werks and
        vbap~lgort in s_lgort and
        vbap~oid_extbol in s_truck and
        vbap~oid_ship in s_shipto.
      if sy-subrc <> 0.
        message i000 with text-002 ' ' ' ' ' '.
      endif.
      sort it_extract by vbeln.
      check sy-subrc = 0.
      loop at it_extract.
        at new vbeln.
          count1 = count1 + 1.
        endat.
    * Retrieve and select by load confirmation contacts from header
        select single kunnr from vbpa into it_extract-load_contact
         where vbeln = it_extract-vbeln
           and posnr = '000000'
           and parvw = 'ZB'.
        if it_extract-load_contact in s_load.
          it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
        else.
          delete it_extract.
          continue.
        endif.
    * Retrieve and select by sales order bill-to on header level
    * as well as lookup bill-to customer name/description
        select single kunnr from vbpa into it_extract-billto
         where vbeln = it_extract-vbeln
           and posnr = '000000'
           and parvw = 'RE'.
        if sy-subrc = 0.
          if s_billto is initial.
            it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
          else.
            if it_extract-billto in s_billto.
              it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
            else.
              delete it_extract.
              continue.
            endif.
          endif.
        else.
    * Newalta - always has bill-to, following will not occur but included
    *           as good programming practice.
          it_extract-billto_name = it_extract-billto.
        endif.
    * Retrieve and select by price group of sold-to
        select single konda from knvv into it_extract-konda
         where kunnr = it_extract-kunnr
           and vkorg = it_extract-vkorg
           and vtweg = it_extract-vtweg
           and spart = it_extract-spart.
        if sy-subrc = 0.
          if not ( it_extract-konda in s_konda ).
            delete it_extract.
            continue.
          endif.
        endif.
    * Retrieve trucking company customer
        select single kunnr from vbpa into it_extract-truck where
          vbeln = it_extract-vbeln and
          posnr = '000000' and
          parvw = 'ZT'.
        if sy-subrc = 0.
          it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
        endif.
    * Retrieve sold-to name
        it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
    * Retrieve ship-to name
        it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
    * lookup P.O.
        select single bstkd ihrez from vbkd into (it_extract-bstkd, it_extract-ihrez)
         where vbeln = it_extract-vbeln
           and posnr = '000000'.
    * Retreive the material description.
        it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
    * cosmetic change of material number, donot display leading zeros.
        shift it_extract-matnr left deleting leading '0'.
    * translate unit of measure
        it_extract-mseh3 = it_extract-vrkme.
        select single mseh3 from t006a into it_extract-mseh3
         where spras = sy-langu
           and msehi = it_extract-vrkme.
        w_tdname = it_extract-vbeln.
    * read customer account reference which is under 'text'
        call function 'READ_TEXT'
          exporting
            client                        = sy-mandt
            id                            = 'Z010'
            language                      = sy-langu
            name                          = w_tdname
            object                        = 'VBBK'
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        =
          tables
            lines                         = it_text
          exceptions
            id                            = 1
            language                      = 2
            name                          = 3
            not_found                     = 4
            object                        = 5
            reference_check               = 6
            wrong_access_to_archive       = 7
            others                        = 8.
        if sy-subrc = 0.
          read table it_text index 1.
          if sy-subrc = 0.
            it_extract-tdline = it_text-tdline.
          else.
            clear it_extract-tdline.
          endif.
        else.
          clear it_extract-tdline.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
    * Get the delivery item.
        call method zcl_vbap=>get_delivery
          EXPORTING
            itp_vbeln = it_extract-vbeln
            itp_posnr = it_extract-posnr
          IMPORTING
            etp_vbeln = it_extract-delivery
            etp_posnr = it_extract-posnr_vl.
        if it_extract-delivery is not initial.
          perform process_deliveries.
        else.
          perform invoice_process.
        endif.
        it_extract-count = 1.
        move-corresponding it_extract to it_extract2.
        append it_extract2.
      endloop.
      describe table it_extract2 lines count1.
    endform.                    " EXTRACT_DATA
    *&      Form  SET_FIELDCAT
    * Create the field catalogue.
    form set_fieldcat .
      clear w_field.
      clear t_fieldcat.  refresh t_fieldcat.
      w_field-col_pos = 1.
      w_field-fieldname = 'VBELN'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Document.Nbr'.
      w_field-emphasize = 'X'.
      w_field-hotspot   = 'X'.
      append w_field to t_fieldcat.
      clear w_field.
      w_field-col_pos = 2 .
      w_field-fieldname = 'POSNR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Item'(023).
      append w_field to t_fieldcat.
      clear w_field.
      w_field-col_pos = 3 .
      w_field-fieldname = 'VDATU'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Req. Del. Date'(005).
      append w_field to t_fieldcat.
      w_field-col_pos = 4 .
      w_field-fieldname = 'SOLDTO_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Sold-to'(006).
      append w_field to t_fieldcat.
      w_field-col_pos = 5 .
      w_field-fieldname = 'MATNR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Material'(007).
      append w_field to t_fieldcat.
      w_field-col_pos = 6 .
      w_field-fieldname = 'KWMENG'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Quantity'(008).
      append w_field to t_fieldcat.
      w_field-col_pos = 7.
      w_field-fieldname = 'MSEH3'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'UOM'(009).
      append w_field to t_fieldcat.
      w_field-col_pos = 8 .
      w_field-fieldname = 'BILL_VBELN'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Invoice #'(010).
      w_field-emphasize = 'X'.
      w_field-hotspot   = 'X'.
      append w_field to t_fieldcat.
      clear w_field.
      w_field-col_pos = 9 .
      w_field-fieldname = 'BILL_NETWR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Values'(011).
      append w_field to t_fieldcat.
      w_field-col_pos = 10.
      w_field-fieldname = 'WERKS'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Plant'(012).
      append w_field to t_fieldcat.
      w_field-col_pos = 11.
      w_field-fieldname = 'LGORT'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Storage Loc'(013).
      append w_field to t_fieldcat.
      w_field-col_pos = 12 .
      w_field-fieldname = 'MAKTX'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Description'(014).
      append w_field to t_fieldcat.
      w_field-col_pos = 13 .
      w_field-fieldname = 'SHIPTO_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Ship-to'(015).
      append w_field to t_fieldcat.
      w_field-col_pos = 14 .
      w_field-fieldname = 'BILLTO_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Bill-to'(016).
      append w_field to t_fieldcat.
      w_field-col_pos = 15 .
      w_field-fieldname = 'LOAD_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Load Contact'(017).
      append w_field to t_fieldcat.
      w_field-col_pos = 16 .
      w_field-fieldname = 'TRUCK_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Truck Comp.'(018).
      append w_field to t_fieldcat.
      w_field-col_pos = 17 .
      w_field-fieldname = 'BSTKD'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'P.O.'(019).
      append w_field to t_fieldcat.
      w_field-col_pos = 18 .
      w_field-fieldname = 'IHREZ'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'AFE Nbr'(020).
      append w_field to t_fieldcat.
      w_field-col_pos = 19 .
      w_field-fieldname = 'OID_EXTBOL'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Truck Ticket'(021).
      append w_field to t_fieldcat.
      w_field-col_pos = 20.
      w_field-fieldname = 'STATU'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Status'(022).
      append w_field to t_fieldcat.
      w_field-col_pos = 21.
      w_field-fieldname = 'AUGRU'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Ord.Reason'(024).
      append w_field to t_fieldcat.
      w_field-col_pos = 22.
      w_field-fieldname = 'TDLINE'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'cstmr.acct.ref.'(027).
      append w_field to t_fieldcat.
      w_field-col_pos = 23 .                                    "DEVK906678
      w_field-fieldname = 'VKBUR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Sales Office'(037).
      append w_field to t_fieldcat.
      w_field-col_pos = 24.
      w_field-fieldname = 'KUNNR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Sold-to Customer'(038).
      append w_field to t_fieldcat.
      w_field-col_pos = 25.
      w_field-fieldname = 'OID_SHIP'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Ship-to Customer'(039).
      append w_field to t_fieldcat.
      w_field-col_pos = 26.
      w_field-fieldname = 'BILLTO'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Bill-to Customer'(040).
      append w_field to t_fieldcat.
      w_field-col_pos = 27.
      w_field-fieldname = 'COUNT'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Count'(041).
      w_field-do_sum = 'X'.
      append w_field to t_fieldcat.
    endform.                    " SET_FIELDCAT
    *&      Form  CALL_ALV
    * Call the ALV Grid function.
    form call_alv .
      sort it_extract by lgort vbeln.
    * repid is necessary since the ALV F.M. does not work properly with
    * sy-repid.
      repid = sy-repid.
      alv_variant-variant  = pa_vari.
      alv_variant-report   = sy-repid.
      alv_variant-username = sy-uname.
      call function 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = repid
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = gs_layout
          it_fieldcat             = t_fieldcat[]
          it_sort                 = gt_sort[]
          i_default               = 'X'
          i_save                  = 'A'
          is_variant              = alv_variant
          it_events               = gt_events[]
          is_print                = tp_print
        TABLES
          t_outtab                = IT_EXTRACT2
        EXCEPTIONS
          program_error           = 1
          others                  = 2.
      if sy-subrc ne 0.
        message w000 with text-004 ' ' ' ' ' '.
      endif.
    endform.                    " CALL_ALV
    *&      Form  build_top_of_page
    * Build heading for report.                                            *
    *      -->P_GT_LIST_TOP_OF_PAGE[]  Header stuff for report
    form build_top_of_page using   e04_lt_top_of_page type slis_t_listheader.
      data: ls_line type slis_listheader.  "Header table for top of page
    * construct 'top of page' info. to display. In this case, one line.
      data: w_selections(40) type c,
            w_date_from(10) type c,
            w_date_to(10) type c.
      write: s_vdatu-low to w_date_from dd/mm/yyyy.
      if s_vdatu-high is not initial.
        write: s_vdatu-high to w_date_to dd/mm/yyyy.
        clear w_selections.
        concatenate 'Del.Req.Date: ' w_date_from 'To' w_date_to
          into w_selections separated by space.
        clear ls_line.
        ls_line-typ  = 'H'.
        ls_line-info = w_selections.
        append ls_line to e04_lt_top_of_page.
        gs_list_top_of_page-typ = 'S'.
        gs_list_top_of_page-info = ' Total number of Sales Documents'.
        append gs_list_top_of_page to gt_list_top_of_page.
        gs_list_top_of_page-typ  = 'S'.
        gs_list_top_of_page-info = count1.
        append gs_list_top_of_page to gt_list_top_of_page.
      else.
        clear w_date_to.
        concatenate 'Del.Req.Date: ' w_date_from
             into w_selections separated by space.
        clear ls_line.
        ls_line-typ  = 'H'.
        ls_line-info = w_selections.
        append ls_line to e04_lt_top_of_page.
      endif.
    endform.                    " build_top_of_page
    *&      Form  alv_eventtab_build
    *     Pass list of events to be triggered by the ALV function module
    form alv_eventtab_build using  u_name  type slis_alv_event-name
                                   u_form  type slis_alv_event-form
                                   alv_lt_events  type slis_t_event.
      data: ls_event type slis_alv_event.   " structure for event handling
      ls_event-name = u_name.
      ls_event-form = u_form.
      append ls_event to alv_lt_events.
    endform.                    " alv_eventtab_build
    *       FORM TOP_OF_PAGE                                              *
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'LOGO'
          it_list_commentary = gt_list_top_of_page.
    endform.                    " TOP_OF_PAGE
    *&      Form  process_deliveries
    * Process the delivery related records.
    form process_deliveries .
      data:
        ltp_date  type wadat_ist, " Goods movement date.
        ltp_vbtyp type vbtyp_n,
        ltp_mtart type mtart, " Material type.
        w_lfimg   type lfimg, " Actual quantity delivered (in sales units).
        w_vrkme   type vrkme. " Sales unit of measure.
    * Read delivery quantity and uom.
      select single lfimg vrkme into (w_lfimg, w_vrkme)
        from lips where
        vbeln = it_extract-delivery and
        posnr = it_extract-posnr_vl.
    * these fields have values from vbap. override with lips values
      if sy-subrc = 0.
        it_extract-kwmeng = w_lfimg.
        it_extract-vrkme  = w_vrkme.
    * translate unit of measure
        it_extract-mseh3 = it_extract-vrkme.
        select single mseh3 from t006a into it_extract-mseh3
         where spras = sy-langu
           and msehi = it_extract-vrkme.
      endif.
    * Determine STATUS by reading 'service confirmation', R (goods movemt)
    * it is possible to have multiple 'service confirmation' records for
    * one item. ie. delivery 80010390 in PRD.
    * As long as there is at least one 'service confirmation' record,
    * status is considered 'complete'.
    * Validate the created on date of the goods movement or service confirmation.
      ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
    *  ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
    *                           itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
      call method zcl_lips=>get_goods_mvt_info
        EXPORTING
          itp_vbeln = it_extract-delivery
          itp_posnr = it_extract-posnr_vl
          itp_mtart = ltp_mtart
        IMPORTING
          rtp_date  = ltp_date
          rtp_vbtyp = ltp_vbtyp.
    * 'h' is cancel goods issue
      if ltp_vbtyp = 'h'.
        it_extract-statu = 'Incomplete'(025).
      else.
        if ltp_date is not initial.
          it_extract-statu = 'COMPLETE'(026).
        endif.
      endif.
    * Retrieve the invoice/billing document item.
      call method zcl_lips=>get_invoice
        EXPORTING
          itp_vbeln = it_extract-delivery
          itp_posnr = it_extract-posnr_vl
        IMPORTING
          rtp_vbeln = it_extract-bill_vbeln
          rtp_posnr = it_extract-bill_posnr.
      if it_extract-bill_vbeln is not initial.
    * retrieve net value from the invoice.
        clear it_extract-bill_netwr.
        select single netwr into it_extract-bill_netwr from vbrp
         where vbeln = it_extract-bill_vbeln
           and posnr = it_extract-bill_posnr.
      else.
        it_extract-bill_netwr = it_extract-netwr. " Use order net value.
      endif.
    endform.                    " process_deliveries
    *&      Form  user_command
    * Process the user command.
    *      -->R_UCOMM      User command
    *      -->RS_SELFIELD  Field selected
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
      data: ltp_vbeln type vbeln.  " Sales document number.
      case  r_ucomm.
        when '&IC1'.
          if ( rs_selfield-fieldname = 'VBELN'
            or rs_selfield-fieldname = 'BILL_VBELN' )
           and rs_selfield-value is not initial.        " Display sales document.
            ltp_vbeln = rs_selfield-value.
            zcl_sales_doc=>display( ltp_vbeln ).
          endif.
      endcase.
    endform.                    "user_command
    *&      Form  invoice_process
    * Process for orders without deliveries.                               *
    form invoice_process .
    * Translate unit of measure.
      select single mseh3 from t006a into it_extract-mseh3
       where spras = sy-langu
         and msehi = it_extract-vrkme.
    * Retrieve the invoice/billing document item.
      call method zcl_vbap=>get_invoice
        EXPORTING
          itp_vbeln = it_extract-vbeln
          itp_posnr = it_extract-posnr
        IMPORTING
          rtp_vbeln = it_extract-bill_vbeln
          rtp_posnr = it_extract-bill_posnr.
      if it_extract-bill_vbeln is not initial.
    * retrieve net value from the invoice.
        clear it_extract-bill_netwr.
        select single netwr into it_extract-bill_netwr from vbrp
         where vbeln = it_extract-bill_vbeln
           and posnr = it_extract-bill_posnr.
      else. " If no Invoice, then status becomes 'incomplete'.
        it_extract-bill_netwr = it_extract-netwr. " Use order net value.
        it_extract-statu = 'Incomplete'(025).
      endif.
    endform.                    " invoice_process
    *&      Form  alv_variant_f4
    * Get the display variant.
    *      <--CTP_VARI  Variant name
    form alv_variant_f4 changing ctp_vari type slis_vari.
      alv_variant-report   = sy-repid.             " Report ID
      alv_variant-username = sy-uname.             " User ID
      call function 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = alv_variant
          i_save     = 'A'
        IMPORTING
          es_variant = alv_variant
        EXCEPTIONS
          others     = 1.
      if sy-subrc = 0.
        ctp_vari = alv_variant-variant.
      endif.
    endform.                    " alv_variant_f4

  • ALV report i want to display in each P.O , i want to display item details

    Hi all,
    in alv report i want to display in each P.O , i want to display item details. is it possible without hierarchical display.

    hi,
    once you retrive po number from ekko then retrive data from ekpo and loop at ekpo and append all the item details to your internal table.

  • ALV Report: Input on some line items

    Dear All,
    Can you please help me out in this requirement..
    I have a ALV report with checkbox. If I select some checkbox line items and click on Edit button(Custom button) those line items should get enabled and user should be able to input value for those line items. INPUT in fieldcatalog enables the entire set of output, not individually those line items.
    Please can you suggest on that?
    Thanks and regards,
    Atanu

    Hi,
    Herewith i am sending the sample code for the CHECKBOX ALV REPORT.
    TYPE-POOLS: slis.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    DATA: s_layout TYPE slis_layout_alv.
    DATA: BEGIN OF itab OCCURS 0,
    icon TYPE icon-id,
    vbeln TYPE vbeln,
    kunnr TYPE kunnr,
    erdat TYPE erdat,
    box TYPE c,
    END OF itab.
    DATA: v_repid TYPE syrepid.
    START-OF-SELECTION.
    Get the data.
    SELECT vbeln kunnr erdat UP TO 100 ROWS
    FROM vbak
    INTO CORRESPONDING FIELDS OF TABLE itab.
    IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'No data found'.
    LEAVE LIST-PROCESSING.
    ENDIF.
    Modify the record with red light.
    itab-icon = '@0A@'.
    MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
    v_repid = sy-repid.
    Get the field catalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '1'.
    s_fieldcatalog-fieldname = 'ICON'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-seltext_l = 'Status'.
    s_fieldcatalog-icon = 'X'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '2'.
    s_fieldcatalog-fieldname = 'VBELN'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'VBELN'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '3'.
    s_fieldcatalog-fieldname = 'KUNNR'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'KUNNR'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '4'.
    s_fieldcatalog-fieldname = 'ERDAT'.
    s_fieldcatalog-tabname = 'ITAB'.
    s_fieldcatalog-rollname = 'ERDAT'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    Set the layout.
    s_layout-box_fieldname = 'BOX'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    is_layout = s_layout
    i_callback_pf_status_set = 'SET_PF_STATUS'
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat = t_fieldcatalog[]
    TABLES
    t_outtab = itab.
    FORM SET_PF_STATUS *
    --> EXTAB *
    FORM set_pf_status USING extab TYPE slis_t_extab.
    SET PF-STATUS 'TEST2'.
    ENDFORM.
    FORM user_command *
    --> UCOMM *
    --> SELFIELD *
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
    Check the ucomm.
    IF ucomm = 'DETAIL'.
    LOOP AT itab WHERE box = 'X'.
    itab-icon = '@08@'.
    MODIFY itab TRANSPORTING icon.
    ENDLOOP.
    ENDIF.
    selfield-refresh = 'X'.
    ENDFORM.
    Thanks,
    Shankar

  • ALV report-Add a count row at teh botttom.

    Hi!
    I would like to adda row to my ALV report at the bottom of the report which will show me the count of number of billing documents existing in the repport. Even when the report is fileterd on certain conditions , the total at teh bottom should change as per the records showing. basically I need to add a total row at teh bottom of my report which will give the number of billintg documents that show up in the report.
    Is it possible ? If so how do I go about please.
    Thanks

    I have this , but not sure where to insert the line count in this .
    *&      Form  CALL_ALV
    Call the ALV Grid function.
    FORM call_alv .
      SORT it_extract BY vbeln.
    repid is necessary since the ALV F.M. does not work properly with
    sy-repid.
      repid = sy-repid.
      alv_variant-variant  = pa_vari.
      alv_variant-report   = sy-repid.
      alv_variant-username = sy-uname.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = repid
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = gs_layout
          it_fieldcat             = t_fieldcat[]
          it_sort                 = gt_sort[]
          i_default               = 'X'
          i_save                  = 'A'
          is_variant              = alv_variant
          it_events               = gt_events[]
          is_print                = tp_print
        TABLES
          t_outtab                = it_extract2
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
      IF sy-subrc NE 0.
        MESSAGE w000 WITH text-004 ' ' ' ' ' '.
      ENDIF.
    ENDFORM.                    " CALL_ALV
    *&      Form  alv_eventtab_build
        Pass list of events to be triggered by the ALV function module
    FORM alv_eventtab_build USING  u_name  TYPE slis_alv_event-name
                                   u_form  TYPE slis_alv_event-form
                                   alv_lt_events  TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.   " structure for event handling
      ls_event-name = u_name.
      ls_event-form = u_form.
      APPEND ls_event TO alv_lt_events.
    ENDFORM.                    " alv_eventtab_build
          FORM TOP_OF_PAGE                                              *
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'NEWALTA_LOGO'
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    " TOP_OF_PAGE
    You said the count will show along with or below the LOGO on top , but how do I incorporate the line count ihn it?

  • Vendor open items wise ALV Grid Display (FBL1N) report to Excel Sheet

    Hi All,
    I need vendor wise open items and cleared items in ALV Grid format in excel sheet.
    I'm Trying that in T Code FBL1N, After the execution. I had select ALV Grid format like this From the menu bar->Settings-> Switch list.
    After that i get ALV  Grid format, Then i'm doing export the data to excel sheet. like this From the Menu bar->List->Export->Spread sheet.
    That time i'm getting Error Message no. 0K064, Filter criteria, sorting, totals and subtotals are not taken into account.
    I want vendor wise sorting totals and subtotals,
    How can i over come this Error please let me now.
    Thanks,
    Amar

    Hi Amar,
    Please check the KBA 2083705.
    https://websmp230.sap-ag.de/sap(bD1odSZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3230383337303526
    Regards,
    Monika

  • How to give no of lines per page in alv report

    hi
    could anybody tell me
    how to give no of lines per page in alv report
    i need bottom of page too
    if possible plz send the code too
    it ll be very helpful to me
    thanx
    kals.

    Hi,
    This is possible, using some of the events in the ALV.
    You could use AFTER_LINE_OUTPUT event and call you form after say, a certain line count is reached on the list output.
      MOVE 'AFTER_LINE_OUTPUT' TO gw_event-name.
      MOVE 'AFTER_LINE_OUTPUT' TO gw_event-form.
      APPEND gw_event TO gt_events.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                it_events                = gt_events[]
    and define the form for each event as follows - this would be a dynamic call by the ALV.
    *&      Form  after_line_output
    *       Form for the After Line Output Event in the internal table
    *      --> rs_lineinfo
    FORM after_line_output USING rs_lineinfo TYPE slis_lineinfo.
      IF sy-linno eq v_linno.          "Defaulted value for line count
        perform write_footer.
        NEW-PAGE.
      ENDIF.
    ENDFORM.                    " after_line_output
    For lines per page:
    rs_lineinfo-tabindex would give you the index of the current line in the list, which you could use to read the t_outtab table, and reduce the line count of items displayed on the earlier page.
    There are a few other events too, like BEFORE_LINE_OUTPUT and END_OF_LIST which you can use as required and print the data.
    Regards,
    Anil.

  • Problem in ALV report o/p to Excel

    Hi to all
    I have developed an ALV report, which is showing correct display and out put.
    But when I am downloading it to excel, o/p is not coming in proper way. Fields are misplaced from there actual place and not in readable condition.
    Please guide me..
    Regards
    Anubhav

    Hello Lakshmiraj
    I am sending you the coding of my ALV report program.
    Please check.
    REgards
    Anubhav
    *& Report  YRMR033_AMENDMENT_ORDER_LIST
    *& DEVELOPER : ANUBHAV GUPTA
    *& DATE : 21.03.2008
    *&  REPORT DESCRIPTION : REPORT TO DISPLAY  AMENDMENTS IN PURCDHASE ORDERS
                            WITH OLD VALUES AND NEW VALUES.
    REPORT YRMR033_AMENDMENT_ORDER_LIST LINE-SIZE 132 NO STANDARD PAGE HEADING
    LINE-COUNT 065(001)
    MESSAGE-ID VR.
    TABLES: DD04T,
    CDHDR,
    CDPOS,
    DD03L,
    DD41V,
    T685T,
    VBPA,
    TPART,
    KONVC,
    EKKO.
    TABLES : NAST,  LFA1,ekpo.
    SELECT-OPTIONS: "XUDATE FOR nast-erdat OBLIGATORY, "Created on date
                    XUDATE FOR CDHDR-UDATE OBLIGATORY, "Amendment date
                    S_EKGRP FOR EKKO-EKGRP,
                    s_lifnr for ekko-lifnr.
    SELECTION-SCREEN SKIP.
    DATA: WFLAG,
    WCHANGENR LIKE CDHDR-CHANGENR.
    DATA: INDTEXT(60) TYPE C.
    DATA: BEGIN OF ICDHDR OCCURS 50.
            INCLUDE STRUCTURE CDHDR.
    DATA: END OF ICDHDR.
    DATA: BEGIN OF ICDSHW OCCURS 50.
            INCLUDE STRUCTURE CDSHW.
    DATA: END OF ICDSHW.
    DATA: BEGIN OF EKKEY,
    EBELN LIKE EKET-EBELN,
    EBELP LIKE EKET-EBELP,
    ETENR LIKE EKET-ETENR,
    END OF EKKEY.
    DATA: BEGIN OF ITAB OCCURS 50,
    BEGIN OF EKKEY,
    EBELN LIKE EKET-EBELN,
    EBELP LIKE EKET-EBELP,
    ETENR LIKE EKET-ETENR,
    END OF EKKEY,
    ebeln like ekko-ebeln,
    ebelp like ekpo-ebelp,
    CHANGENR LIKE CDHDR-CHANGENR,
    UDATE LIKE CDHDR-UDATE,
    UTIME LIKE CDHDR-UTIME,
    USERNAME LIKE CDHDR-USERNAME,
    CHNGIND LIKE CDSHW-CHNGIND,
    FNAME LIKE CDSHW-FNAME,     "ADDED BY ANUBHAV
    FTEXT LIKE CDSHW-FTEXT,
    OUTLEN LIKE CDSHW-OUTLEN,
    F_OLD LIKE CDSHW-F_OLD,
    F_NEW LIKE CDSHW-F_NEW,
    END OF ITAB.
    DATA : BEGIN OF ITAB1 OCCURS 0,
            EBELN LIKE EKET-EBELN,
            bedat like ekko-bedat,
            EBELP LIKE EKET-EBELP,
            txz01 like ekpo-txz01,
            lifnr like ekko-lifnr,
            name1 like lfa1-name1,
            UDATE LIKE CDHDR-UDATE,
            FTEXT LIKE CDSHW-FTEXT,
            F_OLD LIKE CDSHW-F_OLD,
           ekgrp like ekko-ekgrp,
           F_NEW LIKE CDSHW-F_NEW,
           CHANGENR LIKE CDHDR-CHANGENR,
    UTIME LIKE CDHDR-UTIME,
    USERNAME LIKE CDHDR-USERNAME,
    CHNGIND LIKE CDSHW-CHNGIND,
    FNAME LIKE CDSHW-FNAME,     "ADDED BY ANUBHAV
    OUTLEN LIKE CDSHW-OUTLEN,
    AMDNO TYPE CHAR4,
    END OF ITAB1.
    DATA: OLD_OBJECTID LIKE CDHDR-OBJECTID.
          INTERNAL TABLES
    ----"modification
    DATA: BEGIN OF I_NAST OCCURS 0,
           OBJKY TYPE NAST-OBJKY,
           ERDAT TYPE NAST-ERDAT,
           KAPPL TYPE NAST-KAPPL,
           KSCHL TYPE NAST-KSCHL,
           PARVW TYPE NAST-PARVW,
           PARNR TYPE NAST-PARNR,
           ERUHR TYPE NAST-ERUHR,
           AMDNO TYPE CHAR4,
           EBELN TYPE EKKO-EBELN,
          END OF I_NAST.
    DATA : I_NAST1 LIKE TABLE OF I_NAST WITH HEADER LINE.
    DATA: BEGIN OF I_TAB OCCURS 0,
           OBJKY TYPE NAST-OBJKY,
           ERDAT TYPE NAST-ERDAT,
           KAPPL TYPE NAST-KAPPL,
           KSCHL TYPE NAST-KSCHL,
           PARVW TYPE NAST-PARVW,
           PARNR TYPE NAST-PARNR,
           ERUHR TYPE NAST-ERUHR,
          END OF I_TAB.
    DATA: INDEX TYPE I.
    TYPE-POOLS : SLIS.
              ALV Declarations                                          *
    DATA: W_REPID            LIKE      SY-REPID,
          P_I_FIELDCAT       TYPE      SLIS_T_FIELDCAT_ALV,
          P_I_HEADING        TYPE      SLIS_T_LISTHEADER,
          I_LAYOUT           TYPE      SLIS_LAYOUT_ALV,
          I_EVENTS           TYPE      SLIS_T_EVENT,
          I_HEADING          TYPE      SLIS_T_LISTHEADER.
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          SR TYPE I.
    INITIALIZATION----
    INITIALIZATION.
      CLEAR I_NAST.
      CLEAR I_TAB.
      REFRESH I_NAST.
      REFRESH I_TAB.
    AT SELECTIN SCREEN----
    AT SELECTION-SCREEN.
    PERFORM DATA_VALIDATION.
    TOP OF PAGE----
    TOP-OF-PAGE.
    PERFORM TOP_OF_PAGE.
    END OF PAGE----
    END-OF-PAGE.
    START OF SELECTION----
    START-OF-SELECTION.
      PERFORM BUILD_COMMENT  USING I_HEADING.
      PERFORM EVENT_BUILD CHANGING I_EVENTS.
      SELECT * FROM EKKO . " WHERE EBELN IN XEBELN AND
    *LIFNR IN XLIFNR.
        CLEAR CDHDR.
        CLEAR CDPOS.
        CDHDR-OBJECTCLAS = 'EINKBELEG'.
        CDHDR-OBJECTID = EKKO-EBELN.
        PERFORM GETCHGDOCS.
      ENDSELECT.
      DELETE ITAB WHERE ( FNAME NE 'NETPR'
                       AND FNAME NE 'NETWR'
                       AND FNAME NE 'MENGE' ).
      loop at itab.
        read table itab.
        itab-ebeln = itab-ekkey+0(10).
        itab-ebelp = itab-ekkey+11(4).
        modify itab.
      endloop.
      LOOP AT ITAB.
        MOVE-CORRESPONDING ITAB TO ITAB1.
        APPEND ITAB1.
      ENDLOOP.
      LOOP AT ITAB1.
        SELECT OBJKY ERDAT KAPPL KSCHL PARVW PARNR ERUHR
         FROM NAST
         INTO CORRESPONDING FIELDS OF TABLE I_NAST
         WHERE OBJKY = ITAB1-EBELN
           AND KAPPL = 'EF'
           AND KSCHL = 'ZNEU'
           AND PARVW = 'LF'
           AND SPRAS = SY-LANGU.
        IF SY-SUBRC NE 0.
          DELETE ITAB1.
        ENDIF.
        LOOP AT I_NAST.
          MOVE-CORRESPONDING I_NAST TO I_NAST1.
          APPEND I_NAST1.
        ENDLOOP.
      ENDLOOP.
      SORT I_NAST1 BY OBJKY ASCENDING ERDAT DESCENDING ERUHR DESCENDING.
      DELETE ADJACENT DUPLICATES FROM I_NAST1 COMPARING OBJKY.
    * Select data from TABLE NAST to get ebeln before selected date
      IF I_NAST1[] IS NOT INITIAL.
        SELECT OBJKY ERDAT KAPPL KSCHL PARVW PARNR ERUHR
        FROM NAST
        INTO CORRESPONDING FIELDS OF TABLE I_TAB
        FOR ALL ENTRIES IN I_NAST1
        WHERE OBJKY =  I_NAST1-OBJKY
          AND ERDAT <= I_NAST1-ERDAT
          AND PARNR =  I_NAST1-PARNR
          AND KAPPL =  'EF'
          AND KSCHL =  'ZNEU'
          AND PARVW =  'LF'
          AND SPRAS = SY-LANGU.
      ENDIF.
    Logic to get no of amendments for one po
      LOOP AT I_NAST1.
        CLEAR INDEX.
        LOOP AT I_TAB WHERE OBJKY = I_NAST1-OBJKY.
          INDEX = INDEX + 1.
        ENDLOOP.
        I_NAST1-AMDNO = INDEX - 1.
        I_NAST1-EBELN = I_NAST1-OBJKY.
        MODIFY I_NAST1 TRANSPORTING AMDNO EBELN.
      ENDLOOP.
    *LOOP AT I_NAST1.
    *READ TABLE ITAB1 WITH KEY EBELN = I_NAST1-EBELN.
    *IF SY-SUBRC = 0.
    *ITAB1-AMDNO = I_NAST1-AMDNO.
    *MODIFY ITAB1 TRANSPORTING AMDNO .
    *ENDIF.
    *ENDLOOP.
    DELETE I_NAST1 WHERE AMDNO = 0. "ADDED BY ANUBHAV
    LOOP AT ITAB1.
    READ TABLE I_NAST1 WITH KEY EBELN = ITAB1-EBELN.
    IF SY-SUBRC NE 0.
    DELETE ITAB1.
    ENDIF.
    ENDLOOP.
      loop at itab1.
        select single *
                                  from ekko
                                  into  ekko
                                  where ebeln = itab1-ebeln.
        if sy-subrc = 0.
          itab1-bedat = ekko-bedat.
          itab1-lifnr = ekko-lifnr.
          itab1-ekgrp = ekko-ekgrp.
          modify itab1.
        endif.
      endloop.
      DELETE ITAB1 WHERE EKGRP NOT IN S_EKGRP.
      DELETE ITAB1 WHERE LIFNR NOT IN S_LIFNR.
      loop at itab1.
        select single *
                      from lfa1
                      into lfa1
                      where lifnr = itab1-lifnr.
        if sy-subrc = 0.
          itab1-name1 = lfa1-name1.
          modify itab1.
        endif.
      endloop.
      loop at itab1.
        select single *
                      from ekpo
                      into ekpo
                      where ebeln = itab1-ebeln
                      and  ebelp = itab1-ebelp.
        if sy-subrc = 0.
          itab1-txz01 = ekpo-txz01.
          modify itab1.
        endif.
      endloop.
      sort itab1 by udate descending ebeln ebelp.
    building field catelogue
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'EBELN'.
      WA_FIELDCAT-SELTEXT_L  = 'PO NO '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'BEDAT'.
      WA_FIELDCAT-SELTEXT_L  = 'PO DATE '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'EBELP'.
      WA_FIELDCAT-SELTEXT_L  = 'Item No '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'TXZ01'.
      WA_FIELDCAT-SELTEXT_L  = 'Item Description'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'LIFNR'.
      WA_FIELDCAT-SELTEXT_L  = 'Vendor NO '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'NAME1'.
      WA_FIELDCAT-SELTEXT_L  = 'Vendor Name'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'UDATE'.
      WA_FIELDCAT-SELTEXT_L  = 'Amendment Date'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'FTEXT'.
      WA_FIELDCAT-SELTEXT_l  = 'Change Field Description'.
      WA_FIELDCAT-just = 'L'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'F_OLD'.
      WA_FIELDCAT-SELTEXT_L  = 'Old Value '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'F_NEW'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-SELTEXT_L  = 'New Value '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      DATA : L_REPID TYPE  SYREPID,
             L_REPID1 LIKE DISVARIANT.
      L_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
         I_BUFFER_ACTIVE                   = 'X'
         I_CALLBACK_PROGRAM                = L_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
         IS_LAYOUT                         = I_LAYOUT
         IT_FIELDCAT                       = P_I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         I_SAVE                            = 'X'
         IS_VARIANT                        = L_REPID1
         IT_EVENTS                         = I_EVENTS
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = ITAB1[]
       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.
    *&      Form  GETCHGDOCS
          text
    FORM GETCHGDOCS.
      CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
        EXPORTING
          DATE_OF_CHANGE    = CDHDR-UDATE
          OBJECTCLASS       = CDHDR-OBJECTCLAS
          OBJECTID          = CDHDR-OBJECTID
          TIME_OF_CHANGE    = CDHDR-UTIME
          USERNAME          = CDHDR-USERNAME
        TABLES
          I_CDHDR           = ICDHDR
        EXCEPTIONS
          NO_POSITION_FOUND = 1
          OTHERS            = 2.
      CHECK SY-SUBRC EQ 0.
      DELETE ICDHDR WHERE CHANGE_IND EQ 'I'.
      CHECK NOT ICDHDR[] IS INITIAL.
      LOOP AT ICDHDR.
        CHECK ICDHDR-UDATE IN XUDATE.
       CHECK ICDHDR-USERNAME IN XNAME.
        CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
          EXPORTING
            CHANGENUMBER      = ICDHDR-CHANGENR
          IMPORTING
            HEADER            = CDHDR
          TABLES
            EDITPOS           = ICDSHW
          EXCEPTIONS
            NO_POSITION_FOUND = 1
            OTHERS            = 2.
        CHECK SY-SUBRC EQ 0.
        DELETE ICDSHW WHERE ( CHNGIND NE 'U' OR TABNAME NE 'EKPO' ).
        LOOP AT ICDSHW.
          CHECK ICDSHW-TEXT_CASE EQ SPACE.
          MOVE-CORRESPONDING ICDSHW TO ITAB.
          MOVE-CORRESPONDING ICDHDR TO ITAB.
          MOVE ICDSHW-TABKEY+3 TO ITAB-EKKEY.
          APPEND ITAB.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.                    "GETCHGDOCS
    *&      Form  BUILD_COMMENT
          text
         -->P_I_HEADING  text
    FORM BUILD_COMMENT  USING  P_I_HEADING TYPE SLIS_T_LISTHEADER.
      DATA: WA_LINE TYPE SLIS_LISTHEADER,
              TEXT1(50) TYPE C,
              TEXT2(40) TYPE C,
              W_DATE1(10) TYPE C,
              W_DATE2(10) TYPE C.
      CONCATENATE ' CHAMBAL FERTILISERS AND CHEMICALS LIMITED' ' ' INTO TEXT1.
      WA_LINE-TYP  = 'H'.
      WA_LINE-INFO = TEXT1.
      APPEND WA_LINE TO P_I_HEADING.
      CLEAR TEXT1.
      CONCATENATE ' AMENDED ORDERS' ' ' INTO TEXT1.
      WA_LINE-TYP  = 'S'.
      WA_LINE-INFO = TEXT1.
      APPEND WA_LINE TO P_I_HEADING.
      write xudate-low to w_date1 DD/MM/YYYY .
      write xudate-high to w_date2 DD/MM/YYYY .
      concatenate 'PERIOD FROM : ' W_DATE1 ' TO ' W_DATE2 INTO TEXT2 SEPARATED BY SPACE.
      WA_LINE-TYP = 'S'.
      WA_LINE-INFO = TEXT2.
      APPEND WA_LINE TO P_I_HEADING.
    ENDFORM.                    " build_comment
    *&      Form  EVENT_BUILD
          text
         -->P_I_EVENTS text
    FORM EVENT_BUILD  CHANGING P_I_EVENTS  TYPE SLIS_T_EVENT.
      DATA: W_EVENT TYPE SLIS_ALV_EVENT.
      CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = P_I_EVENTS.
      READ TABLE P_I_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO W_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO W_EVENT-FORM.
        APPEND W_EVENT TO P_I_EVENTS.
      ENDIF.
    ENDFORM.                    " event_build
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE .
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_HEADING
          I_LOGO             = 'CFCLLOGO'.
    ENDFORM.                    " top_of_page

  • How to use pf-status u2018menuu2019  in ALV report ?

    Hi Friends,
    How to use pf-status u2018menuu2019  in ALV report ?
    I want to use back button ( F3). whenever press it should show
    another report.
    I used  subroutine
    form SUB_ERROR_OUTPUT USING RT_EXTAB TYPE SLIS_T_EXTAB .
    SET PF-STATUS 'ZMENU' EXCLUDING RT_EXTAB.  u201C( the button name is u201C back u201C)
    CASE SY-UCOMM.
    *WHEN '&F03'.
    WHEN 'BACK'
    ( my coding is there ).
    endcase.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PF_STATUS_SET          = 'SUB_ERROR_OUTPUT'
    but it is  executing, working the back button but not showing another report .
    any other procedure to use back button in alv report ?
    plz any idea .
    For correct answer  reword most.
    Thanking you.

    Purchase day Book .
    Data to be down loaded / printed for EDP dept. CGL.
    CGL - Requirement .
    WRITTEN  BY : ADI.****
    *CONSULTANT : SANJAY JAJOO..
    AS PER DP REQUIREMENT.
    -CHANGED BY    :    KRISHNA MOHAN  (15/01/2002)--
    -CHANGE REQ BY :    JAJU S--
    -DESCRIPTION   :    SUMMRY BY TAX CODE WISE & GL CODE WISE--
    ---MODIFIED LINES: -
    ---CHANGED BY    :    -
    ---CHANGE REQ BY :    -
    ---DESCRIPTION   :    -
    ---MODIFIED LINES: -
    *---changed by    :    sanjay jajoo on 23/08
    *---changed req by:    Ranka
    *---Description   :    Inserting Range of period as sel field
      changed by    :    krishna mohan
      func. consultant:  sanjay jajoo
    REPORT ZMMPURDB MESSAGE-ID 00
                    LINE-SIZE 255
                    LINE-COUNT 60
                    NO STANDARD PAGE HEADING .
    TABLES :   MKPF   ,  MSEG  ,SKAT,
               EKKO   ,  EKPO  , EKBE ,
               BSEG   ,  BKPF  , BSET ,
               T009B  ,  T001  , T007S ,
               T001W  ,  T001K ,LFA1.
    ******Table deactivated on 30/8/2000------jaju
    *tables : zcgltaxatn .
    DATA  : ZFILE1(65) VALUE '/DOWNLOAD/'.
    DATA  : ZFILE2(65) .
    DATA  : ZFILE(30) TYPE C VALUE '/DOWNLOAD/'.
    DATA   : ZMON(2).
    DATA : ZTOTAL(11) TYPE N.
    DATA: ZTOT1 TYPE P DECIMALS 2.
    DATA: ZTXT LIKE SKAT-TXT50.
    TYPES: BEGIN OF COMPANY ,
    HKONT LIKE BSEG-HKONT,
    TOTAL LIKE BSEG-DMBTR,
    END OF COMPANY.
    DATA: COMP TYPE COMPANY,
          COMPTAB TYPE HASHED TABLE OF COMPANY WITH UNIQUE KEY HKONT
          WITH HEADER LINE.
    DATA : NEXT LIKE BSEG-BUZEI.           "A.A. (28/03/2000)
    DATA : DOC LIKE BSEG-BELNR.            "A.A. (28/03/2000)
    DATA  S_GSBER.
    DATA: CTR TYPE I.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-B01.
    PARAMETERS : T_BUKRS LIKE T001-BUKRS OBLIGATORY MEMORY ID BUK .
    ***********CH--ID- ADI- 29 / 09 / 1999
    SELECT-OPTIONS : ZGL FOR BSEG-HKONT OBLIGATORY.
    ***********CH--ID- ADI- 29 / 09 / 1999
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(9) TEXT-C01 .
    PARAMETERS : POPER RADIOBUTTON GROUP RAD1 .
    SELECTION-SCREEN COMMENT 13(7) TEXT-C02 .
    PARAMETERS : MONTH RADIOBUTTON GROUP RAD1 .
    SELECTION-SCREEN COMMENT 23(8) TEXT-C03 .
    SELECTION-SCREEN POSITION 33 .
    commented on 22/08 sanjay jajoo
    *PARAMETERS :  T_MONAT LIKE BKPF-MONAT .
    SELECTION-SCREEN END OF LINE.
    PARAMETERS : T_GJAHR LIKE BKPF-GJAHR OBLIGATORY .
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS : S_DOCTYP FOR BKPF-BLART,
                     S_VENDOR FOR LFA1-LIFNR  MATCHCODE  OBJECT KRED,
                     S_MATNR FOR BSEG-MATNR NO-DISPLAY,
                    T_BUDAT FOR MKPF-BUDAT NO-EXTENSION MODIF ID DAT,
                    p_gsber FOR bseg-gsber  OBLIGATORY,
                     P_GSBER FOR BSEG-GSBER,
    mod starts for inserting range of period - sanjay jajoo
                     T_MONAT FOR BKPF-MONAT OBLIGATORY.
    mod ends
    *SELECT-OPTIONS: br_blart FOR mkpf-blart.
    *Select-options:  br_blart for bkpf-blart.
    SELECTION-SCREEN END OF BLOCK B1 .
    Start of Delete by B.Elan on 23/12/2005
    *PARAMETERS : errors AS CHECKBOX .
    *PARAMETERS : summary AS CHECKBOX .
    *PARAMETERS : nodetail AS CHECKBOX .
    **selection-screen skip 2.
    *SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-b03.   "<<<
    *Add
    *PARAMETER : stax_reg RADIOBUTTON GROUP rad2 .                   "<<<
    *Add
    *PARAMETER : pur_db RADIOBUTTON GROUP rad2 .                     "<<<
    *Add
    *SELECTION-SCREEN END OF BLOCK b3 .     "<<< Add
    *SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-b02.
    *PARAMETERS : display RADIOBUTTON GROUP grp1 ,
                dload RADIOBUTTON GROUP grp1.
    *PARAMETERS : fname1 LIKE rlgrap-filename .
    *DATA : zdoc LIKE bseg-belnr.
    *DATA : fname LIKE rlgrap-filename.
    *SELECTION-SCREEN END OF BLOCK b2 .
    End of Delete by B.Elan on 23/12/2005
    Start of Insert by B.Elan on 23/12/2005
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(5) TEXT-C01.
    PARAMETER : PUR_DB RADIOBUTTON GROUP RAD2.
    SELECTION-SCREEN COMMENT 10(25) TEXT-C06.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(5) TEXT-C01.
    PARAMETERS : MAT_SM RADIOBUTTON GROUP RAD2.
    SELECTION-SCREEN COMMENT 10(25) TEXT-C04.
    SELECTION-SCREEN COMMENT 35(5) TEXT-C01.
    PARAMETERS : VEN_SM RADIOBUTTON GROUP RAD2.
    SELECTION-SCREEN COMMENT 44(20) TEXT-C05.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(5) TEXT-C01.
    PARAMETERS : MAT_DT RADIOBUTTON GROUP RAD2.
    SELECTION-SCREEN COMMENT 10(25) TEXT-C07.
    SELECTION-SCREEN COMMENT 35(5) TEXT-C01.
    PARAMETERS : VEN_DT RADIOBUTTON GROUP RAD2.
    SELECTION-SCREEN COMMENT 44(20) TEXT-C08.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B2.
    End of Insert by B.Elan on 23/12/2005
    Hard coded values used in the program
    added by krishna mohan on 09/02/02
    DATA : BEGIN OF IT_MSEG OCCURS 0,
            BELNR LIKE BSEG-BELNR,
            MBLNR LIKE MSEG-MBLNR,
            EBELN LIKE BSEG-EBELN,
            EBELP LIKE BSEG-EBELP,
          END OF IT_MSEG.
    mod ends
    Start of Insert by B.Elan on 23/12/2005
    *--vikky
    DATA : BEGIN OF IT_FINAL OCCURS 0,
             MATNR LIKE MARA-MATNR,
             BLART LIKE BKPF-BLART,         "  doctype
             BELNR LIKE BSEG-BELNR,         "sr - nO  10
             XBLNR LIKE BKPF-XBLNR ,        " Bill-no  16
             NAME1_VENDOR(25),
             "lfa1-name1,   " Vendor Name 35
             HKONT LIKE BSEG-HKONT ,        " Alloc-cd  10
             MWSKZ LIKE EKPO-MWSKZ ,        " St-cd     2
             BUDAT LIKE BKPF-BUDAT ,        " Bill-dt  10
             DUE_DATE LIKE BSEG-ZFBDT ,     " Due date 10
             PON    LIKE EKKO-EBELN ,                           " PON 10
             MAKTX LIKE MAKT-MAKTX,         "Material text 40
             MBLNR LIKE MSEG-MBLNR,
             QTY(8) TYPE P DECIMALS 2  ,                        "Qty 11
             RATE(9) TYPE P DECIMALS 2  ,                       "Rate11
             DISCOUNT(7) TYPE P DECIMALS 2,  "DISCOUNT 11
             PROD-AMT(9) TYPE P DECIMALS 2,
                                                                "AMOUNT 13
             EXCISE(8) TYPE P DECIMALS 2 ,   "eXCISE TAX 11
             SALES(5) TYPE P DECIMALS 2 ,    "SALES TAX   11
             FREIGHT(9) TYPE P DECIMALS 2,   "FREIGHT     11
             OTHERS(11) TYPE P DECIMALS 2,    " OTHERS     11
             TOTAL(9) TYPE P DECIMALS 2,     "TOTAL       17
           END OF IT_FINAL.
    *DATA : BEGIN OF IT_FINAL OCCURS 0,
            MATNR LIKE MARA-MATNR,
            BLART LIKE BKPF-BLART,         "  doctype
            BELNR LIKE BSEG-BELNR,         "sr - nO  10
            XBLNR LIKE BKPF-XBLNR ,        " Bill-no  16
            NAME1_VENDOR(25),
            "lfa1-name1,   " Vendor Name 35
            HKONT LIKE BSEG-HKONT ,        " Alloc-cd  10
            MWSKZ LIKE EKPO-MWSKZ ,        " St-cd     2
            BUDAT LIKE BKPF-BUDAT ,        " Bill-dt  10
            DUE_DATE LIKE BSEG-ZFBDT ,     " Due date 10
            PON    LIKE EKKO-EBELN ,                           " PON  10
            MAKTX LIKE MAKT-MAKTX,         "Material text 40
            MBLNR LIKE MSEG-MBLNR,
            QTY(13) TYPE P DECIMALS 2  ,                       "Qty 11
            RATE(13) TYPE P DECIMALS 2  ,                      "Rate 11
            DISCOUNT(13) TYPE P DECIMALS 2,  "DISCOUNT 11
            PROD-AMT(13) TYPE P DECIMALS 2,
                                                               "AMOUNT 13
            EXCISE(13) TYPE P DECIMALS 2 ,   "eXCISE TAX 11
            SALES(13) TYPE P DECIMALS 2 ,    "SALES TAX   11
            FREIGHT(13) TYPE P DECIMALS 2,   "FREIGHT     11
            OTHERS(13) TYPE P DECIMALS 2,    " OTHERS     11
            TOTAL(13) TYPE P DECIMALS 2,     "TOTAL       17
          END OF IT_FINAL.
    *--vikky
    DATA : BEGIN OF IT_FINAL_VN OCCURS 0,
               NAME1_VENDOR(25),
               "lfa1-name1,   " Vendor Name 35
               MATNR LIKE MARA-MATNR,
               BLART LIKE BKPF-BLART,         "  doctype
               BELNR LIKE BSEG-BELNR,         "sr - nO  10
               XBLNR LIKE BKPF-XBLNR ,        " Bill-no  16
               HKONT LIKE BSEG-HKONT ,        " Alloc-cd  10
               MWSKZ LIKE EKPO-MWSKZ ,        " St-cd     2
               BUDAT LIKE BKPF-BUDAT ,        " Bill-dt  10
               DUE_DATE LIKE BSEG-ZFBDT ,     " Due date 10
               PON    LIKE EKKO-EBELN ,                         " PON  10
               MAKTX LIKE MAKT-MAKTX,         "Material text 40
               MBLNR LIKE MSEG-MBLNR,
               QTY(8) TYPE P DECIMALS 2  ,                      "Qty 11
               RATE(9) TYPE P DECIMALS 2  ,                     "Rate 11
               DISCOUNT(7) TYPE P DECIMALS 2,  "DISCOUNT 11
               PROD-AMT(9) TYPE P DECIMALS 2,
                                                                "AMOUNT 13
               EXCISE(5) TYPE P DECIMALS 2 ,   "eXCISE TAX 11
               SALES(5) TYPE P DECIMALS 2 ,    "SALES TAX   11
               FREIGHT(5) TYPE P DECIMALS 2,   "FREIGHT     11
               OTHERS(9) TYPE P DECIMALS 2,    " OTHERS     11
               TOTAL(9) TYPE P DECIMALS 2,     "TOTAL       17
           END OF IT_FINAL_VN.
    End of Insert by B.Elan on 23/12/2005
    DATA: BEGIN OF ITAB_DISPLAY OCCURS 0,
            BLART LIKE BKPF-BLART,         "  doctype
            BELNR LIKE BSEG-BELNR,         "sr - nO  10
            XBLNR LIKE BKPF-XBLNR ,        " Bill-no  16
            NAME1_VENDOR(25),              "lfa1-name1,   " Vendor Name 35
            HKONT LIKE BSEG-HKONT ,        " Alloc-cd  10
            MWSKZ LIKE EKPO-MWSKZ ,        " St-cd     2
            BUDAT LIKE BKPF-BUDAT ,        " Bill-dt  10
            DUE_DATE LIKE BSEG-ZFBDT ,     " Due date 10
            PON    LIKE EKKO-EBELN ,                            " PON  10
            MAKTX LIKE MAKT-MAKTX,         "Material text 40
           QTY(8) TYPE P DECIMALS 2  ,                          "Qty 11
                                                                "qty 5
         RATE(5) TYPE P DECIMALS 2  ,                         "Rate 11
         mod starts on 21/08 for inc size to 7
           RATE(9) TYPE P DECIMALS 2  ,                         "Rate 11
                                                                "Rate 7
         mod ends -  sanjay jajoo 21/08
           DISCOUNT(7) TYPE P DECIMALS 2,  "DISCOUNT 11
           PROD-AMT(9) TYPE P DECIMALS 2,                       "AMOUNT 13
           EXCISE(5) TYPE P DECIMALS 2 ,   "eXCISE TAX 11
           SALES(5) TYPE P DECIMALS 2 ,    "SALES TAX   11
           FREIGHT(5) TYPE P DECIMALS 2,   "FREIGHT     11
           OTHERS(9) TYPE P DECIMALS 2,    " OTHERS     11 " added by vik on
    *21.08.2008
           TOTAL(9) TYPE P DECIMALS 2,     "TOTAL       17
           TOTAL1(9) TYPE P DECIMALS 2,
           MATNR LIKE MARA-MATNR,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
        END OF ITAB_DISPLAY.
    DATA: BEGIN  OF ITAB_TOTAL1 OCCURS 0,
          HKONT LIKE BSEG-HKONT,
          TOTAL TYPE P DECIMALS 2,
          TXT50 LIKE SKAT-TXT50,
          END OF ITAB_TOTAL1.
    DATA: BEGIN  OF ITAB_KONV OCCURS 0,
            KNUMV LIKE KONV-KNUMV,
            KPOSN LIKE KONV-KPOSN,
            STUNR LIKE KONV-STUNR,
            ZAEHK LIKE KONV-ZAEHK,
            KSCHL LIKE KONV-KSCHL,
            KWERT LIKE KONV-KWERT,
          END OF ITAB_KONV.
    DATA:BEGIN OF ITAB_RATE_MODVAT OCCURS 0,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MENGE LIKE EKPO-MENGE,
           BRTWR LIKE EKPO-BRTWR,
           KZWI5 LIKE EKPO-KZWI5,
           KNUMV LIKE EKKO-KNUMV,
           MATNR LIKE EKPO-MATNR,
           TXZ01 LIKE EKPO-TXZ01,
         END OF ITAB_RATE_MODVAT.
    DATA: BEGIN OF ITAB_PO OCCURS 0,
            EBELN LIKE EKPO-EBELN,
            EBELP LIKE EKPO-EBELP,
          END OF ITAB_PO.
    DATA: BEGIN OF ITAB_PO_ITEM OCCURS 0,
            BELNR LIKE BSEG-BELNR,
            EBELN LIKE BSEG-EBELN,
            BUZID LIKE BSEG-BUZID,
            XBLNR LIKE BKPF-XBLNR,
            MATNR LIKE BSEG-MATNR,
            EBELP LIKE BSEG-EBELP,
            MENGE LIKE BSEG-MENGE,
            WRBTR LIKE BSEG-WRBTR,
            EXCISE LIKE BSEG-DMBTR, " ADDED ON 21/01/02 FOR 27500 EXCISE
          SGTXT LIKE BSEG-SGTXT, " ADDED ON 24/01/02
            FLAG,
          END OF ITAB_PO_ITEM.
    DATA:BEGIN OF I_LFA1 OCCURS 0,
           LIFNR LIKE BSEG-LIFNR,
         END OF I_LFA1.
    DATA: BEGIN  OF I_VENDOR OCCURS 0,
            LIFNR LIKE LFA1-LIFNR,
            NAME1 LIKE LFA1-NAME1,
          END OF I_VENDOR.
    DATA: BEGIN OF ITAB_PO_OTHERS OCCURS  0,
            BELNR LIKE BSEG-BELNR,
            MATNR LIKE BSEG-MATNR,
            EBELN LIKE BSEG-EBELN,
            EBELP LIKE BSEG-EBELP,
            MENGE LIKE BSEG-MENGE,
            WRBTR LIKE BSEG-WRBTR,
          END OF ITAB_PO_OTHERS.
    DATA: BEGIN OF ITAB_FINAL OCCURS 0,
            BUKRS LIKE BSEG-BUKRS,
            BELNR LIKE BSEG-BELNR,
            GJAHR LIKE BSEG-GJAHR,
            BUZEI LIKE BSEG-BUZEI,
            BUZID LIKE BSEG-BUZID,
            SHKZG LIKE BSEG-SHKZG,
            EBELN LIKE BSEG-EBELN,
            EBELP LIKE BSEG-EBELP,
            MENGE LIKE BSEG-MENGE,
            WRBTR LIKE BSEG-WRBTR,
            MATNR LIKE BSEG-MATNR,
            HKONT LIKE BSEG-HKONT, " ADDED ON 21/01/02 FOR 27500 EXCISE
            SGTXT LIKE BSEG-SGTXT,         " ADDED ON 24/01/02 FOR SALES TAX
          END OF ITAB_FINAL.
    DATA : BEGIN OF ITAB OCCURS 100 ,
               MWSKZ LIKE EKPO-MWSKZ ,     " St-cd
               HKONT LIKE BSEG-HKONT ,     " Alloc-cd
               MBLNR LIKE MKPF-MBLNR ,     " Sr-No
               LIFNR LIKE LFA1-LIFNR ,     " Supp-cd
               XBLNR LIKE BKPF-XBLNR ,     " Bill-no
               BUDAT LIKE BKPF-BUDAT ,     " Bill-dt
               DUE_DATE LIKE BSEG-ZFBDT ,  " Due date
               PON    LIKE EKKO-EBELN ,    " PON
               BELNR LIKE BKPF-BELNR ,     " CCI no
               DMBTR LIKE BSEG-DMBTR ,     " Prod-amount
               EXCISE LIKE BSEG-DMBTR ,    " Excise / ModVAT
               ST_INV LIKE BSEG-DMBTR ,    " Sales Tax Loaded on Inv.
               ST_SET LIKE BSEG-DMBTR ,    " Sales Tax setoff .
               OCT_TOT LIKE BSEG-DMBTR ,   " A,A, (29/03/2000) Octroi chargs
               PT_PABLE LIKE BSEG-DMBTR ,  " Purchase tax payable
               ST_TOT LIKE BSEG-DMBTR ,    " Sales Tax total
               OTHR_CHRG LIKE BSEG-DMBTR , " Other chagres
               NEBTR LIKE BSEG-NEBTR,      " Total-amount
               NAME1_VENDOR LIKE LFA1-NAME1,   " Vendor Name
         END OF ITAB.
    DATA: BEGIN OF ITAB_DOC OCCURS 0,
            BELNR LIKE BKPF-BELNR,
            BLART LIKE BKPF-BLART,
          END OF ITAB_DOC.
    DATA : BEGIN OF DOCTAB OCCURS 100 ,
             MWSKZ LIKE BSEG-MWSKZ ,
             HKONT LIKE BSEG-HKONT ,
             BELNR LIKE BKPF-BELNR ,
    Changed By Pankaj              19.03.99
    Included field fiscal year
             GJAHR LIKE BKPF-GJAHR ,
             BUDAT LIKE BKPF-BUDAT ,
             XBLNR LIKE BKPF-XBLNR ,
             LIFNR LIKE LFA1-LIFNR ,
             ZTERM LIKE BSEG-ZTERM ,
             AMOUNT LIKE BSEG-DMBTR ,
             DMBTR  LIKE BSEG-DMBTR ,
             OTHR_CHRG LIKE BSEG-DMBTR ,
             MBLNR LIKE MKPF-MBLNR ,
             MJAHR LIKE MSEG-MJAHR ,
             DUE_DATE LIKE BSEG-ZFBDT ,
             PON    LIKE EKKO-EBELN ,
             JMO1  LIKE BSEG-DMBTR ,
             JMO2  LIKE BSEG-DMBTR ,
             JIP1  LIKE BSEG-DMBTR ,
             JIP2  LIKE BSEG-DMBTR ,
    ************CH-ID-ADI-START-28 / 09 / 1999
             JIP4 LIKE BSEG-DMBTR ,
             ZTUT LIKE BSEG-DMBTR ,
    *****************ABEY
             ZOCT LIKE BSEG-DMBTR ,
    *****************END
    ************CH-ID-ADI-START-28 / 09 / 1999
             ZSET  LIKE BSEG-DMBTR ,
             ZPTX  LIKE BSEG-DMBTR ,
             BLART LIKE BKPF-BLART ,
          END OF DOCTAB .
    Download for EDP    "EDP
    DATA : BEGIN OF DOWNLOAD OCCURS 100 ,
           SIGN1(1) ,
           TOT_VAL(11) TYPE N,
           SIGN2(1) ,
           TAXABLE(11) TYPE N ,
           SIGN3(1) ,
           TOT_TAX(11) TYPE N ,
           SIGN4(1) ,
           SURCHARG(9) TYPE N ,
           SIGN5(1) ,
           ST_AMT(9) TYPE N ,
           SIGN6(1) ,
           OTH_CHRG(9) TYPE N ,
    ******************************ch-adi-start-28 / 09 / 1999
           SIGN7(1),
           TOT(9) TYPE N,
    ******************************ch-adi-end-28 / 09 / 1999
           TYPE(1) TYPE N ,
           STKY1(1) TYPE N ,
           STBR(2) ,
           STDV(2) ,
           STCC(1) ,
           STKY(1) ,
           STDC(2) TYPE N ,
           STTYP(1) ,
           STCODE(2) ,
           STRATE(2) TYPE N ,
           STRTT(2) TYPE N ,
           SERIAL_NO(6) TYPE N ,
           STACP(9) ,
           BLANK1(3) ,
           STYRMN(6) ,
           BLANK2(7) TYPE C .
    DATA : END OF DOWNLOAD .
    DATA : BEGIN OF GLTAB OCCURS 5 ,
               MWSKZ LIKE BSEG-MWSKZ,      " << ADD A.A. (01.02.2000)
               HKONT LIKE BSEG-HKONT ,
               DMBTR LIKE BSEG-DMBTR ,     " Prod-amount
               EXCISE LIKE BSEG-DMBTR ,    " Excise / ModVAT
               ST_INV LIKE BSEG-DMBTR ,    " Sales Tax Loaded on Inv.
               ST_SET LIKE BSEG-DMBTR ,    " Sales Tax setoff .
               PT_PABLE LIKE BSEG-DMBTR ,  " Purchase tax payable
               ST_TOT LIKE BSEG-DMBTR ,    " Sales Tax total
               OTHR_CHRG LIKE BSEG-DMBTR , " Other Charges
               NEBTR LIKE BSEG-NEBTR.      " Total-amount
    DATA : END OF GLTAB .
    DATA : BEGIN OF ERRORTAB OCCURS 5 .
            INCLUDE STRUCTURE ITAB .
    DATA : END OF ERRORTAB .
    *- Start of change by Raj on 3-Spet-05
    DATA : V_TMPVAL TYPE P DECIMALS 2.
    *- End of change by Raj on 3-Spet-05
    DATA : STRING LIKE BKPF-AWKEY ,
           V_NO TYPE I,
           V_EBELN LIKE BSEG-EBELN,
           V_MATNR LIKE BSEG-MATNR. " ADDED ON 21/01/02 FOR BUZID = 'S'
    Start of Insert by B.Elan on 23/12/2005
    WORK AREA
    DATA : WA_DISPLAY LIKE ITAB_DISPLAY.
    DATA : V_UCOMM TYPE SY-UCOMM.
    CONSTANTS : C_X TYPE C VALUE 'X'.
    End of Insert by B.Elan on 23/12/2005
    AT SELECTION-SCREEN ON T_BUKRS.
      SELECT SINGLE * FROM T001 WHERE BUKRS = T_BUKRS .
      IF SY-SUBRC NE 0 .
        MESSAGE E368 WITH T_BUKRS TEXT-M01 .
      ENDIF .
    AT SELECTION-SCREEN ON T_MONAT.
    PERFORM check_period_year USING 'X'.   " COMMENTED
    AT SELECTION-SCREEN ON T_GJAHR.
    PERFORM check_period_year USING ' '.   "COMMENTED
    Start of Delete by B.Elan on 23/12/2005
    *AT SELECTION-SCREEN ON RADIOBUTTON GROUP grp1 .
    CLEAR fname .
    DATA : BEGIN OF xt247 OCCURS 12 .
             INCLUDE STRUCTURE t247 .
    DATA : END OF xt247 .
    CHECK dload EQ 'X' .
    REFRESH xt247 .
    IF poper EQ 'X' .
       MESSAGE e368 WITH text-m05 .
    ENDIF .
    CALL FUNCTION 'MONTH_NAMES_GET'
       TABLES
         month_names           = xt247
       EXCEPTIONS
         month_names_not_found = 1
         OTHERS                = 2.
    READ TABLE xt247 WITH KEY mnr = t_monat .
    CONCATENATE 'STAXSUMM.' xt247-ktx INTO fname .
    CONCATENATE  '
    DOWNLOAD\'   fname    INTO fname1.
    CONCATENATE  zfile1   fname    INTO   zfile2.
    CONDENSE fname1 NO-GAPS.
    CONDENSE zfile2 NO-GAPS.
    CONCATENATE 'STAXSUMM.' xt247-ktx INTO fname .
    End of Delete by B.Elan on 23/12/2005
    AT SELECTION-SCREEN OUTPUT .
      LOOP AT SCREEN .
        IF SCREEN-NAME EQ 'FNAME' .
          SCREEN-INPUT = 0.
          MODIFY SCREEN .
        ENDIF .
        IF SCREEN-GROUP2 EQ 'DBS' .
          SCREEN-ACTIVE = 0 .
          MODIFY SCREEN .
          IF SCREEN-NAME EQ 'BR_BLART-LOW' .
    Form the select option for the LDB .
            CLEAR BR_BLART . REFRESH BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
            BR_BLART-LOW = 'RE' .
            APPEND BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
            BR_BLART-LOW = 'SR' .
            APPEND BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
            BR_BLART-LOW = 'SP' .
            APPEND BR_BLART .       " ADD ON 11122003 JAJ
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
           br_blart-low = 'VI' .
            BR_BLART-LOW = 'ST'.
            APPEND BR_BLART .
            BR_BLART-LOW = 'S1'.
            APPEND BR_BLART .
            BR_BLART-LOW = 'P1'.
            APPEND BR_BLART .
            BR_BLART-LOW = 'PM'.
            APPEND BR_BLART .
            BR_BLART-LOW = 'R1'.
            APPEND BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
            BR_BLART-LOW = 'KR' .
            APPEND BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
    *************CH-ID-ADI---30 / 09 / 1999.
            BR_BLART-LOW = 'RA'.
            APPEND BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
            BR_BLART-LOW = 'EM'.
            APPEND BR_BLART .
            BR_BLART-SIGN = 'I' .
            BR_BLART-OPTION = 'EQ' .
            BR_BLART-LOW = 'EI' .
            APPEND BR_BLART .
          ENDIF .
        ENDIF .
        CHECK SCREEN-GROUP1 EQ 'DAT' .
        SCREEN-INPUT = 0.
        MODIFY SCREEN .
      ENDLOOP .
    START-OF-SELECTION .
    Block 1 - Selection of accounting documents in the posting period
    is done through the LDB
    GET BKPF .
    commented on 22/08
    CHECK BKPF-MONAT = T_MONAT.
      CHECK BKPF-MONAT IN T_MONAT.
      CHECK BKPF-GJAHR = T_GJAHR.
      CHECK BKPF-STBLG IS INITIAL .        "<<<< Reversed
    *CHECK bkpf-budat IN t_budat .
      CHECK BKPF-BUKRS EQ T_BUKRS .
      CHECK BKPF-BUKRS EQ T_BUKRS .
      CHECK BKPF-BSTAT EQ SPACE .          "<<< Sample docs
      CHECK BKPF-BLART EQ 'RE'             "MM-IV
        OR  BKPF-BLART EQ 'KR'             "FI-IV
      OR  bkpf-blart EQ 'VI'          "FI-IV Direct
    *************CH-ID-ADI-30 / 09  / 1999
      OR  bkpf-blart EQ 'RA'           "CASH CCI
      OR  bkpf-blart EQ 'EM'           "MAINTAINANCE
      OR  bkpf-blart EQ 'EI' .        "IDT
        OR BKPF-BLART EQ  'P1'
        OR BKPF-BLART EQ 'PM'
        OR  BKPF-BLART EQ 'R1'
        OR  BKPF-BLART EQ 'S1'
        OR  BKPF-BLART EQ 'ST'
        OR  BKPF-BLART EQ 'SR'      " ADD ON 101203 JAJ
        OR  BKPF-BLART EQ 'SP'.
    *************CH-ID-ADI-30 / 09  / 1999
      CLEAR DOCTAB .
      DOCTAB-BLART = BKPF-BLART .
      DOCTAB-BELNR = BKPF-BELNR .
      DOCTAB-BUDAT = BKPF-BUDAT .
      DOCTAB-XBLNR = BKPF-XBLNR .
    Added By Pankaj                   19.03.99
    Initializing fiscal year for document table
      DOCTAB-GJAHR = BKPF-GJAHR .
      APPEND DOCTAB.
    Tax details
    GET BSET .   " Commented because LDB gives wrong BSET entries
      " for some documents
      CASE BSET-KSCHL .
        WHEN 'JMO1' .
          DOCTAB-JMO1 = DOCTAB-JMO1 + BSET-HWSTE .
        WHEN 'JMO2' .
          DOCTAB-JMO2 = DOCTAB-JMO2 + BSET-HWSTE .
        WHEN 'JIP1' .
          DOCTAB-JIP1 = DOCTAB-JIP1 + BSET-HWSTE .
        WHEN 'JIP2' .
          DOCTAB-JIP2 = DOCTAB-JIP2 + BSET-HWSTE .
        WHEN 'ZSET' .
         break deven .
          DOCTAB-ZSET = DOCTAB-ZSET + BSET-HWSTE .
        WHEN 'ZPTX' .
          DOCTAB-ZPTX = DOCTAB-ZPTX + BSET-HWSTE .
      ENDCASE .
      DOCTAB-MWSKZ = BSET-MWSKZ.
      MODIFY DOCTAB INDEX SY-TABIX.
    Item details
    *changed by srinivas yerra.
    GET BSEG .
      IF BSEG-KOART = 'K' .              "<<< Vendor Line
    IF BSEG-KOART = 'K' .
    *end of chnages by srinivas yerra.
        DOCTAB-LIFNR = BSEG-LIFNR .
        IF NOT BSEG-ZTERM IS INITIAL .
          DOCTAB-ZTERM = BSEG-ZTERM .
          DOCTAB-DUE_DATE = BSEG-ZFBDT + BSEG-ZBD1T .
        ENDIF .
        IF BSEG-SHKZG EQ 'H' .             "<< Add credits
          DOCTAB-AMOUNT = DOCTAB-AMOUNT + BSEG-DMBTR .
        ELSE .                             "<< Subtr debits
          DOCTAB-AMOUNT = DOCTAB-AMOUNT - BSEG-DMBTR .
        ENDIF .
      ENDIF .
      CASE BSEG-KTOSL .
        WHEN 'WRX' .
          DOCTAB-PON = BSEG-EBELN .
          IF DOCTAB-MWSKZ IS INITIAL .
            DOCTAB-MWSKZ = BSEG-MWSKZ .
          ENDIF .
        WHEN 'BSX' .
    ***********ABEY
          IF NEXT = BSEG-BUZEI
             AND
             DOC = BSEG-BELNR
             AND
             ( BSEG-BUZID = 'M'
               OR
               BSEG-HKONT = 50765 ).
            DOCTAB-ZOCT = DOCTAB-ZOCT + BSEG-DMBTR.
            IF BSEG-SHKZG EQ 'H' .         "<< Subtr credits
              DOCTAB-OTHR_CHRG = DOCTAB-OTHR_CHRG - BSEG-DMBTR .
            ELSE .                         "<< Add debits
              DOCTAB-OTHR_CHRG = DOCTAB-OTHR_CHRG + BSEG-DMBTR .
            ENDIF .
          ENDIF .
    ************END
          IF BSEG-SHKZG EQ 'S' .
            DOCTAB-DMBTR = DOCTAB-DMBTR + BSEG-DMBTR .
          ELSE .
            DOCTAB-DMBTR = DOCTAB-DMBTR - BSEG-DMBTR .
          ENDIF .
        WHEN 'OCT' OR 'FRE' OR 'FR1' OR SPACE .
    *****CH-ID-ADI-30 / 09 /1999.
          IF ( ( BKPF-BLART = 'EM'  OR  BKPF-BLART = 'RA'  OR  BKPF-BLART =
          'EI')
           AND BSEG-KTOSL = SPACE ) OR  BSEG-MWSKZ = '9W' OR BSEG-MWSKZ =
           'K9' OR
                                                                BSEG-MWSKZ =
                                                                'X9'.
            DOCTAB-OTHR_CHRG = 0.
          ELSE.
    *********CH-ID-ADI--01 / 10 / 1999
         Other Charges only for accounts other than vendor acc.
            CHECK BSEG-BUZID NE 'T' .
            CHECK BSEG-BUZID NE 'P' .
            IF BSEG-KOART NE 'K' .
    *********ABEY (25/02/2000), (21/02/2000)
              IF BSEG-BUZID = 'F'
               OR BSEG-HKONT = 75461.
                NEXT = BSEG-BUZEI + 1.
                DOC = BSEG-BELNR.
                DOCTAB-ZOCT = DOCTAB-ZOCT + BSEG-DMBTR.
              ENDIF.
              IF BSEG-BUZEI = NEXT
                 AND
                 ( BSEG-BUZID = 'M'
                   OR
                   BSEG-HKONT = 50765 ).
                DOCTAB-ZOCT = DOCTAB-ZOCT + BSEG-DMBTR.
              ENDIF.
    *********END
              IF BSEG-SHKZG EQ 'H' .       "<< Subtr credits
                DOCTAB-OTHR_CHRG = DOCTAB-OTHR_CHRG - BSEG-DMBTR .
              ELSE .                       "<< Add debits
                DOCTAB-OTHR_CHRG = DOCTAB-OTHR_CHRG + BSEG-DMBTR .
              ENDIF .
            ENDIF .
    *****NEXT-LINE ADDED BY ADI
          ENDIF .
    *************END.
      ENDCASE .
    *CHANGED BY SRINIVAS YERRA
    *MODIFY DOCTAB INDEX SY-TABIX.
      APPEND DOCTAB.
    *END OF CHANGES.
    PO History
    GET EKBE .
      CHECK DOCTAB-BELNR EQ EKBE-BELNR .
      DOCTAB-MBLNR = EKBE-LFBNR .
      DOCTAB-MJAHR = EKBE-LFGJA .
      MODIFY DOCTAB INDEX SY-TABIX .
    PERFORM show_indicator USING text-m02 .
    *PERFORM convert_data.
    END-OF-SELECTION .
    Data read from LDB is converted into printable format.
      PERFORM SHOW_INDICATOR USING TEXT-M04 .
      PERFORM CONVERT_DATA .
    Start of Delete by B.Elan on 23/12/2005
    IF stax_reg EQ 'X' .                 "<<< Add
       SORT itab BY mwskz hkont belnr .
    ELSE .                               "<<< Add
       SORT itab BY belnr .               "<<< Add
        SORT itab BY pon.
    ENDIF .                              "<<< Add
    Perform further operation based on user input
    IF display EQ 'X' .
       PERFORM write_itab.
       PERFORM write_data .
    ELSE .
      PERFORM download_data .
    ENDIF .
    End of Delete by B.Elan on 23/12/2005
    Start of Insert by B.Elan on 23/12/2005
      SORT ITAB BY BELNR.
      PERFORM WRITE_DATA.
      IF MAT_SM = C_X.
        PERFORM WRITE_MATERIAL_SUMMARY.
      ELSEIF MAT_DT = C_X.
        PERFORM WRITE_MATERIAL_DETAILS.
      ELSEIF VEN_SM = C_X.
        PERFORM WRITE_VENDOR_SUMMARY.
      ELSEIF VEN_DT = C_X.
        PERFORM WRITE_VENDOR_DETAILS.
      ENDIF.
    End of Insert by B.Elan on 23/12/2005
    Start of Insert by B.Elan on 23/12/2005
    AT USER-COMMAND.
      V_UCOMM = SY-UCOMM.
      CASE V_UCOMM.
        WHEN 'DETLS'.
          NEW-PAGE.
          PUR_DB = C_X.
          PERFORM CLEAR_DETAILS.
          PERFORM WRITE_DATA.
        WHEN 'MSUMRY'.
          PERFORM WRITE_MATERIAL_SUMMARY.
        WHEN 'MDETL'.
          PERFORM WRITE_MATERIAL_DETAILS.
        WHEN 'VSUMRY'.
          PERFORM WRITE_VENDOR_SUMMARY.
        WHEN 'VDETL'.
          PERFORM WRITE_VENDOR_DETAILS.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    End of Insert by B.Elan on 23/12/2005
    *- - - - - - - - - End Of Execution .- - - - - - - - - - - - - - - - - -
    TOP-OF-PAGE .
      IF PUR_DB = C_X.
        PERFORM TOP_OF_PAGE.
        PERFORM TOP_OF_PAGE_PUR_DB.
      ELSEIF MAT_SM = C_X.
        PERFORM TOP_OF_PAGE.
        PERFORM TOP_OF_PAGE_MAT_SM.
      ELSEIF MAT_DT = C_X.
        PERFORM TOP_OF_PAGE.
        PERFORM TOP_OF_PAGE_MAT_DT.
      ELSEIF VEN_SM = C_X.
        PERFORM TOP_OF_PAGE.
        PERFORM TOP_OF_PAGE_VEN_SM.
      ELSEIF VEN_DT = C_X.
        PERFORM TOP_OF_PAGE.
        PERFORM TOP_OF_PAGE_VEN_DT.
      ENDIF.
    TOP-OF-PAGE DURING LINE-SELECTION.
      CASE V_UCOMM.
        WHEN 'DETLS'.
          PERFORM TOP_OF_PAGE.
          PERFORM TOP_OF_PAGE_PUR_DB.
        WHEN 'MSUMRY'.
          PERFORM TOP_OF_PAGE.
          PERFORM TOP_OF_PAGE_MAT_SM.
        WHEN 'MDETL'.
          PERFORM TOP_OF_PAGE.
          PERFORM TOP_OF_PAGE_MAT_DT.
        WHEN 'VSUMRY'.
          PERFORM TOP_OF_PAGE.
          PERFORM TOP_OF_PAGE_VEN_SM.
        WHEN 'VDETL'.
          PERFORM TOP_OF_PAGE.
          PERFORM TOP_OF_PAGE_VEN_DT.
      ENDCASE.
    *&      Form  WRITE_DATA
          text                                                           *
    FORM WRITE_DATA.
      DATA:     V_SALES LIKE ITAB_DISPLAY-SALES,
                V_RATE LIKE ITAB_DISPLAY-RATE,
                V_DISCOUNT LIKE ITAB_DISPLAY-DISCOUNT,
                V_PROD-AMT LIKE ITAB_DISPLAY-PROD-AMT,
                V_EXCISE1 LIKE ITAB_DISPLAY-EXCISE,
                V_EXCISE LIKE ITAB_DISPLAY-EXCISE,
                V_PON LIKE ITAB_DISPLAY-PON,
                V_OTHERS LIKE ITAB_DISPLAY-OTHERS,
                V_FREIGHT LIKE ITAB_DISPLAY-FREIGHT.
      CLEAR ITAB .
    Write the correct data i.e. tax code and G/L code both available .
      LOOP AT ITAB .
    *************CH-ID-ADI-30 / 09 / 1999
        IF ( ITAB-MWSKZ = '9W' OR ITAB-MWSKZ = 'K9' OR ITAB-MWSKZ = 'X9' )
                                                   AND ITAB-OTHR_CHRG NE 0 .
          ITAB-DMBTR = ITAB-OTHR_CHRG.
          ITAB-OTHR_CHRG = 0.
          MODIFY ITAB.
        ENDIF.
      ENDLOOP.
      LOOP AT ITAB.
        I_LFA1-LIFNR = ITAB-LIFNR.
        APPEND I_LFA1.
        CLEAR I_LFA1.
      ENDLOOP.
      SORT I_LFA1.
      DELETE ADJACENT DUPLICATES FROM I_LFA1 COMPARING ALL FIELDS.
      SELECT LIFNR
             NAME1
        FROM LFA1 INTO TABLE I_VENDOR
        FOR ALL ENTRIES IN I_LFA1 WHERE
                                       LIFNR = I_LFA1-LIFNR.
      FREE I_LFA1.
      LOOP AT ITAB.
        READ TABLE I_VENDOR WITH KEY LIFNR = ITAB-LIFNR .
        IF SY-SUBRC EQ 0.
          ITAB-NAME1_VENDOR = I_VENDOR-NAME1.
          MODIFY ITAB  TRANSPORTING NAME1_VENDOR.
        ENDIF.
      ENDLOOP.
      LOOP AT ITAB.
        IF NOT  ITAB-LIFNR IN S_VENDOR.
          DELETE ITAB.
        ENDIF.
      ENDLOOP.
      SELECT BUKRS  BELNR GJAHR BUZEI BUZID SHKZG EBELN EBELP ERFMG WRBTR
       MATNR HKONT SGTXT " ERFMG for MENGE,HKONT,SGTXT Added by KrishnaMohan
             INTO TABLE ITAB_FINAL
            FROM BSEG FOR ALL ENTRIES IN ITAB
            WHERE BUKRS = T_BUKRS AND                           "'1000' AND
                  BELNR = ITAB-BELNR AND
    *added by srinivas
                 hkont in zgl and
    *end
                  GJAHR = T_GJAHR AND
    *- Start of change by Raj on 030905
                 buzid IN ('W', 'M', 'K', 'S', 'F' , 'P' ) AND
                   BUZID IN ('W', 'M', 'K', 'S', 'F' , 'P' , 'T', ' ') AND
                   " ADD T 090206  JAJ
                   KOART <> 'K'   AND    " mod by vik on 21.08.2008" sjaj si
    *- End of change by Raj on 030905
    BUZID = P Added on 21/01/02 by Krishna Mohan
                  GSBER IN P_GSBER AND
                 gsber IN p_gsber OR gsber = ' ' AND
                  MATNR IN S_MATNR.
      SELECT BELNR BLART INTO TABLE ITAB_DOC FROM BKPF
                FOR ALL ENTRIES IN ITAB_FINAL WHERE
                           BUKRS = T_BUKRS AND                  "'1000' AND
                           BELNR  = ITAB_FINAL-BELNR AND
                           GJAHR = T_GJAHR AND
                           BLART NOT IN ('WA' , 'WE').
      SORT ITAB_DOC BY BELNR BLART.
      LOOP AT ITAB_DOC.
        IF NOT ITAB_DOC-BLART IN S_DOCTYP .
          DELETE ITAB_DOC.
        ENDIF.
      ENDLOOP.
      LOOP AT ITAB_FINAL.
        READ TABLE ITAB_DOC WITH KEY BELNR = ITAB_FINAL-BELNR BINARY SEARCH.
        IF SY-SUBRC NE 0.
          DELETE ITAB_FINAL.
        ENDIF.
      ENDLOOP.
      DELETE ITAB_FINAL WHERE BUZID = 'K' AND BUZEI = '1'.
      LOOP AT ITAB_FINAL WHERE SHKZG = 'H'.
        ITAB_FINAL-WRBTR = ITAB_FINAL-WRBTR * ( -1 ).
        MODIFY ITAB_FINAL TRANSPORTING WRBTR.
      ENDLOOP.
      LOOP AT ITAB_FINAL WHERE BUZID = 'M'.
        IF ITAB_FINAL-SGTXT NE ' '.
          TRANSLATE ITAB_FINAL-SGTXT TO UPPER CASE.
          MODIFY ITAB_FINAL.
        ENDIF.
      ENDLOOP.
      LOOP AT ITAB_FINAL .
        IF ITAB_FINAL-BUZID = 'W'.
          CLEAR V_MATNR.
          V_EBELN = ITAB_FINAL-EBELN.
          V_MATNR = ITAB_FINAL-MATNR.
          ITAB_PO_ITEM-BELNR = ITAB_FINAL-BELNR.
          ITAB_PO_ITEM-BUZID = ITAB_FINAL-BUZID.
          ITAB_PO_ITEM-MATNR = ITAB_FINAL-MATNR.
          ITAB_PO_ITEM-EBELN = ITAB_FINAL-EBELN.
          ITAB_PO_ITEM-EBELP = ITAB_FINAL-EBELP.
          ITAB_PO_ITEM-MENGE = ITAB_FINAL-MENGE.
          ITAB_PO_ITEM-WRBTR = ITAB_FINAL-WRBTR.
          COLLECT ITAB_PO_ITEM.
          CLEAR ITAB_PO_ITEM.
        ELSEIF ITAB_FINAL-BUZID = 'M' OR ITAB_FINAL-BUZID = 'K' OR
                                          ITAB_FINAL-BUZID = 'S' OR
            ITAB_FINAL-BUZID = 'P' OR      " ADDED ON 21/01/02
    *- Start of change by Raj on 030905
            ITAB_FINAL-BUZID = ' ' OR
             ITAB_FINAL-BUZID = 'T' OR   " ADD BY JAJ ON 090206
    *- End of change by Raj on 030905
                                          ITAB_FINAL-BUZID = 'F'.
          IF ITAB_FINAL-MATNR IS INITIAL.
            ITAB_FINAL-MATNR = V_MATNR.
          ENDIF.
        CLEAR V_MATNR.
          ITAB_PO_OTHERS-BELNR = ITAB_FINAL-BELNR.
         ITAB_PO_OTHERS-MATNR = ITAB_FINAL-MATNR.
         ITAB_PO_OTHERS-EBELN = ITAB_FINAL-EBELN.
         ITAB_PO_OTHERS-EBELP = ITAB_FINAL-EBELP.
         ITAB_PO_OTHERS-MENGE = ITAB_FINAL-MENGE.
          ITAB_PO_OTHERS-WRBTR = ITAB_FINAL-WRBTR.
    IF CONDITION,ADDED ON 21/01/02 FOR GETTING EXCISE WHEN CONDITION MEETS
    ie TOTAL AMOUNT = EXCISE WHEN BUZID = S AND HKONT = 27500
    *IF itab_final-buzid = 'S' AND ( itab_final-hkont = '0000027500' OR  "
    *COMM BY JAJ ON 090206
          IF ITAB_FINAL-BUZID = 'S' OR ITAB_FINAL-BUZID = 'T' AND (
          ITAB_FINAL-HKONT = '0000027500' OR
                                        ITAB_FINAL-HKONT = '0000027515'
            OR  ITAB_FINAL-HKONT = '0000027550'       " jaj on 090206
           OR  ITAB_FINAL-HKONT = '0000027507' OR
            ITAB_FINAL-HKONT = '0000027508').  "Added on 050905 - Raj
            ITAB_FINAL-EBELN = V_EBELN.
    to get ebeln value into header so that when there are 2 po's
    and 2 W's excise can go into only one po which is v_ebeln
    Start of insert by B.Elan on 10/02/2006
            READ TABLE ITAB_PO_ITEM WITH KEY BELNR = ITAB_FINAL-BELNR
                                             EBELN = ITAB_FINAL-EBELN
                                             MATNR = ITAB_FINAL-MATNR.
            ITAB_PO_ITEM-EXCISE = ITAB_PO_ITEM-EXCISE + ITAB_FINAL-WRBTR.
    End of insert by B.Elan on 10/02/2006
    Start of delete by B.Elan on 10/02/2006
          itab_po_item-excise = itab_final-wrbtr.
    End of delete by B.Elan on 10/02/2006
            MODIFY ITAB_PO_ITEM TRANSPORTING EXCISE
                  WHERE BELNR EQ ITAB_FINAL-BELNR AND
                        EBELN EQ ITAB_FINAL-EBELN.
            CLEAR ITAB_PO_ITEM.
          ELSE.
            COLLECT ITAB_PO_OTHERS.
          ENDIF.
          CLEAR ITAB_PO_OTHERS.
        ENDIF.
      ENDLOOP.
    sateesh
      SORT ITAB_PO_ITEM BY BELNR EBELN.
      LOOP AT ITAB_PO_ITEM.
       AT NEW BELNR.
        AT NEW EBELN.
          READ TABLE ITAB_PO_ITEM INDEX SY-TABIX.
          ITAB_PO_ITEM-FLAG = 'X'.
          MODIFY ITAB_PO_ITEM INDEX SY-TABIX.
        ENDAT.
       ENDAT.
      ENDLOOP.
      LOOP AT ITAB_PO_ITEM.
        ITAB_PO_ITEM-EXCISE = 0.
        MODIFY ITAB_PO_ITEM TRANSPORTING EXCISE
         WHERE EXCISE > 0
           AND FLAG = SPACE.
      ENDLOOP.
    end
      LOOP AT ITAB_PO_ITEM.
        ITAB_PO-EBELN = ITAB_PO_ITEM-EBELN.
        ITAB_PO-EBELP = ITAB_PO_ITEM-EBELP.
        APPEND ITAB_PO.
        CLEAR ITAB_PO.
      ENDLOOP.
      LOOP AT ITAB_PO_OTHERS.
        ITAB_PO-EBELN = ITAB_PO_OTHERS-EBELN.
        ITAB_PO-EBELP = ITAB_PO_OTHERS-EBELP.
        APPEND ITAB_PO.
        CLEAR ITAB_PO.
      ENDLOOP.
      SORT ITAB_PO.
      DELETE ADJACENT DUPLICATES FROM  ITAB_PO COMPARING ALL FIELDS.
      SELECT EKPO~EBELN
             EBELP
             MENGE
             BRTWR
             KZWI5
             EKKO~KNUMV
             EKPO~MATNR
             EKPO~TXZ01
             INTO TABLE ITAB_RATE_MODVAT
             FROM EKPO INNER JOIN EKKO
                 ON EKPO~EBELN = EKKO~EBELN
        FOR ALL ENTRIES IN ITAB_PO WHERE
                        EKPO~EBELN = ITAB_PO-EBELN AND
                        EBELP = ITAB_PO-EBELP.
      SELECT KNUMV KPOSN STUNR ZAEHK KSCHL KWERT
        INTO TABLE ITAB_KONV
        FROM KONV
        FOR ALL ENTRIES IN ITAB_RATE_MODVAT
            WHERE KNUMV = ITAB_RATE_MODVAT-KNUMV AND
      KSCHL IN ('YT02', 'YF07', 'YOTH', 'YPF1', 'YD01', 'YD02', 'YD03' ) .
      SORT ITAB_KONV BY KNUMV KSCHL.
      SORT ITAB BY BELNR.
      SORT ITAB_RATE_MODVAT BY EBELN EBELP.
      SORT ITAB_PO_OTHERS BY BELNR MATNR.
      LOOP AT ITAB_PO_ITEM.
        ITAB_DISPLAY-BELNR = ITAB_PO_ITEM-BELNR.
        READ TABLE ITAB_DOC WITH KEY BELNR = ITAB_PO_ITEM-BELNR BINARY
        SEARCH.
        IF SY-SUBRC EQ 0.
          ITAB_DISPLAY-BLART = ITAB_DOC-BLART.
        ENDIF.
        READ TABLE ITAB WITH KEY BELNR = ITAB_PO_ITEM-BELNR BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          ITAB_DISPLAY-XBLNR = ITAB-XBLNR.
          ITAB_PO_ITEM-XBLNR = ITAB-XBLNR.
          ITAB_DISPLAY-NAME1_VENDOR = ITAB-NAME1_VENDOR.
          ITAB_DISPLAY-HKONT = ITAB-HKONT.
          ITAB_DISPLAY-MWSKZ = ITAB-MWSKZ.
          ITAB_DISPLAY-BUDAT = ITAB-BUDAT.
          ITAB_DISPLAY-DUE_DATE   = ITAB-DUE_DATE.
         ITAB_DISPLAY-PON    =  ITAB_PO_ITEM-EBELN.
        ENDIF.
        ITAB_DISPLAY-QTY  =    ITAB_PO_ITEM-MENGE.
        READ TABLE ITAB_RATE_MODVAT WITH KEY EBELN = ITAB_PO_ITEM-EBELN
                                             EBELP = ITAB_PO_ITEM-EBELP
                                             BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          ITAB_DISPLAY-PON    =  ITAB_PO_ITEM-EBELN.
          ITAB_DISPLAY-MATNR = ITAB_RATE_MODVAT-MATNR.
          ITAB_DISPLAY-MAKTX  =  ITAB_RATE_MODVAT-TXZ01.
          ITAB_DISPLAY-RATE = ITAB_RATE_MODVAT-BRTWR /
          ITAB_RATE_MODVAT-MENGE.
          ITAB_DISPLAY-PROD-AMT = ITAB_DISPLAY-RATE * ITAB_PO_ITEM-MENGE.
          IF ITAB_PO_ITEM-EXCISE NE 0.
            ITAB_DISPLAY-EXCISE = ITAB_PO_ITEM-EXCISE.
        ELSE.
    *ITAB_DISPLAY-EXCISE = ( ITAB_PO_ITEM-MENGE * ITAB_RATE_MODVAT-KZWI5 ) /
                                      ITAB_RATE_MODVAT-MENGE.
    *commentedon 210102 to get excise directly from BSEG - IV
          ENDIF.
        ENDIF.
        READ TABLE ITAB_KONV WITH KEY KNUMV = ITAB_RATE_MODVAT-KNUMV
                                      KPOSN = ITAB_RATE_MODVAT-EBELP
                                      KSCHL = 'YT02' .
        IF SY-SUBRC EQ 0.
          ITAB_DISPLAY-SALES  = ( ITAB_PO_ITEM-MENGE * ITAB_KONV-KWERT ) /
                                 ITAB_RATE_MODVAT-MENGE.
          READ TABLE ITAB_FINAL WITH KEY BELNR = ITAB_PO_ITEM-BELNR
                                         BUZID = 'M'
                                        SGTXT(9) = 'SALES TAX'.
          IF SY-SUBRC EQ 0.
          IF ITAB_FINAL-SGTXT(9) EQ 'SALES TAX'
             OR ITAB_FINAL-SGTXT(9) EQ 'sales tax'.
            ITAB_DISPLAY-SALES = ITAB_DISPLAY-SALES + ITAB_FINAL-WRBTR.
          ENDIF.
          ENDIF.
        ENDIF.
        READ TABLE ITAB_KONV WITH KEY KNUMV = ITAB_RATE_MODVAT-KNUMV
                                      KPOSN = ITAB_RATE_MODVAT-EBELP
                                      KSCHL = 'YF07'.
        IF SY-SUBRC EQ 0.
          ITAB_DISPLAY-FREIGHT = ( ITAB_PO_ITEM-MENGE * ITAB_KONV-KWERT ) /
                                  ITAB_RATE_MODVAT-MENGE.
        ENDIF.
        READ TABLE ITAB_KONV WITH KEY KNUMV = ITAB_RATE_MODVAT-KNUMV
                                      KPOSN = ITAB_RATE_MODVAT-EBELP
                                      KSCHL = 'YD01' .
        IF SY-SUBRC EQ 0.
         ITAB_DISPLAY-DISCOUNT = ( ITAB_PO_ITEM-MENGE * ITAB_KONV-KWERT ) /
                                              ITAB_RATE_MODVAT-MENGE.
        ELSE.
          READ TABLE ITAB_KONV WITH KEY KNUMV = ITAB_RATE_MODVAT-KNUMV
                                        KPOSN = ITAB_RATE_MODVAT-EBELP
                                      KSCHL = 'YD02' .
          IF SY-SUBRC EQ 0.
           ITAB_DISPLAY-DISCOUNT = ( ITAB_PO_ITEM-MENGE * ITAB_KONV-KWERT )
    ITAB_RATE_MODVAT-MENGE.
          ELSE.
            READ TABLE ITAB_KONV WITH KEY KNUMV = ITAB_RATE_MODVAT-KNUMV
                                          KPOSN = ITAB_RATE_MODVAT-EBELP
                                          KSCHL = 'YD03' .
            IF SY-SUBRC EQ 0.
             ITAB_DISPLAY-DISCOUNT = ( ITAB_PO_ITEM-MENGE * ITAB_KONV-KWERT
    ITAB_RATE_MODVAT-MENGE.
            ENDIF.
          ENDIF.
        ENDIF.
        LOOP AT ITAB_KONV WHERE KNUMV = ITAB_RATE_MODVAT-KNUMV AND KPOSN =
                                 ITAB_RATE_MODVAT-EBELP AND
                       (  KSCHL = 'YPF1' OR KSCHL = 'YOTH' ) .
          ITAB_KONV-KWERT = ( ITAB_PO_ITEM-MENGE * ITAB_KONV-KWERT ) /
                                   ITAB_RATE_MODVAT-MENGE.
          ITAB_DISPLAY-OTHERS = ITAB_DISPLAY-OTHERS + ITAB_KONV-KWERT.
        ENDLOOP.
        READ TABLE ITAB_PO_OTHERS WITH KEY BELNR = ITAB_PO_ITEM-BELNR.
                                          EBELN = ITAB_PO_ITEM-EBELN.
                                          BINARY SEARCH.
    sateesh as on 10092003
        IF SY-SUBRC NE 0. CLEAR ITAB_PO_OTHERS. ENDIF.
    end
        IF NOT ITAB_PO_OTHERS-EBELN IS INITIAL.
          READ TABLE ITAB_PO_OTHERS WITH KEY EBELN = ITAB_PO_ITEM-EBELN
                                             EB

  • Alv report please help

    Hi,
         Please help me in this.
    1) Create the selection screen with the following fields on it.
         S_REQUESTOR for ZSWAPHISTORY- REQUESTOR
         S_APPROVER for ZSWAPHISTORY- APPROVER providing range
         S_to_customer for ZSWAPHISTORY- to_customer providing range
         S_from_customer for ZSWAPHISTORY- from_customer providing range
         S_MRPC     for MARC-DISPO providing range
         S_MATNR     for MARA-MATNR providing range
         S_APPR_DATE for ZSWAPHISTORY- APPR_DATE Default to yesterdays date
         S_QUAN     for ZSWAPHISTORY-quan
    2) Validate the fields entered in the selection screen.
    3) Check the user authorizations for this report.
    4) Select the entries from the table ZSWAPHISTORY into an internal table based on the input from the selection screen and the value of the field ZSWAPHISTORY -STATUS is APPROVED.
    5) Then select the MRP Controller ID (DISPO) from the Table MARC for all entries in the internal table where MARC-MATNR equals to the internal table -material number.
    6) Move the field value of MRP Controller ID (DISPO) into the final internal table for the corresponding entries.
    7) Declare the Filed Catalogue with the fields that are to be displayed in the ALV
    Please help to create this , iam new to this area.
    Thanks
    Ali

    Hi
    See the sample code of ALV and do accordingly
    Since you are using a Z table it is not clear to create
    report ZRGRIRNA no standard page heading
           line-count 65
           line-size 255
           message-id mm.
                       GR IR Detail Report                               *
    Description          : The output has to be displayed
                           in the ALV Grid format with the Selection     *
                           screen appearing on the output. In The Output *
                           Subtotals for Vendor, Plant, Period, Material,*
                           Valuation Class, Purchase Order,Cost Center,  *
                           Cost Element and Receipt Date are displayed   *
                           after sorting the data by same fields.        *
    Declaration for Tables
    tables: t001,      " Company Codes
            t001w,     " Plants/Branches
            lfa1,      " Vendor Master
            ska1,      " GL Account Master
            mara,      " Material Master
            mbew,      " Material Valuation
            ekko,      " PO Header Data
            cska,      " Cost Elements
            csks,      " Cost Centers
            bsis,      " GL Accounts: Open Items Data
            bkpf.      " Accounting Doc: Header Data
    Type-pools
    Type pools for ALV display
    type-pools : slis.
    Global variables
    data: g_repid       like sy-repid,
          g_exit        type c,
          g_events      type slis_t_event,
          g_list_top_of_page type slis_t_listheader,
          g_exit_caused_by_caller,
          g_exit_caused_by_user type slis_exit_by_user,
          g_top_of_page  type slis_formname value 'TOP_OF_PAGE',
          g_variant like disvariant,
          g_save.
    Declaration for Constants
    constants : c_x  type c  value 'X',         " Flag
                c_c  type c  value 'C',         " Flag
                c_l  type c  value 'L',         " Flag
                c_a  type c  value 'A',         " Line Type
                c_h  type c  value 'H',         " Dr/Cr
                c_s  type c  value 'S',         " Line Type
                c_mkpf(4) type c value 'MKPF'.  " Table
    Declaration of Internal Tables
    Internal Table for BSIS Table data
    data: begin of i_bsis occurs 0,
            bukrs like bsis-bukrs,          " Company Code
            hkont like bsis-hkont,          " GR IR Account
            gjahr like bsis-gjahr,          " Fiscal Year
            belnr like bsis-belnr,          " Acc Document
            buzei like bsis-buzei,          " Item No
            budat like bsis-budat,          " Receipt Date(Posting)
            monat like bsis-monat,          " Period
          end of i_bsis.
    Internal Table for BSEG Table data
    data: begin of i_bseg occurs 0,
            bukrs like bsis-bukrs,          " Company Code
            belnr like bsis-belnr,          " Acc Document
            buzei like bsis-buzei,          " Item No
            gjahr like bsis-gjahr,          " Fiscal Year
            shkzg like bseg-shkzg,          " Dr/Cr Indicator
            lifnr like bseg-lifnr,          " Vendor Code
            matnr like bseg-matnr,          " Material No
            ebeln like bseg-ebeln,          " Purchase Order
            ebelp like bseg-ebelp,          " PO Item
            werks like bseg-werks,          " Plant
            menge like bseg-menge,          " PO Quantity
            meins like bseg-meins,          " UOM
            dmbtr like bseg-dmbtr,          " Amount in Local Currency
            wrbtr like bseg-wrbtr,          " Amount in Trans.Currency
          end of i_bseg.
    Internal Table for BKPF Table data
    data: begin of i_bkpf occurs 0,
            bukrs like bkpf-bukrs,          " Company Code
            belnr like bkpf-belnr,          " Acc Document
            gjahr like bkpf-gjahr,          " Fiscal Year
            waers like bkpf-waers,          " Trans. Currency
            awkey like bkpf-awkey,          " Object Key
            awtyp like bkpf-awtyp,          " Reference Procedure
          end of i_bkpf.
    Internal Table for MSEG Table data
    data: begin of i_mseg occurs 0,
            mblnr like mseg-mblnr,          " Material Document
            mjahr like mseg-mjahr,          " Fiscal Year
            bwart like mseg-bwart,          " Movement Type
            matnr like mseg-matnr,          " Material No
            menge like mseg-menge,          " PO Quantity
            meins like mseg-meins,          " UOM
          end of i_mseg.
    Internal Table for MBEW Table data
    data: begin of i_mbew occurs 0,
            matnr like mbew-matnr,          " Material No
            werks like mbew-bwkey,          " Plant
            bklas like mbew-bklas,          " Valuation Class
          end of i_mbew.
    Internal Table for EKPO Table data
    data: begin of i_ekpo occurs 0,
            ebeln like ekpo-ebeln,          " Purchase Order
            ebelp like ekpo-ebelp,          " PO Item
            matnr like ekpo-matnr,          " Material No
            txz01 like ekpo-txz01,          " Material Text
          end of i_ekpo.
    Internal Table for EKKN Table data
    data: begin of i_ekkn occurs 0,
            ebeln like ekkn-ebeln,          " Purchase Order
            ebelp like ekkn-ebelp,          " PO Item
            kostl like ekkn-kostl,          " Cost Center
            sakto like ekkn-sakto,          " Cost Element
          end of i_ekkn.
    Internal Table for LFA1 Table data
    data: begin of i_lfa1 occurs 0,
            lifnr like lfa1-lifnr,          " Vendor
            name1 like lfa1-name1,          " Name
          end of i_lfa1.
    Declaration of Output Internal Table
    data: begin of i_final occurs 0,
            lifnr like lfa1-lifnr,     " Vendor
            werks like bseg-werks,     " Plant
            monat like bsis-monat,     " Period
            matnr like mara-matnr,     " Material Number
            bklas like mbew-bklas,     " Val Class
            ebeln like bseg-ebeln,     " PO
            kostl like ekkn-kostl,     " Cost Center
            sakto like ekkn-sakto,     " Cost Element
            budat like bsis-budat,     " Rec. Date
            name1 like lfa1-name1,     " Vendor Name
            belnr like bsis-belnr,     " FI Document
            bwart like mseg-bwart,     " Movement Type
            txz01 like ekpo-txz01,     " Material Text
            menge like bseg-menge,     " Quantity
            meins like bseg-meins,     " UOM
            dmbtr like bseg-dmbtr,     " Local Amount
            wrbtr like bseg-wrbtr,     " Tran.Amount
            waers like bkpf-waers,     " Tran.Currency
            status type c,             " Material Status
          end of i_final.
    Internal table to hold field catgory data
    data:  i_fldcat  type slis_t_fieldcat_alv.   " Table - field catgory
    Internal table to hold Sort/Subtotals criteria data
    data:  i_sort  type slis_t_sortinfo_alv.     " Table - sort/Subtotals
    Structure
    data:  x_layout   type slis_layout_alv,      " Structure-layout
           x_fldcat   like line of i_fldcat,     " Structure-field catagory
           x_sort     like line of i_sort.       " Structure-Sort/Subtotals
           Selection screen
    selection-screen : begin of block b1 with frame title text-000.
    parameters:
       p_bukrs like t001-bukrs obligatory,          " Company Code
       p_grira like ska1-saknr default '0241101000' obligatory. " Account
    select-options:
       s_budat for bkpf-budat,        " Posting Date
       s_werks for t001w-werks,       " Plant
       s_lifnr for lfa1-lifnr,        " Vendor
       s_matnr for mara-matnr,        " Material Number
       s_kostl for csks-kostl,        " Cost Center
       s_kstar for cska-kstar,        " Cost Element
       s_ebeln for ekko-ebeln,        " Purchase Order
       s_monat for bsis-monat.        " Period
    selection-screen skip.
    parameters:
       p_incmt as checkbox default 'X',
       p_incnm as checkbox default 'X'.
    selection-screen end of block b1.
    Initialization
    initialization.
      g_repid = sy-repid.
      perform layout_init using x_layout.
      perform eventtab_build using g_events[].
      g_variant-report = g_repid.
      g_save           = 'A'.
    At selection screen
    at selection-screen.
    Validation of Selection Screen Fields
      perform validate_screen.
    Start of selection
    start-of-selection.
    Read Data from Database Tables
      perform read_data.
    End of selection
    end-of-selection.
    Build layout report layout.
      perform populate_layout_stucture.
    Perform build_field_catalog and Sort Table
      perform build_field_catalog.
      perform build_sort_totals.
    List Header for Top-Of-Page
      perform comment_build using g_list_top_of_page[].
    Call list viewer function module
      perform call_list_viewer .
    ****************Form - Routines**************************************
          Form        : layout_init
          Description : Form to Build layout for list display
    form layout_init using rs_layout type slis_layout_alv.
      rs_layout-detail_popup      = c_x.
    endform.
    Form         : Eventtab_build
    Description  : Registration of events to happen during list display
    form eventtab_build using rt_events type slis_t_event.
    Registration of events to happen during list display
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = rt_events.
      read table rt_events with key name = slis_ev_top_of_page
                               into ls_event.
      if sy-subrc = 0.
        move g_top_of_page to ls_event-form.
        append ls_event to rt_events.
      endif.
    endform.                                   "eventtab_build
          Form : top_of_page
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
             I_LOGO             = 'ENJOYSAP_LOGO'
                it_list_commentary = g_list_top_of_page.
    endform.
          Form validate_screen
    Validation of Selection Screen fields
    form validate_screen.
    Validation of Company Code
      clear t001.
      if not p_bukrs is initial.
        select single bukrs
          into t001-bukrs
          from t001
          where bukrs eq p_bukrs.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Company Code'(012).
        endif.
      endif.
    Validation of GL Account (GR/IR)
      clear ska1.
      if not p_grira is initial.
        select saknr
          into ska1-saknr
          from ska1
          up to 1 rows
          where saknr eq p_grira.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid GR/IR Account'(013).
        endif.
      endif.
    Validation of Vendor Code
      clear lfa1.
      if not s_lifnr[] is initial.
        select single lifnr
          into lfa1-lifnr
          from lfa1
          where lifnr in s_lifnr.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Vendor'(001).
        endif.
      endif.
    Validation of Plant Code
      clear t001w.
      if not s_werks[] is initial.
        select single werks
          into t001w-werks
          from t001w
          where werks in s_werks.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Plant'(014).
        endif.
      endif.
    Validation of Material Code
      clear mara.
      if not s_matnr[] is initial.
        select single matnr
          into mara-matnr
          from mara
          where matnr in s_matnr.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Material'(015).
        endif.
      endif.
    Validation of Purchase Order
      clear ekko.
      if not s_ebeln[] is initial.
        select single ebeln
          into ekko-ebeln
          from ekko
          where ebeln in s_ebeln.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Purchase Order'(016).
        endif.
      endif.
    Validation of Cost Center
      clear csks.
      if not s_kostl[] is initial.
        select kostl
          into csks-kostl
          from csks
          up to 1 rows
          where kostl in s_kostl.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Cost Center'(017).
        endif.
      endif.
    Validation of Cost Element
      clear cska.
      if not s_kstar[] is initial.
        select kstar
          into cska-kstar
          from cska
          up to 1 rows
          where kstar in s_kstar.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Cost Element'(018).
        endif.
      endif.
    endform.                          "validate_screen
    *&      Form  read_data
    Read the Data from the database Tables
    form read_data.
    Get the Accounting Documents for the GR/IR Account Entered on
    Selection Screen
      clear i_bsis.
      refresh i_bsis.
      select bukrs           " Company Code
             hkont           " GR IR Account
             gjahr           " Fiscal Year
             belnr           " Acc Document
             buzei           " Item No
             budat           " Receipt Date(Posting)
             monat           " Period
       into table i_bsis
       from  bsis
       where  bukrs = p_bukrs
         and  hkont = p_grira
         and  budat in s_budat
         and  monat in s_monat .
      if sy-subrc <> 0.
        message i899 with 'No data found'(043).
        g_exit = c_x.
        stop.
      endif.
      sort i_bsis by bukrs hkont gjahr belnr buzei.
    Get the Vendor,PO,Material,Qty details from BSEG Table
      if not i_bsis[] is initial.
        clear i_bseg.
        refresh i_bseg.
        select bukrs           " Company Code
               belnr           " Acc Document
               buzei           " Item No
               gjahr           " Fiscal Year
               shkzg           " Dr/Cr Indicator
               lifnr           " Vendor Code
               matnr           " Material No
               ebeln           " Purchase Order
               ebelp           " PO Item
               werks           " Plant
               menge           " PO Quantity
               meins           " UOM
               dmbtr           " Amount in Local Currency
               wrbtr           " Amount in Trans.Currency
        into table i_bseg
        from   bseg
        for all entries in i_bsis
        where  bukrs = p_bukrs
        and    belnr = i_bsis-belnr
        and    gjahr = i_bsis-gjahr
        and    buzei = i_bsis-buzei
        and    lifnr in s_lifnr
        and    werks in s_werks
        and    matnr in s_matnr
        and    ebeln in s_ebeln.
        sort i_bseg by bukrs belnr buzei gjahr.
    Select the Trans.Currency from BKPF Table
        clear i_bkpf.
        refresh i_bkpf.
        select bukrs           " Company Code
               belnr           " Acc Document
               gjahr           " Fiscal Year
               waers           " Trans. Currency
               awkey           " Object Key
               awtyp           " Reference Procedure
        into table i_bkpf
        from   bkpf
        for all entries in i_bsis
        where  bukrs = p_bukrs
        and    belnr = i_bsis-belnr
        and    gjahr = i_bsis-gjahr.
      endif.
      sort i_bkpf by bukrs belnr gjahr.
    Get the Quantity and UOM of Material from MSEG Table
      if not i_bkpf[] is initial.
        clear i_mseg.
        refresh i_mseg.
        select mblnr           " Material Document
               mjahr           " Fiscal Year
               bwart           " Movement Type
               matnr           " Material No
               menge           " PO Quantity
               meins           " UOM
          into table i_mseg
          from   mseg
          for all entries in i_bkpf
          where  mblnr = i_bkpf-awkey(10).
      endif.
      sort i_mseg by mblnr mjahr.
    Get the Material And Description from EKPO Table
      if not i_bseg[] is initial.
        clear i_ekpo.
        refresh i_ekpo.
        select ebeln           " Purchase Order
               ebelp           " PO Item
               matnr           " Material No
               txz01           " Material Text
        into table i_ekpo
        from   ekpo
        for all entries in i_bseg
        where  ebeln = i_bseg-ebeln
        and    ebelp = i_bseg-ebelp.
        sort i_ekpo by ebeln ebelp.
    Get the Valuation Class from MBEW Table
        clear i_mbew.
        refresh i_mbew.
        select matnr           " Material No
               bwkey           " Plant
               bklas           " Valuation Class
        into table i_mbew
        from   mbew
        for all entries in i_bseg
        where  matnr = i_bseg-matnr
        and    bwkey = i_bseg-werks.
        sort i_mbew by matnr werks.
    Get the Cost Center and Cost Element of the PO from EKKN Table
        clear i_ekkn.
        refresh i_ekkn.
        select ebeln           " Purchase Order
               ebelp           " PO Item
               kostl           " Cost Center
               sakto           " Cost Element
        into table i_ekkn
        from   ekkn
        for all entries in i_bseg
        where  ebeln = i_bseg-ebeln
        and    ebelp = i_bseg-ebelp
        and    kostl in s_kostl
        and    sakto in s_kstar.
        sort i_ekkn by ebeln ebelp.
    Get the Vendor Name
        clear i_lfa1.
        refresh i_lfa1.
        select lifnr            " Vendor
               name1            " Name
        into table i_lfa1
        from   lfa1
        for all entries in i_bseg
        where  lifnr = i_bseg-lifnr.
      endif.
      sort i_lfa1 by lifnr.
    Move the data to Final Output Internal Table
      loop at i_bsis.
        i_final-belnr = i_bsis-belnr.     " FI Document
        i_final-monat = i_bsis-monat.     " Period
        i_final-budat = i_bsis-budat.     " Rec. Date
    Read the Transaction Currency from BKPF Internal Table
        read table i_bkpf with key bukrs = i_bsis-bukrs
                                   belnr = i_bsis-belnr
                                   gjahr = i_bsis-gjahr
                                   binary search.
        if sy-subrc = 0.
          i_final-waers = i_bkpf-waers.     " Tran.Currency
    Read the Movement Type for all Material Related
    Documents from MSEG Internal Table
          if i_bkpf-awtyp = c_mkpf.
            read table i_mseg with key mblnr = i_bkpf-awkey(10)
                                       mjahr = i_bkpf-awkey+10(4).
            if sy-subrc = 0.
              i_final-bwart = i_mseg-bwart.     " Movement Type
            endif.
          endif.
        endif.
    Read Vendor, Plant, PO Document, Local And Trans.Amounts
    from BSEG Internal Table
        read table i_bseg with key bukrs = i_bsis-bukrs
                                   belnr = i_bsis-belnr
                                   gjahr = i_bsis-gjahr
                                   buzei = i_bsis-buzei
                                   binary search.
        if sy-subrc = 0.
          i_final-lifnr = i_bseg-lifnr.     " Vendor
          i_final-werks = i_bseg-werks.     " Plant
          i_final-ebeln = i_bseg-ebeln.     " PO
          i_final-dmbtr = i_bseg-dmbtr.     " Local Amount
          i_final-wrbtr = i_bseg-wrbtr.     " Tran.Amount
          i_final-menge = i_bseg-menge.     " Quantity
          i_final-meins = i_bseg-meins.     " UOM
    For Credit Indicator(SHKZG = H) amounts should be (-)ve
          if i_bseg-shkzg = c_h.
            i_final-dmbtr = i_final-dmbtr * -1.
            i_final-wrbtr = i_final-wrbtr * -1.
            i_final-menge = i_final-menge * -1.
          endif.
    Read the Material and its Description from EKPO Internal Table
          read table i_ekpo with key ebeln = i_bseg-ebeln
                                     ebelp = i_bseg-ebelp
                                     matnr = i_bseg-matnr
                                     binary search.
          if sy-subrc = 0.
            i_final-matnr = i_ekpo-matnr.     " Material Number
            i_final-txz01 = i_ekpo-txz01.     " Material Text
    Populate the Material Status depending on the Input Checkbox
    On Selection Screen
            if not i_ekpo-matnr is initial.
              i_final-status = c_x.
            endif.
          endif.
    Read the PO related Cost Element and Cost Centers
    from EKKN Internal Table
          read table i_ekkn with key ebeln = i_bseg-ebeln
                                     ebelp = i_bseg-ebelp
                                     binary search.
          if sy-subrc = 0.
            i_final-kostl = i_ekkn-kostl.     " Cost Center
            i_final-sakto = i_ekkn-sakto.     " Cost Element
          endif.
    Read the Valuation Class from MBEW Internal Table
          read table i_mbew with key matnr = i_bseg-matnr
                                     werks = i_bseg-werks
                                     binary search.
          if sy-subrc = 0.
            i_final-bklas = i_mbew-bklas.     " Val Class
          endif.
    Read the Vendor Name from LFA1 Internal Table
          read table i_lfa1 with key lifnr = i_bseg-lifnr
                                     binary search.
          if sy-subrc = 0.
            i_final-name1 = i_lfa1-name1.     " Vendor Name
          endif.
        endif.
        append i_final.
        clear i_final.
      endloop.
      sort i_final by lifnr werks monat matnr.
    Depending on the check Box Selected display the data
      if p_incmt = c_x and p_incnm ne c_x.
        delete i_final where matnr eq space.
      elseif p_incnm = c_x and p_incmt ne c_x.
        delete i_final where matnr ne space.
      endif.
    endform.           "Read Data
         Form        : populate_layout_stucture
         Description : Populating the layout structure
    form populate_layout_stucture.
      clear x_layout .
    Layout properties
      x_layout-zebra                = c_x.
      x_layout-detail_popup         = c_x.
      x_layout-detail_initial_lines = c_x.
      x_layout-colwidth_optimize    = c_x.
    endform.                    " populate_layout_stucture
         Form        : build_field_catalog
         Description : Building the field catalog data
    form build_field_catalog.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
           exporting
                i_program_name         = g_repid
                i_internal_tabname     = 'I_FINAL'
                i_inclname             = g_repid
           changing
                ct_fieldcat            = i_fldcat
           exceptions
                inconsistent_interface = 1
                program_error          = 2
                others                 = 3.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    Getting the Header text for the coloums
      loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
                                           fieldname = 'NAME1' or
                                           fieldname = 'WERKS' or
                                           fieldname = 'MONAT' or
                                           fieldname = 'MATNR' or
                                           fieldname = 'BKLAS' or
                                           fieldname = 'EBELN' or
                                           fieldname = 'KOSTL' or
                                           fieldname = 'SAKTO' or
                                           fieldname = 'BUDAT' or
                                           fieldname = 'BELNR' or
                                           fieldname = 'BWART' or
                                           fieldname = 'TXZ01' or
                                           fieldname = 'MENGE' or
                                           fieldname = 'MEINS' or
                                           fieldname = 'DMBTR' or
                                           fieldname = 'WRBTR' or
                                           fieldname = 'WAERS' or
                                           fieldname = 'STATUS'.
        if x_fldcat-fieldname = 'LIFNR'.
          x_fldcat-seltext_l   = 'Vendor'(003).
          x_fldcat-seltext_m   = 'Vendor'(003).
          x_fldcat-seltext_s   = 'Vendor'(003).
          x_fldcat-reptext_ddic = 'Vendor'(003).
          x_fldcat-inttype   = c_c.
        endif.
        if x_fldcat-fieldname = 'NAME1'.
          x_fldcat-seltext_l   = 'Vendor Name'(002).
          x_fldcat-seltext_m   = 'Vendor Name'(002).
          x_fldcat-seltext_s   = 'Vendor Name'(002).
          x_fldcat-reptext_ddic = 'Vendor Name'(002).
          x_fldcat-inttype   = c_c.
        endif.
        if x_fldcat-fieldname = 'WERKS'.
          x_fldcat-seltext_l   = 'Plant'(010).
          x_fldcat-seltext_m   = 'Plant'(010).
          x_fldcat-seltext_s   = 'Plant'(010).
          x_fldcat-reptext_ddic   = 'Plant'(010).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'MONAT'.
          x_fldcat-seltext_l   = 'Period'(011).
          x_fldcat-seltext_m   = 'Period'(011).
          x_fldcat-seltext_s   = 'Period'(011).
          x_fldcat-reptext_ddic   = 'Period'(011).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'MATNR'.
          x_fldcat-seltext_l   = 'Material'(004).
          x_fldcat-seltext_m   = 'Material'(004).
          x_fldcat-seltext_s   = 'Material'(004).
          x_fldcat-reptext_ddic   = 'Material'(004).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BKLAS'.
          x_fldcat-seltext_l   = 'Valuation Class'(009).
          x_fldcat-seltext_m   = 'Valuation Class'(009).
          x_fldcat-seltext_s   = 'Valuation Class'(009).
          x_fldcat-reptext_ddic   = 'Valuation Class'(009).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'EBELN'.
          x_fldcat-seltext_l   = 'Purchase Order'(005).
          x_fldcat-seltext_m   = 'Purchase Order'(005).
          x_fldcat-seltext_s   = 'Purchase Order'(005).
          x_fldcat-reptext_ddic   = 'Purchase Order'(005).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'KOSTL'.
          x_fldcat-seltext_l   = 'Cost Center'(006).
          x_fldcat-seltext_m   = 'Cost Center'(006).
          x_fldcat-seltext_s   = 'Cost Center'(006).
          x_fldcat-reptext_ddic   = 'Cost Center'(006).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'SAKTO'.
          x_fldcat-seltext_l   = 'Cost Element'(007).
          x_fldcat-seltext_m   = 'Cost Element'(007).
          x_fldcat-seltext_s   = 'Cost Element'(007).
          x_fldcat-reptext_ddic   = 'Cost Element'(007).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BUDAT'.
          x_fldcat-seltext_l   = 'Receipt Date'(008).
          x_fldcat-seltext_m   = 'Receipt Date'(008).
          x_fldcat-seltext_s   = 'Receipt Date'(008).
          x_fldcat-reptext_ddic   = 'Receipt Date'(008).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BELNR'.
          x_fldcat-seltext_l   = 'Acc.Document'(100).
          x_fldcat-seltext_m   = 'Acc.Document'(100).
          x_fldcat-seltext_s   = 'Acc.Document'(100).
          x_fldcat-reptext_ddic   = 'Acc.Document'(100).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BWART'.
          x_fldcat-seltext_l   = 'Movement Type'(101).
          x_fldcat-seltext_m   = 'Movement Type'(101).
          x_fldcat-seltext_s   = 'Movement Type'(101).
          x_fldcat-reptext_ddic   = 'Movement Type'(101).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'TXZ01'.
          x_fldcat-seltext_l   = 'Material Text'(102).
          x_fldcat-seltext_m   = 'Material Text'(102).
          x_fldcat-seltext_s   = 'Material Text'(102).
          x_fldcat-reptext_ddic   = 'Material Text'(102).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'MENGE'.
          x_fldcat-seltext_l   = 'Quantity'(103).
          x_fldcat-seltext_m   = 'Quantity'(103).
          x_fldcat-seltext_s   = 'Quantity'(103).
          x_fldcat-reptext_ddic   = 'Quantity'(103).
          x_fldcat-ddictxt   = c_l.
          x_fldcat-do_sum    = c_x.
        endif.
        if x_fldcat-fieldname = 'MEINS'.
          x_fldcat-seltext_l   = 'UOM'(104).
          x_fldcat-seltext_m   = 'UOM'(104).
          x_fldcat-seltext_s   = 'UOM'(104).
          x_fldcat-reptext_ddic   = 'UOM'(104).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'DMBTR'.
          x_fldcat-seltext_l   = 'Amount in Local Curr'(105).
          x_fldcat-seltext_m   = 'Amount in Local Curr'(105).
          x_fldcat-seltext_s   = 'Amount in Local Curr'(105).
          x_fldcat-reptext_ddic   = 'Amount in Local Curr'(105).
          x_fldcat-ddictxt   = c_l.
          x_fldcat-do_sum    = c_x.
        endif.
        if x_fldcat-fieldname = 'WRBTR'.
          x_fldcat-seltext_l   = 'Amount in Trans.Curr'(106).
          x_fldcat-seltext_m   = 'Amount in Trans.Curr'(106).
          x_fldcat-seltext_s   = 'Amount in Trans.Curr'(106).
          x_fldcat-reptext_ddic   = 'Amount in Trans.Curr'(106).
          x_fldcat-ddictxt   = c_l.
          x_fldcat-do_sum    = c_x.
        endif.
        if x_fldcat-fieldname = 'WAERS'.
          x_fldcat-seltext_l   = 'Trans.Currency'(107).
          x_fldcat-seltext_m   = 'Trans.Currency'(107).
          x_fldcat-seltext_s   = 'Trans.Currency'(107).
          x_fldcat-reptext_ddic   = 'Trans.Currency'(107).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'STATUS'.
          x_fldcat-seltext_l   = 'Material Status'(019).
          x_fldcat-seltext_m   = 'Material Status'(019).
          x_fldcat-seltext_s   = 'Material Status'(019).
          x_fldcat-reptext_ddic   = 'Material Status'(019).
          x_fldcat-ddictxt   = c_l.
        endif.
        modify i_fldcat from x_fldcat index sy-tabix.
      endloop.
    endform.                    " build_field_catalog
         Form        : build_sort_totals
         Description : Building the Criteria for Sort/Subtotals
    form build_sort_totals.
      x_sort-fieldname = 'LIFNR'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  1.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'WERKS'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  2.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'MONAT'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  3.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'MATNR'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  4.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'BKLAS'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  5.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'EBELN'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  6.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'KOSTL'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  7.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'SAKTO'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  8.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'BUDAT'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  9.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
    endform.                    " build_sort_totals
      Form        : comment_build
      Description : This form is used to display the Report Header(ALV)
    form comment_build using lt_top_of_page type
                                            slis_t_listheader.
      data: l_line type slis_listheader,
            l_heading1 like rs38m-repti,
            l_date(10), l_time(8).
      clear l_line.
      l_heading1 = 'GR/IR DETAIL REPORT'(021).
      g_repid = sy-repid.
      write sy-uzeit to l_time.
      write sy-datum to l_date.
      l_line-typ = c_h.
      move l_heading1 to l_line-info.
      append l_line to lt_top_of_page.
      clear l_line.
      l_line-typ  = c_s.
      concatenate 'System:'(023) sy-sysid
                  'Date:'(024) l_date
                  ' Time:'(025)
                  l_time into l_line-info.
      append l_line to lt_top_of_page.
      concatenate 'Report:'(026) g_repid
                  ' User:'(027) sy-uname into
                  l_line-info.
      append l_line to lt_top_of_page.
      l_line-typ = c_a.
      move 'SELECTION CRITERIA:'(028) to l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Company Code : '(029)
                  p_bukrs into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' GR/IR Account: '(030)
                  p_grira into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Posting Date : '(032) s_budat-low
                  ' To: '(031) s_budat-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Plant : '(033) s_werks-low
                  ' To: '(031) s_werks-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Vendor: '(034) s_lifnr-low
                  ' To: '(031) s_lifnr-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Material: '(035) s_matnr-low
                  ' To: '(031) s_matnr-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Cost Center : '(036) s_kostl-low
                  ' To: '(031) s_kostl-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Cost Element: '(037) s_kstar-low
                  ' To: '(031) s_kstar-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Purchase Order: '(038) s_ebeln-low
                  ' To: '(031) s_ebeln-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Period : '(039) s_monat-low
                  ' To: '(031) s_monat-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Include Material Items: '(040)
                  p_incmt into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Include Non-Material Items: '(041)
                  p_incnm into l_line-info.
      append l_line to lt_top_of_page.
    endform.
         Form        : call_list_viewer
         Description : This form is used to display the grid through ALV
    form call_list_viewer.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = g_repid
                is_layout               = x_layout
                it_fieldcat             = i_fldcat[]
                i_default               = c_x
                it_sort                 = i_sort[]
                i_save                  = g_save
                is_variant              = g_variant
                it_events               = g_events[]
           importing
                e_exit_caused_by_caller = g_exit_caused_by_caller
                es_exit_caused_by_user  = g_exit_caused_by_user
           tables
                t_outtab                = i_final
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
        write: / 'Problem in calling the ALV report'(042).
      endif.
    endform.                    " call_list_viewer
    Regards
    Anji

  • Need Help in  Interactive ALV Report

    Hi guru's,
      I need sample code of Interactive ALV   when on selecting an particular field, it should open an another ALV windows or pop-up window. Please help me and points will be rewarded for the right code.
    Regards
    Rajiv Christopher

    hi,
    may b it will b helpful 2 u.
    INTERACTIVE ALV
    REPORT Z50651_ALV_INTERACTIVE MESSAGE-ID ZMSG_50651
    LINE-SIZE 100
    LINE-COUNT 60
    NO STANDARD PAGE HEADING.
    ******************TABLES DECLARATION*****************
    TABLES : VBAP,MARA.
    *****************TYPE POOLS**************************
    TYPE-POOLS : SLIS.
    ****************INTERNAL TABLES**********************
    DATA : BEGIN OF IT_VBAP OCCURS 0,
    VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
    POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
    MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
    END OF IT_VBAP.
    ****************TEMPORARY VARIABLES******************
    DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
    DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
    *****************FIELD CATALOG***********************
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    ****************LAYOUT*******************************
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    ***************VARIANT*******************************
    DATA : G_VARIANT LIKE DISVARIANT.
    ****************SAVE*********************************
    DATA : G_SAVE(1) TYPE C.
    *****************EVENTS******************************
    DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
    G_EVENTS TYPE SLIS_T_EVENT.
    ******************PF STATUS**************************
    DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
    ******************USER COMMAND************************
    DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
    R_UCOMM LIKE SY-UCOMM.
    ****************SELECTION SCREEN************************
    SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
    ***************AT SELECTION SCREEN*********************
    AT SELECTION-SCREEN.
    PERFORM VALIDATE.
    **************START-OF-SELECTION**************************
    START-OF-SELECTION.
    PERFORM GET_DETAILS.
    PERFORM FIELDCAT.
    PERFORM LAYOUT.
    PERFORM VARIANT.
    PERFORM SAVE.
    PERFORM EVENTS.
    PERFORM ALV_DISPLAY.
    *********************FORMS*******************************************
    *& Form validate
    text
    --> p1 text
    <-- p2 text
    FORM VALIDATE .
    SELECT SINGLE VBELN
    FROM VBAP
    INTO V_VBELN
    WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E000 WITH 'enter valid vbeln'.
    ENDIF.
    ENDFORM. " validate
    *& Form get_details
    text
    --> p1 text
    <-- p2 text
    FORM GET_DETAILS .
    SELECT VBELN
    POSNR
    MATNR
    FROM VBAP
    INTO TABLE IT_VBAP
    WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E000 WITH 'no details found'.
    ENDIF.
    ENDFORM. " get_details
    *& Form fieldcat
    text
    --> p1 text
    <-- p2 text
    FORM FIELDCAT .
    WA_FIELDCAT-TABNAME = 'IT_VBAP'.
    WA_FIELDCAT-FIELDNAME = 'VBELN'.
    WA_FIELDCAT-OUTPUTLEN = 10.
    WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_VBAP'.
    WA_FIELDCAT-FIELDNAME = 'POSNR'.
    WA_FIELDCAT-OUTPUTLEN = 6.
    WA_FIELDCAT-SELTEXT_L = 'ITEM'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_VBAP'.
    WA_FIELDCAT-FIELDNAME = 'MATNR'.
    WA_FIELDCAT-OUTPUTLEN = 18.
    WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    ENDFORM. " fieldcat
    *& Form LAYOUT
    text
    --> p1 text
    <-- p2 text
    FORM LAYOUT .
    WA_LAYOUT-ZEBRA = 'X'.
    ENDFORM. " LAYOUT
    *& Form VARIANT
    text
    --> p1 text
    <-- p2 text
    FORM VARIANT .
    CLEAR G_VARIANT.
    G_VARIANT-REPORT = SY-REPID.
    ENDFORM. " VARIANT
    *& Form SAVE
    text
    --> p1 text
    <-- p2 text
    FORM SAVE .
    CLEAR G_SAVE.
    G_SAVE = 'A'.
    ENDFORM. " SAVE
    *& Form EVENTS
    text
    --> p1 text
    <-- p2 text
    FORM EVENTS .
    CLEAR XS_EVENTS.
    XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
    XS_EVENTS-FORM = 'TOP_OF_PAGE'.
    APPEND XS_EVENTS TO G_EVENTS.
    ENDFORM. " EVENTS
    *& Form TOP_OF_PAGE
    text
    FORM TOP_OF_PAGE.
    WRITE :/ ' INTELLI GROUP'.
    ENDFORM. "TOP_OF_PAGE
    *& Form ALV_DISPLAY
    text
    --> p1 text
    <-- p2 text
    FORM ALV_DISPLAY .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = PF_STATUS
    I_CALLBACK_USER_COMMAND = USER_COMMAND
    I_STRUCTURE_NAME =
    IS_LAYOUT = WA_LAYOUT
    IT_FIELDCAT = IT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = G_SAVE
    IS_VARIANT = G_VARIANT
    IT_EVENTS = G_EVENTS
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = IT_VBAP
    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. " ALV_DISPLAY
    *& Form SET_PF_STATUS
    text
    FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
    SET PF-STATUS 'Z50651_PFSTATUS' EXCLUDING EXTAB.
    ENDFORM. "SET_PF_STATUS
    *& Form SET_USER_COMMAND
    text
    FORM SET_USER_COMMAND USING R_UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    CASE R_UCOMM.
    WHEN 'DC'.
    READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
    IF SY-SUBRC = 0.
    SELECT SINGLE MTART
    FROM MARA
    INTO V_MTART
    WHERE MATNR = IT_VBAP-MATNR.
    IF SY-SUBRC 0.
    MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
    ELSE.
    WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
    WRITE :/ 'MATERIAL TYPE :' , V_MTART.
    ENDIF.
    ENDIF.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    WHEN 'CLOSE'.
    CALL TRANSACTION 'SE38'.
    ENDCASE.
    ENDFORM. "SET_USER_COMMAND
    Reward if useful...

Maybe you are looking for

  • Not able to start Coherence Server on Unix environment

    Hi, I am trying to configure Coherence-Web on Weblogic server on Unix. But when i try to start the server getting the below error. I am tried with Coherence 3.7.1 but say Bad class version so then tried with Coherence 3.6.1 And i used the below commo

  • Issues in Table with Multi-Row Insert

    I have created a master detail screens using jheadstart on 2 separate pages, Master in the Form layout and detail in the Table Layout with multi-row insert, update and delete flags ON. Have set the New Rows count = 2. Issue 1 If I try to delete any e

  • IPhone 4 from Apple store in Germany (Oberhausen) NOT UNLOCKED !

    i have iPhone 4 factory unlocked, then i travelled to germany and my iphone had some problems so i went to the nearest Apple Store in Germany (Oberhausen) and the Genius Bar told me that my iPhone can't be repaired and out of warranty so they told me

  • Possible to change the DAC in iPod Classic?

    I have a 160GB iPod Classic filled with around 300 cds in lossless format. The size of the hard drive and ipod interface are great but the sound quality leaves a lot to be desired. I use Sure SE530 and Etymotic ER4P earphones, which sound amazing thr

  • I can't get mail to add any accounts.

    Hello I have used many Apple computers in the past. I have recently decided to utilize my iMac more, and have been trying to add my accounts into Apple. I am adding in from Gmail, Yahoo, and Google Apps. I have done this before on a MacBook with an o