Urgent: sales report

Hi All,
I want to devlop a sales report,
please can any one explain me how to write select and go ahead
the requiremnet is like this
Based on selection criteria
Sales organisation (VBRK-VKORG),
Distribution channel (VBRK-VTWEG),
Division (VBRK_SPART),
Billing date(VBRK-ERDAT),
Customer (VBRK-KUNAG),
plant (VBRP-WERKS), and
Material Group1(VBRP-MVGR1).
Check if VBRK-FKSTO # X, VBRK-RFBSK = C, VBRK-FKART #S1 and S2, take all VBRK-VBELNs (Print in Invoice number ).
VBRK-ERDAT(Print in Invoice Date).
Pass VBRK-VBELN to VBRP-VBELN and check for every VBRP-MVGR1 pass VBRP-POSNR to KONV-KPOSN and
For KONV-KSCHL =’ZPTS” sum all KONV-KWERT and display(PTS value).
For KONV-KSCHL =”YNRV” sum all KONV-KWERT and display(NRV Value).
thanks in advacne
points will be rewarded if it is use full
jay

Hi,
Refer this code.
REPORT  z_daily_sales
        NO STANDARD PAGE HEADING
        MESSAGE-ID sabapdocu.
                      TABLES                                         *
TABLES : vbak,                              "Sales Document: Header Data
         tfacs,                             "Factory calendar (display)
         vbrk,                              "Billing: Header Data
         vbrp,                              "Billing: Item Data
         vbpa,                              "Sales Document: Partner
         lips,                              "SD doc: Delivery: Item data
         mkpf,                              "Header: Material Document
         mseg,                              "Document Segment: Material
         konv.                              "Conditions (Trans Data)
                      CONSTANTS                                      *
CONSTANTS : c_top_of_page(15) TYPE c VALUE 'SUB_TOP_OF_PAGE'.
                      TYPE-POOL                                      *
TYPE-POOLS : slis. "Global types for generic cunning building blocks
                      VARIABLES                                      *
DATA : v_repid    TYPE sy-repid,             "Report ID
       v_month(2) TYPE c,                    "Variable for Month
       v_year(4)  TYPE c,                    "Variable for year
       v_days(31) TYPE c,                    "Variable for days
       v_ship(10) TYPE c VALUE 0,            "Variable for total days
       v_jan(31)  TYPE c,                    "Variable for month
       v_count(2) TYPE c VALUE 0,            "Variable for count
       v_wdays(2) TYPE c VALUE 0,            "Variable for working days
       v_ndays(2) TYPE c VALUE 0,            "Variable for non work days
       v_tdays(2) TYPE c VALUE 0,            "Variable for total days
       v_oltot    TYPE i VALUE 0,            "Variable for order total
       v_sotot    TYPE i VALUE 0,            "Variable for special order
       v_corebus  TYPE kzwi2 VALUE 0,        "Variable for core bus
       v_onbulk   TYPE kzwi2 VALUE 0,        "Variable for bulk orders
       v_premier  TYPE kzwi2 VALUE 0,        "Variable for premier prog
       v_shipit   TYPE kzwi2 VALUE 0,        "Variable for ship it prog
       v_onpromo  TYPE kzwi2 VALUE 0,        "Variable for on promo
       v_netrev   TYPE kzwi2 VALUE 0,        "Variable for net rev
       v_storev   TYPE kzwi2 VALUE 0,        "Variable for store rev
       v_connet   TYPE kzwi2 VALUE 0,        "Variable for consignment
       v_sporder  TYPE kzwi2 VALUE 0,        "Variable for special order
       v_stdvd    TYPE kzwi2 VALUE 0,        "Variable for dvd
       v_totrev   TYPE kzwi2 VALUE 0,        "Variable for total rev
       v_totbud   TYPE kzwi2 VALUE 0,        "Variable for total budget
       v_ordsize  TYPE kzwi2 VALUE 0.        "Variable for order size
                      TYPES                                          *
*--Structure for VBRP Table
TYPES : BEGIN OF t_vbrp,
        vbeln  TYPE vbeln,                  "Billing document
        fkdat  TYPE fkdat,                  "Billing date
        fktyp  TYPE fktyp,                  "Billing category
        fkart  TYPE fkart,                  "Billing type
        vtweg  TYPE vtweg,                  "Distribution channel
        knumv  TYPE knumv,                  "Number of doc condition
        posnr  TYPE posnr,                  "Billing item
        matnr  TYPE matnr,                  "Material Number
        werks  TYPE werks_d,                "Plant
        vgbel  TYPE xblnr,                  "Referance
        vgbel1 TYPE vgbel,                  "Doc no reference document
        kzwi2  TYPE kzwi2,                  "Subtotal 2
        wavwr  TYPE wavwr,                  "Cost in document currency
        kunnr  TYPE kunnr,                  "Customer
        END OF t_vbrp,
*--Structure for MKPF Table
        BEGIN OF t_mkpf,
        fkdat TYPE fkdat,                   "Billing date
        mblnr TYPE mblnr,                   "Number of material document
        mjahr TYPE mjahr,                   "Material doc. year
        xblnr TYPE xblnr,                   "Referance
        kunnr  TYPE kunnr,                  "Customer
        END OF t_mkpf,
*--Structure for MSEG Table
        BEGIN OF t_mseg,
        fkdat TYPE fkdat,                   "Billing date
        mblnr TYPE mblnr,                   "Number of material document
        mjahr TYPE mjahr,                   "Material doc. year
        bwart TYPE bwart,                   "Movement type
        sobkz TYPE sobkz,                   "Special Stock indicator
        dmbtr TYPE dmbtr,                   "Amount in local currency
        kunnr TYPE kunnr,                   "Customer
        matnr TYPE matnr,                   "Material Number
        werks TYPE werks_d,                 "Plant
        END OF t_mseg,
