Вы находитесь на странице: 1из 16

Hi, You can get the sales order data from tables VBAK (sales order header), VBAP

(sales order item) VBEP (sales order schedule lines). You must have to give ERDAT in the selection screen as select option so that you can restrict sales order based on a particular duration. Others depending on the requirement. Sample report: For alv you would need to pass the data (internal table to the function module or method). REUSE_ALV_FIELDCATALOG_MERGE .... For field catalog REUSE_ALV_GRID_DISPLAY Output of a simple list (single-line)

Method SET_TABLE_FOR_FIRST_DISPLAY ..... of Class CL_GUI_ALV_GRID In Second level this report will interact with user where they can select date to see the full Details of Sales Order Selection - Sales Organisation - Date - Customer this will be usefull when Selecting the Checkbox Standard Variants - Output - Sales Order Example Date SalesOrderNo Material Amount Currency 10.01.2007 8530 732 1000 INR &---*& Report ZCHE_SALES_ORDER *&---Done by V.Chellavelu on 11.01.2007 * REPORT zche_sales_order .

***************************Declarations******************************* TABLES: vbkd,vepvg.",vbak,vbap,vbpa,vakpa, vapma. DATA: BEGIN OF sal OCCURS 0, ch TYPE checkbox, vbeln LIKE vbak-vbeln, " sales document netwr LIKE vbak-netwr, "Net Value of the SalesOrder matnr LIKE vbap-matnr, "material no. waerk LIKE vbak-waerk, "curr. dat LIKE vbak-erdat, "date. END OF sal.

DATA: newsal LIKE sal OCCURS 0 WITH HEADER LINE. DATA: amount LIKE vbak-netwr, date2(15),date3(8),date4(1), date5(2),date6(2). DATA: lin LIKE sy-curow VALUE 1,"Screens, vertical cursor position at "PAI available in SYST struc. checkbox TYPE c dat LIKE vbak-erdat. ,

******************SelectionScreenDesign*************************** SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001. PARAMETERS: vkorg LIKE vepvg-vkorg, vtweg LIKE vepvg-vtweg, spart LIKE vepvg-spart. SELECT-OPTIONS date FOR vbkd-bstdk DEFAULT sy-datum TO sy-datum OBLIGATORY. SELECTION-SCREEN END OF BLOCK blk1. SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 10. PARAMETERS: chk1 AS CHECKBOX. SELECTION-SCREEN POSITION 20. PARAMETERS: kunnr1 LIKE vbpa-kunnr. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK blk2. *******************FirstLevelOperation**************************** IF chk1 <> 'X'. IF vkorg <> ''. PERFORM organisation. ELSE. PERFORM organisation_else. ENDIF. ELSE. IF vkorg <> ''. PERFORM cus_orga. ELSE. PERFORM cus_orga_else. ENDIF. ENDIF.

Displaying the contents which is selected from table by -selection conditions SORT sal BY dat. LOOP AT sal. ON CHANGE OF sal-dat.

FORMAT HOTSPOT ON. IF sy-tabix = 1. WRITE: sy-vline, sal-ch AS CHECKBOX,sal-dat . CLEAR amount. ELSE. WRITE:sy-vline, amount,/ sy-vline, sal-ch AS CHECKBOX,sal-dat. CLEAR amount. ENDIF. ENDON. amount = amount + sal-netwr. AT LAST. WRITE:sy-vline, amount. ULINE.

SUM. FORMAT HOTSPOT OFF. FORMAT COLOR = 3. WRITE:/ ' Total Amount:', sal-netwr UNDER amount. ENDAT. ENDLOOP. *********************Interaction with report************************* SET PF-STATUS 'BANU'. " To create Application ToolBar for Display Button

To verify Double click on BANU AT USER-COMMAND. " This will execute after pressing Display Button CASE sy-ucomm. WHEN 'DISP'. free newsal. DO. READ LINE lin FIELD VALUE sal-ch INTO checkbox. IF sy-subrc NE 0. EXIT. ENDIF. IF checkbox = 'X'. PERFORM datecon. PERFORM process. ENDIF. lin = lin + 1. ENDDO. PERFORM selection. ENDCASE.

