Hello,
I am new in Abap Development, therefore i am unable to solve this problem,please let me know any other person facing same problem
problem is i have added a button in ALV Grid by using this articles
http://www.oneabap.com/2013/11/problem-statement-insome-situation.html
its working fine according to this program and article but when i implement it in my own version it unable to show ALV Grid Toolbar.
i have attached what i am uploading to my program.
here is my program.
Kind Regards
Saad Mehmood
*&---------------------------------------------------------------------*
*& Report Z_TESTAPP9 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT Z_TESTAPP9.
TYPE-POOLS: slis. " SLIS contains all the ALV data types
* Standard includes
include zabpxin_frm.
include zabpxin_udf.
* include bdcrecxy.
TYPES: BEGIN OF ttab,
rec(1000) TYPE c,
END OF ttab.
TYPES: begin of record,
ANLN1_001(012), " Asset No
ANLN2_002(004), " Code
BLDAT_003(010), " Document Date
BUDAT_004(010), " Posting Date
BZDAT_005(010), " Asset val. date
SGTXT_006(050), " Text
XBANL_007(001),
XNANL_008(001),
ANLN1_009(012),
ANLN2_010(004),
BLDAT_011(010),
BUDAT_012(010),
BZDAT_013(010),
SGTXT_014(050),
XNANL_015(001),
ANLKL_016(008), " Class
ANLKL_017(008),
XVLABG_018(001),
TXT50_019(050),
KOSTL_020(010),
TXT50_021(050), " Remarks
NDJAR_01_022(003), " Useful.life 1
NDJAR_02_023(003), " Useful.life 2
ANLN1_024(012),
ANLN2_025(004),
BLDAT_026(010),
BZDAT_027(010),
SGTXT_028(050),
XNANL_029(001),
end of record.
DATA: itab TYPE TABLE OF ttab WITH HEADER LINE.
DATA: idat TYPE TABLE OF record WITH HEADER LINE.
DATA: file_str TYPE string.
DATA: GD_REPID LIKE SY-REPID.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
data : begin of t_head occurs 0.
include structure bkpf.
data : box type char1,
lights type char1,
expand type char1,
text like t100-text,
bldat2(12), "t_head-bldat2=To display in ALV; t_head-bldat=To post data in SAP
budat2(12), "t_head-budat2=To display in ALV; t_head-budat=To post data in SAP
end of t_head.
data : begin of t_item occurs 0.
include structure bseg.
data : box type char1,
icon type icon_l4,
text like t100-text,
newbw(3), "Transaction Type
end of t_item.
*$---------------------------------------------------------------------*
*$ Initialization *
*$---------------------------------------------------------------------*
initialization.
*$---------------------------------------------------------------------*
*$ Selection screen *
*$---------------------------------------------------------------------*
selection-screen begin of block b1 with frame title text-001.
macro_udf_fname_parameters p_file 'C:\'. "'\\saad'.
selection-screen end of block b1.
*$---------------------------------------------------------------------*
*AT SELECTION-SCREEN.
*$---------------------------------------------------------------------*
AT SELECTION-SCREEN.
macro_udf_f4_fname p_file.
*$---------------------------------------------------------------------*
*START-OF-SELECTION.
*$---------------------------------------------------------------------*
START-OF-SELECTION.
macro_udf_upload p_file 'ASC' itab.
macro_check_selection_table itab.
perform f_transfer_data.
perform build_fieldcatalog.
*$---------------------------------------------------------------------*
*END-OF-SELECTION.
*$---------------------------------------------------------------------*
END-OF-SELECTION.
perform Show_Alv_Grid.
*&---------------------------------------------------------------------*
*& Form sub_pf_status
*&---------------------------------------------------------------------*
* Sub-Routine to Set the PF status
*----------------------------------------------------------------------*
FORM sub_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD' excluding rt_extab.
ENDFORM. "sub_pf_status
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* Sub-Routine to handle the click on the ALV aoutput
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
IF r_ucomm EQ '&UPL2'.
MESSAGE 'Custom button is clicked.' TYPE 'I'.
ENDIF.
ENDFORM. "User_command
*&---------------------------------------------------------------------*
*& Form F_TRANSFER_DATA
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
form f_transfer_data.
data : filelen type i,
file_extn type STRING.
filelen = strlen( p_file ).
filelen = filelen - 4 .
file_extn = p_file+filelen.
* translate file_extn to upper case.
if file_extn ne '.csv'.
message 'Invalid file format.File extension should be .CSV' TYPE 'I'.
LEAVE PROGRAM.
endif.
file_str = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_str
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
LOOP AT itab.
CLEAR idat.
SPLIT itab-rec AT ',' INTO idat-ANLN1_001 idat-ANLN2_002 idat-BLDAT_003 idat-BUDAT_004 idat-BZDAT_005 idat-SGTXT_006 idat-ANLKL_016 idat-NDJAR_01_022 idat-TXT50_021.
APPEND idat.
* SPLIT itab-rec AT ',' INTO idat-assetno idat-subno idat-docdate idat-postdate idat-assetvaldate idat-txt idat-newAsst idat-cls idat-ulink idat-remarks.
* APPEND idat.
ENDLOOP.
endform. " F_TRANSFER_DATA
*$---------------------------------------------------------------------*
* Show_Alv_Grid.
*$---------------------------------------------------------------------*
form Show_Alv_Grid.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = GD_REPID
i_callback_pf_status_set = 'sub_pf_status'
i_callback_user_command = 'user_command'
it_fieldcat = it_fieldcat[]
* is_layout = gd_layout
i_save = 'X'
* it_events = gt_events
TABLES
t_outtab = idat
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE 'Error in displaying output.' TYPE 'E'.
ENDIF.
endform.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
*Build field catalog
wa_fieldcat-FIELDNAME = 'FLAG'.
wa_fieldcat-SELTEXT_M = 'Check'.
wa_fieldcat-INPUT = 'X'.
wa_fieldcat-EDIT = 'X'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-COL_POS = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ANLN1_001'. " Fieldname in the data table
wa_fieldcat-seltext_m = 'Asset No'. " Column description in the output
wa_fieldcat-COL_POS = 1.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ANLN2_002'.
wa_fieldcat-seltext_m = 'Code'.
wa_fieldcat-COL_POS = 2.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'BLDAT_003'.
wa_fieldcat-seltext_m = 'Doc. Date'.
wa_fieldcat-COL_POS = 3.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'BUDAT_004'.
wa_fieldcat-seltext_m = 'Post. Date'.
wa_fieldcat-COL_POS = 4.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'BZDAT_005'.
wa_fieldcat-seltext_m = 'Asset. Val. Date'.
wa_fieldcat-COL_POS = 5.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'SGTXT_006'.
wa_fieldcat-seltext_m = 'Text'.
wa_fieldcat-COL_POS = 6.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ANLKL_016'.
wa_fieldcat-seltext_m = 'Class'.
wa_fieldcat-COL_POS = 7.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'NDJAR_01_022'.
wa_fieldcat-seltext_m = 'Use.life'.
wa_fieldcat-COL_POS = 8.
APPEND wa_fieldcat TO it_fieldcat.
endform.