REPORT Z_TEST7 .
*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.
type-pools: slis.
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.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
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
*&---------------------------------------------------------------------*
*& Form write_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM write_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
* IS_LAYOUT = gt_layout
IT_FIELDCAT = gt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = 'X'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_sales
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. " write_data
*&---------------------------------------------------------------------*
*& Form fill_fieldcatalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
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.