SUB ROUTINE Area ****************************** *This Process SubRoutine will assign the values from current -InternalTable (sal) into other IT(newsal), by date which is - selected by CheckBox FORM process. LOOP AT sal WHERE dat = dat. newsal-ch = 'X'. newsal-vbeln = sal-vbeln.

newsal-netwr = sal-netwr. newsal-matnr = sal-matnr. newsal-waerk = sal-waerk. newsal-dat = sal-dat. APPEND newsal. ENDLOOP. ENDFORM. &---This will display the values for selected dates from new --internal Table (newsal)-*& &------FORM selection. ULINE. FORMAT COLOR = 1. WRITE:sy-vline,'Date',AT 14 sy-vline, 'Order NO', AT 27 sy-vline, 'Order Material', AT 48 sy-vline,'Order Value(AMT) Currency '. FORMAT COLOR OFF. ULINE. LOOP AT newsal. ON CHANGE OF newsal-dat. IF sy-tabix <> 1. WRITE:/ sy-vline, AT 14 sy-vline,AT 27 sy-vline,AT 48 sy-vline. WRITE:/ sy-vline,newsal-dat,sy-vline,AT 27 sy-vline,AT 48 sy-vline. ELSE. WRITE: sy-vline,newsal-dat,sy-vline,AT 27 sy-vline,AT 48 sy-vline. ENDIF. ENDON. WRITE:/ sy-vline, AT 14 sy-vline,newsal-vbeln,sy-vline, newsal-matnr, sy-vline, newsal-netwr, newsal-waerk. AT LAST. SUM. ULINE. FORMAT COLOR = 3. WRITE:/ sy-vline, AT 15 'Total Amount for selected month:', newsal-netwr UNDER newsal-netwr. FORMAT COLOR OFF. ULINE. ENDAT. ENDLOOP. lin = 1. FREE newsal. ENDFORM. "SELECTION Form SELECTION "process

This Date convertion is must for pick the particular Date from the -displayed line, and here we are reversing the Date like YYYY/MM/DD -because to Check or assign the date we need to give in reverse order &---*& Form DATECON &----

----

text

FORM datecon. date2 = sy-lisel(17). SHIFT date2 LEFT BY 4 PLACES. WHILE date2 <> ''. SHIFT date2 RIGHT. date4 = date2+11. IF date4 <> '.'. CONCATENATE date4 date3 INTO date3. ENDIF. ENDWHILE. date5 = date3(2). date6 = date3+2. date3 = date3+4. CONCATENATE date3 date6 date5 INTO date3.

dat = date3. SORT dat BY dat. DELETE ADJACENT DUPLICATES FROM dat COMPARING dat. ENDFORM. "DATECON

Here we are doing different kinds of selections by the EndUser's needs &-When user selectiong an Sales Organisation-*& Form ORGANISATION &----

----

text

FORM organisation. SELECT fvbeln pmatnr cnetwr cwaerk p~audat INTO (sal-vbeln, sal-matnr, sal-netwr,sal-waerk, sal-dat) FROM ( vakpa AS f INNER JOIN

vbak AS c ON fvbeln = cvbeln ) INNER JOIN vapma AS p ON fvbeln = pvbeln WHERE paudat IN date AND pvkorg = vkorg. APPEND sal. ENDSELECT. ENDFORM. "ORGANISATION

&-Without Sales Organisation i.e All Organisation-*& Form ORGANISATION_ELSE &----

----

text

FORM organisation_else. SELECT fvbeln pmatnr cnetwr cwaerk p~audat INTO (sal-vbeln, sal-matnr, sal-netwr,sal-waerk, sal-dat) FROM ( vakpa AS f INNER JOIN vbak AS c ON fvbeln = cvbeln ) INNER JOIN vapma AS p ON fvbeln = pvbeln WHERE p~audat IN date. APPEND sal. ENDSELECT. ENDFORM. &-When Selecting Customer by choosing CheckBox-*& &---Form CUS_ORGA "ORGANISATION_ELSE

----

text

