Top Of Page in ABAP Queries
Hello everyone,
I want to write some text in theTop-of-page event of Queries.
I am trying to print the text by using a write statement.But I am not succesful.
Let me know how to use top-of-page in ABAP Queries.
Regards,
Najam
Hi,
you need to write the desired code in the top of page event....
here is the piece of code ..just go through this... and call top of page before start of selection.
TOP OF PAGE
TOP-OF-PAGE .
To Write the header of the Report
PERFORM write_header .
*& Form WRITE_HEADER
text :Subroutine to write header
FORM write_header .
DATA: v_date(10),
v_start(10),
v_end(10) .
WRITE : sy-datum TO v_date MM/DD/YYYY,
p_prcdte TO v_start MM/DD/YYYY.
WRITE 5 '|' . ULINE AT 5(95) . WRITE 100 '|' .
WRITE /30 text-028 INVERSE COLOR 7 . WRITE 100'|' .
WRITE 5 '|' . ULINE AT /5(95) . WRITE 100 '|' .
WRITE: /7 'Date/Time :', v_date, ' / ' , sy-uzeit .WRITE 100 '|' .
WRITE 5 '|' . ULINE AT /5(95) .WRITE 100 '|' .
WRITE: /7 'Processing Month :', v_start . WRITE 100 '|' .
WRITE 5 '|' . ULINE AT /5(95).WRITE 100 '|' .
SKIP 2 .
ENDFORM. " WRITE_HEADER
if u wanna to do for alv then the piece of code provided by Nick will be helpful..
Thanks & Regards
Similar Messages
-
TOP of PAGE using ABAP oo with single CUSTOM CONTROL
Can anybody please tell me how to handle TOP_OF_PAGE using ABAP OBJECTS with a SINGLE CUSTOM CONTROL and not with SPLIT CONTAINER(i.e. using single CL_GUI_CUSTOM_CONTAINER and single grid CL_GUI_ALV_GRID ). Is it possible if so Please help me out?
Hi Ravi,
Here is my code. i didn't handle the top_of_page event yet but created a method to handle.
REPORT ZSATEESH_ALV_CONTAINER MESSAGE-ID ZZ
LINE-SIZE 150 NO STANDARD PAGE HEADING.
PROGRAM id : ZSATEESH_ALV_CONTAINER *
Title : Sales document report *
Author : Sateesh *
Date : *
CR# : *
Dev Initiative :
Description :ALV GRID/LIST Report which displays the sales
document header data using ABAP Objects.
Modification Log
Corr. no date programmer description
TYPES Declaration
*--Type for the Header Sales data
TYPES: BEGIN OF TY_VBAK ,
INDICAT LIKE ICON-ID, " Icon
VBELN LIKE VBAK-VBELN, " Sales Document
AUDAT LIKE VBAK-AUDAT, " Document date
VBTYP LIKE VBAK-VBTYP, " SD document category
AUART LIKE VBAK-AUART, " Sales Document Type
AUGRU LIKE VBAK-AUGRU, " Order reason
NETWR LIKE VBAK-NETWR, " Net Value
WAERK LIKE VBAK-WAERK, " SD document currency
END OF TY_VBAK.
DATA Declaration
*--Tableto hold the header sales data
DATA: TB_VBAK TYPE STANDARD TABLE OF TY_VBAK.
*--Table to hold the Icons
DATA: BEGIN OF TB_ICON OCCURS 0,
ID TYPE ICON-ID, " Icon
NAME TYPE ICON-NAME, " Name of an Icon
END OF TB_ICON.
*--Declaration of ALV Grid Tables
DATA: TB_FDCAT TYPE LVC_T_FCAT, " Fieldcatalog
TB_SORT TYPE LVC_T_SORT. " Sorting
DATA: OK_CODE LIKE SY-UCOMM. " sy-ucomm
*--Reference variables for container and grid control.
DATA: CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
" Container reference
OBJ_ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
" Alv Grid reference
S T R U C T U R E S
DATA: X_FDCAT TYPE LVC_S_FCAT, " Fieldcatalog
X_LAYOUT TYPE LVC_S_LAYO, " layout
X_SORT TYPE LVC_S_SORT, " Sorting
X_VBAK TYPE TY_VBAK, " sales header stucture
X_ICON LIKE TB_ICON. " icons structure
C O N S T A N T S
*--Declaration of Constants
CONSTANTS :
C_GREEN(40) TYPE C VALUE 'ICON_GREEN_LIGHT',
C_RED(40) TYPE C VALUE 'ICON_RED_LIGHT',
C_YELLOW(40) TYPE C VALUE 'ICON_YELLOW_LIGHT',
C_X TYPE C VALUE 'X'. " Flag
SELECTION SCREEN
*--Block 1.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER: P_AUDAT LIKE VBAK-AUDAT
DEFAULT '20050101'(003). " doc date.
SELECTION-SCREEN: END OF BLOCK B1.
*--bLOCK 2.
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETER :P_ALVDIS AS CHECKBOX. " For List/Grid
SELECTION-SCREEN : END OF BLOCK B2.
Class LC_VBAK definition
CLASS LC_VBAK DEFINITION.
PUBLIC SECTION.
METHODS: VBAK_POPULATE, " sales header population
ICON_POPULATE, " Icons population
FINAL_POPULATE, " Final ALV population
DISPLAY, " Displaying ALV
TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
ENDCLASS. "LC_VBAK DEFINITION
Class LC_VBAK IMPLEMENTATION
CLASS LC_VBAK IMPLEMENTATION.
METHOD VBAK_POPULATE.
*-- selecting from VBAK
SELECT VBELN
AUDAT
VBTYP
AUART
AUGRU
NETWR
WAERK
INTO CORRESPONDING FIELDS OF TABLE TB_VBAK
FROM VBAK
WHERE AUDAT > P_AUDAT AND
NETWR > 0.
IF SY-SUBRC <> 0.
SORT TB_VBAK BY AUART VBTYP WAERK .
ENDIF.
ENDMETHOD . "VBAK_POPULATE
METHOD ICON_POPULATE.
*--selecting from ICON table
SELECT ID
NAME
INTO TABLE TB_ICON
FROM ICON.
IF SY-SUBRC = 0.
SORT TB_ICON BY NAME .
ENDIF.
ENDMETHOD . "ICON_POPULATE
METHOD FINAL_POPULATE.
*--looping through VBAK table into the work area
LOOP AT TB_VBAK INTO X_VBAK .
IF X_VBAK-NETWR <= 10.
*--Reading the ICON table into work area comparing field NAME
READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_GREEN
BINARY SEARCH.
IF SY-SUBRC = 0.
X_VBAK-INDICAT = X_ICON-ID.
*--modifying the TB_VBAK table
MODIFY TB_VBAK FROM X_VBAK.
ENDIF.
ELSEIF X_VBAK-NETWR > 10 AND X_VBAK-NETWR < 100.
*--Reading the ICON table into work area comparing field NAME
READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_YELLOW
BINARY SEARCH.
IF SY-SUBRC = 0.
X_VBAK-INDICAT = X_ICON-ID.
*--modifying the TB_VBAK table
MODIFY TB_VBAK FROM X_VBAK.
ENDIF.
ELSEIF X_VBAK-NETWR >= 100.
*--Reading the ICON table into work area comparing field NAME
READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_RED
BINARY SEARCH.
IF SY-SUBRC = 0.
X_VBAK-INDICAT = X_ICON-ID.
*--modifying the TB_VBAK table
MODIFY TB_VBAK FROM X_VBAK.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD. "FINAL_POPULATE
METHOD top_of_page *
METHOD TOP_OF_PAGE.
PERFORM EVENT_TOP_OF_PAGE USING E_DYNDOC_ID.
ENDMETHOD. "top_of_page
METHOD DISPLAY.
*--Building fieldcatalog table
PERFORM FIELDCATLOG.
*--FOr making the Layout settings
PERFORM LAYOUT.
*--For sorting the fields
PERFORM SORTING.
*--perform for displaying the ALV
PERFORM ALV_GRID_DISPLAY.
ENDMETHOD. "DISPLAY
ENDCLASS. "LC_VBAK IMPLEMENTATION
*& Form FIELDCATLOG
Building the FIELDCATALOG
FORM FIELDCATLOG .
CLEAR: X_FDCAT,TB_FDCAT[].
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 1.
X_FDCAT-FIELDNAME = 'INDICAT'(004) .
X_FDCAT-TABNAME = 'TB_VBAK'(005).
X_FDCAT-SCRTEXT_L = 'STATUS_INDICATOR'(006).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 2.
X_FDCAT-FIELDNAME = 'VBELN'(007) .
X_FDCAT-TABNAME = 'TB_VBAK'(005).
X_FDCAT-SCRTEXT_L = 'SALES DOC'(008).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 3.
X_FDCAT-FIELDNAME = 'AUDAT'(009) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'DOC DATE'(010).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 4.
X_FDCAT-FIELDNAME = 'VBTYP'(011) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'SALES CATEGORY'(012).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 5.
X_FDCAT-FIELDNAME = 'AUART'(013) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'DOC TYPE'(014).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 6.
X_FDCAT-FIELDNAME = 'AUGRU'(015) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'REASON'(016).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 7.
X_FDCAT-FIELDNAME = 'NETWR'(017) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'NET VALUE'(018).
X_FDCAT-DO_SUM = C_X.
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 8.
X_FDCAT-FIELDNAME = 'WAERK'(019) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'UNIT'(020).
APPEND X_FDCAT TO TB_FDCAT.
ENDFORM. " FIELDCATLOG
*& Module STATUS_0007 OUTPUT
module for setting the pf status
MODULE STATUS_0007 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0007 OUTPUT
*& Module USER_COMMAND_0007 INPUT
module for handling the user commands
MODULE USER_COMMAND_0007 INPUT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0007 INPUT
*& Form LAYOUT
ALV Layout settings
FORM LAYOUT .
CLEAR X_LAYOUT.
*-- making Layout settings
X_LAYOUT-GRID_TITLE = 'Sales Header Document'(021).
X_LAYOUT-ZEBRA = C_X.
IF P_ALVDIS = C_X.
X_LAYOUT-NO_HGRIDLN = C_X.
X_LAYOUT-NO_VGRIDLN = C_X.
ENDIF.
ENDFORM. " LAYOUT
*& Form SORTING
sub routine for sorting criteria
FORM SORTING .
CLEAR X_SORT.
X_SORT-SPOS = '1'(022).
X_SORT-FIELDNAME = 'AUART'.
X_SORT-UP = C_X.
APPEND X_SORT TO TB_SORT.
CLEAR X_SORT.
X_SORT-SPOS = '2'(023).
X_SORT-FIELDNAME = 'VBTYP'.
X_SORT-UP = C_X.
APPEND X_SORT TO TB_SORT.
CLEAR X_SORT.
X_SORT-SPOS = '3'(024).
X_SORT-FIELDNAME = 'WAERK'.
X_SORT-UP = C_X.
X_SORT-SUBTOT = C_X.
APPEND X_SORT TO TB_SORT.
ENDFORM. " SORTING
*& Form CREATE_CONTAINER_OBJECT
subroutine to create object of container
FORM CREATE_CONTAINER_OBJECT .
CREATE OBJECT CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'CUST_CONTROL'(025)
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CREATE_CONTAINER_OBJECT
*& Form CREATE_ALV_GRID_OBJECT
subroutine to create object of ALV GRID
FORM CREATE_ALV_GRID_OBJECT .
CREATE OBJECT OBJ_ALV_GRID
EXPORTING
I_PARENT = CUSTOM_CONTAINER
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CREATE_ALV_GRID_OBJECT
*& Form ALV_GRID_DISPLAY
subroutine to call method for displaying the ALV GRID
FORM ALV_GRID_DISPLAY .
CALL METHOD OBJ_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = X_LAYOUT
CHANGING
IT_OUTTAB = TB_VBAK
IT_FIELDCATALOG = TB_FDCAT
IT_SORT = TB_SORT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL SCREEN 0007.
ENDFORM. " ALV_GRID_DISPLAY
START OF SELECTION
START-OF-SELECTION.
*--Creating a reference variable for the class LC_VBAK
DATA : OBJ1 TYPE REF TO LC_VBAK.
*--Creating a container object
PERFORM CREATE_CONTAINER_OBJECT.
*--Creating a ALV GRID control object
PERFORM CREATE_ALV_GRID_OBJECT.
*--Creating a object of class LC_VBAK
CREATE OBJECT OBJ1.
*--calling vbak population method
CALL METHOD OBJ1->VBAK_POPULATE.
*--calling icon population method
CALL METHOD OBJ1->ICON_POPULATE.
*--calling fianl table population method
CALL METHOD OBJ1->FINAL_POPULATE.
*--calling final method for display
CALL METHOD OBJ1->DISPLAY.
*& Form EVENT_TOP_OF_PAGE
text
-->P_E_DYNDOC_ID text
FORM EVENT_TOP_OF_PAGE USING P_E_DYNDOC_ID TYPE REF TO
CL_DD_DOCUMENT.
ENDFORM. " EVENT_TOP_OF_PAGE -
Display data on top of page and sort issue. Pls help
Hi guys,
I need some help. I can't seem to get the code to work. Below is my code to display the ALV. It works fine but I want it to print some top of page details according to the SORT (grouping) but the sort isn't even working?
http://i987.photobucket.com/albums/ae354/runningandrew/2010/Other_Random/Screenshot1.jpg
HEre is screenshot of the output
Sales Order Number : 1100001541
Purchase Order Number : 4500352015
Distributor Number : 20061 <====
Ship To Name : ALPHA EZZ EL ARAB CO.,
Order Date : 29.04.2010
Delivery Date : 29.04.2010
There should be another one printing but its not.
Sales Order Number : 1100001542 <=====
Purchase Order Number : 4500352015
Distributor Number : 20063 <=====
Ship To Name : ALPHA EZZ EL ARAB CO.,
Order Date : 29.04.2010
Delivery Date : 29.04.2010
My it_report structure is
BEGIN OF t_report,
ebeln TYPE bapivbeln-vbeln,
purch_no TYPE bstnk,
kunnr TYPE kunnr,
wename1 TYPE name1_gp,
order_date TYPE edatu_vbak,
vdate TYPE vbak-vdatu,
matnr TYPE matnr,
matnr_txt TYPE arktx,
qty TYPE kwmeng,
END OF t_report.
Here are the sort fields
PERFORM add_sort_key USING: 'EBELN' 'X' 'X',
'PURCH_NO' 'X' 'X',
'KUNNR' 'X' 'X'.
FORM add_sort_key USING pv_field TYPE any
pv_ascen TYPE any
pv_group TYPE any.
it_alv_sort-fieldname = pv_field.
it_alv_sort-up = pv_ascen.
it_alv_sort-group = pv_group.
APPEND it_alv_sort.
CLEAR it_alv_sort.
it_sort_new-fieldname = pv_field.
APPEND it_sort_new.
CLEAR it_sort_new.
ENDFORM. " ADD_SORT_KEY
Here is my display ALV part
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = l_alv_layout
it_fieldcat = it_alv_fieldcat[]
i_tabname = c_it_report
it_events = it_alv_events[]
it_sort = it_sort_new[]
TABLES
t_outtab = it_report
Edited by: Slow ABAPer on Apr 29, 2010 5:43 AMHi,
You should always put the code in the tags as :
for it to be displayed as proper code.
With Regards,
Samreen. -
Field Descriptions without TOP OF PAGE
Hi Experts,
I have one Z report and this was written somebody long back.
This report was normal standard report i.e just writing the table values to screen using WRITE statement.
Eventhogh there is no TOP OF PAGE event in the report, field names were displaying in the screen output with highlighted color.
As soon as WITE statement calling, program is displaying fieldnames automatically? how it possible?
Now, I modified my program by adding another field values to the screen output.
The field which I added it's not showing field name.
How can I display my field description to that output. (without adding TOP OF PAGE)
As I told you report doesn't have TOP OF PAGE event. Please help me.
Thanks
RaghuRaghu,
I'm guessing that your report is organized in a tabular form and by field description you mean column headings. There are two ways to display column headings 1) by explicitely writing the WRITE statements to output to the column headings, 2) by maintaining the standard list & column headings. (in ABAP editor follow menu path GOTO>Text Elements>List Headings.
You can disable the display of standard headings by using addition in NO STANDARD PAGE HEADING as below.
REPORT YTEST NO STANDARD PAGE HEADING
LINE-SIZE 120
LINE-COUNT 65
MESSAGE ZMSG.
Regards,
Gajendra -
Changing customer number in alv top of page for every new customer
hi experts,
in alv grid display top-of- page, how to change customer number customer name for every new customer.
please help me.
Regards
Naveen.You may look into this blog
http://help-abap.blogspot.com/2008/09/salv-model-5-add-header-top-of-page.html
This is has been contributed by one of the SCN contributor Naimesh Patel.
a® -
I need page no's and top of page header to every page
Hi Experts,
i need page no's and top of page header to every page
to this report.
i took print outs it came only page number 1 to all the pages, after took prints it seems header to all the pages
but not displaying in output screen.
TYPE-POOLS: SLIS.
TABLES: MKPF,LFA1,MSEG,EKET,T001L,MAKT,S031,S032,MARA,LIPS,LIKP,T001W.
DATA FLAG TYPE I.
DATA : MENGE_RE LIKE MSEG-MENGE,
MENGE_IS LIKE MSEG-MENGE,
MENGE_O LIKE MSEG-MENGE,
MENGE_BAL LIKE MSEG-MENGE.
DATA MAGBB LIKE S031-MAGBB.
DATA MZUBB LIKE S031-MZUBB.
DATA V_MONTH LIKE S031-SPMON.
DATA XBLNR LIKE MKPF-XBLNR.
DATA : BEGIN OF ITAB1 OCCURS 100,
MATNR LIKE MAKT-MATNR,
END OF ITAB1.
DATA : BEGIN OF ITAB2 OCCURS 100,
MATNR LIKE MAKT-MATNR,
WERKS LIKE MARD-WERKS,
LGORT LIKE MARD-LGORT,
BUSTW LIKE MSEG-BUSTW,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
MENGE LIKE MSEG-MENGE,
END OF ITAB2.
DATA: PAGNO(5) TYPE C.
DATA : PAGENO LIKE SY-PAGNO.
DATA: STR1 TYPE DATS,
STR2(14) TYPE C,
STR3(10) TYPE C.
DATA : V_MONUM LIKE T015M-MONUM,
V_MONAM LIKE T015M-MONAM.
TYPES: FARBE TYPE SLIS_T_SPECIALCOL_ALV.
DATA V_STOCK LIKE MSEG-MENGE.
DATA V_STOCK1 LIKE MSEG-MENGE.
DATA: V_MONTH1 LIKE S031-SPMON.
DATA: OSTOCK LIKE MSEG-MENGE.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GT_LAYOUT TYPE SLIS_LAYOUT_ALV,
GS_KEYINFO TYPE SLIS_KEYINFO_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
GT_EVENTS TYPE SLIS_T_EVENT,
G_PRINT TYPE SLIS_PRINT_ALV.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.
DATA: FC_HIER TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: GT_REPID LIKE SY-REPID.
DATA: GT_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: GT_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST'.
DATA: FLD(15).
DATA: TXT(50).
I N I T I A L I Z A T I O N
GT_REPID = SY-REPID.
PAGNO = SY-PAGNO.
PERFORM EVENTTAB_BUILD USING GT_EVENTS[].
A T S E L E C T I O N S C R E E N
*AT SELECTION-SCREEN ON BUDAT.
PERFORM VALIDATION.
S T A R T O F S E L E C T I O N
START-OF-SELECTION.
PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
PERFORM FETCH_DATA.
E N D O F S E L E C T I O N
END-OF-SELECTION.
IF NOT ITAB2[] IS INITIAL.
PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GT_REPID
IT_FIELDCAT = GT_FIELDCAT[]
IT_EVENTS = GT_EVENTS[]
IT_SORT = GT_SORT[]
IS_LAYOUT = GT_LAYOUT
TABLES
T_OUTTAB = ITAB2.
ELSE.
MESSAGE S006(Z1).
ENDIF.
CLEAR : GT_LAYOUT.
Report Selections
DATA: BEGIN OF IT_HEADER OCCURS 10,
WERKS LIKE MSEG-WERKS,
NAME1 LIKE T001W-NAME1,
MAKTX LIKE MAKT-MAKTX,
MATNR LIKE MSEG-MATNR,
MENGE_O LIKE MSEG-MENGE,
END OF IT_HEADER.
DATA: BEGIN OF ITAB OCCURS 50,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BWART LIKE MSEG-BWART,
LGORT LIKE MSEG-LGORT,
EBELN LIKE MSEG-EBELN,
XBLNR LIKE MKPF-XBLNR,
BUDAT LIKE MKPF-BUDAT,
MBLNR LIKE MSEG-MBLNR,
MENGE LIKE MSEG-MENGE,
MAKTX LIKE MAKT-MAKTX,
XAUTO LIKE MSEG-XAUTO,
NAME1 LIKE T001W-NAME1,
MENGE_O LIKE MSEG-MENGE,
SHKZG LIKE MSEG-SHKZG,
MENGE_IS LIKE MSEG-MENGE,
MENGE_RE LIKE MSEG-MENGE,
END OF ITAB.
DATA: BEGIN OF INT_DATA OCCURS 50,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BWART LIKE MSEG-BWART,
XBLNR LIKE MKPF-XBLNR,
MBLNR LIKE MSEG-MBLNR,
BUDAT LIKE MKPF-BUDAT,
MAKTX LIKE MAKT-MAKTX,
MENGE_O LIKE MSEG-MENGE,
MENGE_R LIKE MSEG-MENGE,
MENGE_TO LIKE MSEG-MENGE,
MENGE_TI LIKE MSEG-MENGE,
MENGE_S LIKE MSEG-MENGE,
MENGE_ST LIKE MSEG-MENGE,
MENGE_AD LIKE MSEG-MENGE,
MENGE_RT LIKE MSEG-MENGE,
MENGE_C LIKE MSEG-MENGE,
MENGE_CL LIKE MSEG-MENGE,
MENGE_BAL LIKE MSEG-MENGE,
MENGE_CR LIKE MSEG-MENGE,
NAME1 LIKE T001W-NAME1,
MENGE_RE LIKE MSEG-MENGE,
MENGE_IS LIKE MSEG-MENGE,
MENGE_BAL1 LIKE MSEG-MENGE,
SHKZG LIKE MSEG-SHKZG,
MENGE LIKE MSEG-MENGE,
END OF INT_DATA.
DATA: BEGIN OF INT_DATA1 OCCURS 50,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BWART LIKE MSEG-BWART,
MENGE_ST LIKE MSEG-MENGE,
MENGE_O LIKE MSEG-MENGE,
WAMNG LIKE EKET-WAMNG,
WEMNG LIKE EKET-WEMNG,
MENGE LIKE MSEG-MENGE,
RETPO LIKE EKPO-RETPO,
UMREN LIKE EKPO-UMREN,
UMREZ LIKE EKPO-UMREZ,
BSTMG LIKE EKPO-MENGE,
XBLNR LIKE MKPF-XBLNR,
END OF INT_DATA1.
DATA: BEGIN OF INT_DATA2 OCCURS 50,
WERKS LIKE MSEG-WERKS,
LGORT LIKE S031-LGORT,
MATNR LIKE MSEG-MATNR,
BWART LIKE MSEG-BWART,
MENGE_IS LIKE MSEG-MENGE,
MBWBEST LIKE S032-MBWBEST,
MAKTX LIKE MAKT-MAKTX,
END OF INT_DATA2.
DATA:V_GJAHR LIKE MKPF-BUDAT.
DATA : FLAG6 TYPE C,
PAGENO1 LIKE SY-PAGNO,
PAGENO2 LIKE SY-PAGNO.
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-064.
SELECT-OPTIONS:
MATNR FOR MSEG-MATNR,
MATKL FOR MARA-MATKL OBLIGATORY,
WERKS FOR MSEG-WERKS OBLIGATORY,
LGORT FOR MSEG-LGORT,
*CHARG FOR MSEG-CHARG,
BWART FOR MSEG-BWART,
*LIFNR FOR LFA1-LIFNR,
*WADAT FOR LIKP-WADAT_IST,
BUDAT FOR MKPF-BUDAT.
SELECTION-SCREEN END OF BLOCK 0.
*SELECTION-SCREEN SKIP 1.
Parameters
*SELECTION-SCREEN SKIP 1.
Variante
*SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-064.
DATA: P_VARI LIKE DISVARIANT-VARIANT.
*SELECTION-SCREEN END OF BLOCK 0.
Layout
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-060.
DATA: P_ZEBRA VALUE 'X'.
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-063.
PARAMETERS:
P_EXPAND AS CHECKBOX DEFAULT ' '.
DATA: P_DETPOP VALUE 'X' .
SELECTION-SCREEN END OF BLOCK D.
DATA: G_BOXNAM TYPE SLIS_FIELDNAME VALUE 'BOX',
G_EXPANDNAME TYPE SLIS_FIELDNAME VALUE 'EXPAND',
P_F2CODE LIKE SY-UCOMM VALUE '&ETA',
P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'LIGHTS',
G_SAVE(1) TYPE C,
G_TABNAME_HEADER TYPE SLIS_TABNAME,
G_TABNAME_ITEM TYPE SLIS_TABNAME,
G_EXIT(1) TYPE C,
GX_VARIANT LIKE DISVARIANT,
G_VARIANT LIKE DISVARIANT.
INITIALIZATION.
GT_REPID = SY-REPID.
G_TABNAME_HEADER = 'IT_HEADER'.
G_TABNAME_ITEM = 'INT_DATA'.
define keyinfo
CLEAR GS_KEYINFO.
GS_KEYINFO-HEADER01 = 'MATNR'.
GS_KEYINFO-ITEM01 = 'MATNR'.
*GS_KEYINFO-HEADER01.
PERFORM E01_FIELDCAT_INIT USING GT_FIELDCAT[].
PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].
PERFORM E04_COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
PERFORM E06_T_SORT_BUILD USING GT_SORT[].
PERFORM E07_SP_GROUP_BUILD USING GT_SP_GROUP[].
Schalter Varianten benutzerspezifisch/allgemein speicherbar setzen
Set Options: save variants userspecific or general
G_SAVE = 'A'.
PERFORM VARIANT_INIT.
Get default variant
GX_VARIANT = G_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
Process on value request
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
PERFORM F4_FOR_VARIANT.
AT SELECTION-SCREEN.
PERFORM PAI_OF_SELECTION_SCREEN.
START-OF-SELECTION.
END-OF-SELECTION.
PERFORM LAYOUT_BUILD USING GT_LAYOUT. "wg. Parameters
Call ABAP/4 List Viewer
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GT_REPID
IS_LAYOUT = GT_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
IT_SPECIAL_GROUPS = GT_SP_GROUP[]
IT_SORT = GT_SORT[]
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = GT_EVENTS[]
I_TABNAME_HEADER = G_TABNAME_HEADER
I_TABNAME_ITEM = G_TABNAME_ITEM
IS_KEYINFO = GS_KEYINFO
IS_PRINT = G_PRINT
TABLES
T_OUTTAB_HEADER = IT_HEADER
T_OUTTAB_ITEM = INT_DATA.
FORM E01_FIELDCAT_INIT *
--> E01_LT_FIELDCAT *
FORM FIELDCAT_INIT
USING RT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: POS TYPE I VALUE 1.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'WERKS'.
LS_FIELDCAT-TABNAME = G_TABNAME_HEADER .
LS_FIELDCAT-SELTEXT_L = 'Plant'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'NAME1'.
LS_FIELDCAT-TABNAME = G_TABNAME_HEADER .
LS_FIELDCAT-SELTEXT_L = 'Description'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-TABNAME = G_TABNAME_HEADER .
LS_FIELDCAT-SELTEXT_M = 'Material'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-TABNAME = G_TABNAME_HEADER .
LS_FIELDCAT-SELTEXT_M = 'Material Description'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'XBLNR'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Doc No.'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'BUDAT'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Doc Date.'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'BWART'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Mvt.'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MBLNR'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Mat.Doc No'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_R'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' STO-In '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_RT'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Sales Returns '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_CL'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Canc of Invoice'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_AD'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Adjustments '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_S'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Sales. '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_TO'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' STO-Out '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_CR'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Canc of Sal Returns'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_AD'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = 'Adjustments '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_O'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Opening Balance '.
LS_FIELDCAT-NO_ZERO = 'X'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MENGE_BAL'.
LS_FIELDCAT-TABNAME = G_TABNAME_ITEM .
LS_FIELDCAT-SELTEXT_M = ' Balance '.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
ENDFORM. "E01_FIELDCAT_INIT
FORM E02_DATA_ADD *
--> E02_LT_SFLIGHT *
FORM E03_EVENTTAB_BUILD *
--> E03_LT_EVENTS *
*FORM E03_EVENTTAB_BUILD USING E03_LT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 1
IMPORTING
ET_EVENTS = E03_LT_EVENTS.
READ TABLE E03_LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO E03_LT_EVENTS.
ENDIF.
*ENDFORM. "E03_EVENTTAB_BUILD
FORM E04_COMMENT_BUILD *
--> E04_LT_TOP_OF_PAGE *
FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
Listenüberschrift: Typ H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = TEXT-001.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-050.
LS_LINE-INFO = TEXT-010.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
LS_LINE-KEY = TEXT-051.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
Aktionsinfo: Typ A
CLEAR LS_LINE.
LS_LINE-TYP = 'A'.
LS_LINE-INFO = TEXT-002.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
ENDFORM. "E04_COMMENT_BUILD
FORM E05_LAYOUT_BUILD *
<-> E05_LS_LAYOUT *
FORM LAYOUT_BUILD USING LS_LAYOUT TYPE SLIS_LAYOUT_ALV.
LS_LAYOUT-F2CODE = P_F2CODE.
LS_LAYOUT-ZEBRA = P_ZEBRA.
LS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
IF P_EXPAND = 'X'.
LS_LAYOUT-EXPAND_FIELDNAME = G_EXPANDNAME.
ELSE.
CLEAR LS_LAYOUT-EXPAND_FIELDNAME.
ENDIF.
LS_LAYOUT-DETAIL_POPUP = P_DETPOP.
ENDFORM. "E05_LAYOUT_BUILD
FORM E06_T_SORT_BUILD *
--> E06_LT_SORT *
*FORM E06_T_SORT_BUILD USING E06_LT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'WERKS'.
LS_SORT-TABNAME = G_TABNAME_HEADER.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO E06_LT_SORT.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'MATNR'.
LS_SORT-TABNAME = G_TABNAME_ITEM.
LS_SORT-SPOS = 2.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO E06_LT_SORT.
*ENDFORM. "E06_T_SORT_BUILD
FORM E07_SP_GROUP_BUILD *
--> E07_LT_SP_GROUP *
FORM E07_SP_GROUP_BUILD USING E07_LT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.
DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.
CLEAR LS_SP_GROUP.
LS_SP_GROUP-SP_GROUP = 'A'.
LS_SP_GROUP-TEXT = TEXT-005.
APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.
ENDFORM. "E07_SP_GROUP_BUILD
FORM SELECTION *
FORM FETCH_DATA .
STR3 = BUDAT-LOW+0(4).
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB1
WHERE MATNR IN MATNR AND
MATKL IN MATKL.
SELECT MATNR WERKS LGORT
INTO TABLE ITAB2
FROM MARD FOR ALL ENTRIES IN ITAB1
WHERE WERKS IN WERKS AND
LGORT IN LGORT AND
MATNR = ITAB1-MATNR.
SELECT SINGLE NAME1 FROM T001W INTO INT_DATA-NAME1
WHERE WERKS = INT_DATA-WERKS.
LOOP AT ITAB2.
SELECT M~MATNR M~WERKS M~LGORT M~MENGE M~MBLNR M~MJAHR M~XAUTO M~SHKZG
M~BWART M~EBELN N~BUDAT N~XBLNR S~NAME1
INTO CORRESPONDING FIELDS OF ITAB
FROM MSEG AS M INNER JOIN MKPF AS N ON
M~MBLNR = N~MBLNR
AND M~MJAHR = N~MJAHR
INNER JOIN T001W AS S ON
M~WERKS = S~WERKS
WHERE N~BUDAT IN BUDAT AND
M~WERKS = ITAB2-WERKS AND
M~LGORT = ITAB2-LGORT AND
M~MATNR = ITAB2-MATNR AND
M~BWART IN BWART.
APPEND ITAB.
CLEAR ITAB.
ENDSELECT.
IF SY-SUBRC NE 0.
ITAB-MATNR = ITAB2-MATNR.
ITAB-WERKS = ITAB2-WERKS.
ITAB-LGORT = ITAB2-LGORT.
ITAB-BWART = ITAB2-BWART.
APPEND ITAB.
ENDIF.
CLEAR: ITAB2,ITAB.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ITAB2 COMPARING MATNR WERKS .
V_MONTH = BUDAT-LOW+0(6).
SELECT * INTO CORRESPONDING FIELDS OF TABLE INT_DATA2
FROM S032 FOR ALL ENTRIES IN ITAB2
WHERE MATNR = ITAB2-MATNR
AND WERKS = ITAB2-WERKS
AND LGORT = SPACE
AND MBWBEST <> SPACE.
LOOP AT INT_DATA2 .
SELECT SINGLE * FROM S031
WHERE MATNR = INT_DATA2-MATNR AND
WERKS = INT_DATA2-WERKS AND
LGORT = SPACE AND
SPMON GT V_MONTH.
MODIFY INT_DATA2.
CLEAR: INT_DATA2, S031.
ENDLOOP.
DELETE INT_DATA WHERE MENGE_O IS INITIAL .
DELETE ADJACENT DUPLICATES FROM INT_DATA COMPARING XBLNR MATNR MAKTX.
V_MONTH1 = BUDAT-LOW+0(6).
SORT ITAB BY MATNR WERKS XBLNR .
LOOP AT ITAB.
XBLNR = ITAB-XBLNR.
INT_DATA-MENGE = ITAB-MENGE.
INT_DATA-BWART = ITAB-BWART.
INT_DATA-XBLNR = ITAB-XBLNR.
INT_DATA-BUDAT = ITAB-BUDAT.
INT_DATA-MATNR = ITAB-MATNR.
INT_DATA-MBLNR = ITAB-MBLNR.
INT_DATA-MENGE = ITAB-MENGE.
INT_DATA-SHKZG = ITAB-SHKZG.
INT_DATA-MENGE_IS = ITAB-MENGE_IS.
INT_DATA-MENGE_RE = ITAB-MENGE_RE.
INT_DATA-MENGE_O = ITAB-MENGE_O.
INT_DATA-NAME1 = ITAB-NAME1.
AT NEW MATNR.
FLAG = 1.
IT_HEADER-MATNR = INT_DATA-MATNR.
SELECT SINGLE MAKTX FROM MAKT INTO IT_HEADER-MAKTX WHERE
MATNR = INT_DATA-MATNR.
APPEND IT_HEADER.
CLEAR IT_HEADER.
ENDAT.
IF FLAG = 1.
PERFORM GET_OPENING_STOCK.
ENDIF.
INT_DATA-MENGE_O = OSTOCK.
CASE ITAB-BWART.
WHEN '101'.
IF INT_DATA-SHKZG = 'S'.
INT_DATA-MENGE_R = INT_DATA-MENGE_R + ITAB-MENGE.
ENDIF.
WHEN '453'.
IF INT_DATA-SHKZG = 'S'.
IF ITAB-XAUTO = 'X'.
INT_DATA-MENGE_RT = INT_DATA-MENGE_RT + ITAB-MENGE.
ENDIF.
ENDIF.
WHEN '351' OR '641'.
IF ITAB-LGORT = 0.
INT_DATA-MENGE_R = INT_DATA-MENGE_R + ITAB-MENGE.
ELSE.
INT_DATA-MENGE_TO = INT_DATA-MENGE_TO + ITAB-MENGE.
ENDIF.
WHEN '602' OR '642'.
IF INT_DATA-SHKZG = 'S'.
IF ITAB-LGORT = 0.
INT_DATA-MENGE_CL = INT_DATA-MENGE_CL + ITAB-MENGE.
ENDIF.
ENDIF.
WHEN '552' OR '310'.
IF INT_DATA-SHKZG = 'S'.
INT_DATA-MENGE_AD = INT_DATA-MENGE_AD - ITAB-MENGE.
ENDIF.
WHEN '601'.
IF INT_DATA-SHKZG = 'H'.
INT_DATA-MENGE_S = INT_DATA-MENGE_S + ITAB-MENGE.
ENDIF.
WHEN '641' .
IF INT_DATA-SHKZG = 'H'.
IF ITAB-LGORT = 0.
INT_DATA-MENGE_TO = INT_DATA-MENGE_TO + ITAB-MENGE.
ENDIF.
ENDIF.
WHEN '454' OR '102'.
IF INT_DATA-SHKZG = 'H'.
IF ITAB-XAUTO = 'X'.
INT_DATA-MENGE_CR = INT_DATA-MENGE_CR - ITAB-MENGE.
ENDIF.
ENDIF.
WHEN '551' OR '309'.
IF INT_DATA-SHKZG = 'H'.
INT_DATA-MENGE_AD = INT_DATA-MENGE_AD + ITAB-MENGE.
ENDIF.
IF INT_DATA-SHKZG = 'S'.
MENGE_O = INT_DATA-MENGE_O + ITAB-MENGE.
ENDIF.
ENDCASE.
IF INT_DATA-SHKZG = 'S'.
MENGE_RE = INT_DATA-MENGE_R + INT_DATA-MENGE_RT + INT_DATA-MENGE_CL
+ INT_DATA-MENGE_AD.
ENDIF.
IF INT_DATA-SHKZG = 'H'.
MENGE_IS = INT_DATA-MENGE_S + INT_DATA-MENGE_TO +
INT_DATA-MENGE_CR + INT_DATA-MENGE_AD.
ENDIF.
PERFORM BALANCE.
COLLECT INT_DATA.
CLEAR: INT_DATA,ITAB ,XBLNR, FLAG, OSTOCK.
ENDLOOP.
SORT INT_DATA BY XBLNR BUDAT WERKS MATNR.
LOOP AT INT_DATA.
READ TABLE INT_DATA2 WITH KEY MATNR = INT_DATA-MATNR
WERKS = INT_DATA-WERKS.
SELECT SINGLE * FROM MAKT WHERE MATNR = INT_DATA-MATNR.
INT_DATA-MAKTX = MAKT-MAKTX.
MODIFY INT_DATA.
CLEAR: INT_DATA, INT_DATA2.
ENDLOOP.
LOOP AT INT_DATA WHERE MENGE_O = 0 AND MENGE_RT = 0 AND
MENGE_CL = 0 AND MENGE_AD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND MENGE_BAL = 0.
DELETE IT_HEADER WHERE MATNR = INT_DATA-MATNR.
ENDLOOP.
DELETE INT_DATA WHERE MENGE_O = 0 AND MENGE_RT = 0 AND
MENGE_CL = 0 AND MENGE_AD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND MENGE_BAL = 0.
ENDFORM. "SELECTION
*& Form EVENTTAB_BUILD
text
-->P_GT_EVENTS[] text
FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 1
IMPORTING
ET_EVENTS = RT_EVENTS.
READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GT_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO RT_EVENTS.
ENDIF.
ENDFORM. " EVENTTAB_BUILD
FORM TOP_OF_PAGE *
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = LT_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE
FORM F4_FOR_VARIANT *
FORM F4_FOR_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE = G_SAVE
I_TABNAME_HEADER = G_TABNAME_HEADER
I_TABNAME_ITEM = G_TABNAME_ITEM
IMPORTING
E_EXIT = G_EXIT
ES_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF G_EXIT = SPACE.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDIF.
ENDFORM. "F4_FOR_VARIANT
*& Form PAI_OF_SELECTION_SCREEN
text
FORM PAI_OF_SELECTION_SCREEN.
IF NOT P_VARI IS INITIAL.
MOVE G_VARIANT TO GX_VARIANT.
MOVE P_VARI TO GX_VARIANT-VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT.
G_VARIANT = GX_VARIANT.
ELSE.
PERFORM VARIANT_INIT.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*& Form VARIANT_INIT
text
--> p1 text
<-- p2 text
FORM VARIANT_INIT.
CLEAR G_VARIANT.
G_VARIANT-REPORT = GT_REPID.
ENDFORM. " VARIANT_INIT
*& Form GET_OPENING_STOCK
text
FORM GET_OPENING_STOCK.
SELECT SUM( MZUBB ) SUM( MAGBB ) INTO (V_STOCK, V_STOCK1)
FROM S031 WHERE MATNR = ITAB-MATNR AND
WERKS = ITAB-WERKS AND
SPMON LT V_MONTH1 AND LGORT = ITAB-LGORT.
OSTOCK = V_STOCK1 - V_STOCK.
IF OSTOCK < 0.
OSTOCK = OSTOCK * -1.
ENDIF.
ENDFORM. " GET_OPENING_STOCK
*& Form check
text
FORM CHECK.
AUTHORITY-CHECK OBJECT 'M_IS_MATNR'
ID 'ACTVT' DUMMY
ID 'MATNR' FIELD MATNR-LOW.
IF SY-SUBRC <> 0.
MESSAGE E016(Z1) WITH MATNR-LOW.
ENDIF.
ENDFORM. "CHECK_AUTHORIZATION
*& Form EVENTTAB_BUILD
text
-->P_GT_EVENTS[] text
*FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 1
IMPORTING
ET_EVENTS = RT_EVENTS.
READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GT_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO RT_EVENTS.
ENDIF.
*ENDFORM. " EVENTTAB_BUILD
FORM TOP_OF_PAGE
*FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
*ENDFORM. "TOP_OF_PAGE
*& Form COMMENT_BUILD
text
-->P_GT_LIST_TOP_OF_PAGE[] text
FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE
SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
DATA: LV_PAGE_STRING(11),
LV_PAGE_NO(3).
PAGNO = SY-PAGNO.
DATA: PAGNO(5) TYPE C.
CLEAR
LS_LINE.
REFRESH LT_TOP_OF_PAGE.
CLEAR
LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Page Number'.
PAGNO = SY-PAGNO.
IF
PAGNO = 0.
PAGNO = 1.
ENDIF.
SHIFT PAGNO LEFT DELETING LEADING SPACE.
LS_LINE-INFO = PAGNO.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = TEXT-001.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'A'.
SELECT SINGLE * FROM T001W WHERE
WERKS IN WERKS.
CONCATENATE 'Name Of The Plant ' '-' T001W-NAME1 INTO
TXT SEPARATED BY SPACE.
LS_LINE-INFO = TXT.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR:TXT, LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = TEXT-002.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
IF WERKS-HIGH EQ SPACE.
CONCATENATE 'Plant : ' WERKS-LOW INTO TXT.
ELSE.
CONCATENATE 'FROM PLANT : ' WERKS-LOW 'TO PLANT : ' WERKS-HIGH INTO TXT SEPARATED BY SPACE.
ENDIF.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = TXT.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
IF BUDAT-HIGH EQ SPACE.
BUDAT-HIGH = BUDAT-LOW.
ENDIF.
CONCATENATE 'Date : From ' BUDAT-LOW6(2) '-' BUDAT-LOW4(2) '-'
BUDAT-LOW0(4) 'to' BUDAT-HIGH6(2) '-'
BUDAT-HIGH4(2) '-' BUDAT-HIGH0(4) INTO
TXT SEPARATED BY SPACE.
CLEAR LS_LINE.
LS_LINE-TYP = 'A'.
LS_LINE-INFO = TXT.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
ENDFORM. "COMMENT_BUILD
*& Form LAYOUT_INIT
text
-->P_GT_LAYOUT text
FORM LAYOUT_INIT USING RS_LAYOUT TYPE SLIS_LAYOUT_ALV.
RS_LAYOUT-DETAIL_POPUP = 'X'.
RS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " LAYOUT_INIT
*& Form BALANCE
text
--> p1 text
<-- p2 text
FORM BALANCE.
IF INT_DATA-SHKZG = 'S'.
MENGE_RE = INT_DATA-MENGE_O + INT_DATA-MENGE.
INT_DATA-MENGE_BAL = MENGE_RE.
INT_DATA-MENGE_RE = INT_DATA-MENGE.
ELSEIF INT_DATA-SHKZG = 'H'.
MENGE_RE = MENGE_RE - INT_DATA-MENGE.
INT_DATA-MENGE_BAL = MENGE_RE.
INT_DATA-MENGE_IS = INT_DATA-MENGE.
ENDIF.
ENDFORM. " BALANCE
Thanks & Regards,
Sreedhar.Hi,
try like this.........
get v_linct from system varaible sy-linct
describe table t_output lines lv_lines - Where
t_output is ur final internal table which is displayed
v_pagct = ( lv_lines div v_linct ) + 3.
write: 'PAGE NO:' , sy-pagno ,'/', v_pagct.
Madhavi -
How to add a push button in ALV Grid Top-of-page
Is it possible to add a push button to the top-of-page in Alv grid display?if yes, then how? I am not using OO ABAP and am using reuse_alv_grid_display with top-of-page event.
Hi,
I am not sure whether we can add push button in top-of -page or not. But instead of that if you want to add button on toolbar as per your requirement then follow below link. it will useful.
http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm
Ram. -
Reg : Top-of-page in classical report.
Hello all,
This is regarding the page count that needs to be written in top-of-page event depending on the data in the internal table.
I have internal table with feqw fields for example :
Field 1----- Field2
Val1----
text1
Val1----
text2
Val1----
text3
Val1----
text4
Val1----
text5
Val2----
text1
Val2----
text2
Val2----
text3
Val2----
text4
Let us assume each 'text' occupies half of page.
the VAL1 has 5 texts so it occupies 2.5 pages.
for this I want the pages to be displayed as 1 of 3, 2 of 3 and 3 of 3.
Then for the VAL2 will have 2 pages.
For this I want the pages to be dispalyed as 1 of 2 , 2 of 2.
Thisis an example I have given the no.of similar values in field1 may vary and length of text also vary.
with regards,
sandeep akella.
Edited by: sandeep akella on Jun 8, 2010 10:22 AMYou can see logo fully when you modify the code in top-of-page filling the header.
suppose you have top-of-page with heading and logo.
heading - you can give some space so that logo will come properly.
See the below sample code :
FS_LIST_COMMENTARY-TYP = 'S'.
FS_LIST_COMMENTARY-KEY = 'ANANTH'. -> fill empty value
FS_LIST_COMMENTARY-INFO = 'ANANTH KUMAR SUDANI'. -> fill empty value
APPEND FS_LIST_COMMENTARY TO T_LIST_COMMENTARY.
so depend upon your logo size ,you need to fill empty values.
Check the below link for top-of-page program:
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Check the below link for how to load logo
http://www.sap-img.com/fu002.htm
Thanks
Seshu -
Problem while displaying top of page in list display
Hi,
M facing problem in displaying top of page in list .
M using following methods:-
lr_outer_grid TYPE REF TO cl_salv_form_layout_grid,
lr_inner_grid TYPE REF TO cl_salv_form_layout_grid,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text.
For displaying the top of page m using event TOP_OF_PAGE.
CREATE OBJECT lr_outer_grid.
*Outer grid
lr_inner_grid = lr_outer_grid->create_grid(
row = 1
column = 1 ).
*... create lable information in inner_grid
User ID
lr_label = lr_inner_grid->create_label(
row = 1
column = 1
text = text-h03 ).
*... create text information in inner_grid
lr_text = lr_inner_grid->create_text(
row = 1
column = 2
text = sy-uname ).
*... set label for text
lr_label->set_label_for( lr_text ).
But while m going to do same coding for second parameter its not intializing length so adding extra spaces while displaying second row.
e.g
USERID abcdefghjik
PLANT jhk to hjk
I want that output should look like
USERID abcdefghjik
PLANT jhk to hjk
Please tell me the solution what should i do for avoiding extra spaceHi Neelema,
You could try this sample code.
[http://sap-img.com/fu037.htm]
[http://sap-img.com/abap/sample-alv-heading-in-alv.htm]
Regards,
Amit. -
Print with write statements from webynpro does not trigger top-of-page
Print launched from webdynpro application via application server created with write statements does not trigger top-of-page event. When print is done from sapgui it works ok. The idea is to reuse backend print which was created for sapgui with abap list made application log in webdynpro application.
Hi,
here a short extract like i do it:
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
HANDLE_PRINT_TOP_OF_PAGE
FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID,
ENDCLASS. "LCL_EVENT_HANDLER DEFINITION
* Event-Händer Implementierung
CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
METHOD HANDLE_PRINT_TOP_OF_PAGE.
PERFORM PRINT_TOP_OF_PAGE.
ENDMETHOD.
ENDCLASS.
CREATE OBJECT GR_EVENT_HANDLER.
SET HANDLER
GR_EVENT_HANDLER->HANDLE_PRINT_TOP_OF_PAGE FOR GR_ALVGRID_LEFT.
CALL METHOD GR_ALVGRID_LEFT->SET_TABLE_FOR_FIRST_DISPLAY
FORM PRINT_TOP_OF_PAGE.
LINSZ = SY-LINSZ - 16.
WRITE: / 'Report: ', SY-REPID,
AT LINSZ 'Datum:', SY-DATUM.
WRITE: / 'Benutzer: ', SY-UNAME,
AT LINSZ 'Zeit: ', SY-UZEIT.
ENDFORM.
hope it helps.
Regards, Dieter -
Problem in downloading top-of-page to excel
Hi All,
I have developed a report using OOALV. Im using split containers to display the data of Docking container.
The problem is when I'm downloading the report to excel, its only printing the main data from bottom container. Its not displaying the top-of-page data, which is printing in top container.
Here is the sample code, which Im using to print the top-of-page.
CALL METHOD o_document->new_line. (SAMPLE CODE)
***Fiscal Year
CLEAR:v_string.
CONCATENATE 'Run Date:'(143) v_print_date INTO v_string SEPARATED BY space.
CONDENSE v_string.
* Adding Text
CALL METHOD o_document->add_text
EXPORTING
text = v_string.
* Display the data
CALL METHOD o_document->display_document
EXPORTING
parent = o_top_container.
* Calling the method of ALV to process top of page
CALL METHOD alv_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_document.
Please advise me how to download the data along with the top of page from OOALV output.
Thanks,
PriyaHi Priya,
Sorry for the delay.. here
Simple explanation...
ABAP - OLE Automation using MS-Excel - Code Gallery - SCN Wiki
You can find a detail doc here
http://www.heyiamonline.com/abap/pdf/ABAPOLEAUTOMATION.pdf
Regards -
In ALV I want to align Top-Of-Page in Center which contains some TEXT
Hi Abap Gurus',
In ALV's i want to align TOP-OF-PAGE in center.
Which contains some TEXT.
Can you please help me out.
Points will be Given.
Many thanks
Anil Roy.hi anil
The header line is always left-justified .
We basically have three options for formatting :
S , A and H.
every line in Alv top-of-page is of 60 char length(slis_listheader-info).so i think the only option we have is to add required spaces to the left and display the required string
regards
navjot
reward if helpfull -
hi all ,
please let me know that ,can we use write statement to display top of page in ALV.if not suggest alternative.
thanks in advance.
janardhan.Hi Janajana,
Here is the code. Reward points if it helps you.
REPORT ZALV_SAMPLE.
* NO STANDARD PAGE HEADING
* LINE-COUNT 58
* LINE-SIZE 220.
TYPE-POOLS: SLIS. "for 'REUSE_ALV...list&grids'
* TABLES *
TABLES: KNA1. "General Data in Customer Master
* Internal data *
DATA: BEGIN OF LT_ALVTABLE OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
NAME2 LIKE KNA1-NAME2,
STRAS LIKE KNA1-STRAS,
PSTLZ LIKE KNA1-PSTLZ,
ORT01 LIKE KNA1-ORT01,
UMSA1 LIKE KNA1-UMSA1,
KTOKD LIKE KNA1-KTOKD,
END OF LT_ALVTABLE.
* data-statements that are necessary for the use of the ALV-grid
DATA: GT_XEVENTS TYPE SLIS_T_EVENT.
DATA: XS_EVENT TYPE SLIS_ALV_EVENT.
DATA: REPID TYPE SY-REPID.
DATA: ZTA_PRINT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA: LO_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: LO_ITABNAME TYPE SLIS_TABNAME.
DATA: LS_VARIANT TYPE DISVARIANT.
* Initialization *
INITIALIZATION.
* Parameters and select-options *
SELECT-OPTIONS SO_KUNNR FOR KNA1-KUNNR DEFAULT '2000' TO '2300'.
SELECT-OPTIONS SO_NAME FOR KNA1-NAME1.
PARAMETERS: PA_PSTCD AS CHECKBOX DEFAULT 'X'.
PARAMETERS: PA_VAR AS CHECKBOX DEFAULT 'X'.
* Start of main program *
START-OF-SELECTION.
PERFORM SELECT_RECORDS.
PERFORM PRINT_ALVLIST.
END-OF-SELECTION.
*& Form select_records
FORM SELECT_RECORDS.
SELECT * FROM KNA1 INTO CORRESPONDING FIELDS OF LT_ALVTABLE
WHERE KUNNR IN SO_KUNNR
AND NAME1 IN SO_NAME.
APPEND LT_ALVTABLE.
ENDSELECT.
ENDFORM. " select_records
*& Form print_alvlist
FORM PRINT_ALVLIST.
REPID = SY-REPID.
LO_ITABNAME = 'LT_ALVTABLE'. "NB: ONLY USE CAPITALS HERE!
* Fill the variables of the ALV-grid.
PERFORM SET_LAYOUT USING LO_LAYOUT. "Change layout-settings
PERFORM SET_EVENTS USING GT_XEVENTS."Set the events (top-page etc)
PERFORM FILL_STRUCTURE. "Read the structure of the itab
PERFORM MODIFY_STRUCTURE. "Modify itab's field-properties
* Sort the table
SORT LT_ALVTABLE BY KUNNR.
* Present the table using the ALV-grid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = ZTA_PRINT[]
IS_LAYOUT = LO_LAYOUT
IT_EVENTS = GT_XEVENTS
I_SAVE = 'A'
IS_VARIANT = LS_VARIANT
TABLES
T_OUTTAB = LT_ALVTABLE.
ENDFORM. " print_alvlist
*& Form SET_LAYOUT
FORM SET_LAYOUT USING PA_LAYOUT TYPE SLIS_LAYOUT_ALV.
* Minimize the columnwidth
PA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
* Give the table a striped pattern
PA_LAYOUT-ZEBRA = 'X'.
* Set the text of the line with totals
PA_LAYOUT-TOTALS_TEXT = 'Total:'.
* Set the text of the line with subtotals
PA_LAYOUT-SUBTOTALS_TEXT = 'Subtotal:'.
* Set the variant, as requested via the checkbox
IF PA_VAR = 'X'.
LS_VARIANT-VARIANT = '/ZLAYOUT'.
ELSE.
CLEAR LS_VARIANT-VARIANT.
ENDIF.
ENDFORM. " SET_LAYOUT
*& Form Set_events
* Appends the values of the events to the events-variable that is
* used by REUSE_ALV_LIST_DISPLAY
FORM SET_EVENTS USING PA_EVENTS TYPE SLIS_T_EVENT.
XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
XS_EVENT-FORM = 'XTOP_OF_LIST'.
APPEND XS_EVENT TO PA_EVENTS.
XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
XS_EVENT-FORM = 'XEND_OF_LIST'.
APPEND XS_EVENT TO PA_EVENTS.
XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENT-FORM = 'XTOP_OF_PAGE'.
APPEND XS_EVENT TO PA_EVENTS.
XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
XS_EVENT-FORM = 'XEND_OF_PAGE'.
APPEND XS_EVENT TO PA_EVENTS.
ENDFORM.
*& Form XTOP_OF_LIST
FORM XTOP_OF_LIST.
DATA LO_DATE(8).
CONCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM+2(2)
INTO LO_DATE.
WRITE: AT 1 'Report:'(T01), 20 'Reportname'(T02).
WRITE: AT 50 'Date:'(T03), LO_DATE.
NEW-LINE.
WRITE: AT 1 'Abap-name report: '(T04), SY-REPID.
WRITE: AT 50 'Page:'(T05), SY-CPAGE.
ENDFORM. "xtop_of_list
*& Form XEND_OF_LIST
FORM XEND_OF_LIST.
WRITE: 'Footer of the list'(002).
ENDFORM. "xend_of_list
*& Form XTOP_OF_PAGE
FORM XTOP_OF_PAGE.
WRITE:/ 'Top of the page.'(003).
*()*Here your selection-criteria can be printed
ENDFORM. "xtop-of-page
*& Form XEND_OF_PAGE
FORM XEND_OF_PAGE.
WRITE:/ 'End of the page.'(004).
ENDFORM. "xtop-of-page
*& Form FILL_STRUCTURE
FORM FILL_STRUCTURE.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = REPID
I_INTERNAL_TABNAME = LO_ITABNAME
I_INCLNAME = 'ZALV_SAMPLE'
CHANGING
CT_FIELDCAT = ZTA_PRINT[].
ENDFORM. " FILL_STRUCTURE
*& Form MODIFY_STRUCTURE
* Set the fieldproperties to your wishes
FORM MODIFY_STRUCTURE.
LOOP AT ZTA_PRINT.
CLEAR ZTA_PRINT-KEY.
CASE ZTA_PRINT-FIELDNAME.
WHEN 'KUNNR'. "Klantnummer
ZTA_PRINT-COL_POS = 0.
ZTA_PRINT-SELTEXT_S = 'Cstm'(H01).
ZTA_PRINT-SELTEXT_M = 'Customer'(H01).
ZTA_PRINT-SELTEXT_L = 'Customer is king'(H01).
WHEN 'NAME1'. "Name1
ZTA_PRINT-COL_POS = 1.
WHEN 'NAME2'. "Name 2 (now set to invisible)
ZTA_PRINT-COL_POS = 2.
ZTA_PRINT-NO_OUT = 'X'.
WHEN 'STRAS'. "Month
ZTA_PRINT-COL_POS = 3.
WHEN 'PSTLZ'. "Postcode
ZTA_PRINT-COL_POS = 4.
IF PA_PSTCD = ''.
ZTA_PRINT-NO_OUT = 'X'.
ELSE.
CLEAR ZTA_PRINT-NO_OUT.
ENDIF.
WHEN 'ORT01'. "Stad
ZTA_PRINT-COL_POS = 5.
WHEN 'UMSA1'. "Annual sales
ZTA_PRINT-COL_POS = 6.
WHEN 'KTOKD'. "
ZTA_PRINT-COL_POS = 7.
* when others. "set all other fields to invisible
* zta_print-no_out = 'X'.
ENDCASE.
MODIFY ZTA_PRINT.
ENDLOOP.
ENDFORM. " modify_structure
Regards,
Amit Mishra -
Wat is the diff. between at first and top of page
pls let me know
<b>AT - itab </b>
Syntax
LOOP AT itab result ...
[AT FIRST.
ENDAT.]
[AT NEW comp1.
ENDAT.
[AT NEW comp2.
ENDAT.
AT END OF comp2.
ENDAT.]
AT END OF comp1.
ENDAT.]
[AT LAST.
ENDAT.]
ENDLOOP.
Extras:
1. ... FIRST
2. ... |{END OF} comp
3. ... LAST
Effect
The statement block of a LOOP loop can contain control structures for control level processing. The respective control statement is AT. The statements AT and ENDAT define statement blocks that are executed at control breaks. Within these statement blocks, the statement SUM can be specified to total numeric components of a group level. In the case of output behavior result, the same applies as for LOOP AT.
So that group level processing can be executed correctly, the following rules should be noted:
After LOOP there should be no limiting condition cond specified.
The internal table must not be modified within the LOOP loop.
The work area wa specified in the LOOP statement after the INTO addition must be compatible with the line type of the table.
The content of a work area wa specified in the LOOP statement after the INTO addition must not be modified.
The prerequisite for control level processing is that the internal table is sorted in exactly the same sequence as the component of its line type - that is, first in accordance with the first component, then in accordance with the second component, and so on. The line structure and the corresponding sorting sequence gives a group structure of the content of the internal table, whose levels can be evaluated using AT statements. The AT-ENDAT control structures must be aligned one after the other, in accordance with the group structure.
The statement blocks within the AT-ENDAT control structures are listed if an appropriate control break is made in the current table line. Statements in the LOOP-ENDLOOP control structure that are not executed within an AT-ENDAT control structure are executed each time the loop is run through.
If the INTO addition is used in the LOOP statement to assign the content of the current line to a work area wa, its content is changed upon entry into the AT-ENDAT control structure as follows:
The components of the current group key will remain unchanged.
All components with a character-type, flat data type to the right of the current group key are set to character "*" at that position.
All the other components to the right of the current group key are set to their initial value.
When the AT-ENDAT control structure is exited, the content of the current table line is assigned to the entire work area wa.
Note
If the INTO addition is used in the LOOP statement, a field symbol can be specified outside of the classes after AT |{END OF}. The appropriate component of the work area wa is assigned to this field symbol.
Addition 1
... FIRST
Effect
First line of the internal table.
Addition 2
... |{END OF} comp
Effect
Beginning or end of a group of lines with the same content in the component comp1 comp2 ... and in the components to the left of comp1 comp2 .... The components comp1 comp2 ... can be specified, as described in the section Specification of Components, with the limitation that access to object attributes is not possible here.
Addition 3
... LAST
Effect
The last line of the internal table.
<b>TOP-OF-PAGE </b>
Syntax
TOP-OF-PAGE [DURING LINE-SELECTION].
Addition:
... DURING LINE-SELECTION
Effect
This statement defines an event block whose event is triggered by the ABAP runtime environment during the creation of a list. This occurs when a new page is started - that is, immediately before the first line in a new page is to be output. All list outputs that take place in the event block are placed below the standard page header of the list. You cannot output more lines than are available in the page within the event block. The NEW-PAGE statement is ignored within this event block.
The entire output written to the list in the event block belongs to the page header of the current list page. The top page header cannot be moved when you scroll vertically in a list displayed on the screen.
Addition
... DURING LINE-SELECTION
Effect
If you do not use an addition, an event block is triggered for event TOP-OF-PAGE during the creation of a basic list. If you use the addition DURING LINE-SELECTION, an event block is triggered for the corresponding events during the creation of details lists. You have to use system fields like sy-lsind to distinguish between the individual details lists.
Regards,
Pavan -
Regarding scrollable Top of Page in ALV's
hi all,
I am doing one report in ALV's, in that Columns are more . I am declaring some text above the some columns. when i am scrolling the columns(horizontally) Header is fixed.
I want scrollable (horizontally) top of page.
How can i achieve this.
Regards
RamiPls Co ordinate with your ABAPer as this is a pure techincal issue, Or post in ABAP Genaral Forum.
Maybe you are looking for
-
Okay so I have a huge question. Why am I paying retail prices for movies and getting horrible encoding. At least with a physical disc (which is the same price) I can rip it off at least with the 5.1 Surround Sound and with a MUCH MUCH better encoding
-
When I plug my iPad Air into charge it bleeps constantly whereas in the past it just bleeped once then charged
-
Hr: code for maternity.
hi sap, i have a requirment on HR but honestly speaking i dont have any idea of HR. but i have modify the current program to cater the functionality using the USER EXIT. I have found the USER EXIT but i dont know how to write the code in HR. Please h
-
HT1420 I am trying to authorise my computer using my Apple id.
I am being told to go to the itunes Store>authorise computer but there IS NO authorise computer? No advanced tab...
-
Can the Droid calendar and Outlook calendar on my home computer be synced?