*--Structure for LIPS Table
        BEGIN OF t_lips,
        vbeln TYPE vbeln_vl,                "Delivery
        fkdat TYPE fkdat,                   "Billing date
        knumv TYPE knumv,                   "Number of doc condition
        matnr TYPE matnr,                   "Material Number
        werks TYPE werks_d,                 "Plant
        bwart TYPE bwart,                   "Movement type
        kzwi2 TYPE kzwi2,                   "Subtotal 2
        lfimg TYPE lfimg,                   "Quantity
        END OF t_lips,
*--Structure for VBAK Table
        BEGIN OF t_vbak,
        erdat TYPE erdat,                   "Created On
        vbeln TYPE vbeln_va,                "Delivery
        auart TYPE auart,                   "Sales document type
        vtweg TYPE vtweg,                   "Distribution channel
        knumv TYPE knumv,                   "Number of doc condition
        END OF t_vbak,
*--Structure for KONV Table
        BEGIN OF t_konv,
        knumv TYPE knumv,                   "Number of doc condition
        kschl TYPE kscha,                   "Condition type
        kbetr TYPE kbetr,                   "Rate
        END OF t_konv,
*--Structure for DUMMY Table
        BEGIN OF t_dummy,
        fkdat TYPE fkdat,                   "Billing date
        matnr TYPE matnr,                   "Material Number
        bwart TYPE bwart,                   "Movement type
        kbetr TYPE kzwi2,                   "Net value of billing item
        END OF t_dummy,
*--Structure for NDAY table
        BEGIN OF t_nday,
        erdat   TYPE erdat,                 "Created On
        flag(1) TYPE c,                     "Flag
        END OF t_nday,
*--Structure for TFACS Table
        BEGIN OF t_tfacs,
        ident TYPE wfcid,                   "Factory calendar ID
        jahr  TYPE kjahr,                   "Fiscal Year
        mon01 TYPE mon00,                   "Calendar: Days in a month
        mon02 TYPE mon00,                   "Calendar: Days in a month
        mon03 TYPE mon00,                   "Calendar: Days in a month
        mon04 TYPE mon00,                   "Calendar: Days in a month
        mon05 TYPE mon00,                   "Calendar: Days in a month
        mon06 TYPE mon00,                   "Calendar: Days in a month
        mon07 TYPE mon00,                   "Calendar: Days in a month
        mon08 TYPE mon00,                   "Calendar: Days in a month
        mon09 TYPE mon00,                   "Calendar: Days in a month
        mon10 TYPE mon00,                   "Calendar: Days in a month
        mon11 TYPE mon00,                   "Calendar: Days in a month
        mon12 TYPE mon00,                   "Calendar: Days in a month
        END OF t_tfacs,
*--Structure for shipping days table.
        BEGIN OF t_ship,
        title(35) TYPE c,                   "Title
        days(10)  TYPE c,                   "Days
        END OF t_ship,
*--Structure for Final Table
        BEGIN OF t_final,
        erdat   TYPE erdat,                 "Date
        oltot   TYPE i,                     "Online Order total
        sotot   TYPE i,                     "Special Order Total
        corebus TYPE kzwi2,                 "ECS Online Promo Rev
        onbulk  TYPE kzwi2,                 "ECS online Bulk Orders
        premier TYPE kzwi2,                 "MSFT Premier Program
        shipit  TYPE kzwi2,                 "MSFT online shipit program
        onpromo TYPE kzwi2,                 "MSFT online promo rev
        netrev  TYPE kzwi2,                 "MSFT/Xbox Consignment
        storev  TYPE kzwi2,                 "MSFT Retail Store promo rev
        connet  TYPE kzwi2,                 "MSFT Retail Consign net rev
        sporder TYPE kzwi2,                 "Special order revenue
        stdvd   TYPE kzwi2,                 "Traveling Store/DVD
        totrev  TYPE kzwi2,                 "Total ECS Revenue
        totbud  TYPE kzwi2,                 "Total ECS Budget
        ordsize TYPE kzwi2,                 "Avg online order size
        END OF t_final,
*--Structure for Total Table
        BEGIN OF t_total,
        title(10) TYPE c,                   "Date
        oltot     TYPE i,                   "Online Order total
        sotot     TYPE i,                   "Special Order Total
        corebus   TYPE kzwi2,               "ECS Online Promo Rev
        onbulk    TYPE kzwi2,               "ECS online Bulk Orders
        premier   TYPE kzwi2,               "MSFT Premier Program
        shipit    TYPE kzwi2,               "MSFT online shipit program
        onpromo   TYPE kzwi2,               "MSFT online promo rev
        netrev    TYPE kzwi2,               "MSFT/Xbox Consignment
        storev    TYPE kzwi2,               "MSFT Retail Store promo rev
        connet    TYPE kzwi2,               "MSFT Retail Consign net rev
        sporder   TYPE kzwi2,               "Special order revenue
        stdvd     TYPE kzwi2,               "Traveling Store/DVD
        totrev    TYPE kzwi2,               "Total ECS Revenue
        totbud    TYPE kzwi2,               "Total ECS Budget
        ordsize   TYPE kzwi2,               "Avg online order size
        END OF t_total,
*--Structure for MKPF Table
        BEGIN OF t_jkmkpf,
        budat TYPE budat,                   "Posting date
        mblnr TYPE mblnr,                   "Number of material document
        mjahr TYPE mjahr,                   "Material doc. year
        END OF t_jkmkpf,