FORM cus_orga. SELECT fvbeln pmatnr cnetwr cwaerk p~audat INTO (sal-vbeln, sal-matnr, sal-netwr,sal-waerk, sal-dat) FROM ( vakpa AS f INNER JOIN vbak AS c ON fvbeln = cvbeln ) INNER JOIN vapma AS p ON fvbeln = pvbeln WHERE paudat IN date AND pvkorg = vkorg AND p~kunnr = kunnr1. APPEND sal. ENDSELECT. ENDFORM. &-Without Customer by without choosing CheckBox-"CUS_ORGA

*& Form CUS_ORGA_ELSE &----

----

text

FORM cus_orga_else. SELECT fvbeln pmatnr cnetwr cwaerk p~audat INTO (sal-vbeln, sal-matnr, sal-netwr,sal-waerk, sal-dat) FROM ( vakpa AS f INNER JOIN vbak AS c ON fvbeln = cvbeln ) INNER JOIN vapma AS p ON fvbeln = pvbeln WHERE paudat IN date AND pkunnr = kunnr1. APPEND sal. ENDSELECT. Sample ALV report from one of the other threads: tables: mara. type-pools: slis. data:begin of it_mara occurs 0, matnr like mara-matnr, matkl like mara-matkl, brgew like mara-brgew, end of it_mara. data:begin of it_final occurs 0, matnr like mara-matnr, matkl like mara-matkl, brgew like mara-brgew, end of it_final. data:it_fieldcat type slis_t_fieldcat_alv, wa_fieldcat like line of it_fieldcat, wa_layout type slis_layout_alv. selection-screen begin of block a1 with frame title text-001. select-options: matkl for mara-matkl. selection-screen end of block a1. start-of-selection. perform get_data. perform write_alv. &---*& Form get_data

&----

form get_data . select matnr matkl brgew into table it_mara from mara endform. &---*& Form write_alv &---where matkl in matkl. " get_data

form write_alv . perform populate_fieldcat. perform call_alv. endform. &---*& &---Form populate_fieldcat " write_alv

form populate_fieldcat . wa_fieldcat-fieldname = 'MATNR'. wa_fieldcat-seltext_l = 'Material number'. wa_fieldcat-no_zero = 'X'. append wa_fieldcat to it_fieldcat. wa_fieldcat-fieldname = 'MATKL'. wa_fieldcat-seltext_l = 'Material group'. append wa_fieldcat to it_fieldcat. wa_fieldcat-fieldname = 'BRGEW'. wa_fieldcat-seltext_l = 'Gross weight'. wa_fieldcat-do_sum = 'X'. append wa_fieldcat to it_fieldcat.

wa_layout-colwidth_optimize = 'X'. "column width

endform. *

" populate_fieldcat

&---*& &---Form call_alv

form call_alv . if it_mara[] is initial. message i000 with 'No data found'. else. call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = sy-repid is_layout it_fieldcat tables t_outtab endif. endform. " call_alv = wa_layout = it_fieldcat = it_mara.

Feilds in VBAK: VBELN Sales Document ERDAT ERZET ERNAM ANGDT BNDDT AUDAT VBTYP TRVOG AUART AUGRU Date on which the record was created Entry time Name of Person who Created the Object Quotation/Inquiry is valid from Date until which bid/quotation is binding (valid-to date) Document Date (Date Received/Sent) SD document category Transaction group Sales Document Type Order reason (reason for the business transaction)

GWLDT Guarantee date SUBMI Collective number (SD) LIFSK Delivery block (document header) FAKSK Billing block in SD document NETWR WAERK VKORG VTWEG SPART VKGRP VKBUR GSBER GSKST GUEBG GUEEN KNUMV VDATU Net Value of the Sales Order in Document Currency SD document currency Sales Organization Distribution Channel Division Sales Group Sales Office Business Area Business area from cost center Valid-from date (outline agreements, product proposals) Valid-to date (outline agreements, product proposals) Number of the document condition Requested delivery date

VPRGR AUTLF VBKLA VBKLT KALSM VSBED FKARA

Proposed date type Complete delivery defined for each sales order? Original system with release and transaction control SD document indicator Sales and Distribution: Pricing Procedure in Pricing Shipping conditions Proposed billing type for an order-related billing document

