Professional Documents
Culture Documents
z_alv_demo_total_text.
" Material
ersda
" Creation date
ernam
" Created by
laeda
" Last change date
aenam
" Last change by
vpsta
" Maintenance status
brgew
" Gross weight
ntgew
" Net weight
gewei
" Weight Unit
FROM mara
INTO TABLE i_mara_tmp
UP TO 100 ROWS.
CHECK sy-subrc = 0.
* Populate final table
LOOP AT i_mara_tmp INTO w_mara_tmp.
*
*
= w_mara_tmp-ernam .
w_mara-laeda = w_mara_tmp-laeda.
w_mara-aenam = w_mara_tmp-aenam.
w_mara-vpsta = w_mara_tmp-vpsta.
w_mara-brgew = w_mara_tmp-brgew.
w_mara-ntgew = w_mara_tmp-ntgew.
w_mara-gewei = w_mara_tmp-gewei.
APPEND w_mara TO i_mara.
ENDLOOP.
* Calling the screen to display ALV
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&
Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*
Display ALV report
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
IF oref1 IS INITIAL.
*
*
*
*
*
*
i_structure_name
CHANGING
ct_fieldcat
EXCEPTIONS
inconsistent_interface
program_error
OTHERS
IF sy-subrc = 0.
= 'ZDEMO'
= fieldcat
= 1
= 2
= 3.
IF w_field-fieldname = 'BRGEW' OR
w_field-fieldname = 'NTGEW'.
Summation for Gross & Net weight
w_field-do_sum = 'X'.
MODIFY fieldcat FROM w_field TRANSPORTING do_sum.
ENDIF.
*
*
IF w_field-fieldname = 'SRNO'.
Hide this field so that it can display it's content i.e.
Total text in Subtotal level
w_field-tech = 'X'.
w_field-no_out = 'X'.
MODIFY fieldcat FROM w_field TRANSPORTING tech no_out.
ENDIF.
CLEAR w_field.
ENDLOOP.
ENDIF.
*
*
Populate Sort table with SRNO field so that we can display the total
text in it's subtotal level
wa_sort2-spos = 1.
wa_sort2-fieldname = 'SRNO'.
wa_sort2-up = 'X'.
wa_sort2-subtot = 'X'.
APPEND wa_sort2 TO i_sort2.
ENDIF.
ENDMODULE.
" STATUS_0100
OUTPUT
"SET_PF_STATUS
*&---------------------------------------------------------------------*
*&
Form user_command
*&---------------------------------------------------------------------*
*
Handling custom function codes
*----------------------------------------------------------------------*
*
-->R_UCOMM
Function code value
*
-->RS_SELFIELD Info. of cursor position in ALV
*----------------------------------------------------------------------*
FORM user_command USING
r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.
* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.
* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.
* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.
CASE r_ucomm.
*
WHEN '&IC1'.
*
*
*
*
*
*
*
*
*
ENDFORM.
"user_command
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.
*"-------------------------------------------------------------------------------------------*
*"-------------------------------------------------------------------------------------------*
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 declarations......................................................................
*"-------------------------------------------------------------------------------------------*
* Work variables
*"-------------------------------------------------------------------------------------------*
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..............................................................
*"------------------------------------------------------------------------------------------*
*
*
*"-------------------------------------------------------------------- --------------------*
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 .
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 .
* Check if either delivery document number and delivery date is not
* entered
IF s_deldoc IS INITIAL AND s_dldate IS INITIAL.
MESSAGE E001 display like 'S'.
ENDIF. " IF S_DELDOC IS INITIAL AND....
ENDFORM. " CHECK_FOR_INITIAL
*&---------------------------------------------------------------------*
*& 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 .
* Check if high value is entered without lowvalue
IF s_deldoc-low IS INITIAL AND s_deldoc-high IS NOT INITIAL.
MESSAGE E004 display like 'S'.
ELSE.
* Check if delivery document is in delivery header table
SELECT vbeln " Sales Document
FROM likp
UP TO 1 ROWS
INTO fs_likp-vbeln
WHERE vbeln IN s_deldoc.
ENDSELECT.
* Displays message if there is no record for entered delivery document
* number
IF sy-subrc NE 0.
MESSAGE E002 DISPLAY LIKE 'S'.
ENDIF. " IF SY_SUBRC NE 0
CLEAR fs_likp.
ENDIF. " IF S_DELDOC-LOW IS INITIAL...
ENDFORM. " CHECK_DELIVERY_DOCUMENT
*&---------------------------------------------------------------------*
*& 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 .
* Check if high value is entered without lowvalue
IF s_dldate-low IS INITIAL AND s_dldate-high IS NOT INITIAL.
MESSAGE E004 DISPLAY LIKE 'S'.
ELSE.
* Check if delivery date is in delivery header table
SELECT lfdat " Date on which record is created
FROM likp
UP TO 1 ROWS
INTO fs_likp-lfdat
WHERE lfdat IN s_dldate.
ENDSELECT.
CLEAR fs_likp.
* Displays message if there is no record for entered delivery date
IF sy-subrc NE 0.
MESSAGE E003 DISPLAY LIKE 'S'.
ENDIF. " IF SY_SUBRC NE 0
ENDIF. " IF S_DLDATE-LOW IS INITIAL...
ENDFORM. " CHECK_DELIVERY_DATE
*&---------------------------------------------------------------------*
*& Module STATUS_1500 OUTPUT
*&---------------------------------------------------------------------*
* This module is used to hold pfstatus for the ALV list display
*----------------------------------------------------------------------*
MODULE status_1500 OUTPUT.
* Holds pf-status for the screen 1500
SET PF-STATUS 'SALES_ORDER'.
* Assigns title to the list output
SET TITLEBAR 'SALES'.
ENDMODULE. " STATUS_1500 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1500 INPUT
*&---------------------------------------------------------------------*
* This module is used to hold user command for screen navigation
*----------------------------------------------------------------------*
MODULE user_command_1500 INPUT.
* Navigates screen on back,exit,return user commands
CASE sy-ucomm.