Posted: Sat Jan 26, 2008 4:30 pm Post subject: ALV : switch list
Code:
REPORT z_alv_switch_list_v2.
*---------------------------------------------------------------------*
* Button to switch alv list *
*---------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : [email protected] HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
TYPE-POOLS: slis. " ALV Global types
*---------------------------------------------------------------------*
CONSTANTS:
c_x VALUE 'X',
c_eb9 TYPE syucomm VALUE '&EB9'.
*---------------------------------------------------------------------*
TYPES :
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
waerk TYPE vbak-waerk, " Document currency
END OF ty_vbak,
BEGIN OF ty_vbap,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document item
matnr TYPE vbap-matnr, " Material number
arktx TYPE vbap-arktx, " Short text for sales order item
kwmeng TYPE vbap-kwmeng, " Order Quantity
netwr TYPE vbap-netwr, " Net value of the order item
waerk TYPE vbap-waerk, " SD document currency
END OF ty_vbap.
*---------------------------------------------------------------------*
DATA:
g_flag TYPE i VALUE 1,
gs_print_k TYPE slis_print_alv,
gs_print_p TYPE slis_print_alv,
gs_layout_k TYPE slis_layout_alv,
gs_layout_p TYPE slis_layout_alv,
gt_sort_k TYPE slis_t_sortinfo_alv,
gt_sort_p TYPE slis_t_sortinfo_alv,
gt_filter_k TYPE slis_t_filter_alv,
gt_filter_p TYPE slis_t_filter_alv,
gt_fieldcat_k TYPE slis_t_fieldcat_alv,
gt_fieldcat_p TYPE slis_t_fieldcat_alv.
DATA:
vbak TYPE vbak,
gt_vbak TYPE TABLE OF ty_vbak,
gt_vbap TYPE TABLE OF ty_vbap.
*---------------------------------------------------------------------*
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
*---------------------------------------------------------------------*
INITIALIZATION.
*---------------------------------------------------------------------*
* Form f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.
* Read Sales Document: Header Data
SELECT vkorg kunnr vbeln netwr waerk
UP TO p_max ROWS
INTO TABLE gt_vbak
FROM vbak
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
CHECK NOT gt_vbak[] IS INITIAL.
* Read Sales Document: Header Data and items
SELECT vkorg kunnr k~vbeln posnr matnr arktx kwmeng p~netwr p~waerk
INTO CORRESPONDING FIELDS OF TABLE gt_vbap
FROM vbak AS k
INNER JOIN vbap AS p
ON k~vbeln = p~vbeln
FOR ALL ENTRIES IN gt_vbak
WHERE k~vbeln = gt_vbak-vbeln.
ENDFORM. " F_READ_DATA
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
ENDFORM. " F_DISPLAY_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN c_eb9.
us_selfield-exit = c_x.
IF g_flag = 1.
* Read and Save current ALV list information
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
es_layout = gs_layout_k
et_fieldcat = gt_fieldcat_k
et_sort = gt_sort_k
et_filter = gt_filter_k
es_print = gs_print_k
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE.
* Read and Save current ALV list information
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
es_layout = gs_layout_p
et_fieldcat = gt_fieldcat_p
et_sort = gt_sort_p
et_filter = gt_filter_p
es_print = gs_print_p
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*
* FORM PF_STATUS_SET *
*---------------------------------------------------------------------*
FORM pf_status_set USING ut_extab TYPE slis_t_extab. "#EC CALLED
* Display switch button
DELETE ut_extab WHERE fcode = c_eb9.
SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
EXCLUDING ut_extab.
ENDFORM. " PF_STATUS_SET
**************** END OF PROGRAM Z_ALV_SWITCH_LIST_V2 *******************
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.