AWAHR Sales probability KTEXT Search term for product proposal BSTNK BSARK BSTDK BSTZD Customer purchase order number Customer purchase order type Customer purchase order date Purchase order number supplement

IHREZ Customer's or vendor's internal reference BNAME Name of orderer TELF1 Telephone number MAHZA Number of contacts from the customer MAHDT KUNNR KOSTL STAFO STWAE AEDAT KVGR1 KVGR2 KVGR3 KVGR4 KVGR5 KNUMA Last customer contact date Sold-to party Cost Center Update group for statistics update Statistics currency Date of Last Change Customer group 1 Customer group 2 Customer group 3 Customer group 4 Customer group 5 Agreement (various conditions grouped together)

KOKRS Controlling Area PS_PSP_PNR Work Breakdown Structure Element (WBS Element) KURST KKBER Exchange Rate Type Credit control area

KNKLI Customer's account number with credit limit reference GRUPP Customer Credit Group SBGRP CTLPC CMWAE CMFRE CMNUP CMNGV Credit representative group for credit management Credit management: Risk category Currency key of credit control area Release date of the document determined by credit management Date of next credit check of document Next date

AMTBL Released credit value of the document HITYP_PR Hierarchy type for pricing ABRVW Usage indicator ABDIS MRP for delivery schedule types VGBEL OBJNR Document number of the reference document Object number at header level

BUKRS_VF Company code to be billed TAXK1 Alternative tax classification TAXK2 TAXK3 Tax classification 2 for customer Tax classification 3 for customer

TAXK4 TAXK5 TAXK6 TAXK7 TAXK8 TAXK9 XBLNR ZUONR VGTYP

Tax classification 4 for customer Tax classification 5 for customer Tax classification 6 for customer Tax classification 7 for customer Tax classification 8 for customer Tax classification 9 for customer Reference Document Number Assignment number Document category of preceding SD document

KALSM_CH Search procedure for batch determination AGRZR Accrual period for order-related billing docs.to be accrued AUFNR Order Number QMNUM Notification Number VBELN_GRP Mster contract number SCHEME_GRP Referencing requirement: Procedure ABRUF_PART Check partner authorizations ABHOD Pick up date ABHOV ABHOB Pick up time Pick up time

RPLNR Number of payment card plan type VZEIT Proposed schedule line time (local with ref. to sales org.) STCEG_L Tax destination country LANDTX Tax departure country XEGDR Indicator: Triangular deal within the EU ? ENQUEUE_GRP Block master contr. until all lower level contracts updated DAT_FZAU Cml delivery order qty date FMBDAT Material availability date VSNMR_V Sales document version number HANDLE International unique key for VBAK-VBELN PROLI Dangerous Goods Management Profile in SD Documents CONT_DG Indicator: Document contains dangerous goods CRM_GUID Character field, length 70

Fields in VBAP: VBELN Sales Document POSNR MATNR MATWA PMATN CHARG MATKL ARKTX PSTYV POSAR LFREL FKREL UEPOS GRPOS ABGRU PRODH ZWERT Sales Document Item Material Number Material entered Pricing reference material Batch Number Material group Short text for sales order item Sales document item category Item type Item is relevant for delivery Relevant for Billing Higher-level item in bill of material structures Item for which this item is an alternative Reason for rejection of quotations and sales orders Product hierarchy Target value for outline agreement in document currency

ZMENG ZIEME UMZIZ UMZIN MEINS

Target quantity in sales units Target quantity UoM Factor for converting sales units to base units (target qty) Factor for converting sales units to base units (target qty) Base Unit of Measure

SMENG Scale quantity in base unit of measure ABLFZ Rounding quantity for delivery ABDAT ABSFZ POSEX KDMAT KBVER KEVER VKGRU VKAUS GRKOR FMENG UEBTK UEBTO UNTTO FAKSP ATPKZ RKFKF SPART GSBER NETWR WAERK ANTLF KZTLF Reconciliation date for agreed cumulative quantity Allowed deviation in quantity (absolute) Item Number of the Underlying Purchase Order Material Number Used by Customer Allowed deviation in quantity (in percent) Days by which the quantity can be shifted Repair Processing: Classification of Items Usage indicator Delivery group (items are delivered together) Quantity is fixed Unlimited overdelivery allowed Overdelivery tolerance limit Underdelivery tolerance limit Billing block for item Replacement part Method of billing for CO/PPC orders Division Business Area Net value of the order item in document currency SD document currency Maximum Number of Partial Deliveries Allowed Per Item Partial delivery at item level

