ALV subtotal display
Dear all,
i want to display
field1 field2 fie3 field4
mat1 10 20 tere 50
mar2 60 50 erhr 70
total 120
fright 40
cst 20
G.total 180
like this , is it possible in alv display?, pls tell me
hi,
You use this code it will full fill ur recuirement.
type-pools: slis.
tables: vbak,vbap.
selecting range of soles order no by using below statement.
SELECT-OPTIONS: so_vbeln for vbak-vbeln.
*Creating the structure's to hold sales order header and item details.
types: begin of ty_vbak,
VBELN type vbak-vbeln,
ERDAT type vbak-erdat,
NETWR type vbak-netwr,
WAERK type vbak-waerk,
end of ty_vbak,
begin of ty_vbap,
mandt type vbap-mandt,
vbeln type vbap-vbeln,
POSNR type vbap-posnr,
KWMENG type vbap-KWMENG,
VRKME TYPE VBAP-VRKME,
NETWR type vbap-netwr,
WAERK type vbap-waerk,
DISAMT type vbap-netwr,
end of ty_vbap.
*Creating the referances of required Objects.
data: w_vbak type ty_vbak,
it_vbak type table of ty_vbak,
w_vbap type ty_vbap,
it_vbap type table of ty_vbap,
w_fieldcat type slis_fieldcat_alv,
i_fieldcat type slis_t_fieldcat_alv,
i_fieldcat1 type slis_t_fieldcat_alv,
w_slis_selfield type slis_selfield,
W_IS_LAYOUT TYPE SLIS_LAYOUT_ALV,
repid type sy-repid,
i_event TYPE slis_t_event,
l_s_event TYPE slis_alv_event,
i_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
i_alv_top_of_page TYPE slis_t_listheader.
*This is display date and time on top of page.
PERFORM sub_top_of_page.
This perform to make structure for header details.
PERFORM FIELDCATLOG1.
This perform to make structure for item details.
PERFORM FIELDCATLOG2.
*This is to define Layout structure.
PERFORM LAYOUT_STU.
*This statement is to get header info from header table.
SELECT VBELN ERDAT NETWR WAERK from VBAK into table It_vbak where vbeln in so_vbeln.
repid = SY-REPID.
*This is heder info display grid alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
I_CALLBACK_USER_COMMAND = 'INTERACTIVE'
IS_LAYOUT = w_is_layout
IT_FIELDCAT = i_fieldcat
TABLES
T_OUTTAB = it_vbak
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
& Form INTERACTIVE
This form dispaly item info on alv grid form.
-->R_UCOMM text
-->RS_SELFIELD text
FORM INTERACTIVE USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA: TEMP_VBELN TYPE VBAK-VBELN.
IF RS_SELFIELD-FIELDNAME = 'VBELN'.
CASE R_UCOMM.
WHEN '&IC1'.
refresh: it_vbak , it_vbap , i_event , i_sort.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = RS_SELFIELD-VALUE
IMPORTING
OUTPUT = TEMP_VBELN.
TEMP_VBELN = RS_SELFIELD-VALUE.
*This statement is to get item info from item table
SELECT VBELN POSNR KWMENG VRKME NETWR WAERK INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP WHERE VBELN = TEMP_VBELN.
IF sy-subrc = 0.
SORT IT_VBAP BY VBELN POSNR KWMENG .
ENDIF.
*This is to calculate 30% of discount amount
LOOP AT IT_VBAP INTO W_VBAP .
W_VBAP-DISAMT = ( ( W_VBAP-NETWR / 100 ) * 30 ).
W_VBAP-DISAMT = W_VBAP-NETWR - W_VBAP-DISAMT.
MODIFY TABLE IT_VBAP FROM W_VBAP.
ENDLOOP.
*This is to sort the item info internal table
PERFORM sub_populate_sort.
*This is dynamic call of event.
PERFORM sub_get_event.
*THis is item info display grid alv.
PERFORM ALV_DISPLAY.
ENDCASE.
ENDIF.
ENDFORM. "INTERACTIVE
& Form sub_get_event
This form for event Perform which have decalred above
FORM sub_get_event.
CONSTANTS: c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.
ENDFORM. " sub_get_event
*& Form ALV_DISPLAY
form for item ingo dsplay perform
--> p1 text
<-- p2 text
FORM ALV_DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
IS_LAYOUT = w_is_layout
IT_FIELDCAT = I_FIELDCAT1
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " ALV_DISPLAY
& Form SUBTOTAL_TEXT
This dynamic call of subtotal_text event.
-->P_TOTAL text
-->P_SUBTOT_TEXT text
FORM subtotal_text CHANGING P_TOTAL TYPE ANY
p_subtot_text TYPE slis_subtot_text.
IF p_subtot_text-criteria = 'MANDT'.
p_subtot_text-display_text_for_SUBtotal = 'TOTAL'.
ENDIF.
ENDFORM. "subtotal_text
*& Form sub_populate_sort
This form to sort item internal table.
--> p1 text
<-- p2 text
FORM sub_populate_sort .
wa_sort-spos = '01' .
wa_sort-fieldname = 'MANDT'.
wa_sort-tabname = 'IT_VBAP'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM. " sub_populate_sort
*& Form fIELDCATLOG1
Structure of header fields
--> p1 text
<-- p2 text
FORM FIELDCATLOG1 .
PERFORM sub_fill_alv_field_catalog1 USING:
'01' 'VBELN' 'C' '13' 'S_Order No',
'02' 'ERDAT' 'C' '11' 'Created Date',
'03' 'NETWR' 'C' '18' 'Net_Amt',
'04' 'WAERK' 'C' '10' 'Currency'.
ENDFORM. " fIELDCATLOG1
FORM TOP-OF-PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page
i_logo = 'MOURISOFTLOGO1'.
ENDFORM.
*& Form sub_fill_alv_field_catalog
header fieldcatlog details
-->P_0664 text
-->P_0665 text
-->P_0666 text
-->P_0667 text
-->P_0668 text
FORM sub_fill_alv_field_catalog1 USING p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_justif TYPE char1
p_OUTPUTLEN TYPE dd03p-outputlen
p_seltext TYPE dd03p-scrtext_l.
w_fieldcat-col_pos = p_colpos. "Column
w_fieldcat-fieldname = p_fldnam. "Field Name
w_fieldcat-just = p_justif. "Screen Justified
w_fieldcat-outputlen = p_OUTPUTLEN.
w_fieldcat-seltext_l = p_seltext. "Field Text
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " sub_fill_alv_field_catalog
*& Form FIELDCATLOG2
structure for item fields
--> p1 text
<-- p2 text
FORM FIELDCATLOG2 .
PERFORM sub_fill_alv_field_catalog2 USING:
'01' 'MANDT' 'C' '03' 'Client_No' 'X' ' ',
'02' 'VBELN' 'L' '13' 'Sales_No' ' ' ' ',
'03' 'POSNR' 'C' '08' 'Items_No' ' ' ' ',
'04' 'KWMENG' 'C' '18' 'Quantity' ' ' ' ',
'05' 'VRKME' 'C' '05' 'Unit' ' ' ' ',
'06' 'NETWR' 'C' '18' 'Net_Amt' ' ' ' ',
'07' 'WAERK' 'C' '10' 'Currency' ' ' ' ',
'08' 'DISAMT' 'C' '20' '30% Discount_Amt' ' ' ' ',
'09' 'WAERK' 'C' '10' 'Currency' ' ' ' '.
ENDFORM. " FIELDCATLOG2
*& Form sub_fill_alv_field_catalog2
item fieldcatlog details
-->P_0741 text
-->P_0742 text
-->P_0743 text
-->P_0744 text
-->P_0745 text
-->P_0746 text
-->P_0747 text
FORM sub_fill_alv_field_catalog2 USING p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_justif TYPE char1
p_OUTPUTLEN TYPE dd03p-outputlen
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1.
w_fieldcat-col_pos = p_colpos. "Column
w_fieldcat-fieldname = p_fldnam. "Field Name
w_fieldcat-just = p_justif. "Screen Justified
w_fieldcat-outputlen = p_OUTPUTLEN.
w_fieldcat-seltext_l = p_seltext. "Field Text
W_FIELDCAT-no_out = p_out.
W_FIELDCAT-tech = P_TECH.
IF W_FIELDCAT-FIELDNAME = 'KWMENG'.
W_FIELDCAT-do_sum = 'X'.
ENDIF.
IF W_FIELDCAT-FIELDNAME = 'NETWR'.
W_FIELDCAT-do_sum = 'X'.
ENDIF.
IF W_FIELDCAT-FIELDNAME = 'DISAMT'.
W_FIELDCAT-do_sum = 'X'.
ENDIF.
APPEND w_fieldcat TO i_fieldcat1.
CLEAR w_fieldcat.
ENDFORM. " sub_fill_alv_field_catalog2
*& Form sub_top_of_page
text
--> p1 text
<-- p2 text
FORM sub_top_of_page .
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE SY-UZEIT, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
Run date Display
l_r_line-typ = 'S'. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'.
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.
Time Display
l_r_line-typ = 'S'. " header
WRITE: SY-UZEIT to l_time USING EDIT MASK '__:__:__'.
l_r_line-key = 'Current Time'.
l_r_line-info = l_time.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line, l_time.
ENDFORM. " sub_top_of_page
*& Form LAYOUT_STU
text
--> p1 text
<-- p2 text
FORM LAYOUT_STU .
*Layout declaration for alv display.
W_IS_LAYOUT-ZEBRA = 'X'.
W_IS_LAYOUT-NO_VLINE = 'X'.
W_IS_layout-no_input = 'X'.
*W_IS_layout-colwidth_optimize = 'X'.
w_is_layout-no_totalline = 'X'.
ENDFORM. " LAYOUT_STU
Similar Messages
-
Total count to be displayed in subtotal ALV(GRID Display)
Hello ,
I want to display total count in subtotal.
720 Mr JORGE 522,06
720 Mr JORGE 566,23
720 Mr JORGE 100,33
720 Mr JORGE 123,33
720 Mr JORGE 332,22
subtotal -> 720 1644.2 Count 5
888 Ms Mariam 100,00
subtotal -> 888 100,00 Count 1
Is this possible? Plz dont post same answers how to display subtotal. I am able to display subtotal , only issue is to display with count.
Edited by: Vimalnair on Aug 19, 2009 9:37 AMHi,
You cannot have subtotal for particular number of rows of ALV,
but if you want to get the total number of rows of the ALV data display
you can describe your final internal table from which the data is
getting displayed in ALV output and get it displayed in the header
or footer area of the ALV output.
For Eg:
DATA V_LINES TYPE I.
DESCRIBE TABLE IT_FINAL LINES V_LINES.
DATA: it_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
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 = 'PF_STATUS'
i_callback_user_command = 'COMM'
i_callback_top_of_page = 'TOP' "This top will call the subroutine namely TOP
FORM top.
REFRESH it_header.
wa_header-typ = 'S'.
wa_header-key = text-001.
wa_header-info = sy-repid.
APPEND wa_header TO it_header.
CLEAR wa_header.
wa_header-typ = 'S'.
wa_header-key = text-002.
wa_header-info = sy-uname.
APPEND wa_header TO it_header.
CLEAR wa_header.
wa_header-typ = 'S'.
wa_header-key = text-003.
wa_header-info = V_LINES. "This will print the total number of lines in the header
APPEND wa_header TO it_header.
CLEAR wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
* I_LOGO =
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
ENDFORM. "TOP
Hope it helps
Regards
Mansi -
Page break and Subtotal display in alv
Kindly provide me the resolution for the following issue at your earliest
Issue:
I am sorting the alv list based on invoice payment date with subtotals.
and i need a page break for every new invoice payment date.I have achived
the same by following code but now subtotals are displaying in the new page
first line rather i need subtotals at end of each page.
Thanking you.
Regards
Ravishekar.Thallapally
Mobil:09866887298.
*& Form sub_Build_sort_catalogue
Building Sort Catalog
<-- L_T_SORT : Internal table for sort catalog
FORM sub_build_sort_catalogue CHANGING l_t_sort TYPE slis_t_sortinfo_alv.
DATA: l_v_sortcat TYPE slis_sortinfo_alv.
CLEAR l_v_sortcat.
Sort the fields with Planned Incoming Payment in alv
l_v_sortcat-spos = '1'.
l_v_sortcat-fieldname = 'FAEDT'.
l_v_sortcat-subtot = 'X'.
l_v_sortcat-up = 'X'.
APPEND l_v_sortcat TO l_t_sort.
CLEAR l_v_sortcat.
Sort the fields with Planned Incoming Payment in alv
l_v_sortcat-spos = '002'.
l_v_sortcat-fieldname = 'INV_REF'.
l_v_sortcat-subtot = 'X'.
l_v_sortcat-up = 'X'.
APPEND l_v_sortcat TO l_t_sort.
CLEAR l_v_sortcat.
ENDFORM. " sub_Build_sort_catalogue
*& Form sub_after_line_output
Appending another event 'AFTER_LINE_OUTPUT' to g_t_events
-->L_T_OUTPUT : Internal table with output data
<--L_T_EVENTS : Internal table with events
FORM sub_after_line_output USING l_t_output TYPE ty_t_output
CHANGING l_t_events TYPE slis_t_event.
DATA: l_v_event TYPE slis_alv_event.
l_v_event-name = 'AFTER_LINE_OUTPUT'.
l_v_event-form = 'SUB_AFTER_LINE_OUTPUT1'.
APPEND l_v_event TO l_t_events.
ENDFORM.
*& Form after_line_output
After line output event is handled via this form
L_V_LINE : Capturing line value for page break.
FORM SUB_after_line_output1 USING l_v_line TYPE slis_lineinfo. "#EC CALLED
DATA: l_index1 LIKE sy-tabix,
l_index2 LIKE sy-tabix.
FIELD-SYMBOLS: <l_fs_output1> TYPE ty_output,
<l_fs_output2> TYPE ty_output.
CLEAR l_index1.
l_index1 = l_v_line-tabindex.
READ TABLE g_t_output INDEX l_index1 ASSIGNING <l_fs_output1>.
IF sy-subrc = 0.
CLEAR l_index2.
l_index2 = l_index1 + 1.
READ TABLE g_t_output INDEX l_index2 ASSIGNING <l_fs_output2>.
IF sy-subrc = 0.
IF <l_fs_output1>-FAEDT <> <l_fs_output2>-FAEDT .
WRITE: sy-uline.
NEW-PAGE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " after_line_output
*& Form Sub_display_alv_list
Displaying the ALV list
-->L_T_FIELDCATALOG : Itab with Field Catalog
-->L_T_LAYOUT : Itab with Layout Records
-->L_T_OUTPUT : Itab with Output Data
-->L_T_EVENT : Itab with Event Catalalog
FORM sub_display_alv_list USING l_t_fieldcatalog TYPE slis_t_fieldcat_alv
l_t_layout TYPE slis_layout_alv
l_t_sort TYPE slis_t_sortinfo_alv
CHANGING l_t_event TYPE slis_t_event
l_t_output TYPE ty_t_output .
*Set Report Title.
g_v_title = 'AR Clearing Doc. Details'.
*Perform for after line output
PERFORM sub_after_line_output USING l_t_output
CHANGING l_t_event .
*CALL TO FM REUSE ALV LIST DISPLAY
CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME =
is_layout = l_t_layout
it_fieldcat = l_t_fieldcatalog
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = l_t_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = l_t_event[]
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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = l_t_output[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " Sub_display_alv_listDear Friends,
I have got the solution from my technical lead for the below issue, I like to share this resolution with you all.
Best Regards,
Ravishekar.Thallapally
*& Form after_line_output
After line output event is handled via this form
L_V_LINE : Capturing line value for page break.
FORM sub_after_line_output1 USING l_v_line TYPE slis_lineinfo."#EC CALLED
DATA: l_v_int TYPE int1.
IF l_v_line-sumindex IS NOT INITIAL .
l_v_int = l_v_line-sumindex MOD 2 .
IF l_v_line-subtot = 'X' AND l_v_int = 0.
Write:/ sy-uline.
NEW-PAGE.
CLEAR:l_v_int.
ENDIF.
ENDIF.
ENDFORM. " after_line_output -
How to get subtotal value in ALV list display
Hi all,
How to give condition on the value of subtotal line in ALV list display,
i.e.if value of subtotal of plan quantity = actual quantity (in red oval) it should show the message
'ON TIME DELIVERY' else it should not show messagee.In my case(shown in red oval) its
showing for each subtotal value. I know how to change the subtotal text but i want to change
with respect to value of the subtotal.(plz refer attachment)
Any input regard to this will be achieved great.
Many thanks in advance.
samadhan shinde.Hi Samadhan,
I am awaiting for solution for this problem.....but as i think dynamically displaying sub total based on
matching actual quantity and planned quantity is bit complicated.
My idea is to display matched quantities in one block and unmatched quantities in another. I mean using blocked list.
awaiting suggestions.
regards, -
ALV grid display the subtotal not getting for one column at the output
Hi,
I am working one report ALV grid display and subtotal is not getting for one paricular coulumn.
Eventhough that column has some values.
So can anyone give the proper solution.
Waiting quick response.
Best Regards,
BansiHi
see this link .
https://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTALinALV
or try this program.
REPORT zalv.
DATA:
t_sflight TYPE TABLE OF sflight,
fs_sflight TYPE sflight.
DATA:
r_container TYPE REF TO cl_gui_custom_container,
r_grid TYPE REF TO cl_gui_alv_grid.
*FIELD CATALOG
DATA:
t_fcat TYPE lvc_t_fcat,
fs_fcat TYPE lvc_s_fcat.
*SORTING THE BASIC LIST
DATA:
t_sort TYPE lvc_t_sort,
fs_sort TYPE lvc_s_sort.
fs_fcat-fieldname = 'PRICE'.
fs_fcat-do_sum = 'X'.
APPEND fs_fcat TO t_fcat.
fs_sort-spos ='1'.
fs_sort-fieldname = 'CARRID'.
fs_sort-down = 'X'.
fs_sort-group = '*'.
fs_sort-subtot = 'X'.
APPEND fs_sort TO t_sort.
SELECT * FROM sflight INTO TABLE t_sflight.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.
SET TITLEBAR 'TITLE1'.ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
**& Module HANDLER OUTPUT
MODULE list OUTPUT.
CREATE OBJECT r_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT r_grid
EXPORTING
i_parent = r_container.
CALL METHOD r_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = t_fcat
it_outtab = t_sflight
it_sort = t_sort.
ENDMODULE. "list OUTPUT
Regards
Hareesh Menon -
ALV GRID DISPLAY USING FACTORY METHODS
Hi all
I am using factory methods for my alv grid display.
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen)
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish GargHello Ravish
Regarding the display of zero values as empty cells have a look at my <i>modified </i>sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
go_table TYPE REF TO cl_salv_table,
go_events TYPE REF TO cl_salv_events_table.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT
if_salv_events_actions_table~double_click
OF cl_salv_events_table
IMPORTING
row
column.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lo_table TYPE REF TO cl_salv_table,
lt_orders TYPE STANDARD TABLE OF bapiorders,
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = ls_knb1-kunnr
sales_organization = '1000'
* MATERIAL =
* DOCUMENT_DATE =
* DOCUMENT_DATE_TO =
* PURCHASE_ORDER =
* TRANSACTION_GROUP = 0
* PURCHASE_ORDER_NUMBER =
* IMPORTING
* RETURN =
TABLES
sales_orders = lt_orders.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = lt_orders.
CATCH cx_salv_msg .
ENDTRY.
lo_table->display( ).
** SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
** SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
** CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_knb1.
CATCH cx_salv_msg .
ENDTRY.
* Create event instance
go_events = go_table->get_event( ).
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_events.
PERFORM modify_columns.
go_table->display( ).
END-OF-SELECTION.
*& Form MODIFY_COLUMNS
* text
* --> p1 text
* <-- p2 text
FORM modify_columns .
* define local data
DATA:
lt_dfies TYPE ddfields,
ls_dfies TYPE dfies,
lo_typedescr TYPE REF TO cl_abap_typedescr,
lo_strucdescr TYPE REF TO cl_abap_structdescr,
lo_tabledescr TYPE REF TO cl_abap_tabledescr,
lo_columns TYPE REF TO cl_salv_columns_table,
lo_column TYPE REF TO cl_salv_column.
lo_columns = go_table->get_columns( ).
lo_typedescr = cl_abap_typedescr=>describe_by_data( gt_knb1 ).
lo_tabledescr ?= lo_typedescr.
lo_strucdescr ?= lo_tabledescr->get_table_line_type( ).
lt_dfies = lo_strucdescr->get_ddic_field_list( ).
LOOP AT lt_dfies INTO ls_dfies.
lo_column = lo_columns->get_column( ls_dfies-fieldname ).
IF ( ls_dfies-keyflag = abap_true ).
CONTINUE.
ELSEIF ( ls_dfies-fieldname = 'WEBTR' ). " Bill of ex. limit
lo_column->set_zero( if_salv_c_bool_sap=>true ). " display zero
lo_column->set_zero( if_salv_c_bool_sap=>false ). " hide zero
ELSE.
lo_column->set_technical( if_salv_c_bool_sap=>true ). " hide col
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_COLUMNS
Regards
Uwe -
Shrinking the ALV subtotal icon
Hi Experts
I have developed Interactive Grid ALV. In Basic list Subtotal is for 3 column.
i wanted to display by default the Shrink format, then user will expand the details
as per the requirement. i have seen this query is already posted by Shanthi
i have tried the same option. but it doesnt work. i have also tried COMP and
EXPA fields slis_sorting_alv. but still not getting the shrink version.
Kindly guide me for the same.
Thanks
NishitaHi,
I have tried this. But stil, the subtotal of every item gets displayed. by default, the subtotal alone shoudl be displayed in the output.
On expanding the icon, each item should get displayed.
Pls tell me how to achieve the same in ALV GRID DISPLAY.. -
hi friends,
in alv grid display output on toolbar how to get button of Subtotal,Expand and Colapse
pls,reply...........hi,
try this.
<b>DATA: gt_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF gt_subtot.</b>
subtot-spos = 1.
subtot-fieldname = 'NAME1'.
subtot-tabname = 'ITAB_HEAD'.
subtot-up = 'X'.
subtot-group = 'X'.
subtot-subtot = 'X'.
subtot-expa = 'X'.
APPEND subtot TO gt_subtot.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZRAW_COST'
it_fieldcat = fcat
<b> it_sort = gt_subtot</b>
it_events = eve
i_tabname_header = 'ITAB_HEAD'
i_tabname_item = 'ITAB_ITM'
is_keyinfo = alv_keyinfo
TABLES
t_outtab_header = itab_head
t_outtab_item = itab_itm
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.
reward if useful.
this is whole report for better understanding.
REPORT ZRAW_COST.
TYPE-POOLS:slis.
TABLES:mseg,
lfa1,
mkpf,
ekpo,
mara,
j_1iexchdr,
mbew.
DATA:BEGIN OF itab_vend OCCURS 0,
lifnr LIKE lfa1-lifnr, "Vendor Code
END OF itab_vend.
DATA:BEGIN OF itab_data OCCURS 0,
lifnr LIKE mseg-lifnr, "Vendor Code
mblnr LIKE mseg-mblnr, "Material Doc.
charg LIKE mseg-charg, "Batch
matnr LIKE mseg-matnr, "Material
maktx LIKE makt-maktx, "Description
menge LIKE mseg-menge, "Quantity
dmbtr LIKE mseg-dmbtr, "Amount
budat LIKE mkpf-budat, "G.R.Date
xblnr LIKE mkpf-xblnr, "Delivery Note(Bill No.)
frbnr LIKE mkpf-frbnr, "Bill of Lading(Bill Date)
netpr LIKE ekpo-netpr, "Basic Rate
matkl LIKE ekpo-matkl, "Material Group
END OF itab_data.
DATA:BEGIN OF itab_itm OCCURS 0,
lifnr LIKE mseg-lifnr, "Vendor Code
name1 LIKE lfa1-name1, "Vendor Name
matkl LIKE ekpo-matkl, "Material Group
wgbez LIKE t023t-wgbez, "Material Group Name
mblnr LIKE mseg-mblnr, "Material Doc.
matnr LIKE mseg-matnr, "Material
maktx LIKE makt-maktx, "Description
xblnr LIKE mkpf-xblnr, "Delivery Note(Bill No.)
frbnr LIKE mkpf-frbnr, "Bill of lading(Bill Date)
budat LIKE mkpf-budat, "G.R.Date
exnum LIKE j_1iexchdr-exnum, "Ex.Bill No.
exdat LIKE j_1iexchdr-exdat, "Ex.Bill Date
charg LIKE mseg-charg, "Batch
menge LIKE mseg-menge, "Quantity
netpr LIKE ekpo-netpr, "Basic Rate
verpr LIKE mbew-verpr, "Costing Rate
dmbtr LIKE mseg-dmbtr, "Amount
END OF itab_itm.
DATA:BEGIN OF itab_head OCCURS 0,
lifnr LIKE mseg-lifnr, "Vendor Code
name1 LIKE lfa1-name1, "Vendor Name
matkl LIKE ekpo-matkl, "Material Group
wgbez LIKE t023t-wgbez, "Material Group Name
END OF itab_head.
DATA:fcat TYPE slis_t_fieldcat_alv,
eve TYPE slis_t_event,
alv_keyinfo TYPE slis_keyinfo_alv,
gt_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF gt_subtot.
DATA:ex_doc LIKE j_1iexchdr-exnum,
ex_dat LIKE j_1iexchdr-exdat,
mov_pr LIKE mbew-verpr,
name LIKE lfa1-name1,
gr_nm LIKE t023t-wgbez,
t_mblnr LIKE mseg-mblnr,
yr LIKE mseg-mjahr.
DATA: BEGIN OF record OCCURS 0,
act(003),
rfd(003),
matdoc(010),
docyr(004),
END OF record.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:dt FOR mkpf-budat OBLIGATORY,
vend FOR lfa1-lifnr,
mat_gr FOR mara-matkl.
SELECTION-SCREEN:END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_cat USING fcat.
START-OF-SELECTION.
PERFORM get_data.
PERFORM dis_data.
*& Form build_cat
text
-->T_FCAT text
FORM build_cat USING t_fcat TYPE slis_t_fieldcat_alv.
DATA:wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB_HEAD'.
wa_fcat-fieldname = 'NAME1'.
wa_fcat-seltext_m = 'Vendor Name'.
wa_fcat-outputlen = '30'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_HEAD'.
wa_fcat-fieldname = 'WGBEZ'.
wa_fcat-seltext_m = 'Material Group Name'.
wa_fcat-outputlen = '30'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'MBLNR'.
wa_fcat-seltext_m = 'Material Doc.'.
wa_fcat-outputlen = '15'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-seltext_m = 'Product Name'.
wa_fcat-outputlen = '40'.
wa_fcat-just = 'L'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'XBLNR'.
wa_fcat-seltext_m = 'Bill.No.'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'FRBNR'.
wa_fcat-seltext_m = 'Bill Date'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'BUDAT'.
wa_fcat-seltext_m = 'G.R.Date'.
wa_fcat-outputlen = '10'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'EXNUM'.
wa_fcat-seltext_m = 'Ex.Bill.No.'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'EXDAT'.
wa_fcat-seltext_m = 'Ex.Bill Date'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'CHARG'.
wa_fcat-seltext_m = 'Batch'.
wa_fcat-outputlen = '15'.
wa_fcat-just = 'C'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-seltext_m = 'Qty'.
wa_fcat-do_sum = 'Y'.
wa_fcat-outputlen = '15'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'NETPR'.
wa_fcat-seltext_m = 'Basic Rate'.
wa_fcat-do_sum = 'Y'.
wa_fcat-outputlen = '12'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'VERPR'.
wa_fcat-seltext_m = 'Costing Rate'.
wa_fcat-do_sum = 'Y'.
wa_fcat-outputlen = '12'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITM'.
wa_fcat-fieldname = 'DMBTR'.
wa_fcat-seltext_m = 'Amount'.
wa_fcat-do_sum = 'Y'.
wa_fcat-outputlen = '15'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
subtot-spos = 1.
subtot-fieldname = 'NAME1'.
subtot-tabname = 'ITAB_HEAD'.
subtot-up = 'X'.
subtot-group = 'X'.
subtot-subtot = 'X'.
subtot-expa = 'X'.
APPEND subtot TO gt_subtot.
subtot-spos = 2.
subtot-fieldname = 'WGBEZ'.
subtot-tabname = 'ITAB_HEAD'.
subtot-up = 'X'.
subtot-group = 'X'.
subtot-subtot = 'X'.
subtot-expa = 'X'.
APPEND subtot TO gt_subtot.
ENDFORM. "build_cat
*& Form get_data
text
FORM get_data.
SELECT DISTINCT mseg~lifnr INTO CORRESPONDING FIELDS OF TABLE itab_vend
FROM mseg INNER JOIN mkpf
ON msegmblnr = mkpfmblnr
WHERE mkpfbudat IN dt AND mseglifnr IN vend.
LOOP AT itab_vend.
SELECT mseglifnr msegmblnr msegmatnr maktmaktx msegcharg msegmenge msegdmbtr mkpfbudat mkpfxblnr mkpffrbnr ekponetpr ekpomatkl
INTO CORRESPONDING FIELDS OF TABLE itab_data
FROM mseg INNER JOIN mkpf ON
msegmblnr = mkpfmblnr
INNER JOIN ekpo ON
msegebeln = ekpoebeln AND msegmatnr = ekpomatnr
INNER JOIN makt ON
msegmatnr = maktmatnr
WHERE mkpfbudat IN dt AND mseglifnr IN vend AND msegbwart = '101' AND msegebeln <> '' AND ekpo~matkl IN mat_gr.
ENDLOOP.
SORT itab_data BY lifnr matkl matnr mblnr.
LOOP AT itab_data.
CLEAR: ex_doc,ex_dat,mov_pr,name,gr_nm.
MOVE-CORRESPONDING itab_data TO itab_itm.
SELECT SINGLE name1 FROM lfa1 INTO name WHERE lifnr = itab_data-lifnr.
SELECT SINGLE wgbez FROM t023t INTO gr_nm WHERE matkl = itab_data-matkl.
SELECT SINGLE exnum exdat FROM j_1iexchdr INTO (ex_doc,ex_dat) WHERE rdoc = itab_data-mblnr.
SELECT SINGLE verpr INTO mov_pr FROM mbew WHERE matnr = itab_data-matnr AND bwtar = itab_data-charg.
itab_itm-exnum = ex_doc.
itab_itm-exdat = ex_dat.
itab_itm-verpr = mov_pr.
itab_itm-name1 = name.
itab_itm-wgbez = gr_nm.
APPEND itab_itm.
ENDLOOP.
SORT itab_itm . "BY lifnr matkl mblnr matnr charg.
DELETE ADJACENT DUPLICATES FROM itab_itm.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
alv_keyinfo-header01 = 'LIFNR'.
alv_keyinfo-item01 = 'LIFNR'.
alv_keyinfo-header02 = 'MATKL'.
alv_keyinfo-item02 = 'MATKL'.
REFRESH itab_head.
LOOP AT itab_itm.
ON CHANGE OF itab_itm-lifnr OR itab_itm-matkl .
MOVE-CORRESPONDING itab_itm TO itab_head.
APPEND itab_head.
ENDON.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZRAW_COST'
it_fieldcat = fcat
it_sort = gt_subtot
i_tabname_header = 'ITAB_HEAD'
i_tabname_item = 'ITAB_ITM'
is_keyinfo = alv_keyinfo
TABLES
t_outtab_header = itab_head
t_outtab_item = itab_itm
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. "dis_data -
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. -
Kindly help to develop alv grid display
Hi ,
I have a requirement in which I need to display ALV GRID display and in its tool bar 4 butons are required. In the same view down to alv display i want to develop a tabstrip and its functionalities.I have designed classic alv using SALV_WD_TABLE component. I want a good GRID Display, not like flat field names that comes in list display, looking for bulged fields(like what comes for ALV GRID in normal abap) display with print version etc hidden and buttons at the top of ALV. Kindly help
Highly rewarded
Kindly help
Regards,
Lakshmi
Edited by: Lakshmi Menon on Nov 27, 2008 4:49 PMWell Web Dynpro is generally output in HTML so the output formatting is never going to quite look like a desktop application (which is the case with the ALV Grid). You have very little control over the look of the column headers. In fact you can only manipulate what is available via the Portal Theme.
There is a new Tradeshow Plus theme available in NetWeaver 7.01 which uses a gradiant background for the column headers. This gives them a little more depth:
http://www.flickr.com/photos/tjung/3068850120/
The other option is next year when NetWeaver Business Client version 3.0 comes out, you will be able to render Web Dynpro applications using the NWBC Smart Client Rendering. This will render Web Dynpro applications using desktop libraries instead of HTML/Browser. This gives Web Dynpro a more SAPGUI/Desktop appears of course.
http://www.flickr.com/photos/tjung/2685619882/in/set-72157606418550143/ -
Hide delete option is not working in ALV List Display- urgent
Hi All,
In my program i am displaying the output by using alv list display. after displaying the data i am displaying my own pf status here. in this i have few pushbuttons like
selest all, deselect all, hide . first two options are working fine. when i click hide button selected records are going to be hide.but this is not happening in my program. any body cam send me the code plz.
i am sending my code below. if possible please modify and resend the code asap.
my code:
type-pools : slis.
tables : zuser_secobjects.
data : t_header1 like zuser_secobjects.
data : begin of it_secobjects occurs 0.
include structure t_header1.
*data : box,
input(1) type c,
data : checkbox type c,
flag type c,
end of it_secobjects.
data : wa_ita like line of it_secobjects.
*data : it_secobjects like zuser_secobjects occurs 0 with header line.
data : i_field type slis_t_fieldcat_alv with header line.
data : w_field like line of i_field.
data : i_sort type slis_t_sortinfo_alv.
data : w_sort like line of i_sort.
data : it_filt1 type slis_t_filter_alv with header line.
data:
i_tabname type tabname,
i_repid like sy-repid,
is_lout type slis_layout_alv.
data : it_filt type slis_t_filter_alv with header line,
it_evts type slis_t_event with header line.
DATA : is_vari type disvariant.
constants : c_default_vari value 'X',
c_save_vari value 'U',
c_checkfield type slis_fieldname value 'ACTION',
c_f2code type sy-ucomm value '&ETA'.
data : chk_box type slis_fieldname.
selection-screen: begin of block b1 with frame title text-t01.
parameters : p_appln type zuser_secobjects-appln.
parameters : p_user type usr02-bname, "zuser_secobjects-appln_user,
p_partnr type zuser_secobjects-appln_partner,
p_ptype type zuser_secobjects-partner_type default '02',
p_upostn type zuser_secobjects-user_position,
p_sdate like likp-erdat default sy-datum,
p_edate(10) default '12/31/9999',
p_revnum type zuser_secobjects-revnum,
p_cted type zuser_secobjects-created_by,
p_cdate type zuser_secobjects-creation_date,
p_ctime type zuser_secobjects-creation_time,
p_chnby type zuser_secobjects-changed_by,
p_cdate1 type zuser_secobjects-changed_date,
p_ctime1 type zuser_secobjects-changed_time.
selection-screen: end of block b1.
form user_command using p_ucomm like sy-ucomm
rs_selfield type slis_selfield.
*DATA : it_filt type slis_t_filter_alv with header line.
case p_ucomm.
when 'SELECT_ALL'. " SELALL is the FCODE of ur push button
loop at it_secobjects into wa_ita.
wa_ita-checkbox = 'X'.
modify it_secobjects from wa_ita.
endloop.
rs_selfield-refresh = 'X'. "<- ADD THIS
when 'DESLCT_ALL'.
loop at it_secobjects into wa_ita.
wa_ita-checkbox = ' '.
modify it_secobjects from wa_ita.
endloop.
rs_selfield-refresh = 'X'. "<- ADD THIS
is_lout-f2code = c_f2code.
is_lout-box_fieldname = c_checkfield.
is_lout-get_selinfos = 'X'.
is_lout-detail_popup = 'X'.
is_lout-detail_initial_lines = 'X'.
when 'HIDE_DEL'.
rs_selfield-exit = 'X'.
it_filt-fieldname = 'CHECKBOX'.
it_filt-tabname = '1'.
it_filt-valuf = 'X'.
it_filt-intlen = '1'.
it_filt-inttype = 'C'.
it_filt-datatype = 'CHAR'.
it_filt-valuf_int = 'X'.
it_filt-sign0 = 'E'.
it_filt-optio = 'EQ'.
if it_filt[] is initial.
append it_filt.
else.
modify it_filt index 1.
endif.
perform display using i_object.
PERForm ALV_LIST_DISPLAY.
WHEN 'SHOW_DEL'.
rs_selfield-exit = 'X'.
free it_filt.
PERForm ALV_LIST_DISPLAY.
when 'SAVE1'.
select * from zuser_secobjects where
appln = zuser_secobjects-appln
and appln_partner = zuser_secobjects-appln_partner
and partner_type = zuser_secobjects-partner_type
and start_date = zuser_secobjects-start_date
and end_date = zuser_secobjects-end_date.
endselect.
if sy-subrc eq 0.
message e000(ZV) with 'Duplicate Entry'.
endif.
endcase.
endform.
*& Form delete
form delete.
data : begin of is_secobjects occurs 0.
include structure zuser_secobjects.
data : checkbox type c.
data : end of is_secobjects.
is_secobjects-checkbox = 'X'.
modify is_secobjects
from it_secobjects
transporting checkbox
where checkbox = 'X'.
endform.
*& Form get_data
form get_data.
select * from zuser_secobjects
into table it_secobjects.
endform. " get_data
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
form prepare_fieldcatalog.
clear: w_field,i_field.
refresh:i_field.
i_field-key = 'X'.
i_field-col_pos = 1.
i_field-ddictxt = 'S'.
i_field-seltext_s = '@11@'.
i_field-checkbox = 'X'.
i_field-input = 'X'.
i_field-fieldname = 'HEADER'.
i_field-outputlen = 0.
append i_field.
clear i_field.
w_field-fieldname = 'APPLN'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-seltext_l = text-m01.
w_field-outputlen = '10'.
w_field-col_pos = 1.
append w_field to i_field.
clear w_field.
w_field-fieldname = 'APPLN_USER'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-just = 'C'.
w_field-seltext_l = text-m02.
w_field-outputlen = '7'.
w_field-col_pos = 2.
append w_field to i_field.
clear w_field.
endform. " prepare_fieldcatalog
*& Form ALV_LIST_DISPLAY
text
--> p1 text
<-- p2 text
form alv_list_display.
i_repid = sy-repid.
is_lout-box_fieldname = 'CHECKBOX'.
it_filt-fieldname = 'CHECKBOX'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = i_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout = is_lout
it_fieldcat = i_field[]
it_filter = it_filt[]
it_events = it_evts[]
i_default = c_default_vari
i_save = c_save_vari
is_variant = is_vari
tables
t_outtab = it_secobjects.
endform. " ALV_LIST_DISPLAY
*& Form display
text
-->P_I_OBJECT text
form display using object.
case object.
ENDCASE.
endform. " display
thanks,
maheedhar.tHi,
What do you mean by Hiding the records.
Deleting completely from the screen.
You can just delete the records from the internal table and pass to field catalog before displaying again.
or serach in the slis structrue for hiding the contents of the output.
reward if useful
regards,
Anji -
Issue in ALV List display
Posted: Apr 5, 2008 10:25 AM Edit E-mail this message Reply
Hi Friends,
Can any one help me out in the logic to display the output in the ALV list.
i want to get the out put as
based on the field4 i have to display fieds5, field6 and field 7 values as mentioned below.
field1 field2 field3 field4 field5 field6 field7
0L 123 456 2008 001 123.00 456.00
- - - - 002 213.00 789.00
- - - 003 0.00 0.00
- - - 004 0.00 0.00
- - - 005 0.00 0.00
- - - 006 0.00 0.00
336.00 1245.00
Thanks,
Vijayfor display you have to define fieldcatlaog and use Fm RESUE_ALV_GRID_DISPLAY,
Go through this program
*& Report Z_OPEN_CLOSE *
REPORT Z_OPEN_CLOSE MESSAGE-ID YW2 LINE-SIZE 231 LINE-COUNT 45
NO STANDARD PAGE HEADING.
Type Declaration *
TYPE-POOLS SLIS.
Tables *
TABLES: MKPF, " Material Document: Header Data
MSEG, " Material Document: Item Data
MARA,
MARD,
S031,
EKKO,
EKPO,
LIKP,
MAKT,
J_1IWRKCUS,
T001W,
WB2_V_MKPF_MSEG2,
MMIM_REP_PRINT,
YW2_STKMOVEMENTS,
YPLNT,
MARDH.
Internal Tables *
DATA: I_WERKS LIKE J_1IWRKCUS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_YPLNT OCCURS 0,
PPLNT LIKE YPLNT-PPLNT,
WPLNT LIKE YPLNT-WPLNT,
END OF I_YPLNT.
DATA: BEGIN OF I_MKPF OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
BUDAT LIKE MKPF-BUDAT,
VGART LIKE MKPF-VGART,
BWART LIKE MSEG-BWART,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
KUNNR LIKE MSEG-KUNNR,
ZEILE LIKE MSEG-ZEILE,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
MATNR1 LIKE MSEG-MATNR,
END OF I_MKPF.
DATA: BEGIN OF I_MARDH OCCURS 0,
WERKS LIKE MARDH-WERKS,
MEINS LIKE MARA-MEINS,
MATNR LIKE MARDH-MATNR,
LGORT LIKE MARDH-LGORT,
LABST LIKE MARDH-LABST,
LFGJA LIKE MARDH-LFGJA, "Added -MB
LFMON LIKE MARDH-LFMON, "Added -MB
PERIO(6),
INSME LIKE MARDH-LABST,
EINME LIKE MARDH-LABST,
SPEME LIKE MARDH-LABST,
RETME LIKE MARDH-LABST,
O_STK LIKE MARDH-LABST, " Opening Stock
C_STK LIKE MARDH-LABST, " Closing Stock
END OF I_MARDH.
DATA: BEGIN OF I_MARD OCCURS 0,
WERKS LIKE MARD-WERKS,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
INSME LIKE MARD-LABST,
MEINS LIKE MARA-MEINS,
EINME LIKE MARD-LABST,
SPEME LIKE MARD-LABST,
RETME LIKE MARD-LABST,
END OF I_MARD.
DATA: I_MARD1 LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: I_MARDH1 LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_MKPF1 OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
END OF I_MKPF1.
DATA: BEGIN OF I_MKPF2 OCCURS 0,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
END OF I_MKPF2.
DATA: BEGIN OF I_FINAL5 OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
LGORT LIKE MSEG-LGORT, " Storage Location
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TLOSS LIKE MARDH-LABST, " Total Loss
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
C_STK LIKE MARDH-LABST, " Closing Stock
TRFSTK LIKE MARDH-LABST, "Transfer stock
MENGE LIKE MSEG-MENGE,
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL5.
DATA: BEGIN OF I_FINAL OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL.
DATA: I_FINAL1 LIKE I_FINAL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_FINAL_TEMP OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
MTART LIKE MARA-MTART, " Material Type
MAKTX LIKE MAKT-MAKTX, " Description
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL_TEMP.
For Materials
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MEINS LIKE MARA-MEINS,
LABST TYPE MARD-LABST,
MAKTX LIKE MAKT-MAKTX,
END OF I_MARA.
DATA: BEGIN OF I_STKMVMNTS OCCURS 0,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
VZBEW LIKE YW2_STKMOVEMENTS-VZBEW,
END OF I_STKMVMNTS.
DATA: BEGIN OF I_FINALT OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
MONTH(8) ,
END OF I_FINALT.
DATA: IMKPFT LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT1 LIKE I_MKPF1 OCCURS 0 WITH HEADER LINE.
DATA: IMARDT LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: IMARDHT LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: T_FINAL LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT2 LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
FCAT is used for the field catalog
DATA: FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
for excluding the ICONs from the application toolbar
FEXC TYPE TABLE OF SLIS_EXTAB WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO is used for Grid Layout
FS_LAYO TYPE SLIS_LAYOUT_ALV,
FEVENTS to handle the events TOP OF PAGE & USER_COMMAND
FEVENTS TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER is used for List header
FHEADER TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
sort is used for sorting
FSORT TYPE TABLE OF SLIS_SORTINFO_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FCAT1 TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO1 TYPE SLIS_LAYOUT_ALV,
GT_LIST_TOP_OF_PAGE1 TYPE SLIS_T_LISTHEADER,
FEVENTS1 TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER1 TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT
KEY WITH HEADER LINE INITIAL SIZE 0,
G_STATU_071 TYPE SLIS_FORMNAME VALUE 'Z_PFSTATUS',
ALV_VARIANT1 LIKE DISVARIANT.
Variable Declaration *
TYPES: TRFF_TYPE_DEC_6_5(6) TYPE P DECIMALS 5.
DATA: FYEAR(4),
MON(2),
FYEAR1(4),
MON1(2),
OBAL LIKE MARD-LABST,
CBAL LIKE MARD-LABST,
INDEX TYPE I,
COUNT,
COUNT1 TYPE I,
O_STK TYPE P DECIMALS 3,
C_STK TYPE P DECIMALS 3,
V_MJAHR LIKE MKPF-MJAHR,
MONTHS TYPE TRFF_TYPE_DEC_6_5,
MONTH TYPE I.
Global variables for handling ALV functionality
DATA: ALV_KEYINFO TYPE SLIS_KEYINFO_ALV,
ALV_VARIANT LIKE DISVARIANT,
ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
ALV_REPID LIKE SY-REPID,
ALV_PRINT TYPE SLIS_PRINT_ALV,
ALV_DETAIL_FUNC(30),
ALV_DEFAULT_VARIANT LIKE DISVARIANT-VARIANT,
ALV_COLOURIZE_FIELDS LIKE MMIM_REP_PRINT-COLOR.
RANGES: R_BUDAT FOR MKPF-BUDAT.
*Added by Prabhu for year on 26.4.05.
DATA: IDATE LIKE R_BUDAT OCCURS 0 WITH HEADER LINE.
Selection Screen Elements *
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY NO INTERVALS.
PARAMETER: P_SPMON LIKE S031-SPMON NO-DISPLAY .
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
S_LGORT FOR MSEG-LGORT NO-EXTENSION NO INTERVALS,
S_MBLNR FOR MKPF-MBLNR,
S_BUDAT FOR MKPF-BUDAT OBLIGATORY .
SELECTION-SCREEN END OF BLOCK BLK.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
PARAMETER : MTART LIKE MARA-MTART DEFAULT 'FERT' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK BLK3.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN END OF BLOCK BLK2.
ADDED BY PRABHU FOR DAY-WISE REPORT.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-007.
PARAMETERS: D1 RADIOBUTTON GROUP P1 DEFAULT 'X',
M1 RADIOBUTTON GROUP P1,
Y1 RADIOBUTTON GROUP P1.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
PARAMETERS: ALV_DEF LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK B2.
DATA: S_BUDAT1 LIKE S_BUDAT OCCURS 0 WITH HEADER LINE."prabhu
Initialization *
INITIALIZATION.
PERFORM ALV_INIT.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ALV_DEF.
PERFORM ALV_F4.
At Selection Screen
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
PERFORM monat_f4.
At Selection Screen *
AT SELECTION-SCREEN.
checking for the layout
PERFORM ALV_CHECK.
authorisation check for the Plant
PERFORM auth_check.
Validation for the Plant
PERFORM VALIDITY_CHECK.
IF MTART NE 'FERT'.
MESSAGE E041 WITH 'Material Type must be FERT Only...'.
ENDIF.
IF D1 = 'X'." On 26.4.05.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ELSE.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ENDIF.
LOOP AT S_BUDAT.
IF S_BUDAT-HIGH IS INITIAL.
S_BUDAT-HIGH = S_BUDAT-LOW.
MODIFY S_BUDAT.
ENDIF.
ENDLOOP.
IDATE-LOW = S_BUDAT-LOW.
IDATE-HIGH = S_BUDAT-HIGH.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = IDATE-LOW
I_DATE_TO = IDATE-HIGH
IMPORTING
E_DAYS =
E_MONTHS = MONTH
E_YEARS =
DATA: I(3) TYPE C.
I = S_BUDAT-LOW+4(2).
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*added by Prabhu for Only for Oneday.on 18.5.5
IF MONTH EQ '0'.
MONTH = MONTH + 1.
ENDIF.
*added by Prabhu for Only for Oneday.on 18.5.5
DO MONTH TIMES.
R_BUDAT-LOW = S_BUDAT-LOW.
APPEND R_BUDAT.
ENDDO.
I = 0.
LOOP AT R_BUDAT.
R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2) + I.
I = I + 1.
R_BUDAT-LOW+6(2) = '01'.
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_BUDAT-LOW
IMPORTING
LAST_DAY_OF_MONTH = R_BUDAT-HIGH
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
IF R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2).
R_BUDAT-LOW = S_BUDAT-LOW.
MODIFY R_BUDAT.
ENDIF.
IF R_BUDAT-HIGH4(2) = S_BUDAT-HIGH4(2).
R_BUDAT-HIGH = S_BUDAT-HIGH.
MODIFY R_BUDAT.
ENDIF.
For Summary on 26.4.05.
IF Y1 = 'X'.
CLEAR R_BUDAT.
REFRESH R_BUDAT.
R_BUDAT-LOW = S_BUDAT-LOW.
R_BUDAT-HIGH = S_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR R_BUDAT.
ENDIF.
ENDLOOP.
At Selection Screen *
AT SELECTION-SCREEN OUTPUT.
Start of Selection *
START-OF-SELECTION.
V_MJAHR = P_SPMON+0(4).
Get plant distinction warehouse/production
PERFORM GET_PLANT_DISTINCTION.
Collect the data from various tables
PERFORM GETDATA_FG_STOCK.
here the number of rows in the output table is found
PERFORM OUTPUT_TABLE_CHECK.
here the top of the page code is written, that is to be displayed
in the output
PERFORM Z_TOP_OF_PAGE.
here ALV layout properties are set
PERFORM Z_LAYOUT_SETTINGS.
ALV EVENTS for TOP OF PAGE and for USER COMMAND
PERFORM Z_ALV_EVENTS.
The field catalog is defined for the Primary List is defined in
the subroutine CREATE_FIELD_CATALOG include program ZPRRDOCR_FCAT
PERFORM Z_CREATE_FIELD_CATALOG.
This is for displaying the output
PERFORM Z_REUSE_ALV_GRID_DISPLAY.
*& Form getdata_fg_stock
Getting data from standard tables
FORM GETDATA_FG_STOCK.
For getting the Start date & end date of the month
PERFORM get_month_dates.
Getting the Opening Stock from MARDH table
IF MON EQ '01'.
MON1 = MON.
FYEAR1 = FYEAR.
MON = '12'.
FYEAR = FYEAR - 1.
ELSE.
MON1 = MON.
FYEAR1 = FYEAR.
MON = MON - 1.
FYEAR = FYEAR.
ENDIF.
PERFORM GET_RECORDS_FROM_DB.
*added for Month Summary on 26.4.05.
LOOP AT R_BUDAT.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
*for Month
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
*for summary.
IF Y1 = 'X'.
LOOP AT S_BUDAT.
S_BUDAT1-SIGN = 'I'.
S_BUDAT1-OPTION = 'NB'.
S_BUDAT1-LOW = S_BUDAT-LOW.
S_BUDAT1-HIGH = S_BUDAT-HIGH.
APPEND S_BUDAT1.
CLEAR S_BUDAT1.
ENDLOOP.
ENDIF.
IMKPFT[] = I_MKPF[].
IMKPFT2[] = I_MKPF[].
IMARDT[] = I_MARD[].
IMARDHT[] = I_MARDH[].
PERFORM MONTH_WISE.
PERFORM PROCESS_MOVEMENTS.
PERFORM CALCULATE_OPENING_STOCK.
PERFORM UPDATE_NON_TRANSACTION_ITMS.
PERFORM DELETE_EMPTY_RECORDS.
CLEAR: IMARDHT,IMARDT,IMKPFT1,IMKPFT,I_FINAL,I_FINAL5.
REFRESH: IMARDHT,IMARDT,IMKPFT1,I_FINAL,I_FINAL5,IMKPFT.
ENDLOOP.
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*end of changes for month.
ENDFORM. " getdata_fg_stock
FORM MONAT_F4 *
F4-Hilfe für Monat *
FORM MONAT_F4.
DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1.
INCLUDE STRUCTURE DYNPREAD.
DATA: END OF MF_DYNPFIELDS.
DATA: MF_RETURNCODE LIKE SY-SUBRC,
MF_MONAT LIKE ISELLIST-MONTH,
MF_HLP_REPID LIKE SY-REPID.
FIELD-SYMBOLS: .
Wert von Dynpro lesen
GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.
APPEND MF_DYNPFIELDS.
MF_HLP_REPID = SY-REPID.
DO 2 TIMES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07.
IF SY-SUBRC = 3.
Aktuelles Dynpro ist Wertemengenbild
MF_HLP_REPID = 'SAPLALDB'.
ELSE.
READ TABLE MF_DYNPFIELDS INDEX 1.
Unterstriche durch Blanks ersetzen
TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.
EXIT.
ENDIF.
ENDDO.
IF SY-SUBRC = 0.
Konvertierung ins interne Format
CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
EXPORTING
INPUT = MF_DYNPFIELDS-FIELDVALUE
IMPORTING
OUTPUT = MF_MONAT
EXCEPTIONS
ERROR_MESSAGE = 1.
IF MF_MONAT IS INITIAL.
Monat ist initial => Vorschlagswert aus akt. Datum ableiten
MF_MONAT = SY-DATLO(6).
ENDIF.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = MF_MONAT
IMPORTING
SELECTED_MONTH = MF_MONAT
RETURN_CODE = MF_RETURNCODE
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 01
HOLIDAY_CALENDAR_NOT_FOUND = 02
MONTH_NOT_FOUND = 03.
IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.
ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804
<MF_FELD> = MF_MONAT.
CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
EXPORTING
INPUT = MF_MONAT
IMPORTING
OUTPUT = MF_DYNPFIELDS-FIELDVALUE.
COLLECT MF_DYNPFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07. "<<== note 148804
ENDIF.
ENDIF.
ENDFORM. "MONAT_F4
*& Form get_month_dates
Calculating the Month Start & End Date
FORM GET_MONTH_DATES.
IF M1 = 'X'.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR S_BUDAT.
REFRESH S_BUDAT.
S_BUDAT-SIGN = 'I'.
S_BUDAT-OPTION = 'BT'.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
APPEND S_BUDAT.
ELSE.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
ENDIF.
ENDFORM. " get_month_dates
*& Form output_table_Check
checking for records for output
FORM OUTPUT_TABLE_CHECK .
DESCRIBE TABLE I_FINALT LINES INDEX.
IF INDEX EQ 0.
MESSAGE I041 WITH TEXT-005.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. "OUTPUT_TABLE_CHECK
*& Form Z_TOP_OF_PAGE
for setting the details in the top of page *
has no formal paramters *
FORM Z_TOP_OF_PAGE.
DATA: V_MON(2),
V_YR(40),
V_FIN(18),
V_FIN1(48),
LOW(10),
HIGH(10).
V_MON = P_SPMON+4(2).
V_YR = P_SPMON+0(4).
FHEADER-TYP = 'H'.
FHEADER-INFO = 'Stock Register Report (FG Stock)'.
APPEND FHEADER.
CLEAR FHEADER.
*if m1 = 'X'.
CONCATENATE 'Month = ' v_mon '.' v_yr INTO v_fin.
fheader-typ = 'H'.
fheader-info = v_fin.
APPEND fheader.
CLEAR fheader.
*endif."prabhu on 18.5.5
IF D1 = 'X'.
CLEAR S_BUDAT.
LOOP AT S_BUDAT.
CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/'
S_BUDAT-LOW+0(4) INTO LOW.
CONCATENATE S_BUDAT-HIGH6(2) '/' S_BUDAT-HIGH4(2) '/'
S_BUDAT-HIGH+0(4) INTO HIGH.
CONCATENATE 'Date = ' LOW ' - ' HIGH INTO V_FIN1.
FHEADER-TYP = 'H'.
FHEADER-INFO = V_FIN1.
APPEND FHEADER.
CLEAR FHEADER.
ENDLOOP.
ENDIF.
ENDFORM. " Z_TOP_OF_PAGE
*& Form Z_LAYOUT_SETTINGS
this is done for setting the properties for the layout of the *
grid *
has no formal paramters *
FORM Z_LAYOUT_SETTINGS.
FS_LAYO-ZEBRA = 'X'. " Output in Zebra pattern
FS_LAYO-DETAIL_POPUP = 'X'. " A popup window appears to give
FS_LAYO-DETAIL_TITLEBAR = TEXT-022.
FS_LAYO-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " Z_LAYOUT_SETTINGS
*& Form Z_ALV_EVENTS
This is used for handling the events TOP OF PAGE and the USER *
COMMAND event *
has no formal paramters *
FORM Z_ALV_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = FEVENTS[].
READ TABLE FEVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_TOPOFPAGE'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
READ TABLE FEVENTS WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_USER_COMMAND'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
ENDFORM. "Z_ALV_EVENTS
*& Form Z_CREATE_FIELD_CATALOG
here the field catalog is created for the primary list *
no formal parameters *
FORM Z_CREATE_FIELD_CATALOG.
for the Plant
FCAT-FIELDNAME = 'WERKS'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000005'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Plant'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Type
FCAT-FIELDNAME = 'MTART'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000006'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MatTyp'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material No.
FCAT-FIELDNAME = 'MATNR'.
FCAT-KEY = 'X'.
fcat-hotspot = 'X'.
FCAT-OUTPUTLEN = '000018'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Material'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Description
FCAT-FIELDNAME = 'MAKTX'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '000040'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Description'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Unit of Measure
FCAT-FIELDNAME = 'MEINS'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '03'.
FCAT-JUST = 'C'.
FCAT-SELTEXT_M = 'UOM'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'UNIT'.
APPEND FCAT.
CLEAR FCAT.
for the Plant
FCAT-FIELDNAME = 'MONTH'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '08'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MONTH'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Opening Stock
FCAT-FIELDNAME = 'C_STK'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Opening Stock'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
fcat-do_sum = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Total Receipts
FCAT-FIELDNAME = 'TRECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Receipts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Production
FCAT-FIELDNAME = 'PRODU'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Production'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Other Plant Receipts
FCAT-FIELDNAME = 'RECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Othr Plnt Recpts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Sales Return
FCAT-FIELDNAME = 'SAL_RET'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Sales Return'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Total Dispatches
FCAT-FIELDNAME = 'TDISP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Dispatches'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT. -
Folder in alv grid display report
Hi Experts,
I have a requirement to generate the folder in alv grid display, to display the multiple line items where ever we have.
Actually I am displaying the material details and production order details.
If the material is having the multiple production order details , in that case we need to place all the production order details in one folder, and if you open that folder arrow, we have to display the production order details.
I am using REUSE_ALV_GRID_DISPLAY function module to develope this application. Here Hierseq list is recommended to use for this application, why because folder option is already available in grid display. that we can observe in CL6AN.
Is it possible to implement it through function modules or through OOABAP.
Actually, I have to generate the report which we can see in CL6AN Transaction code,,
Your valuable suggestions surely will attract the benifits.
Thanks in advance.
Ramesh.Hi ramesh,
Hierseq list is not supported in the grid display. You could do this using an OO tree display but this could be rather complicated. What about displaying one field per material line with the number of production orders. At double-click on that field, open a second grid display (possibly as popup) to show the production order details.
Regards,
Clemens -
Popup from ALV for displaying full text = problems!!!
Dear all,
I created an ALV to display data. In this ALV, I have a text column, which just show FIRST 30 characters of the original text.
Now I want to double click on that field, and it will pop up a small window to show full text (the original text, unknown length).
I made lots of references and I decided to use FM POPUP_WITH_TABLE because of some reasons:
a) the original text is retrieved from another FM READ_TEXT. After the call of READ_TEXT, the text will be stored into an internal table. Then, it can be passed to POPUP_WITH_TABLE without more modification.
b) POPUP_WITH_TABLE can show the text more meaningfully. I mean, if the length of the text is greater than the length of the popup window, it <b>automatically break the line and displays the rest in the next line</b>. ( FM POPUP_TO_INFORM does NOT do that.)
However, I've faced some <b>PROBLEMS</b> with FM POPUP_WITH_TABLE
1) The popup window has 2 button OK and Cancel. <b>Is there any way just to display Cancel button?</b>
2) If I click on Cancel or OK without choose any line on the popup window => It will raise an exception, called BREAK_OFF. In this case
If the clicked button is CANCEL => it will close the popup
If the clicked button is OK => nothing happens. And I must click on CANCEL to close the popup.
<b>I want to close the popup windown without raising any exceptions. How can I ?</b>
3) When I enter many complex selection criteria on Selection Screen to limit the result, displaying ALV is good. But when I click on the text field to popup => the report cannot be manipulated. I have to kill the session in SM04.
<b>What's wrong? </b>(because for single selection criteria, it works well.)
Every body has any suggestions?
Thank you in advanceI solved it. I just use another list for pop-up event.
Although it worked well now, I thought it was not a good solution.
Thank you all of you.
Best regards. -
Currency field in alv grid display
Hi,
I am using alv grid display.I am having one currency field netprice.I want it to be displayed as blank when i am not passing any value.But it gives 0.00 when it is not having any value.How to make it blank instead of 0.00.
Points will be rewarded.
Regards,
Sowmya.HI,
If itab-curr = '0.00' .
itab-curr = ''.
modify itab.
endif.
Maybe you are looking for
-
Apple DVI to Video adapter + Mini DVI to DVI adapter pins not same
I just purchased an Apple DVI to Video adaptor so I could plug in a Mac mini to an older tv, however the pin arrangement on the Apple DVI to Video adapter is not the same as the pin arrangement on the Mini DVI to DVI adapter that came with the Mac mi
-
Hey everyone, I've had an Audigy 4 Pro for about a year now and it's an amazing piece of hardware, but I seem to be having some kind of problem. I recently had an HD cable box put in my room and I want to connect the optical out port on the cable box
-
Serial number has been registered before!
I bought a new macbook pro and was trying to register the product online. it is a sucsessful registration on the product. However when i try to update the MAC OS X to Lion, it cannot be updated and request to use the up-to-date program to submit some
-
What processors are compatible with my g62 note book?
what processors are compatible with my g62 note book? product number: WY881EA#ABU currently equiped with an intel pentium p6000 1.87GHz processor i got caught out and bought a game that requires a 2.0 GHz processor and i really want to be able to pla
-
I'm not able to connect to Itunes with my iPhone 4s
I had my iphone now for 3 weeks and am not able to use it to use it on the internet. I have a Bt broadband and bt.technical help desk in India is charging £30 to make the wireless connection possible. Bt never charge me to set up a wireless connect