ALV report that changes depending on Top-of-page info.
Hi,
The requirement is to create an ALV Grid Report that has a one of its field (say company code) in top-of-page. The values in ALV grid should be grouped for the company code. When the values for one company code end, the report should go to next page and have a next company code in top-of-page with its corresponding data.
While I know this can be done in classical report, I have not seen any example of ALV report for it. The solution to this could be just to have company code as one of the fields in ALV Grid and sort. But the client is unrelenting.
Please suggest.
Edited by: siddhesh kandalgaonkar on Jun 23, 2010 2:00 PM
Siddhesh,
You could define buttons / controls ... called 'next comp code' and 'prev comp code', and then in the events for these controls you could re-populate the alv data table with the data for each company code each time a button is pressed.
Hope this helps ...
Duane
Similar Messages
-
ALV report in ECC 6.0 'TOP-OF-PAGE'
Hi Friends,
Please, Kindly help me on below issue with Alv report for 'TOP-OF-PAGE' in ECC 6.0.
I have written the following code for "top-of-page' which is not getting the text given on this event, please help me if i committed any mistake in code.
type-pools : slis.
TABLES : KNA1,VBAK.
TYPES: BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
END OF ty_kna1.
TYPES: BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
ernam TYPE vbak-ernam,
netwr TYPE vbak-netwr,
END OF ty_vbak.
DATA : W_KNA1 TYPE TY_KNA1,
W_VBAK TYPE TY_VBAK,
I_KNA1 TYPE STANDARD TABLE OF TY_KNA1,
I_VBAK TYPE STANDARD TABLE OF TY_VBAK.
DATA : W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : V_REPID LIKE SY-REPID.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
SELECT-OPTIONS : S_KUNNR FOR KNA1-KUNNR.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCAT.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
END-OF-SELECTION.
PERFORM DISPLAY_DATA.
*& Form BUILD_FIELDCAT
text
--> p1 text
<-- p2 text
form BUILD_FIELDCAT .
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'KUNNR'.
W_FIELDCAT-SELTEXT_M = 'CUST NAME'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'LAND1'.
W_FIELDCAT-SELTEXT_M = 'COUNTRY'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'NAME1'.
W_FIELDCAT-SELTEXT_M = 'NAME'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'ORT01'.
W_FIELDCAT-SELTEXT_M = 'CITY'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
endform. " BUILD_FIELDCAT
*& Form DATA_RETRIEVAL
text
--> p1 text
<-- p2 text
form DATA_RETRIEVAL .
SELECT KUNNR LAND1 NAME1 ORT01 FROM KNA1
INTO TABLE I_KNA1
WHERE KUNNR IN S_KUNNR.
endform. " DATA_RETRIEVAL
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
form DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = V_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = I_KNA1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
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. " DISPLAY_DATA
*& Form BUILD_LISTHEADER
text
-->P_IT_LISTHEADER text
form BUILD_LISTHEADER using i_listheader TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'CUSTOMER DETAILS'.
HLINE-TYP = 'H'.
append hline to it_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
endform. " BUILD_LISTHEADER
*& Form EVENT_CALL
text
--> p1 text
<-- p2 text
form EVENT_CALL .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
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. " EVENT_CALL
*& Form POPULATE_EVENT
text
--> p1 text
<-- p2 text
form POPULATE_EVENT .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
Thanks in Advance,
Chandra.type-pools : slis.
TABLES : KNA1,VBAK.
TYPES: BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
END OF ty_kna1.
TYPES: BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
ernam TYPE vbak-ernam,
netwr TYPE vbak-netwr,
END OF ty_vbak.
DATA : W_KNA1 TYPE TY_KNA1,
W_VBAK TYPE TY_VBAK,
I_KNA1 TYPE STANDARD TABLE OF TY_KNA1,
I_VBAK TYPE STANDARD TABLE OF TY_VBAK.
DATA : W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : V_REPID LIKE SY-REPID.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
SELECT-OPTIONS : S_KUNNR FOR KNA1-KUNNR.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCAT.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
END-OF-SELECTION.
PERFORM DISPLAY_DATA.
*& Form BUILD_FIELDCAT
text
--> p1 text
<-- p2 text
form BUILD_FIELDCAT .
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'KUNNR'.
W_FIELDCAT-SELTEXT_M = 'CUST NAME'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'LAND1'.
W_FIELDCAT-SELTEXT_M = 'COUNTRY'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'NAME1'.
W_FIELDCAT-SELTEXT_M = 'NAME'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-TABNAME = 'I_KNA1'.
W_FIELDCAT-FIELDNAME = 'ORT01'.
W_FIELDCAT-SELTEXT_M = 'CITY'.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
endform. " BUILD_FIELDCAT
*& Form DATA_RETRIEVAL
text
--> p1 text
<-- p2 text
form DATA_RETRIEVAL .
SELECT KUNNR LAND1 NAME1 ORT01 FROM KNA1
INTO TABLE I_KNA1
WHERE KUNNR IN S_KUNNR.
endform. " DATA_RETRIEVAL
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
form DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = V_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = I_KNA1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
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. " DISPLAY_DATA
*& Form BUILD_LISTHEADER
text
-->P_IT_LISTHEADER text
form TOP_OF_PAGE using i_listheader TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'CUSTOMER DETAILS'.
HLINE-TYP = 'H'.
append hline to it_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
endform. " BUILD_LISTHEADER
*& Form EVENT_CALL
text
--> p1 text
<-- p2 text
form EVENT_CALL .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
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. " EVENT_CALL
*& Form POPULATE_EVENT
text
--> p1 text
<-- p2 text
form POPULATE_EVENT .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
just change the code as i have u will get it
plz reward points if useful -
I am wondering what this thing is.
It is an icon located on the far right of the page next to the search toolbar. It is shaped like a circle with a number on the bottom right edge. The number changes depending on which tab I have opened. An empty tab has no number. This page results in a 1. I have another page open which results in a 4. The number shows white in a small orange box. The circle is outlined with a thick black line. What does this icon indicate?
Thank you.
JohnHi John, I'm guessing that icon is created and updated by an extension. I'm not sure which one, though. Maybe something that is tracking the trackers, like Lightbeam? Have you tried hovering your mouse over the icon to see whether a tooltip appears, or clicking it?
-
Safari tries repeatedly to open a page. The page partially opens but then Safari reports that there's something wrong with page and I get an error message. This is happening at too many web sites for one site to be having issues.
I have a similar problem, Safari cannot load a complet page. It stalls e.g. ["38 of 42"]. sometimes it will complete loading after a long wait. just as often it will never complete the page,
The same thing happens in chrome and firefox but safari on my iPad works just fine.
I have the latest version of everything
I assume there is a system problem but cleaning up permissions does not help -
Printing an ALV Report: Header to be printed on first page only
Hi All,
I was just wondering if there's a way such that the header of an ALV report appears on the first page only when the report is printed out?
Thanks for your replies.
Edited by: Chris Estanislao on Sep 21, 2010 4:22 AMHi Chris,
Which ALV technique will you use to print out?? (LIST, GRID or something else...).
Please give us more information.
Thanks, -
ALV output download to excel with top of page
Hi,
i want to download ALV grid output to excel sheet including the top of page. i am using the icon in application tool bar. but only data's are download to excel sheet. i cannot download the top of page. with out write coding in program can we download it. if yes pls explain.
thanks.I'm sorry but I can't find FM with DOWNLOAD_EXCEL_*.
I want to know more detail thing.
plz. give answer to me anytime.
I'm waiting..
Edited by: Kwang Seop Kim on Sep 26, 2008 6:57 AM -
PO Form with Terms & Conditions that Change Depending on a Value in Another Field
Hi - I have read through the relevant topics in this forum and have attempted several of them without luck. I am currently working on a form in which there is an empty JFMain (I do not want to populate fields on this page since I don't want things in this page my "static" header - logos, title, etc. since the Terms and Conditions pages should not show any of this.) On my page 2, I have subforms for all my fields except my Terms and Conditions. (These fields are controlled by a data file.) On my remaining pages I have 3 sets of Terms and Conditions - all about a page long - hard-coded as text and placed in subforms with a dummy field off page to ensure they print. What I want to do is print the subforms from page 2 and then the applicable terms from page 3, 4, or 5 depending on the value in a field located in one of the subforms on page 2. What I currently get is my subforms and then ALL my terms printing. Any thoughts?
My preamble overrides look like this:
^define group:D_HEADER \field$POSITION\reserve".11",in\subformHEADER.
^define group:G_HEADER @group:D_HEADER.
^define group:dummy!FldNotAvail \groupG_Terms_Private_Commodity
^define group:dummy2!FldNotAvail \groupG_Terms_Private_Services
^define group:dummy3!FldNotAvail \groupG_Terms_Public
^define group:JfEndData!EndData @group:D_end.
I had to place the JFEndData! statement into the Preamble since the last subform with fields called before the Terms subforms has a global field from another subform above it. For whatever reason, it was duplicating this subform after printing the Terms and Conditions.
I tried adding a nested if statement into field that will control when I want each subform to print but it was ignored. I also tried hardcoding a group call into the preamble with the logic as well with no results. If someone has example code they can share, this would be great.I receive Adobe help forum posts via email and I've been saving a few for the pointers they contain. I have some saved that might help you out a bit...
A reply to the "Please can some one help me out......." post by Mr BoJangles on 10/29/2007 gives some information about forcing a subfield to be displayed.
A reply to the "Conditional logic" post by Marco Degl'Innocenti on 8/2/2006 gives information on initiating a subform based on the value of a field in the data stream.
A reply to the logic post by Marco DeglInnocenti on 2/22/07 also gives information on initiating a subform based on the value of a field.
I hope these can be of help. If you can't access them on the forum I can repost them. -
Creating drop down menus that change dependant upon previous menu
I need to create a drop down menu and then have the next drop down change its content based on the selection in the previous menu
Would anybody have any code that I could play around with that would help me achieve this?
Thanks!!
MarkHi Mark,
This should get you close:
Create a .cfc call it product, as in save as product.cfc
You'll need to change the datasource name and the FROM clause below on both queries.
<cfcomponent output="false">
<cffunction name="getProduct" access="remote" returnType="query">
<cfset var data="" />
<cfquery datasource="yourdb" name="data">
SELECT product_uid,product_title
FROM yourtable
</cfquery>
<cfreturn data>
</cffunction>
<cffunction name="getSubProduct" access="remote" returnType="query">
<cfargument name="product_uid" type="numeric" required="true">
<cfset var data="" />
<cfquery datasource="yourdb" name="data">
SELECT sub_uid,sub_title
FROM yourtable
WHERE sub_product_uid = #ARGUMENTS.product_uid#
</cfquery>
<cfreturn data>
</cffunction>
</cfcomponent>
Imbed this in your your cfm page:
<cfselect
name="Product"
bind="cfc:product.getProduct()"
style="width:387px;"
size="1"
multiple="No"
required="No"
display="product_title"
value="product_uid"
bindonLoad="True">
</cfselect>
<cfselect
name="Sub Product"
bind="cfc:product.getSubProduct({product_uid})"
style="width:387px;"
size="1"
multiple="No"
required="No"
display="sub_title"
value="sub_product_uid">
</cfselect> -
What is the bar that appears at the top of pages and how do I get rid of it?
Whenever a page is showing on the screen, a bar appears at the top of the page with a lot of squares ending with a square that says "diagnose." It sometimes causes a printing problem when the document prints out so small that you can't read it.
It sounds like some kind of advertising. Often behaviors that affect multiple sites are caused by an add-on, particularly an extension. You may want to review your extensions on the following page and disable ALL nonessential extensions.
orange Firefox button ''or'' classic Tools menu > Add-ons > Extensions category
After restarting Firefox, is the bar gone? -
I just seen where it says Windows 32 is not a valid Application. How do I fix that? Will not let me install anything either.
Hi Barbara,
I had a similar problem recently and using the "more like this" feature I discovered an answer. To a problem posed by Holo7, who like myself was a newbie on this platform, b noir proposed a solution to Holo7's problem that also worked with my problem. It involves downloading a version of MS Windows Instal Cleanup and using it to completely remove all traces of the old version.
If you look at my problem (follow OldGit66) and the link to Holo7's problem then you will find b noir's answer which I think may help you. I am new around here so you might want to wait for one of the higher status correspondents.
Regards
John -
ALV sums of lines depending on value of field of the line?
Hi,
We have an ALV and would like to get the sums depending on the value of a field of each line.
For example: imagine we have an ALV, and there are two kinds of lines: one have a counter=1, and others have a counter=2. Is it possible to receive two totals in the ALV, one for the lines that have counter=1, and one for the lines that have counter=2? And that when a filter is being applied, the sums change automatically?
Thx!Hi,
Please the below code which ill help to change the subtotal text, you need do manula total and replace with the wa of the subtotal with you calculated sum. In the below code i replaced a break point where you need to add your coding
*& Report Z_ALV_SUBTOTAL
REPORT Z_ALV_SUBTOTAL.
*& Table declaration
TABLES: EKKO.
*& Type pool declaration
TYPE-POOLS: SLIS. " Type pool for ALV
*& Selection screen
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN.
*& Type declaration
*Type declaration for internal table to store EKPO data
TYPES: BEGIN OF X_DATA,
EBELN TYPE CHAR30, " Document no.
EBELP TYPE EBELP, " Item no
MATNR TYPE MATNR, " Material no
MATNR1 TYPE MATNR, " Material no
WERKS TYPE WERKS_D, " Plant
WERKS1 TYPE WERKS_D, " Plant
NTGEW TYPE ENTGE, " Net weight
GEWE TYPE EGEWE, " Unit of weight
END OF X_DATA.
*& Internal table declaration
DATA:
* INTERNAL TABLE TO STORE EKPO DATA
I_EKPO TYPE STANDARD TABLE OF X_DATA INITIAL SIZE 0,
Internal table for storing field catalog information
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
Internal table for Top of Page info. in ALV Display
I_ALV_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
Internal table for ALV Display events
I_EVENTS TYPE SLIS_T_EVENT,
Internal table for storing ALV sort information
I_SORT TYPE SLIS_T_SORTINFO_ALV,
I_EVENT TYPE SLIS_T_EVENT.
*& Work area declaration
DATA:
WA_EKKO TYPE X_DATA,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_EVENTS TYPE SLIS_ALV_EVENT,
WA_SORT TYPE SLIS_SORTINFO_ALV.
*& Constant declaration
CONSTANTS:
C_HEADER TYPE CHAR1 VALUE 'H', "Header in ALV
C_ITEM TYPE CHAR1 VALUE 'S'.
*& Start-of-selection event
START-OF-SELECTION.
Select data from ekpo
SELECT EBELN " Doc no
EBELP " Item
MATNR " Material
MATNR " Material
WERKS " Plant
WERKS " Plant
NTGEW " Quantity
GEWEI " Unit
FROM EKPO
INTO TABLE I_EKPO
WHERE EBELN IN S_EBELN
AND NTGEW NE '0.00'.
IF SY-SUBRC = 0.
SORT I_EKPO BY EBELN EBELP MATNR .
ENDIF.
* TO BUILD THE PAGE HEADER
PERFORM SUB_BUILD_HEADER.
* TO PREPARE FIELD CATALOG
PERFORM SUB_FIELD_CATALOG.
* PERFORM TO POPULATE THE LAYOUT STRUCTURE
PERFORM SUB_POPULATE_LAYOUT.
* PERFORM TO POPULATE THE SORT TABLE.
PERFORM SUB_POPULATE_SORT.
PERFORM TO POPULATE ALV EVENT
PERFORM SUB_GET_EVENT.
END-OF-SELECTION.
* PERFORM TO DISPLAY ALV REPORT
PERFORM SUB_ALV_REPORT_DISPLAY.
*& Form sub_build_header
To build the header
No Parameter
FORM SUB_BUILD_HEADER .
* LOCAL DATA DECLARATION
DATA: L_SYSTEM TYPE CHAR10 , "System id
L_R_LINE TYPE SLIS_LISTHEADER, "Hold list header
L_DATE TYPE CHAR10, "Date
L_TIME TYPE CHAR10, "Time
L_SUCCESS_RECORDS TYPE I, "No of success records
L_TITLE(300) TYPE C. "Title
Title Display
L_R_LINE-TYP = C_HEADER. " header
L_TITLE = 'Test report'(001).
L_R_LINE-INFO = L_TITLE.
APPEND L_R_LINE TO I_ALV_TOP_OF_PAGE.
CLEAR L_R_LINE.
* RUN DATE DISPLAY
CLEAR L_DATE.
L_R_LINE-TYP = C_ITEM. " Item
WRITE: SY-DATUM TO L_DATE MM/DD/YYYY.
L_R_LINE-KEY = 'Run Date :'(002).
L_R_LINE-INFO = L_DATE.
APPEND L_R_LINE TO I_ALV_TOP_OF_PAGE.
CLEAR: L_R_LINE, L_DATE.
ENDFORM. " sub_build_header
*& Form sub_field_catalog
Build Field Catalog
No Parameter
FORM SUB_FIELD_CATALOG .
* BUILD FIELD CATALOG
PERFORM SUB_FILL_ALV_FIELD_CATALOG USING:
'01' '01' 'EBELN' 'I_EKPO' 'L' 'Doc No'(003) ' ' ' ' ' ' ' ',
'01' '02' 'EBELP' 'I_EKPO' 'L' 'Item No'(004) 'X' 'X' ' ' ' ',
'01' '03' 'MATNR' 'I_EKPO' 'L' 'Material No'(005) 'X' ' ' ' ' ' ',
'01' '03' 'MATNR1' 'I_EKPO' 'L' 'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L' 'Plant'(006) 'X' ' ' ' ' ' ',
'01' '04' 'WERKS1' 'I_EKPO' 'L' 'Plant'(006) ' ' ' ' ' ' ' ',
'01' '05' 'NTGEW' 'I_EKPO' 'R' 'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.
ENDFORM. " sub_field_catalog*
*& Form sub_fill_alv_field_catalog
*& For building Field Catalog
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
FORM SUB_FILL_ALV_FIELD_CATALOG USING P_ROWPOS TYPE SYCUROW
P_COLPOS TYPE SYCUCOL
P_FLDNAM TYPE FIELDNAME
P_TABNAM TYPE TABNAME
P_JUSTIF TYPE CHAR1
P_SELTEXT TYPE DD03P-SCRTEXT_L
P_OUT TYPE CHAR1
P_TECH TYPE CHAR1
P_QFIELD TYPE SLIS_FIELDNAME
P_QTAB TYPE SLIS_TABNAME.
* LOCAL DECLARATION FOR FIELD CATALOG
DATA: WA_LFL_FCAT TYPE SLIS_FIELDCAT_ALV.
WA_LFL_FCAT-ROW_POS = P_ROWPOS. "Row
WA_LFL_FCAT-COL_POS = P_COLPOS. "Column
WA_LFL_FCAT-FIELDNAME = P_FLDNAM. "Field Name
WA_LFL_FCAT-TABNAME = P_TABNAM. "Internal Table Name
WA_LFL_FCAT-JUST = P_JUSTIF. "Screen Justified
WA_LFL_FCAT-SELTEXT_L = P_SELTEXT. "Field Text
WA_LFL_FCAT-NO_OUT = P_OUT. "No output
WA_LFL_FCAT-TECH = P_TECH. "Technical field
WA_LFL_FCAT-QFIELDNAME = P_QFIELD. "Quantity unit
WA_LFL_FCAT-QTABNAME = P_QTAB . "Quantity table
IF P_FLDNAM = 'NTGEW'.
WA_LFL_FCAT-DO_SUM = 'X'.
ENDIF.
APPEND WA_LFL_FCAT TO I_FIELDCAT.
CLEAR WA_LFL_FCAT.
ENDFORM. " sub_fill_alv_field_catalog
*& Form sub_populate_layout
Populate ALV layout
No Parameter
FORM SUB_POPULATE_LAYOUT .
CLEAR WA_LAYOUT.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'." Optimization of Col width
ENDFORM. "SUB_POPULATE_LAYOUT
" sub_populate_layout
*& Form sub_populate_sort
Populate ALV sort table
No Parameter
FORM SUB_POPULATE_SORT .
* SORT ON MATERIAL
WA_SORT-SPOS = '01' .
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-TABNAME = 'I_EKPO'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT .
CLEAR WA_SORT."* SORT ON PLANT
WA_SORT-SPOS = '02'.
WA_SORT-FIELDNAME = 'WERKS'.
WA_SORT-TABNAME = 'I_EKPO'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT .
CLEAR WA_SORT.
ENDFORM. " sub_populate_sort
*& Form sub_get_event
Get ALV grid event and pass the form name to subtotal_text
event
No Parameter
FORM SUB_GET_EVENT .
CONSTANTS : C_FORMNAME_SUBTOTAL_TEXT TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.
DATA: L_S_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 4
IMPORTING
ET_EVENTS = I_EVENT
EXCEPTIONS
LIST_TYPE_WRONG = 0
OTHERS = 0.
* SUBTOTAL
READ TABLE I_EVENT INTO L_S_EVENT WITH KEY NAME = SLIS_EV_SUBTOTAL_TEXT.
IF SY-SUBRC = 0.
MOVE C_FORMNAME_SUBTOTAL_TEXT TO L_S_EVENT-FORM.
MODIFY I_EVENT FROM L_S_EVENT INDEX SY-TABIX.
ENDIF.
ENDFORM. "SUB_GET_EVENT
" sub_get_event
*& Form sub_alv_report_display
For ALV Report Display
No Parameter
FORM SUB_ALV_REPORT_DISPLAY .
DATA: L_REPID TYPE SYREPID .
L_REPID = SY-REPID .
* THIS FUNCTION MODULE FOR DISPLAYING THE ALV REPORT
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = L_REPID
I_CALLBACK_TOP_OF_PAGE = 'SUB_ALV_TOP_OF_PAGE'
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = I_FIELDCAT
IT_SORT = I_SORT
IT_EVENTS = I_EVENT
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_EKPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.
ENDFORM. " sub_alv_report_display
FORM sub_alv_top_of_page
Call ALV top of page
No parameter
FORM SUB_ALV_TOP_OF_PAGE. "#EC CALLED
To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_ALV_TOP_OF_PAGE.
ENDFORM. "alv_top_of_page
*& Form subtotal_text
Build subtotal text
P_total Total
p_subtot_text Subtotal text info
FORM SUBTOTAL_TEXT CHANGING
P_TOTAL TYPE ANY
P_SUBTOT_TEXT TYPE SLIS_SUBTOT_TEXT.
Material level sub total
IF P_SUBTOT_TEXT-CRITERIA = 'MATNR'.
P_SUBTOT_TEXT-DISPLAY_TEXT_FOR_SUBTOTAL = 'Materia l'(009).
BREAK-POINT.
here calucate the total and change the p_total
ENDIF.
* PLANT LEVEL SUB TOTAL
IF P_SUBTOT_TEXT-CRITERIA = 'WERKS'.
P_SUBTOT_TEXT-DISPLAY_TEXT_FOR_SUBTOTAL = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_text -
Problem with subtotal calculation in ALV reports
Hi All,
I am doing one program for calculating subtoals in ALV . For this i want to display subtotal text at each envey subtotal 's row.
For that i have created one form 'SUB_SUBTOT_TEXT' and it has given to IT_EVENTS-FORM. But SUB_SUBTOT_TEXT Form is not called by IT_EVENTS event.
what are all the mandatories for displaying subtotal text.
Can any one please help me.
Thanks in Advance.Hi Sree,
*& Table declaration
&----TABLES: ekko.&----
*& Type pool declaration
TYPE-POOLS: slis. " Type pool for ALV&----
*& Selection screen
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.&----
*& Type declaration
&----* Type declaration for internal table to store EKPO data
TYPES: BEGIN OF x_data,
ebeln TYPE char30, " Document no.
ebelp TYPE ebelp, " Item no
matnr TYPE matnr, " Material no
matnr1 TYPE matnr, " Material no
werks TYPE werks_d, " Plant
werks1 TYPE werks_d, " Plant
ntgew TYPE entge, " Net weight
gewe TYPE egewe, " Unit of weight
END OF x_data.&----
*& Internal table declaration
DATA:* Internal table to store EKPO data
i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
Internal table for storing field catalog information
i_fieldcat TYPE slis_t_fieldcat_alv,
Internal table for Top of Page info. in ALV Display
i_alv_top_of_page TYPE slis_t_listheader,
Internal table for ALV Display events
i_events TYPE slis_t_event,
Internal table for storing ALV sort information
i_sort TYPE slis_t_sortinfo_alv,
i_event TYPE slis_t_event.&----
*& Work area declaration
&----DATA:
wa_ekko TYPE x_data,
wa_layout TYPE slis_layout_alv,
wa_events TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.&----
*& Constant declaration
&----CONSTANTS:
c_header TYPE char1
VALUE 'H', "Header in ALV
c_item TYPE char1
VALUE 'S'.&----
*& Start-of-selection event
&----START-OF-SELECTION.* Select data from ekpo
SELECT ebeln " Doc no
ebelp " Item
matnr " Material
matnr " Material
werks " Plant
werks " Plant
ntgew " Quantity
gewei " Unit
FROM ekpo
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln
AND ntgew NE '0.00'. IF sy-subrc = 0.
SORT i_ekpo BY ebeln ebelp matnr .
ENDIF.* To build the Page header
PERFORM sub_build_header.* To prepare field catalog
PERFORM sub_field_catalog.* Perform to populate the layout structure
PERFORM sub_populate_layout.* Perform to populate the sort table.
PERFORM sub_populate_sort.* Perform to populate ALV event
PERFORM sub_get_event.END-OF-SELECTION.* Perform to display ALV report
PERFORM sub_alv_report_display.
*& Form sub_build_header
To build the header
No Parameter
FORM sub_build_header .* Local data declaration
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE char10, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
Title Display
l_r_line-typ = c_header. " header
l_title = 'Test report'(001).
l_r_line-info = l_title.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR l_r_line.* Run date Display
CLEAR l_date.
l_r_line-typ = c_item. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'(002).
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.ENDFORM. " sub_build_header
*& Form sub_field_catalog
Build Field Catalog
No Parameter
FORM sub_field_catalog .* Build Field Catalog
PERFORM sub_fill_alv_field_catalog USING: '01' '01' 'EBELN' 'I_EKPO' 'L'
'Doc No'(003) ' ' ' ' ' ' ' ', '01' '02' 'EBELP' 'I_EKPO' 'L'
'Item No'(004) 'X' 'X' ' ' ' ', '01' '03' 'MATNR' 'I_EKPO' 'L'
'Material No'(005) 'X' 'X' ' ' ' ', '01' '03' 'MATNR1' 'I_EKPO' 'L'
'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L'
'Plant'(006) 'X' 'X' ' ' ' ', '01' '04' 'WERKS1' 'I_EKPO' 'L'
'Plant'(006) ' ' ' ' ' ' ' ', '01' '05' 'NTGEW' 'I_EKPO' 'R'
'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM. " sub_field_catalog&----
*& Form sub_fill_alv_field_catalog
*& For building Field Catalog
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
FORM sub_fill_alv_field_catalog USING p_rowpos TYPE sycurow
p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_tabnam TYPE tabname
p_justif TYPE char1
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname.* Local declaration for field catalog
DATA: wa_lfl_fcat TYPE slis_fieldcat_alv. wa_lfl_fcat-row_pos = p_rowpos. "Row
wa_lfl_fcat-col_pos = p_colpos. "Column
wa_lfl_fcat-fieldname = p_fldnam. "Field Name
wa_lfl_fcat-tabname = p_tabnam. "Internal Table Name
wa_lfl_fcat-just = p_justif. "Screen Justified
wa_lfl_fcat-seltext_l = p_seltext. "Field Text
wa_lfl_fcat-no_out = p_out. "No output
wa_lfl_fcat-tech = p_tech. "Technical field
wa_lfl_fcat-qfieldname = p_qfield. "Quantity unit
wa_lfl_fcat-qtabname = p_qtab . "Quantity table IF p_fldnam = 'NTGEW'.
wa_lfl_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_lfl_fcat TO i_fieldcat.
CLEAR wa_lfl_fcat.
ENDFORM. " sub_fill_alv_field_catalog&----
*& Form sub_populate_layout
Populate ALV layout
No Parameter
FORM sub_populate_layout . CLEAR wa_layout.
wa_layout-colwidth_optimize = 'X'." Optimization of Col widthENDFORM. " sub_populate_layout&----
*& Form sub_populate_sort
Populate ALV sort table
No Parameter
FORM sub_populate_sort .* Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.* Sort on plant
wa_sort-spos = '02'.
wa_sort-fieldname = 'WERKS'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM. " sub_populate_sort&----
*& Form sub_get_event
Get ALV grid event and pass the form name to subtotal_text
event
No Parameter
FORM sub_get_event .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
'SUBTOTAL_TEXT'. DATA: l_s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.* Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.ENDFORM. " sub_get_event&----
*& Form sub_alv_report_display
For ALV Report Display
No Parameter
FORM sub_alv_report_display .
DATA: l_repid TYPE syrepid .
l_repid = sy-repid .* This function module for displaying the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = i_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.ENDFORM. " sub_alv_report_display&----
FORM sub_alv_top_of_page
Call ALV top of page
No parameter
----FORM sub_alv_top_of_page. "#EC CALLED* To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page.
ENDFORM. "alv_top_of_page&----
*& Form subtotal_text
Build subtotal text
P_total Total
p_subtot_text Subtotal text info
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.* Plant level sub total
IF p_subtot_text-criteria = 'WERKS'.
p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_text
Hopes its helpful.
Regards,
Raj. -
How will i create ALV Report that will show the details of order like order no, order date, customer, product code & description, order quantity and value along with the details of dispatch of those orders like invoice no, invoice date, invoice quantity and pending order quantity.
plz mention the detail coding
Tahnks,
Priya RanjanHi,
See the following example and change it according to ur requirement.
*INTERACTIVE ALV REPORTS***
*& Report ZJE_ALV_INTRACTIVE1
REPORT zje_alv_intractive2.
TYPE-POOLS: slis.
TABLES: kna1, vbak ,vbap.
*Type Declerations*****************************
TYPES: BEGIN OF ty_kna1,
xcpdk LIKE kna1-xcpdk,
kunnr LIKE kna1-kunnr,
land1 LIKE kna1-land1,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
END OF ty_kna1.
TYPES: BEGIN OF ty_vbak,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
ernam LIKE vbak-ernam,
netwr LIKE vbak-netwr,
END OF ty_vbak.
TYPES: BEGIN OF ty_vbap,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
END OF ty_vbap.
TYPES: BEGIN OF ty_mara,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
matkl LIKE mara-matkl,
meins LIKE mara-meins,
END OF ty_mara.
*Data Declerations*****************************
DATA: it_kna1 TYPE STANDARD TABLE OF ty_kna1,
wa_kna1 TYPE ty_kna1.
DATA: it_vbak TYPE STANDARD TABLE OF ty_vbak,
wa_vbak TYPE ty_vbak.
DATA: it_vbap TYPE STANDARD TABLE OF ty_vbap,
wa_vbap TYPE ty_vbap.
DATA: it_mara TYPE STANDARD TABLE OF ty_mara,
wa_mara TYPE ty_mara.
DATA: list1 TYPE i VALUE 0.
DATA: list(5) TYPE c .
DATA: page(5) TYPE c.
DATA: wa_layout TYPE slis_layout_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_event_kna1 TYPE slis_t_event,
wa_event_kna1 TYPE slis_alv_event,
it_event_vbak TYPE slis_t_event,
wa_event_vbak TYPE slis_alv_event,
it_event_vbap TYPE slis_t_event,
wa_event_vbap TYPE slis_alv_event,
it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader,
it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
DATA: i_title_kna1 TYPE lvc_title VALUE 'FIRST LIST DISPLAYED',
i_title_vbak TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED',
i_title_vbap TYPE lvc_title VALUE 'TERTIARY LIST DISPLAYED'.
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr DEFAULT 1000 TO 1500.
*Initialization********************************
INITIALIZATION.
PERFORM layout.
PERFORM fieldcat_kna1.
PERFORM event_kna1.
PERFORM eventpopulate_kna1.
*START OF SELECTION****************************
START-OF-SELECTION.
PERFORM datafetch_kna1.
PERFORM displaygrid_kna1.
*& Form layout
text
--> p1 text
<-- p2 text
FORM layout .
wa_layout-zebra = 'X'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-totals_text = 'GRAND_TOTAL'.
wa_layout-subtotals_text = 'SUB_TOTAL'.
wa_layout-edit = 'X'.
wa_layout-Box_fieldname = 'X'.
ENDFORM. " layout
*FIELD CATALOUGE*******************************
*& Form fieldcat_kna1
text
--> p1 text
<-- p2 text
FORM fieldcat_kna1 .
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-fieldname = 'XCPDK'.
wa_fieldcat-seltext_l = 'CHECK'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 5.
wa_fieldcat-tabname = 'IT_KNA1'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-emphasize = 'C11'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'KUNNR'.
wa_fieldcat-seltext_l = 'CUSTOMER NUMBER'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-tabname = 'IT_KNA1'.
wa_fieldcat-key = 'X'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 2.
wa_fieldcat-emphasize = 'C21'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LAND1'.
wa_fieldcat-seltext_l = 'COUNTRY CODE'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-tabname = 'IT_KNA1'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 5.
wa_fieldcat-emphasize = 'C31'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_l = 'CUSTOMER NAME'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 35.
wa_fieldcat-tabname = 'IT_KNA1'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C71'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ORT01'.
wa_fieldcat-seltext_l = 'COUNTRY '.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-tabname = 'IT_KNA1'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 4.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " fieldcat_kna1
*& Form FIELDCAT_VBAK
text
--> p1 text
<-- p2 text
FORM fieldcat_vbak .
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'VBELN'.
wa_fieldcat-seltext_l = 'SALES ORDER'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-key = 'X'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-emphasize = 'C71'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERDAT'.
wa_fieldcat-seltext_l = 'CREATED ON'.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-outputlen = 35.
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-seltext_l = 'CREATED BY'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 35.
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 2.
wa_fieldcat-emphasize = 'C61'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-seltext_l = 'NET VALUE'.
wa_fieldcat-datatype = 'CURR'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 4.
wa_fieldcat-emphasize = 'C91'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " FIELDCAT_VBAK
*& Form fieldcat_vbap
text
--> p1 text
<-- p2 text
FORM fieldcat_vbap .
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'VBELN'.
wa_fieldcat-seltext_l = 'SALES ORDER'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 25.
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-key = 'X'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-emphasize = 'C11'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'POSNR'.
wa_fieldcat-seltext_l = 'ITEM NUMBER'.
wa_fieldcat-datatype = 'NUMC'.
wa_fieldcat-outputlen = 25.
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 2.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_l = 'MATERIAL NUMBER'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 30.
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C61'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATWA'.
wa_fieldcat-seltext_l = 'MATERIAL ENTERED'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 25.
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C71'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATKL'.
wa_fieldcat-seltext_l = 'MATERIAL GROUP'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 25.
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C81'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " fieldcat_vbap
*& Form fieldcat_MARA
text
--> p1 text
<-- p2 text
FORM fieldcat_mara .
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_l = 'MATERIAL NUMBER'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 15.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-key = 'X'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-seltext_l = 'MATERIAL TYPE'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 15.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATKL'.
wa_fieldcat-seltext_l = 'MATERIAL GROUP'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-outputlen = 15.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-seltext_l = 'UNITS OF MEASUREMENT'.
wa_fieldcat-datatype = 'UNIT'.
wa_fieldcat-outputlen = 22.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-emphasize = 'C51'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " fieldcat_MARA
*END OF FIELD CATLOUGE*************************
*EVENT CALLS***********************************
*& Form event
text
--> p1 text
<-- p2 text
FORM event_kna1.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_event_kna1
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
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. " event
*& Form event_vbak
text
--> p1 text
<-- p2 text
FORM event_vbak .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_event_vbak
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
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. " event_vbak
*& Form event_vbaP
text
--> p1 text
<-- p2 text
FORM event_vbap .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_event_vbap
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
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. " event_vbaP
*END OF EVENT CALLS****************************
*EVENT POPULATE********************************
*& Form eventpopulate
text
--> p1 text
<-- p2 text
FORM eventpopulate_kna1.
READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_event_kna1-form = 'TOP_OF_PAGE'.
MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
ENDIF.
READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'END_OF_LIST'.
IF sy-subrc = 0.
wa_event_kna1-form = 'END_OF_LIST'.
MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
ENDIF.
READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'USER_COMMAND'.
IF sy-subrc EQ 0.
wa_event_kna1-form = 'USER_COMMAND'.
MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
ENDIF.
ENDFORM. " eventpopulate
*& Form eventpopulate_vbak
text
--> p1 text
<-- p2 text
FORM eventpopulate_vbak .
READ TABLE it_event_vbak INTO wa_event_vbak WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_event_vbak-form = 'TOP_OF_PAGE_1'.
MODIFY it_event_vbak FROM wa_event_vbak TRANSPORTING form WHERE name = wa_event_vbak-name.
ENDIF.
READ TABLE it_event_vbak INTO wa_event_vbak WITH KEY name = 'USER_COMMAND'.
IF sy-subrc EQ 0.
wa_event_vbak-form = 'USER_COMMAND_1'.
MODIFY it_event_vbak FROM wa_event_vbak TRANSPORTING form WHERE name = wa_event_vbak-name.
ENDIF.
ENDFORM. " eventpopulate_vbak
*& Form eventpopulate_vbap
text
--> p1 text
<-- p2 text
FORM eventpopulate_vbap .
READ TABLE it_event_vbap INTO wa_event_vbap WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_event_vbap-form = 'TOP_OF_PAGE_2'.
MODIFY it_event_vbap FROM wa_event_vbap TRANSPORTING form WHERE name = wa_event_vbap-name.
ENDIF.
READ TABLE it_event_vbap INTO wa_event_vbap WITH KEY name = 'USER_COMMAND_3'.
IF sy-subrc = 0.
wa_event_vbap-form = 'USER_COMMAND_3'.
MODIFY it_event_vbap FROM wa_event_vbap TRANSPORTING form WHERE name = wa_event_vbap-name.
ENDIF.
ENDFORM. " eventpopulate_vbap
*END OF EVENT POPULATE*************************
**SUBROUTINE FOR PAGE **************************
*& Form TOP_OF_PAGE
text
FORM top_of_page.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Customer Details' .
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_listheader-info. "todays date
APPEND wa_listheader TO it_listheader.
CLEAR: wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'No of Records'.
wa_listheader-info = list.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Page No '.
wa_listheader-info = page.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader
i_logo = 'JELOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM =
REFRESH it_listheader.
ENDFORM. "TOP_OF_PAGE
*& Form TOP_OF_PAGE1
text
FORM top_of_page_1.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Sales Details'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_listheader-info. "todays date
APPEND wa_listheader TO it_listheader.
CLEAR: wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'No of Records'.
wa_listheader-info = list.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Page No '.
wa_listheader-info = page.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader
i_logo = 'JELOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM =
REFRESH it_listheader.
ENDFORM. "TOP_OF_PAGE1
*& Form TOP_OF_PAGE_2
text
FORM top_of_page_2.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Item Details' .
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_listheader-info. "todays date
APPEND wa_listheader TO it_listheader.
CLEAR: wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'No of Records'.
wa_listheader-info = list.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Page No '.
wa_listheader-info = page.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM =
REFRESH it_listheader.
ENDFORM. "TOP_OF_PAGE_2
**END FOR SUBROUTINES OF TOP OF PAGE ***********
*SUBROUTINE FOR END OF LIST*******************
*& Form END_OF_LIST
text
FORM end_of_list.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Page No '.
wa_listheader-info = page.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader
i_logo = 'JELOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM =
REFRESH it_listheader.
REFRESH it_listheader.
ENDFORM. "END_OF_LIST
*& Form datafetch_kna1
text
--> p1 text
<-- p2 text
FORM datafetch_kna1 .
SELECT xcpdk kunnr land1 name1 ort01
FROM kna1
INTO TABLE it_kna1
WHERE kunnr IN s_kunnr.
DESCRIBE TABLE it_kna1 LINES list1.
list = list1.
ENDFORM. " datafetch_kna1
*& Form displaygrid_kna1
text
--> p1 text
<-- p2 text
FORM displaygrid_kna1 .
page = sy-pagno.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ''
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = i_title_kna1
I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = it_event_kna1
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_kna1
EXCEPTIONS
program_error = 1
OTHERS = 2
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. " displaygrid_kna1
*& Form USER_COMMAND
text
-->UCOMM text
-->R_SELFIELD text
FORM user_command
USING ucomm TYPE sy-ucomm
r_selfield TYPE slis_selfield.
SELECT kunnr vbeln erdat ernam netwr
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak
WHERE kunnr = r_selfield-value.
PERFORM fieldcat_vbak.
PERFORM event_vbak.
PERFORM eventpopulate_vbak.
PERFORM sort.
PERFORM displaygrid_vbak.
ENDFORM. "USER_COMMAND
*& Form sort
text
--> p1 text
<-- p2 text
FORM sort .
wa_sort-fieldname = 'ERNAM'.
wa_sort-tabname = 'IT_VBAK'.
wa_sort-subtot = 'X'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
ENDFORM. " sort
*& Form DISPLAYGRID_VBAK
text
--> p1 text
<-- p2 text
FORM displaygrid_vbak .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND_1'
i_callback_top_of_page = 'TOP_OF_PAGE_1'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ''
i_grid_title = i_title_vbak
I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = it_event_vbak
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_vbak
EXCEPTIONS
program_error = 1
OTHERS = 2
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. " DISPLAYGRID_VBAK
*& Form USER_COMMAND1
text
FORM user_command_1
USING ucomm LIKE sy-ucomm
r_selfield1 TYPE slis_selfield.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE it_vbap
WHERE vbeln = r_selfield1-value.
PERFORM fieldcat_vbap.
PERFORM displaygrid_vbap.
PERFORM event_vbap.
PERFORM eventpopulate_vbap.
ENDFORM. "USER_COMMAND1
*& Form displaygrid_vbap
text
--> p1 text
<-- p2 text
FORM displaygrid_vbap .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND_3 '
i_callback_top_of_page = 'TOP_OF_PAGE_2 '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = i_title_vbap
I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = it_event_vbap
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_vbap
EXCEPTIONS
program_error = 1
OTHERS = 2
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. " displaygrid_vbap
&---- -
Problem with ALV Report Column
Hi
I have ALV report that got tons of columns and most of them are showing correctly. But there are two or three where i have a do sum checked got a small problem. The HEADING of the columns says NUMBER instead of its column name...
Look at my code:
ls_fieldcat-fieldname = 'ETIME'.
ls_fieldcat-ref_tabname = 'REC'.
ls_fieldcat-ref_fieldname = 'ETIME'.
ls_fieldcat-seltext_s = 'ET '.
ls_fieldcat-seltext_m = 'Et Tm '.
ls_fieldcat-seltext_l = 'End Time '.
append ls_fieldcat to pt_fieldcat.
ls_fieldcat-fieldname = 'HOURS'.
ls_fieldcat-ref_tabname = 'PC2BF'.
ls_fieldcat-ref_fieldname = 'ANZHL'.
ls_fieldcat-seltext_s = 'Hrs '.
ls_fieldcat-seltext_m = 'Hors '.
ls_fieldcat-seltext_l = 'Hours'.
ls_fieldcat-decimals_out = 2.
ls_fieldcat-no_zero = 'X'.
ls_fieldcat-datatype = 'DEC'.
ls_fieldcat-do_sum = 'X'.
append ls_fieldcat to pt_fieldcat.
ls_fieldcat-no_zero = ''.
ls_fieldcat-datatype = ''.
ls_fieldcat-outputlen = ''.
ls_fieldcat-do_sum = ''.
ls_fieldcat-decimals_out = ''.
ls_fieldcat-fieldname = ''.
ls_fieldcat-fieldname = 'PNUMB'.
ls_fieldcat-ref_tabname = 'PC20E'.
ls_fieldcat-ref_fieldname = 'PRAKN'.
ls_fieldcat-seltext_s = 'P# '.
ls_fieldcat-seltext_m = 'Pre # '.
ls_fieldcat-seltext_l = 'Premium # '.
ls_fieldcat-datatype = 'NUMC'.
append ls_fieldcat to pt_fieldcat.
ls_fieldcat-datatype = ''.
The column with Hours is showing NUMBER with the total sum but the column before and after that shows correctly.
I have tried taken out the
<b> ls_fieldcat-do_sum = 'X'.</b>
Then its shows correctly but i need it to do the sum.
Is there anything i need to do in order to show the columns correctly?
Please help. <b><REMOVED BY MODERATOR></b>. thanks
Message was edited by:
Anwarul Kabir
Message was edited by:
Anwarul Kabir
Message was edited by:
Alvaro Tejada Galindohere is the whole program. you can upload this run it for your self if that helps in any way...
*& Report ZHEADCOUNT *
REPORT ZHEADCOUNT no standard page
heading message-id zw line-size 255.
* Dictionary tables/structures
tables: teven,
ZSHIFTS,
ZHEADCT.
* Global ALV Data Declarations
type-pools slis.
include: rpcxB200, RPTBAL01.
DATA: BEGIN OF REC OCCURS 0,
PERNR LIKE TEVEN-PERNR,
LDATE LIKE TEVEN-LDATE,
LTIME LIKE TEVEN-LTIME,
SATZA LIKE TEVEN-SATZA,
TERID LIKE TEVEN-TERID,
PLANS LIKE TEVEN-PLANS.
DATA: END OF REC.
data:
begin of x_sortinfo_alv occurs 0,
spos like alvdynp-sortpos,
fieldname type slis_fieldname,
tabname type slis_fieldname,
up like alvdynp-sortup,
down like alvdynp-sortdown,
group like alvdynp-grouplevel,
subtot like alvdynp-subtotals,
comp(1) type c,
expa(1) type c,
obligatory(1) type c,
end of x_sortinfo_alv,
d like scal-indicator,
v_variant like disvariant,
v_repid like sy-repid,
v_save(1) type c,
lv_sortseq type i,
s_title(20),
fieldcat type slis_t_fieldcat_alv,
ls_line type slis_listheader,
gd_layout type slis_layout_alv,
gt_sp_group type slis_t_sp_group_alv,
gt_sort type slis_t_sortinfo_alv,
ls_sort type slis_sortinfo_alv,
events type slis_t_event,
list_top_of_page type slis_t_listheader,
top_of_page type slis_formname value 'TOP_OF_PAGE',
v_exit(1) type c,
v_pdsnr like assob-pdsnr,
ls_fieldcat type slis_t_fieldcat_alv.
constants:
alv_slis_formname type slis_formname value 'ALV_USER_COMMAND',
c_yes like space value 'X',
c_no like space value space,
c_dev LIKE sy-sysid VALUE 'DEV',
c_device(4) TYPE c VALUE 'LOCL'.
* define selection screen
selection-screen begin of block elmo with frame title text-001.
selection-screen begin of line.
selection-screen comment 1(30) text-002.
select-options p_terid for TEVEN-TERID.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(30) text-003.
select-options p_shift for ZSHIFTS-DWS.
selection-screen end of line.
selection-screen end of block elmo.
selection-screen begin of block blk2 with frame title text-004.
PARAMETERS: p_vari like disvariant-variant.
selection-screen end of block blk2.
* Form Initialization
initialization.
v_repid = sy-repid.
v_save = 'A'.
clear v_variant.
v_variant-report = v_repid.
* Get default variant
alv_variant = v_variant.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = v_save
CHANGING
cs_variant = alv_variant
EXCEPTIONS
not_found = 2.
if sy-subrc = 0.
p_vari = alv_variant-variant.
endif.
* At Selection-Screen event (value help)
at selection-screen on value-request for p_vari.
perform f4_for_variant.
* At Selection-Screen event (check input data)
at selection-screen on p_vari.
if p_vari <> space.
v_variant-report = v_repid.
v_variant-variant = p_vari.
call function 'REUSE_ALV_VARIANT_SELECT'
EXPORTING
i_dialog = c_no
it_default_fieldcat = field_tab[]
i_layout = gs_layout
CHANGING
cs_variant = v_variant.
if sy-subrc <> 0.
call function 'REUSE_ALV_VARIANT_SELECT'
EXPORTING
i_dialog = c_yes
it_default_fieldcat = field_tab[]
i_layout = gs_layout
CHANGING
cs_variant = v_variant.
endif.
endif.
* main logic
TOP-OF-PAGE.
START-OF-SELECTION.
GET PERNR.
RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
* process the data according to the payroll area
IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
PERFORM RETRIEVE_Time.
ENDIF.
END-OF-SELECTION.
Perform call_alv.
*==================================*
*=================================*
FORM RETRIEVE_Time.
Clear: REC.
Select * from teven where PERNR EQ PERNR-PERNR
AND TERID IN p_terid
AND LDATE >= PNPBEGDA
AND LDATE <= PNPENDDA.
MOVE:
TEVEN-PERNR TO REC-PERNR,
TEVEN-LDATE TO REC-LDATE,
TEVEN-LTIME TO REC-LTIME,
TEVEN-SATZA TO REC-SATZA,
TEVEN-TERID TO REC-TERID,
TEVEN-PLANS TO REC-PLANS.
APPEND REC.
endselect.
ENDFORM. " RETRIEVE_PAYROLL
* CALL_ALV
form call_alv.
perform build_field_catalog using field_tab[].
perform build_eventtab using events[].
perform comment_build using header_alv[].
perform build_sorttab using gt_sort[].
perform build_layout.
* Call ABAP List Viewer
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
i_callback_user_command = 'ALV_USER_COMMAND'
i_structure_name = 'REC'
it_fieldcat = field_tab
it_special_groups = gt_sp_group
it_sort = gt_sort
i_save = v_save
is_variant = v_variant
it_events = events
is_layout = gd_layout
tables
t_outtab = REC
exceptions
program_error = 1
others = 2.
endform. "call_alv
* BUILD_FIELD_CATALOG
form build_field_catalog USING pt_fieldcat type
slis_t_fieldcat_alv.
* data: ls_fieldcat type slis_fieldcat_alv.
clear: fieldcat, pt_fieldcat[].
data : l_tabname type slis_tabname. " Table Name
l_tabname = 'REC'.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = l_tabname
i_inclname = v_repid
changing
ct_fieldcat = ls_fieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
* append ls_fieldcat to pt_fieldcat.
endif.
endform. "build_field_catalog
* BUILD_EVENTTAB
form build_eventtab using events type slis_t_event.
* Registration of events to happen during list display
data: tmp_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = events.
read table events with key name = slis_ev_top_of_page into tmp_event.
if sy-subrc = 0.
move top_of_page to tmp_event-form.
append tmp_event to events.
endif.
endform. "build_eventtab
* COMMENT_BUILD
form comment_build using pt_top_of_page type slis_t_listheader.
data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
clear: ls_line, pt_top_of_page.
ls_line-typ = 'H'.
data pnpfrom(10).
data pnpto(10).
data: print_date(10).
data: print_time(10).
d1 = PNPBEGDA+6(2). d2 = PNPENDDA+6(2).
m1 = PNPBEGDA+4(2). m2 = PNPENDDA+4(2).
y1 = PNPBEGDA+2(2). y2 = PNPENDDA+2(2).
concatenate m1 '/' d1 '/' y1 into pnpfrom.
concatenate m2 '/' d2 '/' y2 into pnpto.
ls_line-info = sy-repid.
append ls_line to pt_top_of_page.
concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
into ls_line-info separated by space.
append ls_line to pt_top_of_page.
ls_line-info = 'BGM INDUSTRIES, INC.'.
append ls_line to pt_top_of_page.
concatenate 'Period:' pnpfrom 'to' pnpto
into ls_line-info separated by space.
append ls_line to pt_top_of_page.
endform. "comment_build
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
* gd_layout-totals_text = 'Totals'(255).
* gd_layout-info_fieldname = 'LINE_COLOR'.
endform. " BUILD_LAYOUT
* TOP_OF_PAGE
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'Z_BGLOGO'
it_list_commentary = header_alv.
endform. "top_of_page
*& Form build_sorttab
* Set up the sorting for the report.
form build_sorttab using pt_sort type slis_t_sortinfo_alv.
clear lv_sortseq.
perform build_sort tables pt_sort changing ls_sort.
ls_sort-fieldname = 'PERNR'.
ls_sort-subtot = 'X'.
endform. " build_sorttab
* Use to add another sort field.
form build_sort
tables pt_sort
changing ls_sort structure x_sortinfo_alv.
clear ls_sort.
add 1 to lv_sortseq.
ls_sort-spos = lv_sortseq.
ls_sort-up = 'X'.
ls_sort-tabname = 'REC'.
endform. "build_sort
*& Form f4_for_variant
form f4_for_variant.
call function 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = v_variant
i_save = v_save
IMPORTING
e_exit = v_exit
es_variant = alv_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 v_exit = space.
p_vari = alv_variant-variant.
endif.
endif.
endform.
Message was edited by:
Anwarul Kabir -
Count of Sales documenst in a ALV report
Hi Gurus!
I have an ALv report that gives me a list of sales document number with other data associated with it like the material number , status , date , iem ect ect. Each docum,ent can have several line items associated with it and it shows on teh report . I have used a count column in my report which gives me the count of line items in the report . Now what I want is the count of documnet numbers in the report rather than the count of line items , which will enable to know how many sales document are ther in the report for therie r report purpose. Is ot possible to get a count of teh document numbers in the ALV report output apart from teh count of the line items . Will I ahve to make changes in my report or it can be acheived in the layout itself. Kindly advice please.
ThanksI ahve done as said
report zztest message-id zsd no standard page heading.
* For ALV usage
type-pools: slis.
data: gs_layout type slis_layout_alv,
tp_print type slis_print_alv,
gt_sort type slis_t_sortinfo_alv,
gt_events type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv with header line,
repid type syrepid, " ABAP Program.
gt_list_top_of_page type slis_t_listheader, " Top of page text.
alv_variant type disvariant. " Customize Disp. Variant
data: w_field type slis_fieldcat_alv.
data: gs_list_top_of_page type slis_listheader.
data: l_count type I.
data: l_vbeln type I.
tables: vbak, vbap, vbpa, knvv.
*DATA : v_count type N.
DATA : count1 type N.
* Definition of selection screen *
* By plant, storage location, sold-to customers, material and *
* posting date of the sales orders *
selection-screen begin of block one with frame title text-001.
parameters: p_vkorg type vkorg obligatory memory id vko,"DEVK906677
p_vtweg type vtweg obligatory default '01',
p_spart type spart obligatory default '01'.
select-options: s_vkbur for vbak-vkbur, " Sales Office "DEVK906677
s_kunnr for vbak-kunnr. " Sold-to customer number.
select-options: s_shipto for vbap-oid_ship, " Ship-to customer number.
s_billto for vbpa-kunnr, " bill-to from S.O. header.
s_load for vbpa-kunnr, " Load confirmation contact.
s_truck for vbap-oid_extbol. " Trucking ticket number.
select-options: s_werks for vbap-werks obligatory no intervals. " Plant.
select-options: s_lgort for vbap-lgort. " Storage location.
select-options: s_matnr for vbap-matnr. " Material number.
select-options: s_konda for knvv-konda. " price group
selection-screen skip 1.
select-options: s_vdatu for vbak-vdatu default sy-datum.
selection-screen end of block one.
* ALV display layout
selection-screen begin of block layout with frame title text-003.
parameters: pa_vari type slis_vari default ' '. " Display variant.
selection-screen end of block layout.
selection-screen begin of block two with frame title text-028.
selection-screen comment: /1(79) text-029.
selection-screen comment: /1(79) text-030.
selection-screen comment: /1(79) text-031.
selection-screen comment: /1(79) text-032.
selection-screen comment: /1(79) text-033.
selection-screen comment: /1(79) text-034.
selection-screen comment: /1(79) text-035.
selection-screen comment: /1(79) text-036.
selection-screen end of block two.
* Data Definitions *
* Storing Extracted Info.
types: begin of t_extract,
vbeln type vbeln_va, " Sales order number.
augru type augru, " order reason
vdatu type edatu_vbak, " Requested delivery date.
kunnr type kunag, " Sold-to customer number.
posnr type posnr_va, " Item number.
matnr type matnr, " Material number.
vrkme type vrkme, " Sales UoM.
mseh3 type mseh3, " UoM text.
netwr type netwr_ap, " Net value of the order item.
kwmeng type p length 13 decimals 1, " Quantity.
werks type werks_d, " Plant.
lgort type lgort_d, " Storage location.
oid_extbol type oid_extbol, " External BOL or truck ticker header.
maktx type maktx, " Material description.
soldto_name type name1_gp, " Sold-to name.
oid_ship type kunwe, " Ship-to customer number.
shipto_name type name1_gp, " Ship-to name.
billto type kunre, " Bill-to customer number.
billto_name type name1_gp, " Bill-to name.
load_contact type kunnr, " Load confirmation contact.
load_name type name1_gp, " Load confirmation contact name.
truck type kunnr, " Truck company number.
truck_name type name1_gp, " Truck company name.
bstkd type bstkd, " PO number.
ihrez type ihrez, " AFE number per the contract/sales order.
delivery type vbeln_vl, " Delivery number.
posnr_vl type posnr_vl, " Delivery item number.
bill_vbeln type vbeln_vf, " Invoice number.
bill_posnr type posnr_vf, " Invoice item number.
bill_netwr type netwr_fp, " Invoice net value.
statu type stats, " Document status.
auart type auart, " order type
vkorg type vkorg, " sales org.
vtweg type vtweg, " distrbtn channel
spart type spart, " division
vkbur like vbak-vkbur, " Sales Office DEVK906677
konda type konda, " price group
tdline type tdline, " text for customer account reference
count type I ,
end of t_extract.
data :
it_extract type table of t_extract with header line,
it_extract2 type table of t_extract with header line.
data: it_text type table of tline with header line.
data: w_index type sy-index,
w_tdname type tdobname.
constants: c_minus1 type netwr_ap value '1.00-'.
*RANGES: r_auart FOR vbak-auart.
data: r_auart type range of t_extract-auart,
r_auart_line like line of r_auart.
* initialization
initialization.
gs_layout-colwidth_optimize = 'X'.
tp_print-no_print_listinfos = 'X'.
tp_print-no_coverpage = 'X'.
perform set_fieldcat.
perform alv_eventtab_build using:
** Event name Form to execute Event internal table
'TOP_OF_PAGE' 'TOP_OF_PAGE' gt_events[].
* changed to exclude following order types
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZEQ'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* credit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* debit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRD'.
clear r_auart_line-high.
append r_auart_line to r_auart.
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZDR'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Industry sales order correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZSOC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield FF correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCF'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield WP correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCW'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Dropdown list for all created ALV layouts, global or user-specific
at selection-screen on value-request for pa_vari.
perform alv_variant_f4 changing pa_vari.
* Main BODY of processing logic
start-of-selection.
perform extract_data.
end-of-selection.
if not it_extract[] is initial.
* Build headings for report.
perform build_top_of_page using gt_list_top_of_page[].
perform call_alv.
endif.
*& Form EXTRACT_KEY_DATA
* Retreive the data for the report.
form extract_data.
clear: it_extract. refresh: it_extract.
* orders
select vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
into corresponding fields of table it_extract
from vbak inner join vbap
on vbak~mandt = vbap~mandt
and vbak~vbeln = vbap~vbeln where
vbak~auart not in r_auart and
vbak~vkorg eq p_vkorg and
vbak~vtweg eq p_vtweg and
vbak~spart eq p_spart and
vbak~vkbur in s_vkbur and "DEVK906677
vbak~vdatu in s_vdatu and
vbak~kunnr in s_kunnr and
vbap~matnr in s_matnr and
vbap~werks in s_werks and
vbap~lgort in s_lgort and
vbap~oid_extbol in s_truck and
vbap~oid_ship in s_shipto.
if sy-subrc <> 0.
message i000 with text-002 ' ' ' ' ' '.
endif.
sort it_extract by vbeln.
check sy-subrc = 0.
loop at it_extract.
at new vbeln.
count1 = count1 + 1.
endat.
* Retrieve and select by load confirmation contacts from header
select single kunnr from vbpa into it_extract-load_contact
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'ZB'.
if it_extract-load_contact in s_load.
it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
else.
delete it_extract.
continue.
endif.
* Retrieve and select by sales order bill-to on header level
* as well as lookup bill-to customer name/description
select single kunnr from vbpa into it_extract-billto
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'RE'.
if sy-subrc = 0.
if s_billto is initial.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
if it_extract-billto in s_billto.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
delete it_extract.
continue.
endif.
endif.
else.
* Newalta - always has bill-to, following will not occur but included
* as good programming practice.
it_extract-billto_name = it_extract-billto.
endif.
* Retrieve and select by price group of sold-to
select single konda from knvv into it_extract-konda
where kunnr = it_extract-kunnr
and vkorg = it_extract-vkorg
and vtweg = it_extract-vtweg
and spart = it_extract-spart.
if sy-subrc = 0.
if not ( it_extract-konda in s_konda ).
delete it_extract.
continue.
endif.
endif.
* Retrieve trucking company customer
select single kunnr from vbpa into it_extract-truck where
vbeln = it_extract-vbeln and
posnr = '000000' and
parvw = 'ZT'.
if sy-subrc = 0.
it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
endif.
* Retrieve sold-to name
it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
* Retrieve ship-to name
it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
* lookup P.O.
select single bstkd ihrez from vbkd into (it_extract-bstkd, it_extract-ihrez)
where vbeln = it_extract-vbeln
and posnr = '000000'.
* Retreive the material description.
it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
* cosmetic change of material number, donot display leading zeros.
shift it_extract-matnr left deleting leading '0'.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
w_tdname = it_extract-vbeln.
* read customer account reference which is under 'text'
call function 'READ_TEXT'
exporting
client = sy-mandt
id = 'Z010'
language = sy-langu
name = w_tdname
object = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
tables
lines = it_text
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc = 0.
read table it_text index 1.
if sy-subrc = 0.
it_extract-tdline = it_text-tdline.
else.
clear it_extract-tdline.
endif.
else.
clear it_extract-tdline.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* Get the delivery item.
call method zcl_vbap=>get_delivery
EXPORTING
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
IMPORTING
etp_vbeln = it_extract-delivery
etp_posnr = it_extract-posnr_vl.
if it_extract-delivery is not initial.
perform process_deliveries.
else.
perform invoice_process.
endif.
it_extract-count = 1.
move-corresponding it_extract to it_extract2.
append it_extract2.
endloop.
describe table it_extract2 lines count1.
endform. " EXTRACT_DATA
*& Form SET_FIELDCAT
* Create the field catalogue.
form set_fieldcat .
clear w_field.
clear t_fieldcat. refresh t_fieldcat.
w_field-col_pos = 1.
w_field-fieldname = 'VBELN'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Document.Nbr'.
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 2 .
w_field-fieldname = 'POSNR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Item'(023).
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 3 .
w_field-fieldname = 'VDATU'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Req. Del. Date'(005).
append w_field to t_fieldcat.
w_field-col_pos = 4 .
w_field-fieldname = 'SOLDTO_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Sold-to'(006).
append w_field to t_fieldcat.
w_field-col_pos = 5 .
w_field-fieldname = 'MATNR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Material'(007).
append w_field to t_fieldcat.
w_field-col_pos = 6 .
w_field-fieldname = 'KWMENG'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Quantity'(008).
append w_field to t_fieldcat.
w_field-col_pos = 7.
w_field-fieldname = 'MSEH3'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'UOM'(009).
append w_field to t_fieldcat.
w_field-col_pos = 8 .
w_field-fieldname = 'BILL_VBELN'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Invoice #'(010).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 9 .
w_field-fieldname = 'BILL_NETWR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Values'(011).
append w_field to t_fieldcat.
w_field-col_pos = 10.
w_field-fieldname = 'WERKS'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Plant'(012).
append w_field to t_fieldcat.
w_field-col_pos = 11.
w_field-fieldname = 'LGORT'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Storage Loc'(013).
append w_field to t_fieldcat.
w_field-col_pos = 12 .
w_field-fieldname = 'MAKTX'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Description'(014).
append w_field to t_fieldcat.
w_field-col_pos = 13 .
w_field-fieldname = 'SHIPTO_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Ship-to'(015).
append w_field to t_fieldcat.
w_field-col_pos = 14 .
w_field-fieldname = 'BILLTO_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Bill-to'(016).
append w_field to t_fieldcat.
w_field-col_pos = 15 .
w_field-fieldname = 'LOAD_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Load Contact'(017).
append w_field to t_fieldcat.
w_field-col_pos = 16 .
w_field-fieldname = 'TRUCK_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Truck Comp.'(018).
append w_field to t_fieldcat.
w_field-col_pos = 17 .
w_field-fieldname = 'BSTKD'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'P.O.'(019).
append w_field to t_fieldcat.
w_field-col_pos = 18 .
w_field-fieldname = 'IHREZ'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'AFE Nbr'(020).
append w_field to t_fieldcat.
w_field-col_pos = 19 .
w_field-fieldname = 'OID_EXTBOL'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Truck Ticket'(021).
append w_field to t_fieldcat.
w_field-col_pos = 20.
w_field-fieldname = 'STATU'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Status'(022).
append w_field to t_fieldcat.
w_field-col_pos = 21.
w_field-fieldname = 'AUGRU'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Ord.Reason'(024).
append w_field to t_fieldcat.
w_field-col_pos = 22.
w_field-fieldname = 'TDLINE'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'cstmr.acct.ref.'(027).
append w_field to t_fieldcat.
w_field-col_pos = 23 . "DEVK906678
w_field-fieldname = 'VKBUR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Sales Office'(037).
append w_field to t_fieldcat.
w_field-col_pos = 24.
w_field-fieldname = 'KUNNR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Sold-to Customer'(038).
append w_field to t_fieldcat.
w_field-col_pos = 25.
w_field-fieldname = 'OID_SHIP'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Ship-to Customer'(039).
append w_field to t_fieldcat.
w_field-col_pos = 26.
w_field-fieldname = 'BILLTO'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Bill-to Customer'(040).
append w_field to t_fieldcat.
w_field-col_pos = 27.
w_field-fieldname = 'COUNT'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Count'(041).
w_field-do_sum = 'X'.
append w_field to t_fieldcat.
endform. " SET_FIELDCAT
*& Form CALL_ALV
* Call the ALV Grid function.
form call_alv .
sort it_extract by lgort vbeln.
* repid is necessary since the ALV F.M. does not work properly with
* sy-repid.
repid = sy-repid.
alv_variant-variant = pa_vari.
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[]
is_print = tp_print
TABLES
t_outtab = IT_EXTRACT2
EXCEPTIONS
program_error = 1
others = 2.
if sy-subrc ne 0.
message w000 with text-004 ' ' ' ' ' '.
endif.
endform. " CALL_ALV
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
form build_top_of_page using e04_lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
data: w_selections(40) type c,
w_date_from(10) type c,
w_date_to(10) type c.
write: s_vdatu-low to w_date_from dd/mm/yyyy.
if s_vdatu-high is not initial.
write: s_vdatu-high to w_date_to dd/mm/yyyy.
clear w_selections.
concatenate 'Del.Req.Date: ' w_date_from 'To' w_date_to
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
else.
clear w_date_to.
concatenate 'Del.Req.Date: ' w_date_from
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
endif.
endform. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
form alv_eventtab_build using u_name type slis_alv_event-name
u_form type slis_alv_event-form
alv_lt_events type slis_t_event.
data: ls_event type slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
append ls_event to alv_lt_events.
endform. " alv_eventtab_build
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'LOGO'
it_list_commentary = gt_list_top_of_page.
endform. " TOP_OF_PAGE
*& Form process_deliveries
* Process the delivery related records.
form process_deliveries .
data:
ltp_date type wadat_ist, " Goods movement date.
ltp_vbtyp type vbtyp_n,
ltp_mtart type mtart, " Material type.
w_lfimg type lfimg, " Actual quantity delivered (in sales units).
w_vrkme type vrkme. " Sales unit of measure.
* Read delivery quantity and uom.
select single lfimg vrkme into (w_lfimg, w_vrkme)
from lips where
vbeln = it_extract-delivery and
posnr = it_extract-posnr_vl.
* these fields have values from vbap. override with lips values
if sy-subrc = 0.
it_extract-kwmeng = w_lfimg.
it_extract-vrkme = w_vrkme.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
endif.
* Determine STATUS by reading 'service confirmation', R (goods movemt)
* it is possible to have multiple 'service confirmation' records for
* one item. ie. delivery 80010390 in PRD.
* As long as there is at least one 'service confirmation' record,
* status is considered 'complete'.
* Validate the created on date of the goods movement or service confirmation.
ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
* ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
* itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
call method zcl_lips=>get_goods_mvt_info
EXPORTING
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
itp_mtart = ltp_mtart
IMPORTING
rtp_date = ltp_date
rtp_vbtyp = ltp_vbtyp.
* 'h' is cancel goods issue
if ltp_vbtyp = 'h'.
it_extract-statu = 'Incomplete'(025).
else.
if ltp_date is not initial.
it_extract-statu = 'COMPLETE'(026).
endif.
endif.
* Retrieve the invoice/billing document item.
call method zcl_lips=>get_invoice
EXPORTING
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
IMPORTING
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
endif.
endform. " process_deliveries
*& Form user_command
* Process the user command.
* -->R_UCOMM User command
* -->RS_SELFIELD Field selected
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: ltp_vbeln type vbeln. " Sales document number.
case r_ucomm.
when '&IC1'.
if ( rs_selfield-fieldname = 'VBELN'
or rs_selfield-fieldname = 'BILL_VBELN' )
and rs_selfield-value is not initial. " Display sales document.
ltp_vbeln = rs_selfield-value.
zcl_sales_doc=>display( ltp_vbeln ).
endif.
endcase.
endform. "user_command
*& Form invoice_process
* Process for orders without deliveries. *
form invoice_process .
* Translate unit of measure.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
* Retrieve the invoice/billing document item.
call method zcl_vbap=>get_invoice
EXPORTING
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
IMPORTING
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else. " If no Invoice, then status becomes 'incomplete'.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
it_extract-statu = 'Incomplete'(025).
endif.
endform. " invoice_process
*& Form alv_variant_f4
* Get the display variant.
* <--CTP_VARI Variant name
form alv_variant_f4 changing ctp_vari type slis_vari.
alv_variant-report = sy-repid. " Report ID
alv_variant-username = sy-uname. " User ID
call function 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = alv_variant
i_save = 'A'
IMPORTING
es_variant = alv_variant
EXCEPTIONS
others = 1.
if sy-subrc = 0.
ctp_vari = alv_variant-variant.
endif.
endform. " alv_variant_f4
Maybe you are looking for
-
Complete Guide to iPad in France
So this past week, I was in France with my new iPad with 4G LTE. I was worried about getting 3G service beforehand due to a few threads I saw posted here. I've decided that after coming back, I would help out any future travellers who would want 3G s
-
I can't sign in to FaceTime keeps sayin check network connections but my network is fine
im havin trouble signin into facetime on my mac and i cant get my head around it ive my ID setup but everytime i click on sign in it keeps coming up with CHEAK YOUR NETWORK CONNECTIONS AND TRY AGAIN. There is nothing wrong with my connections as im r
-
What is the format required in essbase side to show calendar icon in obiee
Hi All, Currently we are bulidng dashboards with Essbase ASO cube as underlined multi-dimensional database. Not sure essbase date is not showing as date format. what is the format required in essbase side to show calendar icon in obiee We tried forma
-
Where do files go after they are unzipped?
I have downloaded a zip file that open up to a .pkg file. It is a user manual that is a .pdf file. When I go to look for it I can't find it anywhere on my computer. I have tried looking for it with spotlight using the file name but it is nowhere to b
-
Rendered composite doesn't show the layers I see in the edit window
In exporting or rendering a segment or a still frame of a four layer composite, I don't see the same effects applied that I see in the edit window. The composite is a luma traveling matte composited over a color corrected background, with a gaussian