CHSPL Batch split allowed KWMENG Cumulative order quantity in sales units LSMENG KBMENG Cumulative required delivery qty (all dlv-relev.sched.lines) Cumulative confirmed quantity in sales unit

KLMENG Cumulative confirmed quantity in base unit VRKME Sales unit UMVKZ UMVKN BRGEW NTGEW GEWEI VOLUM VOLEH VBELV POSNV VGBEL VGPOS VOREF UPFLU ERLRE Numerator (factor) for conversion of sales quantity into SKU Denominator (divisor) for conversion of sales qty. into SKU Gross Weight of the Item Net Weight of the Item Weight Unit Volume of the item Volume unit Originating document Originating item Document number of the reference document Item number of the reference item Complete reference indicator Update indicator for sales document document flow Completion rule for quotation / contract

LPRIO Delivery Priority WERKS Plant (Own or External)

LGORT VSTEL ROUTE STKEY STDAT STLNR STPOS AWAHR ERDAT ERNAM ERZET TAXM1 TAXM2 TAXM3 TAXM4 TAXM5 TAXM6 TAXM7 TAXM8 TAXM9 VBEAF VBEAV VGREF NETPR KPEIN KMEIN SHKZG SKTOF MTVFP SUMBD KONDM KTGRM BONUS PROVG EANNR PRSOK BWTAR BWTEX XCHPF XCHAR LFMNG

Storage location Shipping Point/Receiving Point Route Origin of the bill of material Key date of the bill of material Bill of material Bill of material item number VBAP not used Order probability of the item Date on which the record was created Name of Person who Created the Object Entry time Tax classification material Tax classification material Tax classification material Tax classification material Tax classification material Tax classification material Tax classification material Tax classification material Tax classification material Fixed shipping processing time in days (= setup time) Variable shipping processing time in days Preceding document has resulted from reference Net price Condition pricing unit Condition unit Returns item Cash discount indicator Checking Group for Availability Check Summing up of requirements Material Pricing Group Account assignment group for this material Volume rebate group Commission group European Article Number (EAN) - obsolete!!!!! Pricing is OK Valuation type Indicator: Separate valuation Batch management requirement indicator Batch management indicator (internal) Minimum delivery quantity in delivery note processing

STAFO Update group for statistics update WAVWR Cost in document currency KZWI1 KZWI2 KZWI3 KZWI4 KZWI5 KZWI6 STCUR AEDAT Subtotal 1 from pricing procedure for condition Subtotal 2 from pricing procedure for condition Subtotal 3 from pricing procedure for condition Subtotal 4 from pricing procedure for condition Subtotal 5 from pricing procedure for condition Subtotal 6 from pricing procedure for condition Exchange rate for statistics (Exch.rate at time of creation) Date of Last Change

EAN11 FIXMG PRCTR MVGR1 MVGR2 MVGR3 MVGR4 MVGR5 KMPMG SUGRD SOBKZ

International Article Number (EAN/UPC) Delivery date and quantity fixed Profit Center Material group 1 Material group 2 Material group 3 Material group 4 Material group 5 Component quantity Reason for material substitution Special Stock Indicator

VPZUO Allocation Indicator PAOBJNR Profitability Segment Number (CO-PA) PS_PSP_PNR Work Breakdown Structure Element (WBS Element) AUFNR Order Number VPMAT VPWRK PRBME UMREF KNTTP KZVBR SERNR OBJNR ABGRS BEDAE CMPRE CMTFG CMPNT CMKUA Planning material Planning plant Base unit of measure for product group Conversion factor: quantities Account assignment category Consumption posting BOM explosion number Object number at item level Results Analysis Key Requirements type Item credit price ID for partial release of order item, credit block ID: Item with active credit function / relevant for credit Credit data exchange rate for requested delivery date

