type-pools: slis.
*Table declaration
tables: vbak,vbap.
*internal table
data: begin of i_sales occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
check type c, "checkbox
end of i_sales.
data: begin of i_final occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
end of i_final.
data: v_fieldcat type slis_fieldcat_alv,
gt_fieldcat type slis_t_fieldcat_alv,
gt_layout type slis_layout_alv,
gt_sort type slis_sortinfo_alv,
fieldcat like line of gt_fieldcat.
*Selection screen
parameters: p_vkorg like vbak-vkorg.
select-options: s_vbeln for vbak-vbeln.
*start of selection.
start-of-selection.
perform get_data.
perform fill_fieldcatalog.
perform write_data.
*-----------------------------------------------------------------
* get data
*-----------------------------------------------------------------
FORM get_data .
select a~vbeln
a~erdat
a~audat
a~kunnr
a~vkorg
b~matnr
b~netpr
into corresponding fields of table i_sales
from vbak as a inner join vbap as b on a~vbeln = b~vbeln
where a~vkorg = p_vkorg
and a~vbeln in s_vbeln.
ENDFORM. " get_data
*-----------------------------------------------------------------
* write_data
*-----------------------------------------------------------------
FORM write_data .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'GUI_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = gt_layout
IT_FIELDCAT = gt_fieldcat
TABLES
T_OUTTAB = i_sales .
ENDFORM. " write_data
*-----------------------------------------------------------------
* fill catalog
*-----------------------------------------------------------------
FORM fill_fieldcatalog .
sort i_sales by vbeln.
clear v_fieldcat.
*for check box
v_fieldcat-col_pos = 1.
v_fieldcat-fieldname = 'CHECK'.
v_fieldcat-seltext_m = 'chek'.
v_fieldcat-checkbox = 'X'.
v_fieldcat-input = 'X'.
v_fieldcat-edit = 'X'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 2.
v_fieldcat-fieldname = 'VBELN'.
v_fieldcat-seltext_m = 'Sales Document'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 3.
v_fieldcat-fieldname = 'ERDAT'.
v_fieldcat-seltext_m = 'Creation Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 4.
v_fieldcat-fieldname = 'AUDAT'.
v_fieldcat-seltext_m = 'Document Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 5.
v_fieldcat-fieldname = 'KUNNR'.
v_fieldcat-seltext_m = 'Customer'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 6.
v_fieldcat-fieldname = 'VKORG'.
v_fieldcat-seltext_m = 'Sales Organization'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 7.
v_fieldcat-fieldname = 'MATNR'.
v_fieldcat-seltext_m = 'Material'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 8.
v_fieldcat-fieldname = 'NETPR'.
v_fieldcat-seltext_m = 'Net Value'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
endform.
*&---------------------------------------------------------------------*
*& Form GUI_SET
*&---------------------------------------------------------------------*
FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
SET PF-STATUS 'GETDATA' .
ENDFORM. "GUI_SET
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
R_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DATA'.
CLEAR I_FINAL.
CLEAR I_SALES.
REFRESH I_FINAL.
LOOP AT i_sales .
if i_sales-check = 'X'.
i_final-vbeln = i_sales-vbeln.
i_final-erdat = i_sales-erdat.
i_final-audat = i_sales-audat.
i_final-kunnr = i_sales-kunnr.
i_final-vkorg = i_sales-vkorg.
i_final-matnr = i_sales-matnr.
i_final-netpr = i_sales-netpr.
IF NOT I_FINAL-VBELN IS INITIAL.
append i_final .
ENDIF.
endif.
ENDLOOP.
PERFORM final_display.
endcase.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form final_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------*
form final_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gt_LAYOUT
IT_FIELDCAT = gt_fieldcat
TABLES
t_outtab = i_final .
endform. " final_display
ALSO READ:
- Including Line After Subtotal In ALV Display.
- ALV Subtotals In Different Blocks.
- ALV With Page Numbers & Subtotals.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.