*--Structure for MSEG Table
        BEGIN OF t_jkmseg,
        fkdat TYPE fkdat,                   "Billing date
        matnr TYPE matnr,                   "Material Number
        mblnr TYPE mblnr,                   "Number of material document
        mjahr TYPE mjahr,                   "Material doc. year
        bwart TYPE bwart,                   "Movement type
        menge TYPE menge_d,                 "Quantity
        kbetr TYPE kbetr_kond,              "Rate
        dmbtr TYPE dmbtr,                   "Amount in local currency
        END OF t_jkmseg,
*--Structure for A006 Table
        BEGIN OF t_a006,
        fkdat TYPE fkdat,                   "Billing date
        matnr TYPE matnr,                   "Material Number
        kappl TYPE kappl,                   "Application
        kschl TYPE kschl,                   "Condition type
        vkorg TYPE vkorg,                   "Sales organization
        vtweg TYPE vtweg,                   "Distribution channel
        datbi TYPE kodatbi,                 "Validity end date
        datab TYPE kodatab,                 "Validity start date
        knumh TYPE knumh,                   "Condition record number
        END OF t_a006,
*--Structure for KONP Table
        BEGIN OF t_konp,
        fkdat TYPE fkdat,                   "Billing date
        matnr TYPE matnr,                   "Material Number
        knumh TYPE knumh,                   "Condition record number
        kappl TYPE kappl,                   "Application
        kschl TYPE kschl,                   "Condition type
        kbetr TYPE kbetr_kond,              "Rate
        END OF t_konp.
                      WORK AREAS                                     *
DATA : wa_vbrp   TYPE t_vbrp,          "Work area for VBRP Table
       wa_mkpf   TYPE t_mkpf,          "Work area for MKPF Table
       wa_mseg   TYPE t_mseg,          "Work area for MSEG Table
       wa_jkmkpf TYPE t_jkmkpf,        "Work area for MKPF Table
       wa_jkmseg TYPE t_jkmseg,        "Work area for MSEG Table
       wa_kjmseg TYPE t_jkmseg,        "Work area for MSEG Table
       wa_lips   TYPE t_lips,          "Work area for LIPS Table
       wa_vbak   TYPE t_vbak,          "Work area for VBAK Table
       wa_konv   TYPE t_konv,          "Work area for KONV Table
       wa_dummy  TYPE t_dummy,         "Work area for DUMMY Table
       wa_tfacs  TYPE t_tfacs,         "Work area for TFACS Table
       wa_final  TYPE t_final,         "Work area for Final Table
       wa_total  TYPE t_total,         "Work area for Total Table
       wa_ship   TYPE t_ship,          "Work area for Ship Table
       wa_a006   TYPE t_a006,
       wa_konp   TYPE t_konp,          "Work area for KONP Table
       wa_nday   TYPE t_nday,
       wa_fieldcat TYPE slis_fieldcat_alv,"Work area for fieldcatalog
       wa_layout1 TYPE slis_layout_alv,
       wa_layout2 TYPE slis_layout_alv,
       wa_layout3 TYPE slis_layout_alv.
                      INTERNAL TABLES                                *
DATA : it_vbrp   TYPE STANDARD TABLE OF t_vbrp   INITIAL SIZE 0,
       it_mkpf   TYPE STANDARD TABLE OF t_mkpf   INITIAL SIZE 0,
       it_mseg   TYPE STANDARD TABLE OF t_mseg   INITIAL SIZE 0,
       it_jkmkpf TYPE STANDARD TABLE OF t_jkmkpf INITIAL SIZE 0,
       it_jkmseg TYPE STANDARD TABLE OF t_jkmseg INITIAL SIZE 0,
       it_kjmseg TYPE STANDARD TABLE OF t_jkmseg INITIAL SIZE 0,
       it_lips   TYPE STANDARD TABLE OF t_lips   INITIAL SIZE 0,
       it_vbak   TYPE STANDARD TABLE OF t_vbak   INITIAL SIZE 0,
       it_konv   TYPE STANDARD TABLE OF t_konv   INITIAL SIZE 0,
       it_dummy  TYPE STANDARD TABLE OF t_dummy  INITIAL SIZE 0,
       it_tfacs  TYPE STANDARD TABLE OF t_tfacs  INITIAL SIZE 0,
       it_final  TYPE STANDARD TABLE OF t_final  INITIAL SIZE 0,
       it_total  TYPE STANDARD TABLE OF t_total  INITIAL SIZE 0,
       it_ship   TYPE STANDARD TABLE OF t_ship   INITIAL SIZE 0,
       it_nday   TYPE STANDARD TABLE OF t_nday   INITIAL SIZE 0,
       it_a006   TYPE STANDARD TABLE OF t_a006   INITIAL SIZE 0,
       it_konp   TYPE STANDARD TABLE OF t_konp   INITIAL SIZE 0,
       it_fieldcat  TYPE slis_t_fieldcat_alv WITH HEADER LINE,
       it_fieldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
       it_events TYPE slis_t_event,
       it_event1 TYPE slis_t_event,
       it_event2 TYPE slis_t_event,
       it_header TYPE slis_t_listheader.
                  PARAMETERS &  SELECT-OPTIONS                       *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_erdat FOR vbak-erdat NO-DISPLAY. "Created On
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(10) text-003.
PARAMETERS : p_month(7) TYPE c OBLIGATORY.  "Month
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(40) text-030.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(10) text-004.
PARAMETERS : p_bud(16) TYPE c OBLIGATORY.   "Budget
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blk1.
                  AT SELECTION SCREEN                                *
AT SELECTION-SCREEN ON p_month.
*--Create the date range
  PERFORM sub_create_date.
                  START-OF-SELECTION                                 *
START-OF-SELECTION.
*--Select data from TFACS Table
  PERFORM sub_read_tfacs.
*--Select Data from VBAK Table
  PERFORM sub_read_vbak.
