Professional Documents
Culture Documents
Sales Order Report Using ALV Display
Sales Order Report Using ALV Display
•
• 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..............................................................
SELECT-OPTIONS:
*"--------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified delivery header data *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_likp,
END OF type_s_likp.
*"---------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified delivery item data *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_lips,
END OF type_s_lips.
*"--------------------------------------------------------------------------------------*
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_kna1,
END OF type_s_kna1.
TYPES :
BEGIN OF type_s_vbak,
END OF type_s_vbak.
*"----------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales document item data *
*"---------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_vbap,
END OF type_s_vbap.
*"--------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified billing item data *
*"--------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF type_s_vbrp,
END OF type_s_vbrp.
*"-------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales socument *
* header,sales document item data,delivery item data,billing item data *
*"-------------------------------------------------------------------------------------------*
TYPES:
BEGIN OF type_s_order,
END OF type_s_order.
*" Data declarations......................................................................
*"-------------------------------------------------------------------------------------------*
* Work variables *
*"-------------------------------------------------------------------------------------------*
DATA :
"container
DATA :
DATA :
t_kna1 LIKE
STANDARD TABLE
t_vbak LIKE
STANDARD TABLE
t_vbap LIKE
STANDARD TABLE
t_likp LIKE
STANDARD TABLE
t_lips LIKE
STANDARD TABLE
t_vbrp LIKE
STANDARD TABLE
t_order LIKE
STANDARD TABLE
*"------------------------------------------------------------------------------------------------*
* 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 .
FROM likp
IF sy-subrc EQ 0.
* Get Customer name for customer numbers from Customer master table
FROM kna1
IF sy-subrc EQ 0.
FROM lips
IF sy-subrc EQ 0.
" item
FROM vbap
IF sy-subrc EQ 0.
" Created
FROM vbak
" reference
" item
FROM vbrp
ELSE.
MESSAGE S000.
EXIT.
* Get delivery date and customer number for delivery document number
* from delivery header internal table
INTO fs_likp.
* Get customer name for customer number from customer master internal
* table
IF sy-subrc EQ 0.
INTO fs_kna1.
IF sy-subrc EQ 0.
* Get goods issue date and purchase order number for sales document
IF sy-subrc EQ 0.
IF sy-subrc EQ 0.
fs_vbrp.
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.
CLEAR fs_order.
MESSAGE S000.
EXIT.
ELSE.
*&---------------------------------------------------------------------*
*& 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 .
* Check if either delivery document number and delivery date is not
* entered
*&---------------------------------------------------------------------*
*& Form CHECK_DELIVERY_DOCUMENT
*&---------------------------------------------------------------------*
* This subroutine is used to perform validation on delivery document
* number
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM check_delivery_document .
ELSE.
FROM likp
UP TO 1 ROWS
INTO fs_likp-vbeln
ENDSELECT.
IF sy-subrc NE 0.
CLEAR fs_likp.
*&---------------------------------------------------------------------*
*& Form CHECK_DELIVERY_DATE
*&---------------------------------------------------------------------*
* This subroutine is used to perform validation on goods issue date
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM check_delivery_date .
ELSE.
FROM likp
UP TO 1 ROWS
INTO fs_likp-lfdat
ENDSELECT.
CLEAR fs_likp.
IF sy-subrc NE 0.
*&---------------------------------------------------------------------*
*& Module STATUS_1500 OUTPUT
*&---------------------------------------------------------------------*
* This module is used to hold pfstatus for the ALV list display
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1500 INPUT
*&---------------------------------------------------------------------*
* This module is used to hold user command for screen navigation
*----------------------------------------------------------------------*
CASE sy-ucomm.
*&---------------------------------------------------------------------*
*& Module SALES_DISPLAY OUTPUT
*&---------------------------------------------------------------------*
* This module is used to populate fieldcatalogue and layout and *
* create container and grid and call method of grid to display sales *
* order *
*----------------------------------------------------------------------*
EXPORTING
* parent =
container_name = 'CCONTAINER' .
IF sy-subrc NE 0.
ENDIF.
EXPORTING
* i_shellstyle = 0
* i_lifetime =
i_parent = w_container.
IF sy-subrc NE 0.
EXPORTING
i_structure_name = 'FS_ORDER'
is_layout = fs_lay
CHANGING
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.
*&---------------------------------------------------------------------*
*& 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
*----------------------------------------------------------------------*
value(p_ctext) TYPE c
value(p_cpos) TYPE i.
fs_cat-fieldname = p_fname.
fs_cat-coltext = p_ctext.
fs_cat-col_pos = p_cpos.
CLEAR fs_cat.