Академический Документы
Профессиональный Документы
Культура Документы
Added by Sreesudha Gullapalli, last edited by Sreesudha Gullapalli on Mar 26, 2009 (view change)
This report will take delivery document number and delivery date from user and fetches details from delivery table
and fetches
corresponding sales order details and billing details and displays sales order details with ALV list.
Report sales_order_report .
*"Table declarations..............................................................
TABLES: likp. " SD Document: Delivery Header Data
*"Selection Screen Elements.....................................................
SELECT-OPTIONS:
s_deldoc FOR likp-vbeln, " Delivery
s_dldate FOR likp-lfdat. " Delivery Date
*"--------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified delivery header data *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_likp,
vbeln TYPE likp-vbeln, " Delivery
lfdat TYPE likp-lfdat, " Delivery Date
kunnr TYPE likp-kunnr, " Ship-to party
END OF type_s_likp.
*"---------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified delivery item data
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_lips,
vbeln TYPE lips-vbeln, " Delivery
posnr TYPE lips-posnr, " Delivery Item
vgbel TYPE lips-vgbel, " Document number of the reference document
vgpos TYPE lips-vgpos, " Item number of the reference item
lfimg TYPE lips-lfimg, " Actual quantity delivered (insales units)
vrkme TYPE lips-vrkme, " Sales unit
END OF type_s_lips.
*"--------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified data in Customer Master *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_kna1,
kunnr TYPE kna1-kunnr, " Customer Number 1
name1 TYPE kna1-name1, " Name 1
END OF type_s_kna1.
*" Type declarations..........................................................................
*"------------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales document header data *
*"------------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_vbak,
vbeln TYPE vbak-vbeln, " Sales Document
erdat TYPE vbak-erdat, " Date on Which Record Was Created
aufnr TYPE vbak-aufnr, " Order Number
END OF type_s_vbak.
*"----------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales document item data *
*"---------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_vbap,
vbeln TYPE vbak-vbeln, " Sales Document
posnr TYPE vbap-posnr, " Sales Document Item
matnr TYPE vbap-matnr, " Material Number
arktx TYPE vbap-arktx, " Short text for sales orderitem
kwmeng TYPE vbap-kwmeng, " Cumulative Order Quantity in sales Units
vrkme TYPE vbap-vrkme, " Sales unit
END OF type_s_vbap.
*"--------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified billing item data
*"--------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_vbrp,
vbeln TYPE vbrp-vbeln, " Billing Document
posnr TYPE vbrp-posnr, " Billing item
vgbel TYPE vbrp-vgbel, " Document number of the reference document
vgpos TYPE vbrp-vgpos, " Item number of the reference item
fklmg TYPE vbrp-fklmg, " Billing quantity in stockkeeping unit
vrkme TYPE vbrp-vrkme, " Sales unit
END OF type_s_vbrp.
*"-------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales socument
*"-------------------------------------------------------------------------------------------*
TYPES:
BEGIN OF type_s_order,
vbeln TYPE vbap-vbeln, " Sales Document
posnr TYPE vbap-posnr, " Sales Document Item
erdat TYPE vbak-erdat, " Date on Which Record Was Created
kunnr TYPE likp-kunnr, " Sold-to party
name1 TYPE kna1-name1, " Name 1
aufnr TYPE vbak-aufnr, " Order Number
matnr TYPE vbap-matnr, " Material Number
arktx TYPE vbap-arktx, " Short text for sales orderitem
kwmeng TYPE vbap-kwmeng, " Cumulative Order Quantity in sales Units
vrkme TYPE vbap-vrkme, " Sales unit
vbeln1 TYPE lips-vbeln, " Delivery
posnr1 TYPE lips-posnr, " Delivery Item
lfimg TYPE lips-lfimg, " Actual quantity delivered in sales units
vrkme1 TYPE lips-vrkme, " Sales unit
vbeln2 TYPE vbrp-vbeln, " Billing Document
posnr2 TYPE vbrp-posnr, " Billing item
fklmg TYPE vbrp-fklmg, " Billing quantity in stockkeeping unit
vrkme2 TYPE vbrp-vrkme, " Sales unit
END OF type_s_order.
*"-------------------------------------------------------------------------------------------*
DATA :
w_container TYPE REF TO cl_gui_custom_container," Reference variable for
"container
w_grid TYPE REF TO cl_gui_alv_grid. " Reference variable for grid
*" Field String declarations..............................................................
*"------------------------------------------------------------------------------------------*
* Field string variable to hold sales socument header,sales document
* item data,delivery item data,billing item data,fieldcatalog,layout record
*
*
*"----------------------------------------------------------------------------------------*
DATA :
fs_kna1 TYPE type_s_kna1, " Holds Customer master record
fs_vbak TYPE type_s_vbak, " Holds sales header record
fs_vbap TYPE type_s_vbap, " Holds sales item record
fs_likp TYPE type_s_likp, " Holds delivery header record
fs_lips TYPE type_s_lips, " Holds delivery item record
fs_vbrp TYPE type_s_vbrp, " Holds billing item record
fs_order TYPE type_s_order, " Holds sales order record
fs_cat TYPE lvc_s_fcat, " Holds fieldcatalog record
fs_lay TYPE lvc_s_layo. " Holds layout record
*" Internal Table declarations...........................................................
**"-----------------------------------------------------------------------------------------*
** Internal Table to hold hold sales socument header,sales document
**"-------------------------------------------------------------------------------------------*
DATA :
t_kna1 LIKE
STANDARD TABLE
OF fs_kna1, " Internal table to hold customer master records
t_vbak LIKE
STANDARD TABLE
OF fs_vbak, " Internal table to hold sales header records
t_vbap LIKE
STANDARD TABLE
OF fs_vbap, " Internal table to hold sales item records
t_likp LIKE
STANDARD TABLE
OF fs_likp, " Internal table to hold delivery header records
t_lips LIKE
STANDARD TABLE
OF fs_lips, " Internal table to hold delivery item records
t_vbrp LIKE
STANDARD TABLE
OF fs_vbrp, " Internal table to hold billing item records
t_order LIKE
STANDARD TABLE
OF fs_order, " Internal table to hold sales order records
t_cat TYPE lvc_t_fcat. " Internal table to hold field
" catalog records
*"------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENT *
*"------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN .
PERFORM check_for_initial.
*"--------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN ON S_DELDOC EVENT *
*"--------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN ON s_deldoc.
PERFORM check_delivery_document.
*"-------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN ON S_DLDATE EVENT *
*"------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN ON s_dldate.
PERFORM check_delivery_date.
*"------------------------------------------------------------------------------------------------*
* START-OF-SELECTION EVENT *
*"-------------------------------------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM data_selection.
*&--------------------------------------------------------------------------------------------------*
*& Form DATA_SELECTION
*&---------------------------------------------------------------------*
* This subroutine is used to select required fields from sales header,
* sales item,delivery header,delivery item ,customer master tables
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM data_selection .
* Get delivery document number,delivery date,customer number from
* delivery header table
SELECT vbeln " Delivery
lfdat " Delivery Date
kunnr " Customer Number 1
FROM likp
INTO TABLE t_likp
WHERE vbeln IN s_deldoc
AND lfdat IN s_dldate.
IF sy-subrc EQ 0.
* Get Customer name for customer numbers from Customer master table
SELECT kunnr " Customer Number 1
name1 " Name 1
FROM kna1
INTO TABLE t_kna1
FOR ALL ENTRIES IN t_likp
WHERE kunnr EQ t_likp-kunnr.
IF sy-subrc EQ 0.
* Get delivery item number,sales document number,sales item number,
* delivery quantity from delivery item table
SELECT vbeln " Delivery
posnr " Delivery Item
vgbel " Document number of
" reference document
* Get customer name for customer number from customer master internal
* table
IF sy-subrc EQ 0.
READ TABLE t_kna1 WITH KEY kunnr = fs_likp-kunnr
INTO fs_kna1.
* Get sales document number,item number,ordered quantity for delivery
* document number,item number from sales item internal table
IF sy-subrc EQ 0.
READ TABLE t_vbap WITH KEY vbeln = fs_lips-vgbel
posnr = fs_lips-vgpos INTO fs_vbap.
* Get goods issue date and purchase order number for sales document
* number from sales header internal table
IF sy-subrc EQ 0.
READ TABLE t_vbak WITH KEY vbeln = fs_vbap-vbeln INTO fs_vbak.
IF sy-subrc EQ 0.
* Get billing document number,billing item,billing quantity for delivery
* document number,delivery item number from billing item internal table
READ TABLE t_vbrp WITH KEY vgbel = fs_lips-vbeln
vgpos = fs_lips-posnr INTO
fs_vbrp.
* Assign sales,delivery,billing fields into respective fields of sales
* order internal table
IF sy-subrc EQ 0.
fs_order-vbeln = fs_vbap-vbeln.
fs_order-posnr = fs_vbap-posnr.
fs_order-erdat = fs_vbak-erdat.
fs_order-kunnr = fs_likp-kunnr.
fs_order-name1 = fs_kna1-name1.
fs_order-aufnr = fs_vbak-aufnr.
fs_order-matnr = fs_vbap-matnr.
fs_order-arktx = fs_vbap-arktx.
fs_order-kwmeng = fs_vbap-kwmeng.
fs_order-vrkme = fs_vbap-vrkme.
fs_order-vbeln1 = fs_lips-vbeln.
fs_order-posnr1 = fs_lips-posnr.
fs_order-lfimg = fs_lips-lfimg.
fs_order-vrkme1 = fs_lips-vrkme.
fs_order-vbeln2 = fs_vbrp-vbeln.
fs_order-posnr2 = fs_vbrp-posnr.
fs_order-fklmg = fs_vbrp-fklmg.
fs_order-vrkme2 = fs_vbrp-vrkme.
APPEND fs_order TO t_order.
CLEAR fs_order.
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
ENDLOOP. " LOOP AT T_LIPS INTO FS_LIPS
* Check if the final table is initia
lIF t_order IS INITIAL.
MESSAGE S000.
EXIT.
ELSE.
* Calling screen to display the sales order records
CALL SCREEN 1500.
ENDIF. " IF T_ORDER IS INITIAL
ENDFORM. " DATA_SELECTION
*&---------------------------------------------------------------------*
*& Form CHECK_FOR_INITIAL
*&---------------------------------------------------------------------*
* This subroutine is used to validate selection screen elements
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM check_for_initial .
it_outtab = t_order
it_fieldcatalog = t_cat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF SY_SUBRC NE 0
ENDMODULE. " SALES_DISPLAY OUTPUT
*&---------------------------------------------------------------------*
*& Form POP_FCAT
*&---------------------------------------------------------------------*
* This subroutine is used to populate fieldcatalogue for required
* fields
*----------------------------------------------------------------------*
* -->P_FNAME Holds fieldname
* -->P_CTEXT Holds column text
* -->P_CPOS Holds column position
*----------------------------------------------------------------------*
FORM pop_fcat USING value(p_fname) TYPE c
value(p_ctext) TYPE c
value(p_cpos) TYPE i.
* Assigning fieldname,column text,column position to field catalog
fs_cat-fieldname = p_fname.
fs_cat-coltext = p_ctext.
fs_cat-col_pos = p_cpos.
APPEND fs_cat TO t_cat.
CLEAR fs_cat.
ENDFORM. " POP_FCAT