*--Select Data from VBRP Table
  PERFORM sub_read_vbrp.
*--Select Data from MKPF Table
  PERFORM sub_read_mkpf.
*--Select Data from MSEG Table
  PERFORM sub_read_mseg.
*--Select Data from LIPS Table
  PERFORM sub_read_lips.
*--Select Data from KONV Table
  PERFORM sub_read_konv.
*--Collect all the data into final inetrnal table
  PERFORM sub_collect_data.
*--Collect all the data into final inetrnal table
  PERFORM sub_collect_vbrp.
*--Collect all the data into final inetrnal table
  PERFORM sub_collect_lips.
*--Collect MSFT retail store promo rev & MSFT retail
store consignment net rev
  PERFORM sub_jk_column.
*--Collect consignment cost
  PERFORM sub_collect_consign.
*--Calculate Plug Numbers
  PERFORM sub_claculate_plug.
*--Collect data from vbrp
  PERFORM sub_collect_cost.
*--Calculate the total & avarages
  PERFORM sub_calculate_total.
*--Collect totals & avarages into final internal table
  PERFORM sub_collect_total.
                  END-OF-SELECTION                                   *
END-OF-SELECTION.
*--This perform creates the ALV events
  PERFORM sub_create_events.
*--This perform prepare field catalog.
  PERFORM sub_field_catalogmerge.
*--This perform displays an ALV report
  PERFORM sub_alv_display.
*&      Form  sub_read_vbrp
      text
FORM sub_read_vbrp .
*--Local Variables
  DATA : lv_index LIKE sy-tabix.
*--Select query to pick the Billing document Billing date Billing
category Billing type Distribution channel Number of doc condition
Billing item Material Number Plant Referance Subtotal 2 Cost in
document currency and Partner function from table VBRK VBRP and VBPA
using inner join
  SELECT a~vbeln                            "Billing document
         a~fkdat                            "Billing date
         a~fktyp                            "Billing category
         a~fkart                            "Billing type
         a~vtweg                            "Distribution channel
         a~knumv                            "Number of doc condition
         b~posnr                            "Billing item
         b~matnr                            "Material Number
         b~werks                            "Plant
         b~vgbel                            "Referance
         b~kzwi2                            "Subtotal 2
         b~wavwr                            "Cost in document currency
         c~kunnr                            "Partner function
         FROM vbrk AS a
         INNER JOIN vbrp AS b
         ON avbeln EQ bvbeln
         INNER JOIN vbpa AS c
         ON  bvbeln EQ cvbeln
         INTO CORRESPONDING FIELDS OF TABLE it_vbrp
         WHERE fkdat IN s_erdat
         AND   parvw EQ 'ZS'.
  IF sy-subrc EQ 0.
*--Sort table by Referance
    SORT it_vbrp BY vgbel1.
  ENDIF.
  LOOP AT it_vbrp INTO wa_vbrp.
    lv_index = sy-tabix.
    wa_vbrp-vgbel1 = wa_vbrp-vgbel.
    MODIFY it_vbrp FROM wa_vbrp INDEX lv_index TRANSPORTING
                                      vgbel1.
*--Clear
    CLEAR : wa_vbrp.
  ENDLOOP.
ENDFORM.                    " sub_read_vbrp
*&      Form  sub_read_mkpf
      text
FORM sub_read_mkpf .
*--Local Variables
  DATA : lv_index LIKE sy-tabix.
  IF NOT it_vbrp[] IS INITIAL.
*--Select query to pick the Number of material document Material
document year and Referance from table MKPF
    SELECT DISTINCT
           mblnr                            "Number of material document
           mjahr                            "Material doc. year
           xblnr                            "Referance
           FROM mkpf
           INTO CORRESPONDING FIELDS OF TABLE it_mkpf
           FOR ALL ENTRIES IN it_vbrp
           WHERE xblnr EQ it_vbrp-vgbel.
  ENDIF.
*--Sort table by No of material document and fiscal year
  SORT it_mkpf BY mblnr mjahr.
  IF sy-subrc EQ 0.
    DELETE ADJACENT DUPLICATES FROM it_mkpf COMPARING mblnr mjahr.
  ENDIF.
*--Sort table by referance document
  SORT it_vbrp BY vgbel.
  SORT it_mkpf BY xblnr.
  IF NOT it_mkpf[] IS INITIAL.
    LOOP AT it_mkpf INTO wa_mkpf.
      lv_index = sy-tabix.
*--Clear
      CLEAR : wa_vbrp.
      READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel = wa_mkpf-xblnr
                                               BINARY SEARCH.
      IF sy-subrc EQ 0.
        wa_mkpf-fkdat = wa_vbrp-fkdat.
        wa_mkpf-kunnr = wa_vbrp-kunnr.
      ENDIF.
      MODIFY it_mkpf FROM wa_mkpf INDEX lv_index TRANSPORTING
                                        fkdat kunnr.
*--Clear
      CLEAR : wa_mkpf.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " sub_read_mkpf
*&      Form  sub_read_mseg
      text
FORM sub_read_mseg .
*--Local Variables
  DATA : lv_index LIKE sy-tabix.
  IF NOT it_mkpf[] IS INITIAL.
*--Select query to pick the Number of material document Material
document year Movement type Special Stock indicator and Amount in
local currency from table MSEG
    SELECT mblnr                            "Number of material document
           mjahr                            "Material doc. year
           bwart                            "Movement type
           sobkz                            "Special Stock indicator
           dmbtr                            "Amount in local currency
           matnr                            "Material
           werks                            "Plant
           FROM mseg
           INTO CORRESPONDING FIELDS OF TABLE it_mseg
           FOR ALL ENTRIES IN it_mkpf
           WHERE mblnr EQ it_mkpf-mblnr
           AND   mjahr EQ it_mkpf-mjahr.
          AND   bwart EQ '601'.
          AND   sobkz EQ 'K'.
  ENDIF.
