Totas and sub totals in ALV grid display
Hi all,
how can I get the total for an integer field in internal table. I am using the following code, but unable to display the total. Can anyone give the reason for the same.
Thank you,
Usha
REPORT ZTEST_SUB .
TABLES : vbak.
TYPE-POOLS: slis.
SELECT-OPTIONS : s_vkorg FOR vbak-vkorg,
s_kunnr FOR vbak-kunnr,
s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN : SKIP,
BEGIN OF LINE,
COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '2' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
DATA: BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg,
kunnr LIKE vbak-kunnr,
vbeln LIKE vbak-vbeln,
test type I,
END OF gt_vbak.
START-OF-SELECTION.
PERFORM f_read_data.
loop at gt_vbak.
gt_vbak-test = 1.
modify gt_vbak.
endloop.
PERFORM f_display_data.
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak UP TO p_max ROWS WHERE
kunnr IN s_kunnr AND
vbeln IN s_vbeln AND
vkorg IN s_vkorg.
ENDFORM.
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-ref_FIELDname = &2.
ls_fieldcat-do_sum = &3.
ls_fieldcat-cfieldname = &4.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
ls_sort-group = '*'.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' '' ''.
m_fieldcat 'VBELN' '' '' ''.
m_fieldcat 'TEST' '' 'X' ''.
m_sort 'VKORG' ''.
m_sort 'KUNNR' ''.
m_sort 'VBELN' ''.
m_sort 'TEST' 'X'.
ls_layout-cell_merge = 'X'.
LS_LAYOUT-WINDOW_TITLEBAR = 'test window'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = lt_fieldcat
IT_SORT = lt_sort
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = gt_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.
hi
REPORT ZTEST_SUB .
TABLES : vbak.
TYPE-POOLS: slis.
SELECT-OPTIONS : s_vkorg FOR vbak-vkorg,
s_kunnr FOR vbak-kunnr,
s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN : SKIP,
BEGIN OF LINE,
COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '2' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
DATA: BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg,
kunnr LIKE vbak-kunnr,
vbeln LIKE vbak-vbeln,
test type I,
END OF gt_vbak.
START-OF-SELECTION.
PERFORM f_read_data.
loop at gt_vbak.
gt_vbak-test = 1.
modify gt_vbak.
endloop.
PERFORM f_display_data.
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak UP TO p_max ROWS WHERE
kunnr IN s_kunnr AND
vbeln IN s_vbeln AND
vkorg IN s_vkorg.
ENDFORM.
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-ref_FIELDname = &2.
ls_fieldcat-do_sum = &3.
ls_fieldcat-cfieldname = &4.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
ls_sort-group = '*'.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' '' ''.
m_fieldcat 'VBELN' '' '' ''.
m_fieldcat 'TEST' '' 'X' ''.
m_sort 'VKORG' ''.
m_sort 'KUNNR' ''.
<b> m_sort 'VBELN' 'X'.</b>
*m_sort 'TEST' 'X'.
ls_layout-cell_merge = 'X'.
LS_LAYOUT-WINDOW_TITLEBAR = 'test window'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = lt_fieldcat
IT_SORT = lt_sort
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = gt_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.
Message was edited by: Ashok Parupalli
Similar Messages
-
Totals and Sub-Totals in ALV GRID
Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
Ex: value1 value2
100 50
200 50
subtotal 300 100
total 400
Thanks in advance...Refer below demo code and see perform Sort_list..
it wil serve ur purpose.
REPORT ZGILL_ALV message-id rp .
type-pools slis.
tables: zgill_main,zgill_details.
data z_fieldcat type slis_t_fieldcat_alv.
data begin of itab occurs 0.
DATA ICON TYPE ICON-ID.
include structure zgill_main.
data salary like zgill_details-salary.
data end of itab.
*data itab1 like table of itab with header line.
data : WA_SORT TYPE SLIS_SORTINFO_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
PARAMETERS: p_list radiobutton group A1,
P_GRID RADIOBUTTON GROUP A1.
SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
start-of-selection.
perform fill_itab.
perform sort_list.
**************Start of scenario without container******************************************
*********Method 1***********
perform fill_fieldcat. " Manuallly Preparing Fiedl Catalog
*********Method 2***********
*perform fill_fieldcat1 changing z_fieldcat. "Preparing field catalog with merge function
perform display_alv.
*****************end of scenario without container*****************************************
*& Form fill_itab
text
--> p1 text
<-- p2 text
form fill_itab .
*select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
*ITAB1[] = ITAB[].
select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
from zgill_main as a join zgill_details as b on apernr = bpernr
WHERE A~PERNR IN S_PERNR.
LOOP AT ITAB.
IF ITAB-PERNR < 1111.
ITAB-ICON = '@08@'.
ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
ITAB-ICON = '@09@'.
ELSEIF ITAB-PERNR GE 11111111.
ITAB-ICON = '@0A@'.
ENDIF.
MODIFY ITAB INDEX SY-TABIX.
ENDLOOP.
endform. " fill_itab
*& Form display_alv
text
--> p1 text
<-- p2 text
form display_alv .
data repid like sy-repid.
REPID = SY-REPID.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
IF P_GRID = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = IT_FIELDTAB
IT_SORT = IT_SORT
IS_LAYOUT = WA_LAYOUT
TABLES
t_outtab = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
message e016 with 'Error in Display'.
ENDIF.
ELSEIF P_LIST = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = IT_FIELDTAB
IT_SORT = IT_SORT
IS_LAYOUT = WA_LAYOUT
TABLES
t_outtab = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
message e016 with 'Error in Display'.
ENDIF.
ENDIF.
endform. " display_alv
*& Form fill_fieldcat1
text
--> p1 text
<-- p2 text
form fill_fieldcat1 changing d_fcat type slis_t_fieldcat_alv.
data repid like sy-repid.
data d_fcat1 type slis_t_fieldcat_alv with header line.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = repid
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME = 'ZGILL_MAIN'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = d_fcat[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF sy-subrc <> 0.
message e016 with 'Error in preparing fiedl catalog'.
ENDIF.
loop at d_fcat into d_fcat1.
case d_fcat1-fieldname.
when 'NAME'.
d_fcat1-reptext_ddic = 'Emp Name'.
MODIFY D_FCAT FROM D_FCAT1.
WHEN 'PERNR'.
d_fcat1-reptext_ddic = 'Emp Num'.
MODIFY D_FCAT FROM D_FCAT1.
WHEN 'ORG'.
d_fcat1-reptext_ddic = 'Org Unit'.
MODIFY D_FCAT FROM D_FCAT1.
endcase.
clear d_fcat1.
endloop.
endform. " fill_fieldcat1
*& Form sort_list
text
--> p1 text
<-- p2 text
form sort_list .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'DOB'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'NAME'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
endform. " sort_list
*& Form fill_fieldcat
text
--> p1 text
<-- p2 text
form fill_fieldcat .
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'ICON'.
WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
WA_FIELDCAT-ICON = 'X'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 1.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'PERNR'.
WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 2.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
when 'maktx'.
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'NAME'.
WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 3.
WA_FIELDCAT-OUTPUTLEN = 15.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'ORG'.
WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
WA_FIELDCAT-COL_POS = 4.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'DOB'.
WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
WA_FIELDCAT-COL_POS = 5.
WA_FIELDCAT-OUTPUTLEN = 12.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'SALARY'.
WA_FIELDCAT-SELTEXT_L = 'SALARY'.
WA_FIELDCAT-COL_POS = 6.
WA_FIELDCAT-OUTPUTLEN = 25.
WA_FIELDCAT-do_sum = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
endform. " fill_fieldcat -
Need to add Header and footer in an alv grid display output.
How can I add header and footer in an alv grid dispay output.
For the grid display, I am using the function module "REUSE_ALV_GRID_DISPLAY".HI,
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_html_end_of_list = 'END_OF_LIST_HTML'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.
ls_text = 'Footer title'.
adds and icon (red triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'IL'.
adds test (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.
adds new line (start new line)
CALL METHOD end->new_line.
display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Bold text'
sap_emphasis = 'strong'.
adds new line (start new line)
CALL METHOD end->new_line.
display text(normal)
CALL METHOD end->add_text
EXPORTING
text = 'Nor'.
adds new line (start new line)
CALL METHOD end->new_line.
display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Yellow '
sap_emphasis = 'str'.
adds and icon (yellow triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'IC''.
display text(normal)
CALL METHOD end->add_text
EXPORTING
text = 'Mor'.
*set height of this section
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 14.
ENDFORM. "end_of_list_html.
This will solve it. Post if you need more help in this.
Regards,
Madhu. -
Sub columns in alv grid display
hi everyone,
can anyone tell me the way in which we can include sub-column headings in alv grid display. i.e., for example as shown below.
column1 column2 column3
scol1 scol2 scol3 scol4 scol5 scol6........................
thanks in advance. Here we are generating the column headings by using fm field catalog merge.
regards,
rajsekhar.kcheck this thread, check the sample code in my post
Re: multiple headers in ALV. -
Sub total in ALV GRID using oops concept
Hi,
If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items. Copy all fields from the original order line except for plant and Net Value. Net Value should be the total of item Net Values for all items with the same plant in the order.
Example:
Data:
Order---- Item- Plant- Net Value---
123---- 010- 3467- 100.00---
123---- 020- 7865- 50.00---
123---- 030- 3467- 80.50---
Report:
Order- Plant- Net Value---
123- 3467- 180.50---
123- 7865- 50.00----
I need to dispaly the Report format in ALV Grid using oops concept...
no need of calling any function modules.
Regards,
NithyaHi
Here is example code
This is the method to be called:
get_subtotals
Use
Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).
Integration
Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.
If the field SUBTOT is set for a column in this table, the column is a subtotals column.
The field SPOS then indicates at which level (see below) the subtotal has been calculated.
The field FIELDNAME contains the name of the subtotals column in the output table.
Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).
Features
CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
IMPORTING
EP_COLLECT00 = <reference variable of type REF TO DATA>
EP_COLLECT01 = <reference variable of type REF TO DATA>
EP_COLLECT02 = <reference variable of type REF TO DATA>
EP_COLLECT03 = <reference variable of type REF TO DATA>
EP_COLLECT04 = <reference variable of type REF TO DATA>
EP_COLLECT05 = <reference variable of type REF TO DATA>
EP_COLLECT06 = <reference variable of type REF TO DATA>
EP_COLLECT07 = <reference variable of type REF TO DATA>
EP_COLLECT08 = <reference variable of type REF TO DATA>
EP_COLLECT09 = <reference variable of type REF TO DATA>
ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.
In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).
Parameters
Meaning
EP_COLLECT00
Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.
get_subtotals
EP_COLLECT01 to EP_COLLECT09
Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.
ET_GROUPLEVELS
Manages all indexes for the individual control levels. The fields of the table have the following meaning:
INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created
LEVEL: Subtotals level (see above)
COUNTER: Number of rows for which the subtotal was created
COMPRESS: For this subtotals line, the user has hidden the associated rows.
COLLECT: Indicates the subtotals table (01-09) in which the values are stored
For an overview, see Methods of Class CL_GUI_ALV_GRID
Activities -
How to include change delete and insert options in alv grid display
Hi,
As per my requirement I need to display my output in grid.
When the user makes any changes to any field of the alv it should get reflected in the tatabase table.
Similarly according to the requirement if user enters a new coloumn to the alv or deletes one or more rows of the alv,same should be reflected in the databse table.
I know there are many methods in object oriented.
But its little bit tough for me to implement..
Please suggest how to code for it without oo concepts.
Thanks ,
SmritiHi,
use FM with Edit functionality enabled for all fields and
Create one pf-status with some buttons
if user presses the button the alv output table should be saved and same table can be used to insert /modify /delete the dbtable.
and check this link
[alv list|alv list]
Regards,
Nandha -
Subtotal in ALV grid for a particular type and Grand total in ALV
Hi,
I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
ALV output required as below:
Type VAT registration number Country Total Gross Amounts Total Tax Amounts Total Amount, ex-tax
Goods ATU12345678 AT 222.42 0 222.42
Goods NL123456789B02 NL 3,417.00 0 3,417.00
Goods Total 3,639.42 - 3,639.42
Services ATU12345678 AT 2,342.34 0 2,342.34
Services NL123456789B02 NL 223.33 0 223.33
Services Total 2,565.67 - 2,565.67
Grand Total 6,205.09 - 6,205.09
Let me as to how to achieve the above type in ALV grid...
Regards
Shivacheck this link..
Grand Totals in ALV grid disply function module
or do like this..
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
*& Form getD_data
text
--> p1 text
<-- p2 text
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
*& Form disp_alv
text
--> p1 text
<-- p2 text
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv -
Field Catolgue in alv grid display
Hi Abapers,
I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
sno total col1 col2 col3
1 220 100 20 100
2 320 120 50 150
tot 540 220 70 250
per 40.74 1.87 and so on
or ,
I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
Regards,
PriyaDon't do total by your self in the Pogram.
in the Fieldcatalog there is an Attribute which will do total & Average .
Enable it so that from one internal table data it self it will do good.
example program
Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
display it using the basic ALV grid functionality(including column total). The example details the main
sections of coding required to implement the ALV grid functionality:
Data declaration
Data retrieval
Build fieldcatalog
Build layout setup
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& 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
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
* i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
* i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
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_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
gowri
Message was edited by:
Gowri Krishna -
Sub total in ALV report.
hello everyone,
i am developing one ALV report and one problem is there.
i want Material Group wise total on 1.Quantity 2. Asssessable value 3. Basic duty 4. Edu cess.
Problem is all total are correct but when material group is different it repeat same total again. how to do total different material group wise?
i am using this code...............
*& Report ZHP_EXCISE_INVOICE
REPORT zhp_excise_invoice NO STANDARD PAGE HEADING LINE-SIZE 150 MESSAGE-ID 00.
TYPE-POOLS: slis.
TABLES: j_1iexchdr,vbrk,vbrp,t001w,t023t,konv.
DATA: BEGIN OF ithp_j_1iexchdr OCCURS 0,
docyr LIKE j_1iexchdr-docyr, "Year
bukrs LIKE j_1iexchdr-bukrs, "Company Code
werks LIKE j_1iexchdr-werks, "PLANT
exdat LIKE j_1iexchdr-exdat, "Excise Document Date
rdoc LIKE j_1iexchdr-rdoc, "Reference Document 1
preprn LIKE j_1iexchdr-preprn, "Preprinted Serial Number
kunag LIKE j_1iexchdr-kunag, "Sold-to party
kunwe LIKE j_1iexchdr-kunwe, "Ship-to party
exbed LIKE j_1iexchdr-exbed, "Basic Excise Duty
ecs LIKE j_1iexchdr-ecs, "Edu Cess amount
status LIKE j_1iexchdr-status, "Excise Document Status
censtat LIKE j_1iexchdr-censtat, "CENVAT Utilization status
exccd LIKE j_1iexchdr-exccd, "ECC Number
trntyp LIKE j_1iexchdr-trntyp, "Excise Transaction Type
vbeln LIKE vbrk-vbeln, "Billing Document
kzwi2 LIKE vbrp-kzwi2, "Assessable value
fkimg LIKE vbrp-fkimg, "Actual billed quantity
matkl LIKE vbrp-matkl, "Material group
netwr LIKE vbrp-netwr, "Net value
name1 LIKE t001w-name1, "Plant Name
wgbez LIKE t023t-wgbez, "Material Group Desc.
serial_no TYPE i,
subtot1 TYPE vbrp-fkimg,
price_per TYPE konv-kbetr,
cash_disc TYPE konv-kwert,
vol_disc TYPE konv-kwert,
***_value TYPE konv-kbetr,
***_value1 TYPE konv-kbetr,
BASIC_DUTY1 TYPE konv-kwert,
EDU_CESS1 TYPE konv-kwert,
END OF ithp_j_1iexchdr.
DATA : x TYPE i VALUE 0,
y TYPE i VALUE 0.
DATA: t_fillcat TYPE slis_t_fieldcat_alv,
w_fillcat TYPE slis_fieldcat_alv,
layout TYPE slis_layout_alv,
repid LIKE sy-repid.
TYPES: BEGIN OF ty_itab,
price_per TYPE konv-kbetr,
basic_prc TYPE konv-kbetr,
cash_disc TYPE konv-kwert,
vol_disc TYPE konv-kwert,
***_value TYPE konv-kbetr,
END OF ty_itab.
DATA:it_itab TYPE ty_itab OCCURS 0 WITH HEADER LINE,
wa_itab TYPE ty_itab.
TYPES: BEGIN OF ty_konv,
kschl TYPE konv-kschl,
kbetr TYPE konv-kbetr,
kwert TYPE konv-kwert,
mwsk1 TYPE konv-mwsk1,
knumv TYPE konv-knumv,
kposn TYPE konv-kposn,
END OF ty_konv.
DATA: it_konv TYPE ty_konv OCCURS 0 WITH HEADER LINE,
wa_konv TYPE ty_konv .
TYPES: BEGIN OF ty_vbrk,
fkdat TYPE vbrk-fkdat,
fkart TYPE vbrk-fkart,
knumv TYPE vbrk-knumv,
vbeln TYPE vbrk-vbeln,
vbtyp TYPE vbrk-vbtyp,
bukrs TYPE vbrk-bukrs,
kunrg TYPE vbrk-kunrg,
END OF ty_vbrk.
DATA: it_vbrk TYPE ty_vbrk OCCURS 0 WITH HEADER LINE,
wa_vbrk TYPE ty_vbrk .
TYPES : BEGIN OF ty_vbrp,
werks TYPE vbrp-werks,
spart TYPE vbrp-spart,
vkbur TYPE vbrp-vkbur,
matkl TYPE vbrp-matkl,
vbeln TYPE vbrp-vbeln,
posnr TYPE vbrp-posnr,
vgbel TYPE vbrp-vgbel,
matnr TYPE vbrp-matnr,
brgew TYPE vbrp-brgew,
fkimg TYPE vbrp-fkimg,
vrkme TYPE vbrp-vrkme,
netwr TYPE vbrp-netwr,
arktx TYPE vbrp-arktx,
aubel TYPE vbrp-aubel,
kzwi1 TYPE vbrp-kzwi1,
kzwi2 TYPE vbrp-kzwi2,
kzwi4 TYPE vbrp-kzwi4,
kzwi5 TYPE vbrp-kzwi5,
kzwi6 TYPE vbrp-kzwi6,
END OF ty_vbrp.
DATA: it_vbrp TYPE ty_vbrp OCCURS 0 WITH HEADER LINE,
wa_vbrp TYPE ty_vbrp.
DATA: events TYPE slis_t_event,
gt_list_top_of_page TYPE slis_t_listheader.
top_of_page type slis_formname value 'TOP_OF_PAGE'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: p_bukrs FOR j_1iexchdr-bukrs.
SELECT-OPTIONS: p_exgrp FOR j_1iexchdr-exgrp.
SELECT-OPTIONS: p_werks FOR j_1iexchdr-werks.
SELECT-OPTIONS: p_matkl FOR vbrp-matkl.
SELECT-OPTIONS: p_trntyp FOR j_1iexchdr-trntyp DEFAULT 'DLFC' NO INTERVALS.
SELECT-OPTIONS: p_status FOR j_1iexchdr-status DEFAULT 'C' NO INTERVALS.
SELECT-OPTIONS: p_cnstat FOR j_1iexchdr-censtat DEFAULT 'P' NO INTERVALS.
SELECT-OPTIONS: p_exdat FOR j_1iexchdr-exdat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
repid = sy-repid.
AT SELECTION-SCREEN ON p_bukrs.
SELECT SINGLE * FROM j_1iexchdr WHERE bukrs IN p_bukrs.
IF sy-subrc <> 0.
MESSAGE e001 WITH 'No Table Entries Found'.
EXIT.
ENDIF.
AT SELECTION-SCREEN ON p_werks.
SELECT SINGLE * FROM j_1iexchdr WHERE werks IN p_werks.
IF sy-subrc <> 0.
MESSAGE e001 WITH 'No Table Entries Found'.
EXIT.
ENDIF.
AT SELECTION-SCREEN ON p_matkl.
SELECT SINGLE * FROM vbrp WHERE matkl IN p_matkl.
IF sy-subrc <> 0.
MESSAGE e001 WITH 'No Table Entries Found'.
EXIT.
ENDIF.
AT SELECTION-SCREEN ON p_exdat.
SELECT SINGLE * FROM j_1iexchdr WHERE exdat IN p_exdat.
IF sy-subrc <> 0.
MESSAGE e001 WITH 'No Table Entries Found'.
EXIT.
ENDIF.
START-OF-SELECTION.
PERFORM select.
PERFORM fillcat.
PERFORM display.
END-OF-SELECTION.
*& Form SELECT
text
--> p1 text
<-- p2 text
FORM select .
SELECT DOCYR
BUKRS
WERKS
EXDAT
RDOC
PREPRN
KUNAG
KUNWE
EXBED
ECS
STATUS
CENSTAT
INTO CORRESPONDING FIELDS OF TABLE ITHP_J_1IEXCHDR
FROM J_1IEXCHDR
WHERE BUKRS IN P_BUKRS AND
EXGRP IN P_EXGRP AND
WERKS IN P_WERKS AND
EXDAT IN P_EXDAT.
SELECT VBELN
NETWR
INTO CORRESPONDING FIELDS OF TABLE ITHP_VBRK
FROM VBRK
FOR ALL ENTRIES IN ITHP_J_1IEXCHDR
WHERE VBELN EQ ITHP_J_1IEXCHDR-RDOC AND
BUKRS EQ ITHP_J_1IEXCHDR-BUKRS AND
KUNAG EQ ITHP_J_1IEXCHDR-KUNAG.
SORT ITHP_J_1IEXCHDR BY DOCYR BUKRS WERKS EXDAT RDOC.
SORT ITHP_VBRK BY VBELN.
SELECT a~docyr
a~bukrs
a~werks
a~exdat
a~rdoc
a~preprn
a~kunag
a~kunwe
a~exbed
a~ecs
a~status
a~censtat
a~exccd
a~trntyp
c~netwr
c~kzwi2
c~fkimg
c~matkl
d~name1
e~wgbez
INTO CORRESPONDING FIELDS OF TABLE ithp_j_1iexchdr
FROM j_1iexchdr AS a INNER JOIN vbrk AS b ON ardoc = bvbeln
INNER JOIN vbrp AS c ON bvbeln = cvbeln
INNER JOIN t001w AS d ON awerks = dwerks
INNER JOIN t023t AS e ON cmatkl = ematkl
WHERE a~bukrs IN p_bukrs AND
a~exgrp IN p_exgrp AND
a~werks IN p_werks AND
c~matkl IN p_matkl AND
a~trntyp IN p_trntyp AND
a~status IN p_status AND
a~censtat IN p_cnstat AND
a~exdat IN p_exdat.
SORT ithp_j_1iexchdr BY docyr bukrs werks exdat rdoc matkl.
ENDFORM. " SELECT
*& Form FILLCAT
text
--> p1 text
<-- p2 text
FORM fillcat .
DATA: subtot TYPE vbrp-fkimg.
DATA: BASIC_DUTY TYPE konv-kwert.
DATA: EDU_CESS TYPE konv-kwert.
REFRESH it_vbrk.
REFRESH it_konv.
REFRESH it_vbrp.
LOOP AT ithp_j_1iexchdr.
SELECT fkdat fkart knumv vbeln vbtyp bukrs kunrg
FROM vbrk INTO TABLE it_vbrk
WHERE vbeln EQ ithp_j_1iexchdr-rdoc.
SELECT kschl kbetr kwert mwsk1 knumv kposn FROM konv
INTO TABLE it_konv FOR ALL ENTRIES IN it_vbrk
WHERE knumv EQ it_vbrk-knumv.
SELECT werks spart vkbur matkl vbeln posnr
vgbel matnr brgew fkimg vrkme netwr
arktx aubel kzwi1 kzwi2 kzwi4 kzwi5
kzwi6 FROM vbrp INTO TABLE it_vbrp FOR ALL
ENTRIES IN it_vbrk
WHERE vbeln EQ it_vbrk-vbeln.
SORT it_vbrk BY vbeln knumv.
SORT it_konv BY KSCHL knumv.
SORT it_vbrp BY vbeln.
LOOP AT it_konv.
IF it_konv-kschl = 'ZASS'.
LOOP AT it_konv.
IF it_konv-kschl = 'ZPR0'.
it_itab-***_value = it_konv-kwert.
ithp_j_1iexchdr-***_value = it_itab-***_value.
ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
ithp_j_1iexchdr-***_value1 = ithp_j_1iexchdr-***_value1 - ithp_j_1iexchdr-***_value.
MODIFY ithp_j_1iexchdr.
ENDIF.
IF it_konv-kschl = 'ZASS'.
it_itab-***_value = it_konv-kwert.
ithp_j_1iexchdr-***_value = it_itab-***_value.
ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
MODIFY ithp_j_1iexchdr.
ENDIF.
ENDLOOP.
EXIT.
ENDIF.
IF it_konv-kschl = 'PR00'.
it_itab-***_value = it_konv-kwert.
ithp_j_1iexchdr-***_value = it_itab-***_value.
ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
MODIFY ithp_j_1iexchdr.
ENDIF.
IF it_konv-kschl = 'ZPR0'.
LOOP AT it_konv.
IF it_konv-kschl = 'ZASS'.
EXIT.
ENDIF.
it_itab-***_value = it_konv-kwert.
ithp_j_1iexchdr-***_value = it_itab-***_value.
ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
ithp_j_1iexchdr-***_value1 = ithp_j_1iexchdr-***_value1 - ithp_j_1iexchdr-***_value.
MODIFY ithp_j_1iexchdr.
ENDIF.
IF it_konv-kschl = 'ZPR0'.
it_itab-***_value = it_konv-kwert.
ithp_j_1iexchdr-***_value = it_itab-***_value.
ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
MODIFY ithp_j_1iexchdr.
ENDIF.
ENDLOOP.
EXIT.
ENDIF.
IF it_konv-kschl = 'JEXP'.
BASIC_DUTY = it_konv-kwert.
ADD BASIC_DUTY TO ithp_j_1iexchdr-BASIC_DUTY1.
MODIFY ithp_j_1iexchdr.
ENDIF.
IF it_konv-kschl = 'JECS'.
EDU_CESS = it_konv-kwert.
ADD EDU_CESS TO ithp_j_1iexchdr-EDU_CESS1.
MODIFY ithp_j_1iexchdr.
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT ithp_j_1iexchdr.
AT NEW rdoc.
SUM.
subtot = ithp_j_1iexchdr-fkimg.
ENDAT.
ithp_j_1iexchdr-subtot1 = subtot.
MODIFY ithp_j_1iexchdr.
AT NEW MATKL.
ENDAT.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ithp_j_1iexchdr.
LOOP AT ithp_j_1iexchdr.
x = x + 1.
ithp_j_1iexchdr-serial_no = x.
MODIFY ithp_j_1iexchdr.
ENDLOOP.
repid = sy-repid.
DATA: col_pos TYPE i VALUE 0.
col_pos = col_pos + 1.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'SERIAL_NO'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Serial No'.
w_fillcat-seltext_m = 'Serial No'.
w_fillcat-seltext_l = 'Serial No'.
w_fillcat-outputlen = 8.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'DOCYR'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Year'.
w_fillcat-seltext_m = 'Year'.
w_fillcat-seltext_l = 'Year'.
w_fillcat-outputlen = 5.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'WERKS'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Plant'.
w_fillcat-seltext_m = 'Plant'.
w_fillcat-seltext_l = 'Plant'.
w_fillcat-outputlen = 5.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'EXDAT'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Doc. Date'.
w_fillcat-seltext_m = 'Doc. Date'.
w_fillcat-seltext_l = 'Doc. Date'.
w_fillcat-outputlen = 10.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'RDOC'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Ref. Document'.
w_fillcat-seltext_m = 'Ref. Document'.
w_fillcat-seltext_l = 'Ref. Document'.
w_fillcat-outputlen = 11.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'PREPRN'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Invoice No'.
w_fillcat-seltext_m = 'Invoice No'.
w_fillcat-seltext_l = 'Invoice No'.
w_fillcat-outputlen = 11.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'SUBTOT1'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-do_sum = 'X'.
w_fillcat-seltext_s = 'Quantity'.
w_fillcat-seltext_m = 'Quantity'.
w_fillcat-seltext_l = 'Quantity'.
w_fillcat-outputlen = 13.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = '***_VALUE1'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-do_sum = 'X'.
w_fillcat-seltext_s = 'Assessable value'.
w_fillcat-seltext_m = 'Assessable value'.
w_fillcat-seltext_l = 'Assessable value'.
w_fillcat-outputlen = 15.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'BASIC_DUTY1'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-do_sum = 'X'.
w_fillcat-seltext_s = 'Basic Duty'.
w_fillcat-seltext_m = 'Basic Duty'.
w_fillcat-seltext_l = 'Basic Duty'.
w_fillcat-outputlen = 13.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'EDU_CESS1'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-do_sum = 'X'.
w_fillcat-seltext_s = 'Edu Cess'.
w_fillcat-seltext_m = 'Edu Cess'.
w_fillcat-seltext_l = 'Edu Cess'.
w_fillcat-outputlen = 13.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'KUNAG'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Sold-to pt'.
w_fillcat-seltext_m = 'Sold-to pt'.
w_fillcat-seltext_l = 'Sold-to pt'.
w_fillcat-outputlen = 10.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'KUNWE'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Ship-to pt'.
w_fillcat-seltext_m = 'Ship-to pt'.
w_fillcat-seltext_l = 'Ship-to pt'.
w_fillcat-outputlen = 10.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'STATUS'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Doc. Status'.
w_fillcat-seltext_m = 'Doc. Status'.
w_fillcat-seltext_l = 'Doc. Status'.
w_fillcat-outputlen = 8.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'CENSTAT'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Cenvet status'.
w_fillcat-seltext_m = 'Cenvet status'.
w_fillcat-seltext_l = 'Cenvet status'.
w_fillcat-outputlen = 8.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'MATKL'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Mat. Grp'.
w_fillcat-seltext_m = 'Mat. Grp'.
w_fillcat-seltext_l = 'Mat. Grp'.
w_fillcat-outputlen = 9.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
col_pos = col_pos + 1.
w_fillcat-fieldname = 'WGBEZ'.
w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
w_fillcat-col_pos = col_pos.
w_fillcat-seltext_s = 'Mat. Grp Desc.'.
w_fillcat-seltext_m = 'Mat. Grp Desc.'.
w_fillcat-seltext_l = 'Mat. Grp Desc.'.
w_fillcat-outputlen = 20.
APPEND w_fillcat TO t_fillcat.
CLEAR w_fillcat.
ENDFORM. " FILLCAT
*& Form DISPLAY
text
--> p1 text
<-- p2 text
FORM display .
DATA : lv_grid_title TYPE lvc_title.
DATA: date1(10) TYPE c.
DATA: tperiod(500) TYPE c,
tperiod1(40) TYPE c,
tperiod2(30) TYPE c,
temp(25) TYPE c,
temp1(35) TYPE c,
temp2(25) TYPE c,
temp3(25) TYPE c,
temp4(60) TYPE c,
temp5(100) TYPE c.
CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum+0(4)
INTO date1 SEPARATED BY '/'.
CONCATENATE p_exdat-low6(2) p_exdat-low4(2) p_exdat-low+0(4)
INTO temp1 SEPARATED BY '/'.
CONCATENATE p_exdat-high6(2) p_exdat-high4(2) p_exdat-high+0(4)
INTO temp2 SEPARATED BY '/'.
CONCATENATE 'DUTY DEBIT STMT:'
temp1 'TO' temp2
INTO tperiod
SEPARATED BY space.
IF ithp_j_1iexchdr-werks = '1000'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1101'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1102'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1103'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1104'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1201'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1202'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1203'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1204'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1205'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1261'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1301'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '1901'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '2000'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '2101'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '3000'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSEIF ithp_j_1iexchdr-werks = '3101'.
CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
SEPARATED BY space.
ELSE.
CONCATENATE tperiod ' ' INTO lv_grid_title
SEPARATED BY space.
ENDIF.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 100
text = 'Generating Report ... '.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = '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 = lv_grid_title
I_GRID_SETTINGS =
is_layout = layout
it_fieldcat = t_fillcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'X'
i_save = 'X'
IS_VARIANT =
IT_EVENTS = 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 = ithp_j_1iexchdr
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
Thanks in Advance.....Hi himanshu,
here i am sending some solution.
just create a internal table and wa for IT_SORT in grid display(just like for field cat).
Then u have to populate the internal table by fields for which u want subtotals.
just follow this code.
data: i_sort type SLIS_T_SORTINFO_ALV,
wa_sort type SLIS_SORTINFO_ALV.
wa_sort-fieldname = 'quantity'.
wa_sort-up = 'X'.
wa_sort-subtotal = 'X'.
append wa_sort to i_sort.
Do the same thing for all fields.
mention the internal table name in Grid display.
I think this some what useful to u,
Bye. -
Row seperator in the ALV grid display after the various highest level prod.
Hi,
I have a requirement like user wants a row seperator against the various high level products (Each parent material)in ALV Grid display.We made this change but quantity and pricey fields showing the zero's in the blank line.i know that if we use NO-ZERO
in the ALV field catalog , we can remove the zero's from blank line. But other zerou2019s will remove from rest of the line items. User want's the zero's in other line items, but not in the blank line.
We can convert packed fileds into character format, but this will effect to the summing the quantity, price coumns.
If any body have idea on above mentioned.
Regards,
SK.Hi Suresh,
There is no short cut for this requirement. You have to do following steps.
1. Change the data type of column to char.
2. Programatically find the totals.
Reagards,
Anversha -
TO enable the menu button in ALV Grid Display
Hi Mates,
I have a peculiar problem while doing ALV Grid display for screens.
In the main Screen i have Three coloumns.The 1st coloum will interacted
next screen 101 and 2nd coloum will interacted to screen 102.
Now the problem is in the menu of ALV Grid display,the Total button was enabled for screen
101 and same button is disabled in screen 102.
But the code semms to be fine .
Below i have pasted the code and please have a look and help to come out of this cris.
My Code :
FORM CREATE_ALV_GRID USING R_SCREEN.
DATA: LS_LAYOUT TYPE LVC_S_LAYO,
ITAB_FUNCTIONS TYPE UI_FUNCTIONS. "MHTK903257(+)(add)
CASE R_SCREEN.
*--> SCREEN 9000
WHEN C_SCREEN_9000.
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_9000
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_OVERVIEW' 'WADAT' 'Due date'(004) 'X' 'D' ' ' ' ' ' ' 'C100',
*'ITAB_OVERVIEW' 'HU_UNLOAD' 'Unloaded HU'(005) 'X' 'I' '15' ' ' ' ' 'C500', "MHTK903257(-)
'ITAB_OVERVIEW' 'TOT_TO' 'Total TO'(006) 'X' 'I' ' ' ' ' ' ' 'C30',
GMTK901103: REMOVE HOTSPOT ON ESTIMATED TO:
'ITAB_OVERVIEW' 'EST_TO' 'Estim TO'(030) ' ' 'I' ' ' ' ' ' ' 'C500'.
LOOP AT ITAB_INB_LOC WHERE OUTPUT = 'X'.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_9000
USING:
ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_OVERVIEW' ITAB_INB_LOC-FIELDNAME
ITAB_INB_LOC-Z_INBND_LOC 'X' '' ' ' ' ' 'R' 'C500'. "MHTK903418
ENDLOOP.
LOOP AT ITAB_STORAGE_TYPE WHERE OUTPUT = 'X'.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_9000
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_OVERVIEW' ITAB_STORAGE_TYPE-FIELDNAME
ITAB_STORAGE_TYPE-LGTYP 'X' 'I' ' ' ' ' 'R' 'C500'.
ENDLOOP.
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1000
EXPORTING
I_PARENT = PT_DOCK_1000.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS "MHTK903257(+)(add)
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1000
CHANGING LS_LAYOUT-GRID_TITLE.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1000->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_OVERVIEW
IT_FIELDCATALOG = ITAB_FIELDCAT_9000.
*--> SCREEN 9100
WHEN C_SCREEN_1100.
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1100
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_DETIAL' 'WAUHR' 'Due time'(007) ' ' 'T' ' ' 'X' ' ' 'C100',
'ITAB_DETAIL' 'TOT_TO' 'Total TO'(006) 'X' 'I' ' ' ' ' ' ' 'C30',
'ITAB_DETAIL' 'EST_TO' 'Estim TO'(030) ' ' 'I' ' ' ' ' ' ' 'C500'.
CLEAR ITAB_INB_LOC.
LOOP AT ITAB_INB_LOC WHERE SELECTED = 'X'.
CHECK SY-SUBRC EQ 0.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1100
USING:
ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_DETAIL' ITAB_INB_LOC-FIELDNAME
ITAB_INB_LOC-Z_INBND_LOC '' '' ' ' ' ' 'R' 'C500'.
ENDLOOP.
CLEAR: ITAB_STORAGE_TYPE.
LOOP AT ITAB_STORAGE_TYPE WHERE SELECTED = 'X'.
CHECK SY-SUBRC EQ 0.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1100
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_DETAIL' ITAB_STORAGE_TYPE-FIELDNAME
ITAB_STORAGE_TYPE-LGTYP 'X' 'I' ' ' ' ' 'R' 'C500'.
ENDLOOP.
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1100
EXPORTING
I_PARENT = PT_DOCK_1100.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS "MHTK903257(+)(add)
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1100
CHANGING LS_LAYOUT-GRID_TITLE.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1100->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_DETAIL
IT_FIELDCATALOG = ITAB_FIELDCAT_1100.
screen 1300 TO detail.
*--> SCREEN 9300
WHEN C_SCREEN_1300.
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1300
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_TO2' 'TANUM' 'TO'(020) ' ' 'C' ' ' ' ' ' ' 'C100',
'ITAB_TO2' 'NLPLA' 'Location'(021) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'LETY1' 'SUT'(013) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'MATNR' 'Material'(016) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'NSOLM' 'Quantity'(017) ' ' 'I' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'NLTYP' 'Storage type'(014) ' ' '' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
*'ITAB_TO2' 'POSNR' 'Line'(015) ' ' 'C' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1300
EXPORTING
I_PARENT = PT_DOCK_1300.
*-- Exclude the non-applicable functions from the ALV grid.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1300
CHANGING LS_LAYOUT-GRID_TITLE.
SORT ITAB_TO2 BY TANUM VBELN POSNR.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1300->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_TO2
IT_FIELDCATALOG = ITAB_FIELDCAT_1300.
screen 9400 Pre Processing detail.
*--> SCREEN 9400
WHEN C_SCREEN_9400. "MHTK903418(BEgin Of change)
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1400
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_PRE_PROC2' 'Z_PRE_PROC' 'Pre Processing Number'(030) ' ' 'C' ' ' ' ' ' ' 'C100',
'ITAB_PRE_PROC2' 'Z_PRE_PROC_LN' 'Pre Processing Number'(035) ' ' 'C' ' ' ' ' ' ' 'C100',
'ITAB_PRE_PROC2' 'MATNR' 'Material'(035) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_PRE_PROC2' 'Z_PSH_QTY' 'Quantity'(035) ' ' 'C' ' ' ' ' ' ' 'C500'.
*'ITAB_TO2' 'MATNR' 'Material'(016) ' ' 'C' ' ' ' ' ' ' 'C500',
*'ITAB_TO2' 'NSOLM' 'Quantity'(017) ' ' 'I' ' ' ' ' ' ' 'C500',
*'ITAB_TO2' 'NLTYP' 'Storage type'(014) ' ' '' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
**'ITAB_TO2' 'POSNR' 'Line'(015) ' ' 'C' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1400
EXPORTING
I_PARENT = PT_DOCK_1400.
*-- Exclude the non-applicable functions from the ALV grid.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1400
CHANGING LS_LAYOUT-GRID_TITLE.
SORT ITAB_PRE_PROC2 BY Z_PRE_PROC.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1400->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_PRE_PROC2
IT_FIELDCATALOG = ITAB_FIELDCAT_1400. "MHTK903418(End of change)
ENDCASE.Hi
U copy from standard program and paste ur report ...It will work..'
Regards:
Prabu -
How to devide the top of page in alv grid display
hi all
in the alv grid display am getting the page number and total number of pages in the left hand side
but what i need is i need in the right hand side
how to get thatHi,
PLease refer to the code below:
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& 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
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
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_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
* Form TOP-OF-PAGE *
* ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform.
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
* Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
* Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
Thanks,
Sriram Ponna. -
Hi,
How to display sub headings in alv grid
output format should be:
<COL_HEADING1> <COL_HEADING2>
<SUB_HEADING1> <SUB_HEADING2> <SUB_HEADING1><SUB_HEADING2>
and i want separate templet with side headings?
could you tell me grid supports this?
thanks in advance
cheers
sriniHi Srinivas,
Look ALV grid Multiple Header ... ? which has got a slightly more comprehensive information
Regards,
Anand Mandalika. -
hi,
i am making report in alv in which i have to display the sub totals and den full total.
is it possible to display sub total in ALV acccording to material type wise or itemid wise.
plzz help me with some example.
If find useful he or she will definately rewarded.........Hi,
The following example for sub totall for ALV report..
u have to pass do_sum = 'X'. for perticuler fileds.
if it is use full answer reward me a points..
*& Report ZDEL_ALV1
*Description: This ALV interactive report is display Delivary
status
REPORT zdel_alv1 NO STANDARD PAGE HEADING LINE-SIZE 255 LINE-COUNT 60.
*TABLE DECLARATION
TABLES : likp, "Delivery Header Data
lips, "Delivery item Data
vbup. "sales document item status
TYPE-POOLS : slis.
*SRUCTURE DECLARATION
*THIS TABLE FOR HEADER DETAILS
TYPES : BEGIN OF t_likp ,
vbeln LIKE likp-vbeln, "Delivery number
kosta like vbup-kosta,
kunnr LIKE likp-kunnr, "Customer number
wadat LIKE likp-wadat, "Planned goods movement date
ernam LIKE likp-ernam, "Name of person
vkorg LIKE likp-vkorg, "Sales organization
lfart LIKE likp-lfart, "DELIVERY TYPE
ntgew LIKE likp-ntgew, "NET WEIGHT
END OF t_likp.
*THIS TABLE FOR ITEM DETAILS
TYPES : BEGIN OF t_lips ,
vbeln LIKE lips-vbeln, "Delivery number
posnr LIKE lips-posnr, "delivery item
matnr LIKE lips-matnr, "Material number
lfimg LIKE lips-lfimg, "Actual quantity delivered
ntgew LIKE lips-ntgew, "Net weight
exbwr LIKE lips-exbwr, "Externally entered posting amount
arktx LIKE lips-arktx, "Short text SO Item
END OF t_lips.
*THIS IS FOR FINAL OUTPUT
TYPES : BEGIN OF t_vbup ,
vbeln LIKE likp-vbeln, "Delivery number
kosta LIKE vbup-kosta, "Picking status/Putaway status
posnr LIKE vbup-posnr, "delivery item
matnr LIKE lips-matnr, "Material number
lfimg LIKE lips-lfimg, "Actual quantity delivered
ntgew LIKE lips-ntgew, "Net weight
exbwr LIKE lips-exbwr, "Externally entered posting amount
arktx LIKE lips-arktx, "SHORT text SO Item
description(20), "for display text
END OF t_vbup.
*INTERNAL TABLES
DATA : i_likp TYPE STANDARD TABLE OF t_likp.
DATA : i_lips TYPE STANDARD TABLE OF t_lips.
DATA : i_vbup TYPE STANDARD TABLE OF t_vbup.
DATA : repid LIKE sy-repid.
DATA : delivar1(10) TYPE c.
*WORK AREA
DATA : wa_likp TYPE t_likp.
DATA : wa_lips TYPE t_lips.
DATA : wa_vbup TYPE t_vbup.
DATA: i_vbup1 LIKE wa_vbup OCCURS 0 WITH HEADER LINE.
*SLIS TABLE DECLARATIONS
DATA: i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_events TYPE slis_t_event,
w_events TYPE slis_alv_event,
i_fieldcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_layout TYPE slis_layout_alv.
*SELECTING RANGE OF VALUES
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_vbeln FOR likp-vbeln,
s_kunnr FOR likp-kunnr,
s_wadat FOR likp-wadat.
SELECTION-SCREEN END OF BLOCK b1 .
*CHOOSE ONE CHECK BOX FOR DISPLAYING THE DELIVARY STATUS
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : cb_kostc AS CHECKBOX,"DEFAULT 'X',
cb_kosta AS CHECKBOX,
cb_kostb AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b2.
*INTIALIZATION CHECK
INITIALIZATION.
repid = sy-repid.
*START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_data.
PERFORM get_field.
PERFORM GET_EVENTS.
PERFORM display.
*END-OF-SELECTION
END-OF-SELECTION.
*& Form RUCOMM
This form getting details from lips table for displaying
the item details and all select statements for delivary status
-->R_UCOMM text
-->RS_SELFIELDtext
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
IF rs_selfield-fieldname = 'VBELN'.
delivar1 = rs_selfield-value.
ENDIF.
IF cb_kostc = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'C'.
SELECT VBELN MATNR LFIMG EXBWR INTO TABLE I_LIPS FROM LIPS
WHERE VBELN EQ DELIVAR1.
REFRESH i_vbup1[].
CLEAR i_vbup1.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'C'.
ELSEIF cb_kosta = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'A'.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'A'.
ELSEIF cb_kostb = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'B'.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'B'.
ENDIF.
CLEAR i_vbup1.
LOOP AT i_vbup INTO wa_vbup.
i_vbup1-vbeln = wa_vbup-vbeln.
i_vbup1-kosta = wa_vbup-kosta.
IF wa_vbup-kosta = 'C'.
i_vbup1-description = 'COMPLETELY PROCESSED'.
ELSEIF wa_vbup-kosta = 'B'.
i_vbup1-description = 'PARTIALLY PROCESSED'.
ELSEIF wa_vbup-kosta = 'A'.
i_vbup1-description = 'NOT YET PROCESSED'.
ENDIF.
i_vbup1-posnr = wa_vbup-posnr.
i_vbup1-matnr = wa_vbup-matnr.
i_vbup1-lfimg = wa_vbup-lfimg.
i_vbup1-ntgew = wa_vbup-ntgew.
i_vbup1-exbwr = wa_vbup-exbwr.
i_vbup1-arktx = wa_vbup-arktx.
APPEND i_vbup1 .
ENDLOOP.
SORT i_vbup1 BY vbeln matnr lfimg.
DELETE ADJACENT DUPLICATES FROM i_vbup1 COMPARING vbeln matnr lfimg.
SELECT VBELN MATNR LFIMG EXBWR INTO TABLE I_LIPS FROM LIPS
WHERE VBELN EQ DELIVAR1.
*This function module for displaying the item details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = i_fieldcat1[]
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND1'
it_events = i_events
TABLES
t_outtab = i_vbup1
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.
CLEAR i_vbup1.
ENDFORM. "RUCOMM
*& Form USER_COMMAND1
text
-->R_UCOMM1 text
-->RS_SELFIELDtext
FORM user_command1 USING r_ucomm1 LIKE sy-ucomm rs_selfield1 TYPE
slis_selfield.
DATA: deliv(10) TYPE c.
IF rs_selfield1 = 'VBELN'.
deliv = rs_selfield1-value.
ENDIF.
SET PARAMETER ID 'VL' FIELD delivar1.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ENDFORM. "USER_COMMAND1
*& Form GET_DATA
This form for getting the data from likp table
--> p1 text
<-- p2 text
FORM get_data .
SELECT VBELN KUNNR WADAT FROM LIKP INTO TABLE I_LIKP
WHERE VBELN IN S_VBELN
AND KUNNR IN S_KUNNR
AND WADAT IN S_WADAT.
REFRESH i_likp[].
CLEAR i_likp.
IF cb_kostc = 'X' AND cb_kosta = ' ' AND cb_kostb = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND a~kosta = 'C'.
ELSEIF cb_kosta = 'X' AND cb_kostb = ' ' AND cb_kostc = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND a~kosta = 'A'.
ELSEIF cb_kostb = 'X' AND cb_kosta = '' AND cb_kostc = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND kosta = 'B'.
ELSEIF cb_kostc = 'X' AND cb_kosta = 'X' AND cb_kostb = 'X'.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND kosta NE ' '.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_likp.
ENDFORM. " GET_DATA
*& Form GET_FIELD
This form for defining the every fields from likp & lips tables
FORM get_field .
*This fields are retrieving from header table(likp)
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'VBELN'.
i_fieldcat-seltext_m = 'SALES ORDER NO'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'KUNNR'.
i_fieldcat-seltext_m = 'CUSTOMER NO'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'WADAT'.
i_fieldcat-seltext_m = 'DATE'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'ERNAM'.
i_fieldcat-seltext_m = 'NAME OF PERSON'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'VKORG'.
i_fieldcat-seltext_m = 'SALES ORGANIZATION'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'LFART'.
i_fieldcat-seltext_m = 'DELIVERY TYPE'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'NTGEW'.
i_fieldcat-seltext_m = 'NET WEIGHT'.
i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
*This fields are retrieving from item table(lips)
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'VBELN'.
i_fieldcat1-seltext_m = 'DELIVAR NO'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'POSNR'.
i_fieldcat1-seltext_m = 'DELIVERY ITEM'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'MATNR'.
i_fieldcat1-seltext_m = 'MATERIAL NO'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'LFIMG'.
i_fieldcat1-seltext_m = 'ACTUAL QUANTITY'.
i_fieldcat1-do_sum = 'X'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'NTGEW'.
i_fieldcat1-seltext_m = 'NET WEIGHT'.
i_fieldcat1-do_sum = 'X'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'EXBWR'.
i_fieldcat1-seltext_m = 'AMOUNT'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'ARKTX'.
i_fieldcat1-seltext_m = 'SHORT TEXT FOR so ITEM'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'DESCRIPTION'.
i_fieldcat1-seltext_m = 'PICKING STATUS'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
ENDFORM. " GET_FIELD
*& Form GET_EVENTS
This form defining the events
*FORM GET_EVENTS .
CLEAR W_EVENTS.
W_EVENTS-NAME = 'USER_COMMAND'.
W_EVENTS-FORM = 'RUCOMM'.
APPEND W_EVENTS TO I_EVENTS.
*ENDFORM. " GET_EVENTS
*& Form DISPLAY
This form is going to display header details from likp table
FORM display .
*This function module for displaying the header details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = i_fieldcat[]
i_save = 'X'
it_events = i_events
TABLES
t_outtab = i_likp
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
*& Form TOP-OF-PAGE
This form is going to display top-of-page header text
FORM top-of-page.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments TYPE slis_listheader.
CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-info = 'DELIVERY ORDER DETAILS'.
APPEND w_list_comments TO i_list_comments.
w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-info = 'Basic list'.
APPEND w_list_comments TO i_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'enjoy'
it_list_commentary = i_list_comments.
ENDFORM. "TOP-OF-PAGE
*& Form TOP_OF_PAGE
This form is going to display top-of-page item text
FORM top_of_page.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments TYPE slis_listheader.
DATA : i_line LIKE w_list_comments-info.
CONCATENATE 'DELIVERY ITEM DETAILS :' delivar1 INTO i_line .
SEPARATED BY SPACE.
CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-info = i_line.
APPEND w_list_comments TO i_list_comments.
w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-info = 'Secondary list'.
APPEND w_list_comments TO i_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'enjoy'
it_list_commentary = i_list_comments.
ENDFORM. "TOP_OF_PAGE -
Text after end of each type in ALV GRID DISPLAY
Hi Experts,
My Requirement is that after end of every order type I need to give the text to display how many records are there under that order type in ALV GRID DISPLAY.
Sample internal table is shown below
Ordertyp date
PM1 25/05/2010
PM1 25/05/2010
PM2 25/05/2010
PM2 25/05/2010
PM2 25/05/2010
PM2 25/05/2010
Out put should be as shown below
PM1 25/05/2010
PM1 25/05/2010
Total PM1 order types are 2
PM2 25/05/2010
PM2 25/05/2010
PM2 25/05/2010
PM2 25/05/2010
Total PM2 Order types are 4
Total all order types are 6.
Please note here I am not doing any subtotal, just I want to display how many records are there under that particular order
Thanks
Babumiya MohammadHi,
whatever it may be you can very well use the given logic to build.
Let say you are making the final table for display. While final table display make the process and append the data in final table itself and pass it to ALV.
LOOP AT ITAB.
ITAB1-FLD1 = ITAB-FLD1
ITAB1-FLD2 = ITAB-FLD2
APPEND ITAB1.
*For making the count
L_Cnt = L_cnt + 1.
At end of OrdTYP
L_ord_text = L_cnt.
MOVE L_ORD_TEXT to L_SUB_TEXT.
L_TEXT1 = '' TOTAL"
L_TEXT2 = "Order types are"
concatenate L_TEXT ITAB-ORDTYP L_TEXT2 L_ord_text into l_TOT1.
ITAB1- FLD2 = L_TOT1.
APPEDN ITAB1.
clear : L_cnt, L_ord_text .
ENDLOOP.
L_TOT_TEXT = L_TOT_TEXT + L_SUB_TEXT ( Here you will get total order type count)
Do the conactenate
L_TEXT3 = " Total all order types are"
concatenate L_TEXT3 L_TOT_TEXT INTo L_TOT2.
ITAB1-FLD2 = L_TOT2.
APPEND IATB1.
Here you will total text. Like above you can build the logic. It will work fine.
You should not clear the L_SUB_TEXT.
Maybe you are looking for
-
CRM Activity Replication to SAP R/3
Hi, We have extended CRM Activity and have added the 'Customer Screen' tab. The data gets populated through the PPF BADI. We have a scenario for which we need to replicate this 'Additional Data' along with some standard information from CRM Activity
-
Problem with Windows 8.1 and iTunes
Hi Apple Support I use windows 8.1. on my laptop and I have a problem with iTunes after the latest version. When I connect my iPhone, iTunes doesn´t work ( I cannot see my iPhone on iTunes) and when I connect my iPod nano the latest version, it is wr
-
How to change filename in iPhoto?
Hi, I can't seem to find out how i can "rename" the photos in iPhoto - so it also changes in "Finder"? ("Rename them for eks. "IMG001.jpg" to "Sunrise.jpg") I've tried to rename them in "Finder", but then iPhoto can't recognize them anymore. Is this
-
While checking the MIR5 Report Tax code isn't coming in it?? Can anybody tell me why it isn't coming?? In MIR4 In can see the Tax code. But I want to see the Tax code in All my IV Doc.
-
Will Verizon be carrying the Samsung Note LTE??? I am over my 2 year upgrade but have yet to find a phone that suits my businss needs except for the new Samsung Note. Blogs have said that the FCC has given approval for the note to AT&T's network bu