CUOBJ Configuration CUOBJ_CH Internal object number of the batch classification CEPOK KOUPD SERAIL ANZSN NACHL MAGRV MPROK VGTYP PROSA UEPVW KALNR KLVAR SPOSN KOWRR Status expected price Condition update Serial Number Profile Number of serial numbers Customer has not posted goods receipt Material Group: Packaging Materials Status manual price change Document category of preceding SD document ID for material determination ID for higher-level item usage Cost Estimate Number for Cost Est. w/o Qty Structure Costing Variant BOM Item Number Statistical values

STADAT Statistics date EXART Business Transaction Type for Foreign Trade PREFE KNUMH Preference indicator in export/import Number of condition record from batch determination

CLINT Internal Class Number CHMVS Batches: Exit to quantity proposal

STLTY STLKN STPOZ

BOM category BOM item node number Internal counter

STMAN Inconsistent configuration ZSCHL_K Overhead key KALSM_K Costing Sheet KALVAR Costing Variant KOSCH UPMAT UKONM MFRGR PLAVO KANNR Product allocation determination procedure Pricing reference material of main item Material pricing group of main item Material freight group Planning delivery schedule instruction KANBAN/sequence number

CMPRE_FLT Item credit price ABFOR Form of payment guarantee ABGES Guaranteed (factor between 0 and 1) J_1BCFOP CFOP Code and Extension J_1BTAXLW1 J_1BTAXLW2 Tax law: ICMS Tax law: IPI

J_1BTXSDC SD tax code WKTNR Value contract no. WKTPS SKOPF KZBWS WGRU1 Value contract item Assortment module Valuation of Special Stock Material group hierarchy 1

WGRU2 Material group hierarchy 2 KNUMA_PI Promotion KNUMA_AG Sales deal KZFME ID: Leading unit of measure for completing a transaction LSTANR Free goods delivery control TECHS Parameter Variant/Standard Variant MWSBP Tax amount in document currency BERID MRP area PCTRF Profit Center for Billing LOGSYS_EXT Logical system J_1BTAXLW3 ISS Tax Law

Fields in VBEP: VBELN Sales Document POSNR ETENR ETTYP LFREL Sales Document Item Schedule line Schedule line category Item is relevant for delivery

EDATU Schedule line date EZEIT Arrival time WMENG BMENG VRKME LMENG MEINS BDDAT Order quantity in sales units Confirmed quantity Sales unit Required quantity for mat.management in stockkeeping units Base Unit of Measure Requirement date (deadline for procurement)

BDART PLART VBELE POSNE ETENE RSDAT IDNNR BANFN BSART

Requirement type Planning type Business document number Business item number Schedule line Earliest possible reservation date Maintenance request Purchase requisition number Order type (Purchasing)

BSTYP Purchasing document category WEPOS Confirmation status of schedule line (incl.ALE) REPOS LRGDT PRGRS TDDAT MBDAT LDDAT WADAT CMENG Invoice receipt indicator Return date for returnable packaging Date type (day, week, month, interval) Transportation Planning Date Material availability date Loading Date Goods issue date Corrected quantity in sales unit

LIFSP Schedule line blocked for delivery GRSTR Group definition of structure data ABART ABRUF ROMS1 ROMS2 ROMS3 ROMEI RFORM UMVKZ UMVKN VERFP BWART BNFPO ETART AUFNR PLNUM SERNR AESKD ABGES MBUHR TDUHR LDUHR WAUHR AULWE Release type Forecast Delivery schedule number Committed quantity Size 2 Size 3 Unit of measure for sizes 1 to 3 Formula key Numerator (factor) for conversion of sales quantity into SKU Denominator (divisor) for conversion of sales qty. into SKU Availability confirmed automatically Movement Type (Inventory Management) Item number of purchase requisition Schedule line type EDI Order Number Planned order number BOM explosion number Customer Engineering Change Status Guaranteed (factor between 0 and 1) Material staging time (local time with reference to a plant) Transportation planning -time (local w/ref. to shipping pnt) Loading time (local time with reference to a shipping point) Time of goods issue (local time, with reference to a plant) Route schedule

Hope this will help. Regards,

Вам также может понравиться