*--Sort table by Number of material document
  SORT it_mkpf BY mblnr.
*--Sort table by Number of material document
  SORT it_mseg BY mblnr.
  IF NOT it_mseg[] IS INITIAL.
    LOOP AT it_mseg INTO wa_mseg.
      lv_index = sy-tabix.
*--Clear
      CLEAR : wa_mkpf.
      READ TABLE it_mkpf INTO wa_mkpf WITH KEY mblnr = wa_mseg-mblnr
                                               BINARY SEARCH.
      IF sy-subrc EQ 0.
        wa_mseg-fkdat = wa_mkpf-fkdat.
        wa_mseg-kunnr = wa_mkpf-kunnr.
      ENDIF.
      MODIFY it_mseg FROM wa_mseg INDEX lv_index TRANSPORTING
                                        fkdat kunnr.
*--Clear
      CLEAR: wa_mseg.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " sub_read_mseg
*&      Form  sub_read_lips
      text
FORM sub_read_lips .
*--Local Variables
  DATA : lv_index LIKE sy-tabix.
  IF NOT it_vbrp[] IS INITIAL.
*--Select query to pick the Delivery Material Number Plant
Movement type Subtotal 2 and Quantity from table LIPS
    SELECT vbeln                            "Delivery
           matnr                            "Material Number
           werks                            "Plant
           bwart                            "Movement type
           kzwi2                            "Subtotal 2
           lfimg                            "Quantity
           FROM lips
           INTO CORRESPONDING FIELDS OF TABLE it_lips
           FOR ALL ENTRIES IN it_vbrp
           WHERE vbeln EQ it_vbrp-vgbel1.
    IF sy-subrc EQ 0.
*--Sort table by Delivery
      SORT it_lips BY vbeln.
    ENDIF.
  ENDIF.
*--Sort table
  SORT it_vbrp BY vgbel1.
  LOOP AT it_lips INTO wa_lips.
    lv_index = sy-tabix.
*--CLear
    CLEAR : wa_vbrp.
    READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel1 = wa_lips-vbeln
                                             BINARY SEARCH.
    IF sy-subrc EQ 0.
      wa_lips-fkdat = wa_vbrp-fkdat.
      wa_lips-knumv = wa_vbrp-knumv.
    ENDIF.
    MODIFY it_lips FROM wa_lips INDEX lv_index TRANSPORTING
                                fkdat knumv.
*--Clear
    CLEAR : wa_lips.
  ENDLOOP.
ENDFORM.                    " sub_read_lips
*&      Form  sub_read_konv
      text
FORM sub_read_konv .
  IF NOT it_vbrp[] IS INITIAL.
*--Select query to pick the Number of doc condition Condition type
and Rate from table KONV
    SELECT knumv                            "Number of doc condition
           kschl                            "Condition type
           kbetr                            "Rate
           FROM konv
           INTO TABLE it_konv
           FOR ALL ENTRIES IN it_vbrp
           WHERE knumv EQ it_vbrp-knumv
           AND   kschl EQ 'ZR00'.
  ENDIF.
ENDFORM.                    " sub_read_konv
*&      Form  sub_read_vbak
      text
FORM sub_read_vbak .
*--Select query to pick the Created On Delivery Sales document type
Distribution channel and Number of doc condition from table VBAK
  SELECT erdat                              "Created On
         vbeln                              "Delivery
         auart                              "Sales document type
         vtweg                              "Distribution channel
         knumv                              "Number of doc condition
         FROM vbak
         INTO TABLE it_vbak
         WHERE erdat IN s_erdat.
  IF sy-subrc EQ 0.
*--Sort table by created on
    SORT it_vbak BY erdat.
  ENDIF.
ENDFORM.                    " sub_read_vbak
Regards,
prashant

