Sum in ALV grid
hi guys,
i have an internal table
BEGIN OF itab,
hkont TYPE bseg-hkont,
dmbtr TYPE bseg-dmbtr,
int_amt1 TYPE bseg-dmbtr,
int_amt2 TYPE bseg-dmbtr,
int_amt3 TYPE bseg-dmbtr,
int_amt4 TYPE bseg-dmbtr,
int_amt5 TYPE bseg-dmbtr,
int_amt6 TYPE bseg-dmbtr,
int_amt7 TYPE bseg-dmbtr,
gl_desc TYPE skat-txt20,
END OF itab.
i want to calculate the sum of rows as the field "hkont " changes. i'm using ALV grid to display o/p.
REPORT ztest_alv_perc_13317.
TYPE-POOLS: slis.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
l_layout TYPE slis_layout_alv.
TYPES: BEGIN OF ty_itab,
field1(10),
qty1 TYPE i,
qty2 TYPE i,
qty3 TYPE i,
dummy TYPE c,
END OF ty_itab.
DATA: itab TYPE STANDARD TABLE OF ty_itab WITH HEADER LINE,
itab1 TYPE ty_itab.
START-OF-SELECTION.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'FIELD1'.
wa_fieldcat-tabname = 'ITAB'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'QTY1'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'QTY2'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'QTY3'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'DUMMY'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-no_out = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF.
Similar Messages
-
Hey all,
What i have to enable the sum button on the alv grid ... i guess from application bar....it is sign of sum... please give me option what i have to do....
points will be rewarded.....hi,
there will be sign like E (total ) using this u can have sum
or
u can add this property in ur fieldcat for the field u want sum..
l_r_fieldcat-tabname = 'G_T_ITAB'.
l_r_fieldcat-fieldname = 'NETWR'.
l_r_fieldcat-do_sum = 'X'.
l_r_fieldcat-emphasize = 'C500'.
APPEND l_r_fieldcat TO g_t_fieldcat.
CLEAR l_r_fieldcat.
reward if usefull.... -
Custom tool bar for sorting and summing in alv grid
what is the function module to use the tool bar in the alv output screen which has - summing , sorting and other button above the alv grid control.
It is part of the class CL_GUI_ALV_GRID. Have a look at this class, especially the methods within this class, and search for 'SORT' or 'TOTAL' using the button with 'Binoculars' icon.
-
Sum in ALV grid display using objects
Hi Experts,
I have created a Report with ALV using objects and also am able to get SUM for some fields using do_sum = 'X'.
My problem is i want to do some calculation using the total amount which i have got, how can i do that (or can it be done??).
Thanks in Advance...
SantoshHi this may be of some help.
ABAP List Viewer
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
with regards,
Hema Sundara.
pls reward if u find it helpful. -
ALV Grid- to avoid message in status bar
Hi,
When ever i am doing sum in ALV Grid. I got the following message in statusbar.
' The field BETRAG_ITEM cannot be totalled of field overflow '
I am using currency field of 13 length and 2 decimals (Output length as 18 characters). How can i will aviod this message. could you please help me.
For right answer i can reward the points.
Regards
Bhupal ReddyHI,
Make the output length in the fieldcat for the particular fields as 18.
reward if helpful,
regards,
nazeer -
Problems with do_sum in ALV-GRID OO
Hi,
i want to sum in ALV-GRID OO, but the sum-line are not displayed.
Here my short extrac.
GS_FIELDCAT-REF_TABLE = 'COEP'.
GS_FIELDCAT-REF_FIELD = 'WKGBTR'.
GS_FIELDCAT-FIELDNAME = 'WKGBTR'.
GS_FIELDCAT-DO_SUM = 'X'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
IS_VARIANT = GS_VARIANT
I_SAVE = 'X'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Any idea want i'm doing wrong??
Regards, DieterIF that don't work try this little program to find what is missing
report z_what.
TYPE-POOLS slis.
DATA: ct_fieldcat TYPE slis_t_fieldcat_alv,
zt_fieldcat LIKE LINE OF ct_fieldcat.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'COEP'
CHANGING
ct_fieldcat = ct_fieldcat.
READ TABLE ct_fieldcat INTO zt_fieldcat
WITH KEY fieldname = 'WKGBTR'.
BREAK-POINT.
Regards -
How to use this USER_COMMAND and ALV grid
hi all,
I have requirement.
there are 2 radiobutton in selection screen.
when rad1 is clicked,
some plain report display with button 'SUM" at the application toolbar.
when i click this SUM button , ALV grid report opens
when rad2 is clicked,
ALV grid report opens directly without plain report.
my code:
start-of-selection
if rad1 = 'X"
write """"
at user-command.
case sy-ucomm.
..perform ALV_report.
endcase.
elseif rad2 = 'X"
perform ALV_report.
endif.
I am getting an error " Incorrect nesting: Before the statement "AT, the structure introduced by IF must be concluded by ENDIF"..
kindly help.
points will be rewarded
thanks in advanceHi Jayasree,
As AT User-Command is an event which cannot be used under some condition. Check this sample code.
START-OF-SELECTION.
Perform select_data.
AT USER-COMMAND.
IF l_rad1 EQ 'X'.
CASE sy-ucomm.
WHEN 'ENTR'. "Use your Fcode.
PERFORM alv_report.
ENDCASE.
ELSEIF l_rad2 EQ 'X'.
PERFORM ALV_report.
ENDIF.
Reqard if useful.
Regards,
Ramkumar.K -
Dump when summing up CURR field in ALV GRID display
Hi All,
I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23. I am using classes and methods to display alv grid.
I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
Here is the part it is throwing dump:
ls_lvc_data-value = space.
clear ls_lvc_data-style.
loop at it_fcat_local assigning <ls_fcat>
where tech ne 'X' and no_out ne 'X'.
if l_invisible eq 'X'.
clear l_invisible.
if <ls_fcat>-do_sum is initial.
continue.
else.
clear ls_lvc_data-col_pos.
endif.
endif.
add 1 to ls_lvc_data-col_pos.
assign component <ls_fcat>-fieldname
of structure <ls_data> to <l_field_value>.
_if sy-subrc ne 0.
message x000(0k).
endif._
Regards,
GuruThomas,
Here is the dump:
Runtime Errors MESSAGE_TYPE_X
Date and Time 10/22/2010 23:30:53
Short text
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Long text of error message:
Technical information about the message:
Message class....... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
How to correct the error
Probably the only way to eliminate the error is to correct the program.
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"MESSAGE_TYPE_X" " "
"SAPLSLVC" or "LSLVCF36"
"FILL_DATA_TABLE"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
Source Code Extract
Line
SourceCde
2708
is_subtottxt_info = ls_subtot_info
2709
ip_subtot_line = lr_data
2710
changing
2711
c_subtottxt = l_subtottxt.
2712
ls_lvc_data-value = l_subtottxt.
2713
2714
append ls_lvc_data to ct_lvc_data.
2715
endif.
2716
2717
2718
Column per Fieldcat Entry
2719
2720
ls_lvc_data-value = space.
2721
clear ls_lvc_data-style.
2722
loop at it_fcat_local assigning <ls_fcat>
2723
where tech ne 'X' and no_out ne 'X'.
2724
if l_invisible eq 'X'.
2725
clear l_invisible.
2726
if <ls_fcat>-do_sum is initial.
2727
continue.
2728
else.
2729
clear ls_lvc_data-col_pos.
2730
endif.
2731
endif.
2732
2733
add 1 to ls_lvc_data-col_pos.
2734
2735
assign component <ls_fcat>-fieldname
2736
of structure <ls_data> to <l_field_value>.
2737
if sy-subrc ne 0.
>>>>>
message x000(0k).
2739
endif.
2740
2741
*... work on average
2742
if <ls_fcat>-do_sum eq 'C'.
2743
Initialize average result and entries
2744
<l_field_value> = 0.
2745
clear l_entries.
2746
2747
retrive unit from fieldcatalog
2748
assign space to <l_unit>.
2749
if not <ls_fcat>-cfieldname is initial.
2750
assign component <ls_fcat>-cfieldname
2751
of structure <ls_data> to <l_unit>.
2752
endif.
2753
if not <ls_fcat>-qfieldname is initial.
2754
assign component <ls_fcat>-qfieldname
2755
of structure <ls_data> to <l_unit>.
2756
endif.
2757 -
How do I change a field in the sum in ALV (List or grid)
My alv, for example:
1.10
2.30
1.50
Sum(DO_SUM) : 4.90
But I need to CEIL( 4.90 ) before showing .
It should be shown as 5.00 in alv.
How do I change this field in the sum ?Use the following code in a PBO module or in an adequate event method
data: total type ref to data,
subtotal1 type ref to data.
field-symbols: <total> like gt_sflight,
<subtotal1> like gt_sflight.
call method grid1->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subtotal1.
assign total->* to <total>.
assign subtotal1->* to <subtotal1>.
Look at [ALV Grid Control (BC-SRV-ALE)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf]
Regards -
How can we sum for the field on alv grid
Dear Freinds,
I am having the field count .....in the ouput (iam using alv grid) .......which dispalys the id's which are identical .
i have scneario similar to the below in my ALV Output
ID count total
4000 3 100
100
200 Can i get count 3 also along with 200 in alv?
i am using the code as follows for count can any one please let me know.
my earlier question which i put was confusing.........so i am givin the qustion again
clear ls_fieldcat.
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'ORGUNIT'.
ls_fieldcat-seltext_l = text-015. "'Orgunit'.
ls_fieldcat-key = 'X'.
ls_fieldcat-key_sel = 'X'.
ls_fieldcat-no_out = 'X'.
append ls_fieldcat to fp_i_fieldcat.
clear ls_fieldcat.
ls_fieldcat-col_pos = 2.
ls_fieldcat-fieldname = 'COUNT'.
ls_fieldcat-seltext_l = 'H.Count'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-datatype = 'NUMC'.
append ls_fieldcat to fp_i_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'TOTAL'.
ls_fieldcat-seltext_m = 'total'.
ls_fieldcat-col_pos = 3.
ls_fieldcat-outputlen = 17.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-datatype = 'CURR'.
append ls_fieldcat to fp_i_fieldcat.
Please let me know how can do if so what is the parameter i have to change for COUNT
regards
syamalHi Shamala Kiran.
My name is also kiran.I have a develop a code for u.Actually i cant understand your code.But i know ur problem .Plz check that code.In that code i develop a subtotals and grandttotal.Plz observe the FORM "FIELD CATALOG" in that observe the NETWR FIELD and observe the FORM SORTCATALOG then ur problem will be solved.
Copy the the below code and execute that code and the result.
If u r Satisfied with the answer plz give the REWARD POINTS.
CODE:
Type Pools
TYPE-POOLS:slis.
Tables
TABLES: vbak,vbap.
Global Variable
data: w_var type i.
Global Data
DATA:it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_sortcat TYPE slis_t_sortinfo_alv,
wa_sortcat LIKE LINE OF it_sortcat.
Internal Table
data: BEGIN OF it_salesorder OCCURS 0,
vbeln LIKE vbak-vbeln, " Sales Document Number
posnr like vbap-posnr, " Sales Doc Item
netwr like vbap-netwr, " Net Value
END OF it_salesorder.
SELECT OPTIONS
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document Number.
SELECTION-SCREEN END OF BLOCK b1.
Initialization
INITIALIZATION.
PERFORM initialization.
*& Form initialization
text
--> p1 text
<-- p2 text
form initialization .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
APPEND s_vbeln.
endform. " initialization
Start Of Selection
START-OF-SELECTION.
PERFORM field_catalog. "For Structure Creation
PERFORM fetch_data. "Get the Data From DB Table
PERFORM sorting USING it_sortcat.
End Of Selection
END-OF-SELECTION.
perform display_data.
*& Form field_catalog
text
--> p1 text
<-- p2 text
form field_catalog .
wa_fieldcat-col_pos = w_var. " Column Position Variable
wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name
wa_fieldcat-fieldname = 'VBELN'. " Field Name
wa_fieldcat-key = 'X'. " Blue Color
wa_fieldcat-ref_tabname = 'VBAK'. " Table Name
wa_fieldcat-ref_fieldname = 'VBELN'. " Field Name
wa_fieldcat-seltext_m = 'Sales Doc No'. " Display Text In Screen
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ADD 1 TO w_var.
wa_fieldcat-col_pos = w_var. " Column Position Variable
wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name
wa_fieldcat-fieldname = 'POSNR'. " Field Name
wa_fieldcat-ref_tabname = 'VBAP'. " Table Name
wa_fieldcat-ref_fieldname = 'POSNR'. " Field Name
wa_fieldcat-seltext_m = 'Sales Doc Item'. " Display Text In Screen
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ADD 1 TO w_var.
wa_fieldcat-col_pos = w_var. " Column Position Variable
wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name
wa_fieldcat-fieldname = 'NETWR'. " Field Name
wa_fieldcat-ref_tabname = 'VBAP'. " Table Name
wa_fieldcat-ref_fieldname = 'NETWR'. " Field Name
wa_fieldcat-do_sum = 'X'. " Sum
wa_fieldcat-seltext_m = 'Net Value'. " Display Text In Screen
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ADD 1 TO w_var.
endform. " field_catalog
*& Form sorting
text
-->P_IT_SORTCAT text
form sorting using p_it_sortcat TYPE slis_t_sortinfo_alv.
wa_sortcat-fieldname = 'VBELN'.
wa_sortcat-up ='X'.
wa_sortcat-subtot = 'X'.
APPEND wa_sortcat TO p_it_sortcat.
endform. " sorting
*& 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 = SY-REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_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 =
IT_FIELDCAT = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = it_sortcat
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_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
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_salesorder
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 fetch_data
text
--> p1 text
<-- p2 text
form fetch_data .
select a~vbeln
posnr
b~netwr
from vbak as a
inner join vbap as b on avbeln = bvbeln
into table it_salesorder
where a~vbeln in s_vbeln.
endform. " fetch_data -
Can ALV Grid show credit limit and excess credit limit but do not sum them?
Can ALV Grid show 100,000.00(in ???1) and 84,260.94(???2). Not sum them up.
Credit limit, Inv. Curr, Inv. Amount, Amt in LC, Excess Credit Limit
100,000.00 USD 1,594.20 5,260.86 84,260.94
100,000.00 USD 263.84 870.67 84,260.94
100,000.00 USD 1,935.60 6,270.38 84,260.94
100,000.00 USD 806.70 2,613.30 84,260.94
100,000.00 USD 214.98 696.43 84,260.94
100,000.00 USD 8.50 27.42 84,260.94
???1 USD 4,823.82 15,739.06 ???2
USD 4,823.82 15,739.06Hi Sandeep,
Please refer to the bold figure as they are the credit limit and excess credit limit for 1 vendor.
It is not right if sum the credit limit and excess credit limit.
Is it ALV cant handle this type of requirement?
Is there any way to solve this?
Credit limit, Inv. Curr, Inv. Amount, Amt in LC, Excess Credit Limit
100,000.00 USD 1,594.20 5,260.86 84,260.94
100,000.00 USD 263.84 870.67 84,260.94
100,000.00 USD 1,935.60 6,270.38 84,260.94
100,000.00 USD 806.70 2,613.30 84,260.94
100,000.00 USD 214.98 696.43 84,260.94
100,000.00 USD 8.50 27.42 84,260.94
100,000.00 USD 4,823.82 15,739.06 84,260.94 <--subtotal line
USD 4,823.82 15,739.06 <-- total line
Edited by: Check Chuan Kuan on Feb 24, 2011 10:03 AM -
Reused alv grid - Sum one column of ALV Grid
I'd like that one column of my alv grid to be sum...
How can i do that abap'ly speaking...
regardshi,
DATA: lr_field type ref to cl_salv_wd_field.
*For total calculations...
if wd_comp_controller->gref_model_efforts is not initial.
CALL METHOD wd_comp_controller->gref_model_efforts->if_salv_wd_std_functions~set_aggregation_allowed
EXPORTING
value = abap_true.
lr_field = wd_comp_controller->gref_model_efforts->if_salv_wd_field_settings~get_field( 'BILLABLE_VALUE' ). "The column name for which total needs to be done.
lr_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =
if_salv_wd_c_aggregation=>aggrtype_total ).
endif.
Refer this :
Alv subtotal and total
Thanx. -
ALV Grid Collect Statment for SUM the data.
Hellow Experts,
i am new to ABAP i have on programme which output is coming like ,
Prod.ID ... .... ... Qnty in Date1 .. Qnty in Date2... Qnty in Date3........Qnty in Date31.
0001 12.1 0.00 10.1
0001 12.1 0.00 10.1
I need the summestion of qnty against that date , and prodId should not repate my Output should be like this,
Prod.ID ... .... ... Qnty in Date1 .. Qnty in Date2... Qnty in Date3........Qnty in Date31.
0001 24.2 0.00 20.2
0002 12.1 0.00 10.1
I wrote collect statment but its not working , plz help me for this, and one more thing that i am passing the data to gt_data.
My code is here,
TABLES: AFRU,AUFK,VBAK,KNA1,VBAP,VBKD.
DATA: BEGIN OF i_alv OCCURS 0,
ARBID TYPE AFRU-ARBID,
BUDAT TYPE AFRU-BUDAT,
WERKS TYPE AFRU-WERKS,
LMNGA TYPE AFRU-LMNGA,
AUFNR TYPE AFRU-AUFNR,
KDAUF TYPE AUFK-KDAUF,
KDPOS TYPE AUFK-KDPOS,
VBELN TYPE VBAK-VBELN,
KUNNR TYPE VBAK-KUNNR,
NAME1 TYPE KNA1-NAME1,
MATNR TYPE VBAP-MATNR,
KDKG1 TYPE VBKD-KDKG1,
end of i_alv.
TYPES: BEGIN OF ty_data,
lmnga TYPE AFRU-LMNGA,
BUDAT TYPE AFRU-BUDAT,
ARBID TYPE AFRU-ARBID,
aufnr TYPE AFRU-AUFNR,
kdauf TYPE AUFK-KDAUF,
name1 TYPE KNA1-NAME1,
matnr TYPE VBAP-MATNR,
kdkg1 TYPE VBKD-KDKG1,
END OF ty_data,
tt_data TYPE STANDARD TABLE OF ty_data,
BEGIN OF ty_dyn1, "#EC NEEDED
ARBID TYPE AFRU-ARBID,
aufnr TYPE AFRU-AUFNR,
kdauf TYPE AUFK-KDAUF,
name1 TYPE KNA1-NAME1,
matnr TYPE VBAP-MATNR,
kdkg1 TYPE VBKD-KDKG1,
END OF ty_dyn1,
BEGIN OF ty_dyn2, "#EC NEEDED
date TYPE AFRU-LMNGA,
END OF ty_dyn2,
BEGIN OF ty_cols,
date TYPE BUDAT,
END OF ty_cols,
tt_cols TYPE SORTED TABLE OF ty_cols WITH UNIQUE KEY date.
DATA: gt_data TYPE tt_data,
gt_data2 type tt_data,
gt_cols TYPE tt_cols,
gs_col TYPE ty_cols.
DATA: go_sdescr TYPE REF TO cl_abap_structdescr,
go_sdescr_new TYPE REF TO cl_abap_structdescr,
go_tdescr TYPE REF TO cl_abap_tabledescr,
gdo_handle TYPE REF TO data,
gs_component TYPE abap_compdescr,
gs_comp TYPE abap_componentdescr,
gt_components TYPE abap_component_tab,
gr_data TYPE REF TO cl_salv_table,
gr_funct TYPE REF TO cl_salv_functions,
gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
g_col TYPE lvc_fname,
g_txt TYPE scrtext_l.
FIELD-SYMBOLS: <t_data> TYPE ANY TABLE,
<s_data> TYPE any,
<c> TYPE any,
<d> TYPE ty_data.
DATA: pono TYPE ztecerti-pono,
jobno TYPE ztecerti-jobno,
sdk TYPE string,
insert TYPE c,
ok_code LIKE sy-ucomm.
CALL SCREEN 100.
START-OF-SELECTION.
* Populate test data
FORM get_data.
SELECT A~ARBID
A~BUDAT
A~WERKS
A~LMNGA
A~AUFNR
B~KDAUF
B~KDPOS
C~VBELN
C~KUNNR
D~NAME1
E~MATNR
F~KDKG1
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM AFRU AS A INNER JOIN AUFK AS B ON A~AUFNR EQ B~AUFNR
INNER JOIN VBAK AS C ON B~KDAUF = C~VBELN
INNER JOIN KNA1 AS D ON C~KUNNR = D~KUNNR
INNER JOIN VBAP AS E ON B~KDAUF = E~VBELN
INNER JOIN VBKD AS F ON B~KDAUF = F~VBELN
WHERE A~ARBID = '10000181' AND A~BUDAT BETWEEN PONO AND jobno
GROUP BY A~ARBID A~LMNGA A~BUDAT A~WERKS A~AUFNR B~KDAUF F~KDKG1 E~MATNR D~NAME1 C~KUNNR C~VBELN B~KDPOS
ORDER BY B~KDPOS.
*collect gt_data into gt_data2.
*gt_data
*LOOP AT gt_data ASSIGNING <d>.
ENDFORM.
Thanking you i realy need it badlyAnswer is fully given here: Re: alv grid Cross Tab Issue....
m. -
Regarding Alv Grid Totals_text is not Printing
Hi All,
I am presently working in Alv Grid dispaly.
I need to dispaly Totals_Text = 'Totals'. But this text is not displaying in my output dispaly.i am copying my code here.
Code:
REPORT ZFTRSERV NO STANDARD PAGE HEADING
MESSAGE-ID YV
LINE-SIZE 255.
TABLES: BSIS, "Accounting: Secondary Index for G/L Accounts
BSAS, "Accounting: Secondary Index for G/L Accounts (Cleared Items)
BSID, "Accounting: Secondary Index for Customers
BKPF, "Accounting Document Header
ITCPP. "SAPscript output parameters
TYPE-POOLS: SLIS. "ALV Declarations
$$********************************************************************
$$ GLOBAL TYPES
$$ NAMING CONVENTION: "Y_NAME"
$$********************************************************************
*eject
$$********************************************************************
$$ GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
$$ NAMING CONVENTION: "I_NAME"
$$********************************************************************
$$********************************************************************
$$ GLOBAL INTERNAL TABLES (CUSTOM STRUCTURE)
$$ NAMING CONVENTION: "T_NAME"
$$********************************************************************
*eject
$$********************************************************************
$$ GLOBAL FIELD-SYMBOLS
$$ NAMING CONVENTION: "<FS_NAME>"
$$********************************************************************
FIELD-SYMBOLS: <FS_BSIS> TYPE Y_BSIS.
$$********************************************************************
$$ MACROS DECLARATION
$$ NAMING CONVENTION: M_NAME
$$********************************************************************
$$********************************************************************
$$ PARAMETERS & SELECT-OPTIONS
$$ NAMING CONVENTION: "P_NAME" & "S_NAME"
$$********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK SS01 WITH FRAME TITLE TEXT-B01.
GENERAL SELECTIONS
SELECT-OPTIONS: S_BUKRS FOR BSIS-BUKRS OBLIGATORY,
S_HKONT FOR BSIS-HKONT OBLIGATORY,
S_BLART FOR BSIS-BLART,
S_BELNR FOR BSIS-BELNR.
SELECTION-SCREEN END OF BLOCK SS01.
SELECTION-SCREEN BEGIN OF BLOCK SS02 WITH FRAME TITLE TEXT-B02.
OPEN ITEMS:
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS P_OPIT LIKE ITEMSET-XOPSEL RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) TEXT-003 FOR FIELD P_OPIT.
SELECTION-SCREEN END OF LINE.
PARAMETERS P_STIDA LIKE RFPDO-ALLGSTID DEFAULT SY-DATLO.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN: COMMENT (12) BLANK1,
COMMENT (20) TEXT-006 FOR FIELD P_OSST.
PARAMETERS: P_OSST AS CHECKBOX DEFAULT SPACE.
SELECTION-SCREEN: COMMENT (12) BLANK2,
COMMENT (20) TEXT-007 FOR FIELD P_OUTD.
PARAMETERS:P_OUTD LIKE ITCPP-TDDEST.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK SS03.
*eject
$$********************************************************************
$$ INITIALIZATION
$$********************************************************************
INITIALIZATION.
CLEAR: E_BSID,
E_BSIS,
E_BSAS,
E_BKPF,
E_TOTAL,
E_SUMSHET_OPEN,
E_SUMSHET_CLEAR,
E_SUMSHET_TOTAL,
E_CATLOG,
E_ALV_LAYOUT.
FREE: T_BSID,
T_BSIS,
T_BSAS,
T_BKPF,
T_TOTAL,
T_SUMSHET_OPEN,
T_SUMSHET_CLEAR,
T_SUMSHET_TOTAL.
*eject
$$********************************************************************
$$ AT SELECTION-SCREEN
$$********************************************************************
AT SELECTION-SCREEN .
*eject
$$********************************************************************
$$ START-OF-SELECTION
$$********************************************************************
START-OF-SELECTION.
To Get data from tables
PERFORM F_OUT_DATA_RETRIEVEL.
*eject
$$********************************************************************
$$ END-OF-SELECTION
$$********************************************************************
END-OF-SELECTION.
To Display ALV Grid Layout
PERFORM F_ALV_DATA_RETRIVAL.
*eject
*& Form f_out_data_retrievel
data retrival for Open,Clear and All items
FORM F_OUT_DATA_RETRIEVEL.
IF P_OPIT EQ C_X.
*open items is selected data will be retrieved from BSIS table.
PERFORM F_OPEN_ITEMS.
TO GET DATA FOR SUMMARY SHEET OPEN ITEMS.
PERFORM F_GET_OPEN_SUMSHET.
ENDIF.
ENDFORM. " f_out_data_retrievel
*& Form F_OPEN_ITEMS
getting data for Open items from BSIS Table
FORM F_OPEN_ITEMS .
SELECT BUKRS
HKONT
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI
BUDAT
BLDAT
BLART
BSCHL
MWSKZ
DMBTR
SGTXT
FROM BSIS
INTO CORRESPONDING FIELDS OF TABLE T_BSIS
WHERE BUKRS IN S_BUKRS
AND HKONT IN S_HKONT
AND BLART IN S_BLART
AND BELNR IN S_BELNR
AND AUGDT NE P_STIDA .
IF SY-SUBRC NE C_0.
MESSAGE S999 WITH text-030.
ENDIF.
PERFORM F_GET_DATA_BSIS.
ENDFORM. " F_OPEN_ITEMS
To get the Entry date and Reference Key2
PERFORM F_GET_DATA_BSIS.
*& Form F_GET_DATA_BSAS
GETTING DATA FROM BSAS TABLE
FORM F_GET_DATA_BSAS .
DATA: W_TABIX TYPE SY-TABIX.
UNASSIGN <FS_BSAS>.
GETTING DATA FROM BKPF AND BSID TABLES
LOOP AT T_BSAS ASSIGNING <FS_BSAS>.
CLEAR: E_BKPF,
E_BSID,
W_TABIX.
MOVE SY-TABIX TO W_TABIX.
SELECT SINGLE BUKRS
BELNR
GJAHR
CPUDT
BUDAT
FROM BKPF
INTO CORRESPONDING FIELDS OF E_BKPF
WHERE BUKRS EQ E_BSAS-BUKRS
AND BLART EQ E_BSAS-BLART
AND BELNR EQ E_BSAS-BELNR
AND BUDAT EQ E_BSAS-BUDAT.
IF SY-SUBRC EQ C_0.
MOVE E_BKPF-CPUDT TO <FS_BSAS>-CPUDT.
MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
TRANSPORTING CPUDT.
ENDIF.
SELECT SINGLE BUKRS
KUNNR
UMSKS
UMSKZ
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI
XREF2
FROM BSID
INTO CORRESPONDING FIELDS OF E_BSID
WHERE BUKRS EQ E_BSAS-BUKRS
AND BELNR EQ E_BSAS-BELNR
AND BLART EQ E_BSAS-BLART
AND BUDAT EQ E_BSAS-BUDAT.
IF SY-SUBRC EQ C_0.
MOVE E_BSID-XREF2 TO <FS_BSAS>-XREF2.
FREE T_BSID.
MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
TRANSPORTING XREF2.
ENDIF.
<FS_BSAS>-IDATE = SY-DATUM.
<FS_BSAS>-IEDAT = <FS_BSAS>-CPUDT - <FS_BSAS>-ZUONR.
<FS_BSAS>-PTIME = SY-DATUM - <FS_BSAS>-CPUDT.
MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
TRANSPORTING IEDAT
PTIME
IDATE.
ENDLOOP.
SORT T_BSAS BY HKONT XREF2 CPUDT.
ENDFORM. " F_GET_DATA_BSAS
*& Form F_GET_DATA_BSIS
GETTING DATA FROM BSIS TABLE
FORM F_GET_DATA_BSIS .
DATA: W_TABIX TYPE SY-TABIX,
W_SGTXT LIKE BSIS-SGTXT,
W_SGTXT1 LIKE BSIS-SGTXT,
W_SORTL LIKE KNA1-SORTL.
CLEAR: E_BKPF,
E_BSID,
W_TABIX,
W_SGTXT,
W_SGTXT1,
W_SORTL.
GETTING DATA FROM BKPF AND BSID TABLES
LOOP AT T_BSIS INTO E_BSIS.
MOVE SY-TABIX TO W_TABIX.
SELECT SINGLE BUKRS
BELNR
GJAHR
CPUDT
BUDAT
FROM BKPF
INTO CORRESPONDING FIELDS OF E_BKPF
WHERE BUKRS EQ E_BSIS-BUKRS
AND BLART EQ E_BSIS-BLART
AND BELNR EQ E_BSIS-BELNR
AND BUDAT EQ E_BSIS-BUDAT.
IF SY-SUBRC EQ C_0.
MOVE E_BKPF-CPUDT TO E_BSIS-CPUDT.
FREE T_BKPF.
MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
TRANSPORTING CPUDT.
ENDIF.
SELECT SINGLE BUKRS
KUNNR
UMSKS
UMSKZ
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI
XREF2
FROM BSID
INTO CORRESPONDING FIELDS OF E_BSID
WHERE BUKRS EQ E_BSIS-BUKRS
AND BLART EQ E_BSIS-BLART
AND BELNR EQ E_BSIS-BELNR
AND BUDAT EQ E_BSIS-BUDAT.
IF sy-subrc EQ C_0.
DUMMY CHECK
ENDIF.
SELECT SINGLE KUNNR
FROM BSID
INTO CORRESPONDING FIELDS OF E_BSID
WHERE BUKRS EQ E_BSIS-BUKRS
AND BLART EQ E_BSIS-BLART
AND BELNR EQ E_BSIS-BELNR
AND BUDAT EQ E_BSIS-BUDAT.
IF sy-subrc EQ C_0.
DUMMY CHECK
ENDIF.
SELECT SINGLE SORTL
FROM KNA1
INTO W_SORTL
WHERE KUNNR EQ E_BSID-KUNNR.
IF SY-SUBRC EQ C_0.
MOVE W_SORTL TO E_BSIS-XREF2.
MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
TRANSPORTING XREF2.
ENDIF.
W_SGTXT = E_BSIS-SGTXT.
SPLIT W_SGTXT AT C_SLASH INTO W_SGTXT W_SGTXT1.
MOVE: W_SGTXT TO E_BSIS-SGTXT,
SY-DATUM TO E_BSIS-IDATE.
DATA : W_ZOUNR LIKE BSAS-ZUONR,
W_DATE TYPE D,
W_Z(10) TYPE C.
CLEAR: W_ZOUNR,
W_DATE,
W_Z.
MOVE E_BSIS-ZUONR TO W_ZOUNR.
MOVE : W_ZOUNR4(4) TO W_Z0(4),
W_ZOUNR2(2) TO W_Z4(2),
W_ZOUNR0(2) TO W_Z6(2).
MOVE W_Z TO W_DATE.
E_BSIS-IEDAT = E_BSIS-CPUDT - W_DATE.
CONCATENATE W_ZOUNR+0(2) C_DOT
W_ZOUNR+2(2) C_DOT
W_ZOUNR+4(4) INTO E_BSIS-ZUONR.
E_BSIS-PTIME = SY-DATUM - E_BSIS-CPUDT.
MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
TRANSPORTING IEDAT
PTIME
IDATE
SGTXT
ZUONR. "30TH
ENDLOOP.
SORT T_BSIS BY HKONT XREF2 CPUDT.
ENDFORM. " F_GET_DATA_BSIS
*& Form f_build_fld_catlog1
BUILDING FIELD CATALOG FOR OPEN ITEMS DATA
FORM F_FLD_CATLOG_OPEN_ITEMS.
ORM f_fld_catlog_open_items.
REFRESH i_catlog1.
CLEAR w_col_pos.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_HKONT
C_BSIS
w_col_pos
text-010
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_XREF2
C_BSIS
w_col_pos
text-011
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_BELNR
C_BSIS
w_col_pos
text-012
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_BLART
C_BSIS
w_col_pos
text-013
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_BLDAT
C_BSIS
W_col_pos
text-014
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_BUDAT
C_BSIS
w_col_pos
text-015
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_CPUDT
C_BSIS
w_col_pos
text-016
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_ZUONR
C_BSIS
w_col_pos
text-017
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_BSCHL
C_BSIS
w_col_pos
text-018
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_DMBTR
C_BSIS
w_col_pos
text-019
C_X "dispaly Sum Total
'40'.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_MWSKZ
C_BSIS
w_col_pos
text-020
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_SGTXT
C_BSIS
w_col_pos
text-021
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_IEDAT
C_BSIS
w_col_pos
text-022
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_PTIME
C_BSIS
w_col_pos
text-023
SPACE
SPACE.
CLEAR: W_COL_POS,
I_ALV_EVENTS.
ENDFORM. " f_fld_catlog_open_items
*& Form f_first_report_dispaly
ROUTINE FOR OPEN ITEMS GRID LAYOUT DISPLAY
FORM F_DISPALY_OPEN_ITEMS.
CLEAR W_REPNAME.
W_REPNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = W_REPNAME
I_CALLBACK_PF_STATUS_SET = C_FSTAT
I_CALLBACK_USER_COMMAND = C_FUCOM
I_CALLBACK_TOP_OF_PAGE = C_FTOPI
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 = E_ALV_LAYOUT
IT_FIELDCAT = I_CATLOG1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = C_A
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = I_ALV_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 = T_BSIS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2 .
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " f_dispaly_open_items
*& Form f_first_field_catalog
BUILDING FIELD CATALOG FOR SECONDERY LIST
-->us_fieldname field name
-->us_ref field ref field
-->us_ref tab ref table
-->us_text text
-->us_sum sum
FORM F_FIRST_FIELD_CATALOG USING US_FIELDNAME TYPE ANY
US_REF_TAB TYPE ANY
US_COL_POS TYPE ANY
US_COLTEXT TYPE ANY
US_DO_SUM TYPE ANY
us_out type any.
CLEAR E_CATLOG.
MOVE : US_FIELDNAME TO E_CATLOG-FIELDNAME,
US_REF_TAB TO E_CATLOG-TABNAME,
US_COL_POS TO E_CATLOG-COL_POS,
US_COLTEXT TO E_CATLOG-SELTEXT_L,
US_DO_SUM TO E_CATLOG-DO_SUM,
US_out to E_CATLOG-outputlen.
APPEND E_CATLOG TO I_CATLOG1.
CLEAR E_CATLOG.
APPEND E_CATLOG TO I_CATLOG1.
CLEAR E_CATLOG.
ENDFORM. " f_first_field_catalog
*& Form F_ALV_DATA_RETRIVAL
ALV DATA VALIDATION
FORM F_ALV_DATA_RETRIVAL .
IF P_OPIT EQ C_X
AND P_OSST EQ C_SPACE .
building field catlog for open items list
PERFORM f_fld_catlog_open_items.
first list display open items list
PERFORM f_dispaly_open_items.
Building Alv Layout
PERFORM f_alv_layout_open_items.
ENDIF.
Code to display only summary sheet P_OSST check box
IF P_OPIT EQ C_X
AND P_OSST EQ C_X.
building field catlog for open items Summary sheet
PERFORM F_FLD_CATLOG_SUMSHET_OPEN.
first list display open items Summary sheet
PERFORM F_DISPALY_SUMSHEET_OPEN.
ENDIF.
ENDFORM. " F_ALV_DATA_RETRIVAL
*& Form F_GET_OPEN_SUMSHET
GET SUMMARY SHEET OPEN ITEM DATA
FORM F_GET_OPEN_SUMSHET .
SORT T_BSIS BY SGTXT.
UNASSIGN <FS_BSIS>.
LOOP AT T_BSIS ASSIGNING <FS_BSIS>.
MOVE SY-TABIX TO W_TABIX.
IF W_TABIX EQ C_1.
MOVE : <FS_BSIS>-SGTXT TO W_SGTXT,
<FS_BSIS>-PTIME TO W_PTIME,
<FS_BSIS>-DMBTR TO W_DMBTR,
<FS_BSIS>-IEDAT TO W_IEDAT.
W_COUNT = W_COUNT + C_1.
CONTINUE.
ELSE.
IF <FS_BSIS>-SGTXT EQ W_SGTXT.
W_PTIME = W_PTIME + <FS_BSIS>-PTIME.
W_DMBTR = W_DMBTR + <FS_BSIS>-DMBTR.
W_COUNT = W_COUNT + C_1.
W_IEDAT = W_IEDAT + <FS_BSIS>-IEDAT.
CONTINUE .
ELSE.
W_ATIME = W_PTIME / W_COUNT.
W_IEDAT = W_IEDAT / W_COUNT.
MOVE : W_SGTXT TO E_SUMSHET_OPEN-SGTXT,
W_COUNT TO E_SUMSHET_OPEN-COUNT,
W_ATIME TO E_SUMSHET_OPEN-ATIME,
W_DMBTR TO E_SUMSHET_OPEN-DMBTR,
W_IEDAT TO E_SUMSHET_OPEN-IEDAT.
APPEND E_SUMSHET_OPEN TO T_SUMSHET_OPEN.
CLEAR: W_SGTXT,
W_PTIME,
W_DMBTR,
W_COUNT,
W_IEDAT.
MOVE : <FS_BSIS>-SGTXT TO W_SGTXT,
<FS_BSIS>-PTIME TO W_PTIME,
<FS_BSIS>-DMBTR TO W_DMBTR,
<FS_BSIS>-IEDAT TO W_IEDAT.
W_COUNT = W_COUNT + C_1.
CONTINUE.
ENDIF.
ENDIF.
ENDLOOP.
W_ATIME = W_PTIME / W_COUNT.
W_IEDAT = W_IEDAT / W_COUNT.
MOVE : W_SGTXT TO E_SUMSHET_OPEN-SGTXT,
W_COUNT TO E_SUMSHET_OPEN-COUNT,
W_ATIME TO E_SUMSHET_OPEN-ATIME,
W_DMBTR TO E_SUMSHET_OPEN-DMBTR,
W_IEDAT TO E_SUMSHET_OPEN-IEDAT.
APPEND E_SUMSHET_OPEN TO T_SUMSHET_OPEN.
CLEAR E_SUMSHET_OPEN.
ENDFORM. " F_GET_OPEN_SUMSHET
*& Form F_TOP_OF_PAGE
ITEMS TOP OF PAGE DATA
FORM F_TOP_OF_PAGE .
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE W_HEADER-INFO.
CLEAR W_HEADER.
*TITLE
MOVE C_H TO W_HEADER-TYP.
MOVE C_TEXT TO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
MOVE C_S TO W_HEADER-TYP.
MOVE C_TEXT2 TO W_HEADER-KEY.
CONCATENATE SY-DATUM+6(2) C_SLASH
SY-DATUM+4(2) C_SLASH
SY-DATUM(4) INTO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CLEAR: W_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. " F_TOP_OF_PAGE
FORM F_DISPALY_SUMSHEET_OPEN .
CLEAR w_repname.
w_repname = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = w_repname
I_CALLBACK_PF_STATUS_SET = C_FSTAT
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = C_FTOPS
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 = e_alv_layout
IT_FIELDCAT = i_catlog1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = C_A
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = i_alv_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 = T_SUMSHET_OPEN
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FREE T_SUMSHET_OPEN.
ENDFORM. " F_DISPALY_SUMSHEET_OPEN
*& Form F_TOP_OF_PAGE_SUMSHET
TOP OF PAGE FOR SUMMARY SHEET
FORM F_TOP_OF_PAGE_SUMSHET .
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE W_HEADER-INFO.
CLEAR: W_HEADER,
T_HEADER,
T_LINE.
*TITLE
MOVE C_H TO W_HEADER-TYP.
MOVE C_TEXT1 TO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. " F_TOP_OF_PAGE_SUMSHET
*& Form F_PF_STATUS
GET PF STATUS
FORM F_PF_STATUS USING US_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS C_STAT EXCLUDING US_EXTAB.
ENDFORM. "F_PF_STATUS
*& Form F_USER_COMMAND
GET USER COMMAND
*FORM F_USER_COMMAND USING W_UCOMM LIKE SY-UCOMM
US_SELFIELD TYPE SLIS_SELFIELD.
FORM F_USER_COMMAND USING US_UCOMM LIKE SY-UCOMM
US_SELFIELD TYPE SLIS_SELFIELD.
CONSTANTS:C_NEXT(6) TYPE C VALUE '&NEXT'.
if sy-subrc eq c_0.
MOVE C_TEXT3 TO US_SELFIELD-TABNAME.
endif.
IF P_OPIT EQ C_X
AND US_UCOMM EQ C_NEXT .
PERFORM F_FLD_CATLOG_SUMSHET_OPEN.
PERFORM F_DISPALY_SUMSHEET_OPEN.
ELSEIF P_CLIT EQ C_X
AND US_UCOMM EQ C_NEXT.
PERFORM F_FLD_CATLOG_SUMSHET_CLEAR.
PERFORM F_DISPALY_SUMSHET_CLEAR.
ELSEIF P_ALIT EQ C_X
AND US_UCOMM EQ C_NEXT.
PERFORM F_FLD_CATLOG_SUMSHET_TOTAL.
PERFORM F_DISPALY_SUMSHET_TOTAL.
ENDIF.
ENDFORM. "F_USER_COMMAND
*& Form f_alv_layout_open_items
text
----Hi,
Please refer to the sample code :
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
Thanks,
Sriram Ponna. -
ALV Grid Control - Modifiy data in total and subtotal lines
Hello all,
I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
Material delivered returned quote
..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
..4711 . . . 400 . . . 10 . . . . 2,5
. SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
Is there a possibility to modify data in the total and subtotal lines.
Thank you for your answer
Best regards
Thomasyou said instead of 3.5 you want to show 1,667 ..
how is it possible...
3,5 become 1,667
i thought you are doing any conversions...
vijay
Maybe you are looking for
-
Recently i upgraded my SharePoint server 2013 to SP1, after the upgrade i received following message in manage database Status page " Databases running in compatibility range, upgrade recommended" for Business Data Connectivity Database. Then i ran
-
For a long time I've been syncing notes between my iPhone 3G and my MacBook with no problem. Today I find that the past few syncs have not really worked; a handful of new notes created on the iPhone do not appear in Mail notes on the MacBook. Convers
-
AIP-50077: Cannot Initialize Transport
Hi, I configured custom document over Generic Exchange using JMS tranport. I configured JMS queue in SOA. I am getting the following errors in b2b.log 2008.11.24 at 16:00:56:103: B2BStarter thread: B2B - (DEBUG) oracle.tip.adapter.b2b.transport.Trans
-
Backup task failed with exit code -1
Hello all. I have not been able to backup my Daylite database for almost 2 weeks. This is the error I am getting: "backup task failed with exit code -1" I have a Mac Mini Server running 10.7.1 . I have plenty of disk space available 140GB and the
-
Block text in propertional script shows ugly side-effects
If you look at this message (quoted from here, 4th post down), [quote] If I was satisfied with your previous answer, I wouldn't have posted at all. It seems to me a lot of T61p owners at TPForums and NotebookReviewForums are having this problem. So f