Similar Messages

  • Sales report: Profit center wise includes net, gross and sales tax URGENT

    Helllo Friends,
    Please help me on the below report
    Client requirement is: Sales report which includes the below
    1. Profit center
    2. Net sales
    3. Sales tax
    4. Gross sales
    5. Period
    Please help me
    Thanks for your help in advance
    Narasim

    Hi,
    You will have to get a Z report developed for  this requirement, it will be a Sales Register looking at the requirement
    Firstly discuss with the client and finalize the selection screen , based on which parameters the client wants nto check this report
    1. Customer
    2. Billinng Document
    3. Sales Area
    4. Billing Type
    5, Period
    And based on this system can collect all the billing documents (except cancelled) and pick up the required values from the billing document tables.
    Finalize if the client would also like to see the all the discounts, freights, rebate (if any) , taxes (separetly) , exchange rates (exports) and any other condition types, this will save all the modifications in the future.
    Also finalize what all billing types have to be excluded, like cancelled, credit notes, debit notes etc and also how the values have to be displayed, rounded off.

  • Material Type Vs Sales report.. Urgent

    my client requires materail type vs sales report for particaular period... is there any standard report for these.. or how can we do with a ABAPer.. wat fields we have give to ABAper.... to get the report....
    Kiran

    Hi Kiran,
    Please find the herewith the SAP SD Standard Reports.
    Reports: Reports consist of data, which is expected to be reveiwed or checked the transaction taken in said period. Reports are useful for analysis of decision taking for future activities.
    Some of the standard reports for SD & its configuration guide is as under:
    Standard SAP SD Reports:=
    Statistic Group:
    Purpose – To capture data for Standard Reports, we require to activate Statistic Group as under:
    --> Item category (Configuration)
    --> Sales document type (Configuration)
    --> Customer (Maintain in Master data)
    --> Material (Maintain in Master data)
    When you generate statistics in the logistics information system, the system uses the combination of specified statistics groups to determine the appropriate update sequence. The update sequence in turn determines for exactly which fields the statistics are generated.
    Configuration:
    IMG --> Logistics Information System (LIS) --> Logistics Data Warehouse --> Updating --> Updating Control --> Settings: Sales --> Statistics Groups -->
    1. Maintain Statistics Groups for Customers
    2. Maintain Statistics Groups for Material
    3. Maintain Statistics Groups for Sales Documents
    4. Assign Statistics Groups for Each Sales Document Type
    5. Assign Statistics Groups for each Sales Document Item Type.....
    All Standard Reports which are available are as under:
    SAP Easy Access: Information Systems -> Logistics -> Sales and distribution ->
    1. Customer -> Incoming orders / Returns / Sales / Credit memos / Sales activities / Customer master / Conditions / Credit Master Sheet
    2. Material -> Incoming orders / Returns / Sales / Credit memos / Material master / ...
    3. Sales organization -> Sales organization / Sales office / Sales employee
    4. Shipping point -> Deliveries / Returns
    5. SD documents -> Orders / Deliveries / Billing documents ...
    & so on.
    Some of the Standard reports in SD are:
    Sales summary - VC/2
    Display Customer Hierarchy - VDH2
    Display Condition record report - V/I6
    Pricing Report - V/LD
    Create Net Price List - V_NL
    List customer material info - VD59
    List of sales order - VA05
    List of Billing documents - VF05
    Inquiries list - VA15
    Quotation List - VA25
    Incomplete Sales orders - V.02
    Backorders - V.15
    Outbound Delivery Monitor - VL06o
    Incomplete delivery - V_UC
    Customer Returns-Analysis - MC+A
    Customer Analysis- Sales - MC+E
    Customer Analysis- Cr. Memo - MC+I
    Deliveries-Due list - VL04
    Billing due list - VF04
    Incomplete Billing documents - MCV9
    Customer Analysis-Basic List - MCTA
    Material Analysis(SIS) - MCTC
    Sales org analysis - MCTE
    Sales org analysis-Invoiced sales - MC+2
    Material Analysis-Incoming orders - MC(E
    General- List of Outbound deliveries - VL06f
    Material Returns-Analysis - MC+M
    Material Analysis- Invoiced Sales - MC+Q
    Variant configuration Analysis - MC(B
    Sales org analysis-Incoming orders - MC(I
    Sales org analysis-Returns - MC+Y
    Sales office Analysis- Invoiced Sales - MC-E
    Sales office Analysis- Returns - MC-A
    Shipping point Analysis - MC(U
    Shipping point Analysis-Returns - MC-O
    Blocked orders - V.14
    Order Within time period - SD01
    Duplicate Sales orders in period - SDD1
    Display Delivery Changes - VL22
    Please Reward If Really Helpful,
    Thanks and Regards,
    Sateesh.Kandula

  • Please any one provide crystal report for  Location wise sales report with GP

    Please any one provide crystal report for  Location wise sales report with GP.Please its urgent

    A report writer tool like Crystal reports is not available due to the cost involved in its licenses.Do you think that Oracle Reports is free then? It's $$$$.
    You can download and test it for free, but if you want to use it in production you have to buy a license.

  • Sales Report Generation less the Credit memo

    Anybody can help me regarding Query for Sales Report. Im trying to create a sales report per Per Product and Customer with corresponding Quantity and Amount, I have already get the query the problem is I cant get the Credit Memo deduct from its A./P Invoice so that deduct the quantity and price. With this i can get the exact sales!
    Anybody have an idea? Im having headache already for a week now trying to solve this problem, Thank you very much.
    Clint

    Hi Jeyakanthan,
    Im not referring to Sales Analysis Report. All i want is to get all the sales and Less the the corresponding Credit Memo. Im trying to create a query that will show the sales, Ex.. row
    From A/R invoice Table
    DocNo CardCode   Qty   Price  DocTotal  
    0111     CA-001     10     25      250
    less from A/R Credit Memo
    DocNo CarCode    Qty   Price  DocTotal  
    0111     CA-001     5      25      125
    I want the result to deduct the row Invoice from CM.
    If the corrsponding Invoice doesnt find a CM record then the result will be 0. Ex from above data Invoice less the Credit Memo.
    if the Invoice found a Credit Memo,
    Qty1       Qty2    Qty3, DocTotal1 DocTotal2 = Result
    10   less  5      =  5 ;    250   less 125         =   125
    if the Invoice doesnt have Credit Memo,
    Qty1       Qty2    Qty3, DocTotal1 DocTotal2 = Result
    10   less  0      =  10 ;    250   less 0            =   250
    hope the will clarify everything, thank yuo very much in advance.
    Regards,
    Clint

  • Values are not getting updated in sales report

    I have configured sales information system, and i have been trying to run sales report but values are not getting updated in sales report, System will through message that no data exists.
    regards,
    thooyavan

    Hi,
    Please check with the Customer and Material Statistics group in the Customer and material master respectively.
    Further check with the LIS settings (Sales Area combination with the Update group).
    Reward points if this helps you.
    Regards,
    Harsh

  • Sales Reports with Partial Shipments

    Hello,
    I need to write a sales report for open orders. If the order has been partially shipped, I just need to pull what remains to be shipped and display this total.
    If the order has not been partially shipped, I need to pull the doc total.
    How do I specify if an order has been partially shipped or not? Is there any way to say, "If a line in RDR1 has been shipped or partially shipped, sum the totals of OpenCreQty * Price, else pull DocTotal"?
    I need to display the report in 1 line per sales order.
    Thanks in advance,
    Chris

    Hi Christine, 
    Without knowing the exact fields you are using you should be doing something like: 
    If {TABLE.OpenCreQty} NOT EQUAL {TABLE.Quantity} Then
         0
    Else {TABLE.Quantity};
    NOTE: WHERE IT SAYS NOT EQUAL TO should be LESS THAN and GREATER THAN symbols. They don't show up in here.
    So the If is checking what was shipped with the order's quantity.  If they are not equal then show 0 otherwise show the order's quantity. 
    Now you can do a summary and sum this formula and you should get the proper numbers. 
    Good luck,
    Brian

  • Sales Report for US Sales and Use tax

    Hi,
    I'm looking for t-code to extract detailed sales report having Gross sales, Exempt sales , Ship to state, Ship to County\ City,  Sales Tax collected. If I'm getting this report i can verify what my sales tax software is updating.
    When i extract  tcode - ZINVLIS i don't get much detail.
    Please help me in extracting complete sales detail which can be used for sales and use tax verification process and audit purpose.
    Thanks,
    Karthik

    Hi Karthik,
    There is no standard report available as per my knowledge.You may develop Z report to achive your requirment. Check some LIS report can give data (MC01 is transaction where you can check all type of key figure reports)
    Regards
    Mani Kumar

  • How set authorizations for sales reports and other reports in SAPB1

    Hi, I'm currently working in SAP Business One Version 8.82
    The issue I'm facing is that I want to set it up so that certain users cannot see other users' sales information.  I know that I can turn on or off the Sales Analysis Report for various users for instance, but what I really want specifically is this.  Suppose we have 3 different teams: Team A consists of (Angie, Angela, and Anita the manager), Team B consists of (Bob, Barbara, and Ben the manager), Team C consists of (Cat, Charlie, and Courtney the manager).  I would like to make it so that everyone can view the individual sales order documents of everyone else (in case a customer calls and needs information, but the salesperson who created that document isn't there); however, Angie should only see her own orders when she does a Sales Analysis while Anita, the manager of Team A, should see the the orders of Angie, Angela, and herself of course.
    To summarize, I'd like to see the following
    1.  Each salesperson can lookup and view any sales order.
    2.  Each salesperson can run an sales report to view all his/her own open sales orders.
    3.  Each manager can run a sales report on his/her subordinates, but not on the other managers or their subordinates.
    4.  The boss or other people working in corporate are able to run a report on all open sales orders.
    What's the best way to approach this?  Is it best if I create my own report?  I haven't created any reports from scratch yet, so I'm not sure exactly how that works.  I'd like to be able to group the salespeople up by location if possible.  The sales analysis report doesn't really do that, but it is useful.  I just don't want everyone to be able to see the numbers on their peers.
    Thank you I appreciate any help or advice.

    Hi,
    1.  Each salesperson can lookup and view any sales order.
    Answer:
    Create own report by using query and save under query manager and the assign for all group. So that all sales person can run this query  and can get sales order detail.
    2.  Each salesperson can run an sales report to view all his/her own open sales orders.
    Answer:
    Create individual query ( add condition in where clause slpname = 'XXX') for each sales person and save it under query manager and assign to particular user group
    3.  Each manager can run a sales report on his/her subordinates, but not on the other managers or their subordinates.
    Answer:
    Create query for only particular team (  condition is slpname = XXX OR YYY OR ZZZ) and save under query manager. Make schedule report on this and send it to only particular manger
    Same way create for another manager and schedule report.
    4.  The boss or other people working in corporate are able to run a report on all open sales orders
    Answer.
    Create query for all sales person and schedule report to big boss.
    Hope you can get an idea.
    Let me know if you need sales report ( advice required field)
    Thanks & Regards,
    Nagarajan

  • SALES REPORT (Credit memos Subtracted)

    Hi all,
    I would like to come up with a detailed Sales Reports that shows the Quantity and Value of items sold per day (AR Invoices) excluding the credit memos. I later want to use the same query in crystal reports. I came up with the below query; the select statements are executing individually but using 'UNION ALL' I am getting a 'Conversion' error.
    SELECT T0.[CardCode]Code, T4.[SuppCatNum]cat, T4.[FrgnName]frn, T1.[Quantity]InvQ, T0.[DocTotal]InvT,0 MemoQ,0 MemoT FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry full outer JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode full outer JOIN OUSR T3 ON T0.UserSign = T3.USERID full outer JOIN OITM T4 ON T1.ItemCode = T4.ItemCode WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01')  AND T0.DocDate=[%0]
    union all 
    SELECT  0 Code, 0 cat, 0 frn, 0 InvQ,0 InvT, T1.[Quantity] MemoQ, T0.[DocTotal] MemoT FROM ORIN T0  INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry full outer JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode full outer JOIN OUSR T3 ON T0.UserSign = T3.USERID full outer JOIN OITM T4 ON T1.ItemCode = T4.ItemCode WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01') AND T0.DocDate=[%0]
    kindly assist refine this query or come up with a better one altogether. Thank you.

    Hi,
    Try:
    SELECT T0.CardCode Code, T4.SuppCatNum cat, T4.FrgnName frn, T1.Quantity InvQ, T1.LineTotal InvT,0 MemoQ,0 MemoT
    FROM OINV T0
    INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    LEFT JOIN OITM T4 ON T1.ItemCode = T4.ItemCode
    WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01') AND T0.DocDate=[%0\]
    union all 
    SELECT  '', '', '', 0,0, T1.Quantity, T1.lineTotal
    FROM ORIN T0
    INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
    LEFT JOIN OITM T4 ON T1.ItemCode = T4.ItemCode
    WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01') AND T0.DocDate=[%0\]
    Thanks,
    Gordon

  • XML Publisher Enterprise 5.6.2 - World Sales report (DEMO)

    Hello All;
    Does anybody have problem displaying "World Sales" report as HTML output under Sales Manager folder?
    The demo is provided when downloading and installing XMLP server.
    "World Sales" report uses an XML feed from a URL which I configure per the instruction in the document. I could get the report output in PDF with images but NOT in HTML or RTF as output.
    Any solution or idea how to resolve it?
    Thank you.
    Shaun

    Shaun,
    How did get World Sales report work? What did you put on URL? I put:
    http://Sever name:15101/xmlpserver/Sales Manager/World Sales/WorldSales.xml
    It always showed error message to me.
    Please help, Thanks.
    - Jessie

  • Error in Sales-A/R-Sales Report-Sales Analysis

    Dear All,
    After upgrading Sap 2007B ( PL:10 ) to sap 8.8 ( PL:05), we are facing some problems like when we generate Sales Analysis report Under....Sales-A/R------Sales Report.....Sales Analysis.....select Quaterly Report. In item Description it gives the numeric values instead of item names.
    So plz help us on this matter......................

    Dear Dinesh,
    There seems to be some data corruption/inconsitency in your database.
    Please Log your call to the SAP Support team.
    Thanks
    Asif

  • Intrastat / EC sales reporting for Italy

    Hi all. We have implemented a new company code for italy. Business is now requiring several country specific reporting, namely the intrastat and EC sales reporting. I tried going through some documentation but there are several reports available for intrastat, so i am not getting the whole picture or which report(s) i should be using. Does anyone know the sap note which describes the full intrastat reports or have any similar documentation?
    thanks in advance for your help.

    Hello Simon,
    The below documents might be helpful to you,
    http://www.scmexpertonline.com/downloads/Kees%20Intrastat%20download%201-23-07.doc
    http://www.appliconsolutions.com/fileadmin/filer_solutions/pdf/White_paper/White_Paper_APM__v._2.9.pdf
    http://mbs.microsoft.com/downloads/public/GP10Docs/EnhancedIntrastat.pdf
    This is the last one for oracle,
    http://download.oracle.com/docs/cd/A60725_05/pdf/gemmsin.pdf
    br,
    Pushkar

  • Unable to generate Sales Report of Business Partner  by State-XL Reporter

    We are not able to generate Sales Report of Business Partner  by State using XL Reporter.
    The issue is that we can not access the Bill to State for BPs, or for that matter the Ship-to State.  We can access Bill T street, block, city, country u2013 everything except state.
    There is a CRD State, but for sales reports this is useless.  Can someone advise on this?
    Thanks in advance,
    Srini

    You can get around this by creating a UDF and formatted search to populate it.
    The XL Report can then be created, but, watch out on upgrade - XL Reports with UDF's are not easy on upgrade, especially where the UDF will be a run parameter. I often have to re-write after upgrade, so store a base one without the parameter setting

  • Calculation of Quaterly Figures for Sales Report.

    Hi,
    I would like to display the Sales report in the Quarterly format with respect to  sales employees.
    For Ex :-
    1)Q1-20 Lacs  (April,May June 07)
    2)Q2-30 Lacs   (July Aug ,Sept 07)
    3)Q3-25 Lacs   (Oct,Nov and Dec 07)
    4)Q4-20 Lacs   (Jan.Feb,Mar 08)-Also i would like to view the current month say Jan 08 i.e till date sales.
    It should display Monthly sales and Quartely sales with the Quartely totals.
    Please advise me as to how to proceed with the Formaulae,Restriction in BEX Query.
    Let me knw if u require any further info.
    Thank in Advance
    wth rgds
    SVU
    Edited by: svu123 on Jan 8, 2008 3:47 PM

    Hi Kenneth
    1) you can use statistical FC means with input data your histoy and you outputr your proportional factor if you want e.g. to have an average of the last 13 or 24 months, with use of moving average simply, if you want to have a constant value
    2) you can use a calculated KF that copies from history to proportional factor by shifting by one year, using PERIODID shift. THere are example in the SAP model for a year-1 lag calculation
    3) You can do as in 2, but in addition make use of any additional formula according to your needs
    4) you can NOT have a dynamic calculation, because prerequisite for disaggregation is that you keyfigure used in the fisaggregation
    - is stored and not calculated
    - has the same base planning level than the KF itself
    Yours
    Irmi

Maybe you are looking for

  • Error in webdynpro(ABAP) application development

    Hi,        I am very new in webdynpro (ABAP) application development. I want to create some application based on webdynpro ABAP for few Z- Report. What is the prerequisite to develop a application based  on webdynpro( ABAP ) .Because when I am trying

  • Web service to BW....Urgent!

    Hello experts I am trying to connect JDBC to SAP BW. I am getting a connection error. I checked in "Maintain services" using t-code SICF. default_host --> sap --> bw --> xml --> soap --> xmla. I checked all of the above components are active but stil

  • MYSAPSSO2 issue ...

    Hello all, Maybe you've a good idea ... We're using an ITS 6.20 with PAS module for SSO; in parallel we have an ABAP webdynpro application which uses SSO via a JAVA Engine ( SPNego with Ticket ); when calling the ITS application, we get an MYSAPSSO2

  • Deploying BC4J to Orion 2.0.2

    Is there any how to documents or is it actually possible to deploy business components to Orion Server 2.0.2 (not OC4J), I have a test bc4j and appliction which works fine with the embedded OC4J. When I run it through Orion the application doesn't re

  • Case not coming in group by clause

    Hi I have created the following query: select sum(receipt) , sum(LINE_NO) , case when sum(receipt) = sum(LINE_NO) then 'F' else 'G' end from test_function; It is working fine but i have a doubt as the case is returning some character value then why i