cancel
Showing results for 
Search instead for 
Did you mean: 

Short dump in ALV when clicked on a column.

faisal_pc
Active Contributor
0 Kudos

Hi Everyone.

I have an alv report with following code. Code is given in following posts also as it exceeds the maximum length of a post.

Main program:

report z_sample_program.

include z_top_include. "Data decalrations.

include z_sample_selection_screen. "Selection screen include

include z_sample_subroutines. "All subroutines

*During INITIALIZATION the standard values for parameters or selection criteria,

  • which are declared in logical databases, can be changed.

initialization.

*Clear all tables and work area.

perform f_initialize.

start-of-selection.

*Retrieve Data

*NOTE:TABLES as form parameters is obselete. Instead use CHANGING.

perform f_data_retrieval using p_vkorg p_auart "USING & CHANGING Parameter.

changing i_vbak i_vbap.

end-of-selection.

*Build Fieldcatalog for ALV Report

perform f_build_fieldcatalog.

*Build layout for ALV grid report

perform f_build_layout.

*Build events table

perform f_build_events.

if rb_alv eq c_x. "If the first radio button is pressed.

  • Display report using ALV grid

perform f_display_alv_report.

else.

  • Download to an presentation server file.

perform f_download_to_file using p_path.

endif.

When I click on a column it goes to dump. Earlier I hadnu2019t have the line wa_layout-box_fieldname = c_sel

in form f_build_layout and it was working fine. This line i added for rowselection. Could anyone please help me what is the reason for this dump.?

Accepted Solutions (0)

Answers (3)

Answers (3)

kesavadas_thekkillath
Active Contributor
0 Kudos

Hello,

check this link and do an alv consistency check

link:[http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/15961] [original link is broken] [original link is broken] [original link is broken];

faisal_pc
Active Contributor
0 Kudos

Hi Keshav,

I did the consistency check. It goes to dump. I vl again post the user command form in my program here.

FORM f_user_command USING p_ucomm TYPE sy-ucomm

p_selfield TYPE slis_selfield.

CASE p_ucomm.

WHEN c_ic1.

  • Check field clicked on within ALVgrid report

CASE p_selfield-fieldname.

WHEN c_sales_order_num.

  • Read data table, using index of row user clicked on

READ TABLE i_final_table INTO wa_final_table INDEX

p_selfield-tabindex.

IF sy-subrc = 0.

  • Set parameter ID for transaction screen field

SET PARAMETER ID c_aun FIELD wa_final_table-sales_order_no.

  • Execute transaction VA03, and skip initial data entry screen

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

WHEN c_del_num.

READ TABLE i_final_table INTO wa_final_table INDEX

p_selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID c_vl FIELD wa_final_table-del_no.

  • Execute transaction VL03, and skip initial data entry screen

CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN.

ENDIF.

WHEN c_ship_num.

READ TABLE i_final_table INTO wa_final_table INDEX

p_selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID c_tnr FIELD wa_final_table-shipment_no.

  • Execute transaction VT03, and skip initial data entry screen

CALL TRANSACTION 'VT03' AND SKIP FIRST SCREEN.

ENDIF.

WHEN c_mat_num.

READ TABLE i_final_table INTO wa_final_table INDEX

p_selfield-tabindex.

IF sy-subrc <> 0.

SET PARAMETER ID c_mat FIELD wa_final_table-material_num.

  • Execute transaction MM03, and skip initial data entry screen

CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

ENDIF.

WHEN OTHERS.

  • Do nothing.

ENDCASE.

WHEN OTHERS.

  • Do nothing.

ENDCASE.

ENDFORM. "f_user_command

And in the form build layout, i added one more line wa_layout-box_fieldname = c_sel which enables the row selection. That is when this dump happened. Plz have a look at my build_layout finction.

FORM f_build_layout .

wa_layout-colwidth_optimize = c_x.

wa_layout-box_fieldname = c_sel.

wa_layout-zebra = c_x.

ENDFORM. " F_BUILD_LAYOUT

faisal_pc
Active Contributor
0 Kudos

I get the following error message.

Error in the ABAP Application Program

The current ABAP program "SAPLSLVC_FULLSCREEN" had to be terminated because it

has come across a statement that unfortunately cannot be executed.

A new value is to be assigned to the field "<L_BOX>", although this field is

entirely or partly protected against changes.

The following are protected against changes:

- Character literals or numeric literals

- Constants (CONSTANTS)

- Parameters of the category IMPORTING REFERENCE for functions and

methods

- Untyped field symbols not yet assigned a field using ASSIGN

- TABLES parameters if the actual parameter is protected against changes

- USING reference parameters and CHANGING parameters for FORMs, if the

actual parameter is protected against changes and

- Accesses using field symbols if the field assigned using ASSIGN is

protected (or partially protected, e.g. key components of an internal

table with the type SORTED or HASHED TABLE) against changes

- Accesses using references, if the field bound to the reference is

protected (or partially protected) against changes

- External write accesses to READ-ONLY attributes,

- Content of a shared object area instance accessed using a shared lock

(ATTACH_FOR_READ).

I am using SLIS_LAYOUT_ALV. I don't understand how it's going to LVC then.

faisal_pc
Active Contributor
0 Kudos

Hi Everyone,

I got the solution of the problem.

I should have added one more field into the structure of my final table. That field name i have to give in layout. As in my code, it's SEL. I should include a field named SEL to my final table which is passed to ALV.

faisal_pc
Active Contributor
0 Kudos

Include z_sample_subroutines

&----


*& Form F_INITIALIZE

----


*Initialize all tables and work areas at the beginning.

----


form f_initialize .

refresh: i_vbak,

i_vbap,

i_lips,

i_vttp,

i_final_table,

i_fieldcatalog,

i_tab_group,

i_events.

clear: wa_vbak,

wa_vbap,

wa_lips,

wa_vttp,

wa_final_table,

wa_layout,

wa_prntparams.

wa_variant-report = sy-repid. " report for using variants

endform. " F_INITIALIZE

&----


*& Form F_DATA_RETRIEVAL

&----


*Retrieve data form VBAK,VBAP,LIKP,LIPS,VTTK,VTTP table and populate

*itab i_final_table

----


  • -->P_VKORG Sales organization

  • -->P_AUART Sales document type

  • <--f_I_VBAK Sales header table.

  • <--f_I_VBAP Sales item table.

----


form f_data_retrieval using p_vkorg type vkorg

p_auart type auart

changing t_vbak type tb_tab_vbak

t_vbap type tb_tab_vbap.

*If we have to modify the table we can use Field-SYMBOLS instead of work areas. The declaration of a field symbol is as given below.

  • FIELD-SYMBOLS <lfs_vbap> TYPE t_vbap.

  • Retrieving sales order number

select vbeln "Sales Document

erdat "Date on Which Record Was Created

auart "Sales Document Type

vkorg "Sales Organization

from vbak

into

table i_vbak

where vbeln in s_vbeln

and vkorg = p_vkorg

and auart = p_auart

and erdat in s_erdat.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_six.

else.

sort i_vbak by vbeln.

endif.

  • Retrieving Items

  • In order to avoid nested select statements we can go for "FOR ALL

  • ENTRIES".The use of that is as given below.

if i_vbak is not initial. "Checking the table is empty or not.

select vbeln "Sales Document

posnr "Sales Document Item

kwmeng "Cumulative Order Quantity in Sales Units

from vbap

into

table i_vbap

for all entries in i_vbak

where vbeln eq i_vbak-vbeln.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_seven.

endif.

endif.

*Retrieving delivery number

if i_vbak is not initial.

select vbeln "Sales Document

matnr "Material Number

lfimg "Actual quantity delivered (in sales units)

vgbel "Document number of the reference document

vgpos "Item number of the reference item.

from lips

into

table i_lips

for all entries in i_vbak

where vgbel eq i_vbak-vbeln.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_eight.

else.

sort i_lips by vgbel.

endif.

endif.

  • Retrieving Shipment number.

if i_lips is not initial.

select vbeln "Delivery

tknum "Shipment Number

from vttp

into

table i_vttp

for all entries in i_lips

where vbeln eq i_lips-vbeln.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_ten.

else.

sort i_vttp by vbeln.

endif.

endif.

clear wa_vbap.

loop at i_vbap into wa_vbap.

clear : wa_vbak,

wa_lips,

wa_vttp,

wa_final_table.

read table i_vbak into wa_vbak with key vbeln = wa_vbap-vbeln

binary search.

if sy-subrc = 0.

wa_final_table-sales_order_no = wa_vbak-vbeln.

wa_final_table-sales_org = wa_vbak-vkorg.

wa_final_table-sales_doc_type = wa_vbak-auart.

wa_final_table-date = wa_vbak-erdat.

read table i_lips into wa_lips with key vgbel = wa_vbap-vbeln

vgpos = wa_vbap-posnr binary search.

if sy-subrc = 0.

wa_final_table-del_no = wa_lips-vbeln.

wa_final_table-material_num = wa_lips-matnr.

wa_final_table-order_quant = wa_vbap-kwmeng.

wa_final_table-del_quant = wa_lips-lfimg.

endif.

endif.

read table i_vttp into wa_vttp with key vbeln = wa_lips-vbeln

binary search.

if sy-subrc = 0.

wa_final_table-shipment_no = wa_vttp-tknum.

wa_final_table-item = wa_vbap-posnr.

endif.

if wa_final_table-del_no is not initial and

wa_final_table-material_num is not initial and

wa_final_table-shipment_no is not initial.

append wa_final_table to i_final_table.

clear wa_final_table.

endif.

endloop.

endform. " F_DATA_RETRIEVAL

&----


*& Form F_BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

&----


form f_build_fieldcatalog .

data:lv_col_pos type i.

  • If we have a structure created in SE11 for field catalogue, we can use

  • function module for populating the field catalog.

perform f_create_field_catalog using lv_col_pos

c_sales_order_num

text-002.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_del_num

text-003.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_ship_num

text-004.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_sales_org

text-005.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_date

text-006.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_item

text-007.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_mat_num

text-008.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_sales_org

text-009.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_ord_quan

text-010.

lv_col_pos = lv_col_pos + 1.

perform f_create_field_catalog using lv_col_pos

c_del_quan

text-011.

perform f_sub_populate_sort.

endform. " F_BUILD_FIELDCATALOG

&----


*& Form F_CREATE_FIELD_CATALOG

&----


  • Creating the field catalog for ALV.

----


*-->p_colpos Row position

*-->p_fldnam Field name

*-->p_seltext Seltext

----


form f_create_field_catalog using p_colpos type sycucol

p_fldnam type fieldname

p_seltext type dd03p-scrtext_l.

data:lwa_fieldcatalog type slis_fieldcat_alv.

lwa_fieldcatalog-col_pos = p_colpos. "Column

lwa_fieldcatalog-fieldname = p_fldnam. "Field Name

lwa_fieldcatalog-seltext_l = p_seltext. "Field Text

if p_fldnam = c_ord_quan or p_fldnam = c_del_quan.

lwa_fieldcatalog-do_sum = c_x.

endif.

append lwa_fieldcatalog to i_fieldcatalog.

clear lwa_fieldcatalog.

endform. " F_CREATE_FIELD_CATALOG

faisal_pc
Active Contributor
0 Kudos

&----


*& Form F_SUB_POPULATE_SORT

&----


  • The form for sorting the table and getting subtotal.

----


form f_sub_populate_sort .

  • Sort on material

wa_sort-spos = c_01 .

wa_sort-fieldname = c_sales_order_num.

wa_sort-tabname = c_final_table.

wa_sort-up = c_x.

wa_sort-subtot = c_x.

append wa_sort to i_sort .

clear wa_sort.

endform. " F_SUB_POPULATE_SORT

&----


*& Form F_BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form f_build_layout .

  • wa_layout-no_input = c_x.

wa_layout-colwidth_optimize = c_x.

wa_layout-box_fieldname = c_sel.

wa_layout-get_selinfos = 'X'.

  • wa_layout-edit = c_x.

  • wa_layout-zebra = c_x.

endform. " F_BUILD_LAYOUT

&----


*& Form F_BUILD_EVENTS

&----


  • Build events table

----


form f_build_events .

data: lwa_ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = i_events[]

exceptions

list_type_wrong = 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.

sort i_events by name.

read table i_events

with key name = slis_ev_end_of_page

into lwa_ls_event binary search.

if sy-subrc = 0.

move c_end_of_page to lwa_ls_event-form.

append lwa_ls_event to i_events.

endif.

sort i_events by name.

read table i_events

with key name = slis_ev_end_of_list

into lwa_ls_event binary search.

if sy-subrc = 0.

move c_end_of_list to lwa_ls_event-form.

append lwa_ls_event to i_events.

endif.

endform. " F_BUILD_EVENTS

&----


*& Form F_DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

&----


form f_display_alv_report .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

i_callback_top_of_page = 'F_TOP-OF-PAGE' "see FORM

i_callback_user_command = 'F_USER_COMMAND'

is_layout = wa_layout

it_fieldcat = i_fieldcatalog[]

it_sort = i_sort[]

is_variant = wa_variant " variant name

it_events = i_events

is_print = wa_prntparams

i_save = c_x

tables

t_outtab = i_final_table

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_twelve.

endif.

endform. " F_DISPLAY_ALV_REPORT

----


  • FORM USER_COMMAND *

----


  • --> R_UCOMM *

  • --> RS_SELFIELD *

----


form f_user_command using p_ucomm type sy-ucomm

p_selfield type slis_selfield.

case p_ucomm.

when c_ic1.

  • Check field clicked on within ALVgrid report

case p_selfield-fieldname.

when c_sales_order_num.

  • Read data table, using index of row user clicked on

read table i_final_table into wa_final_table index

p_selfield-tabindex.

if sy-subrc = 0.

  • Set parameter ID for transaction screen field

set parameter id c_aun field wa_final_table-sales_order_no.

  • Execute transaction VA03, and skip initial data entry screen

call transaction 'VA03' and skip first screen.

endif.

when c_del_num.

read table i_final_table into wa_final_table index

p_selfield-tabindex.

if sy-subrc = 0.

set parameter id c_vl field wa_final_table-del_no.

  • Execute transaction VL03, and skip initial data entry screen

call transaction 'VL03' and skip first screen.

endif.

when c_ship_num.

read table i_final_table into wa_final_table index

p_selfield-tabindex.

if sy-subrc = 0.

set parameter id c_tnr field wa_final_table-shipment_no.

  • Execute transaction VT03, and skip initial data entry screen

call transaction 'VT03' and skip first screen.

endif.

when c_mat_num.

read table i_final_table into wa_final_table index

p_selfield-tabindex.

if sy-subrc <> 0.

set parameter id c_mat field wa_final_table-material_num.

  • Execute transaction MM03, and skip initial data entry screen

call transaction 'MM03' and skip first screen.

endif.

when others.

  • Do nothing.

endcase.

when others.

  • Do nothing.

endcase.

endform. "f_user_command

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


form f_top-of-page.

*ALV Header declarations

data: li_header type slis_t_listheader,

lwa_header type slis_listheader,

lv_line like lwa_header-info,

lv_lines(10) type c,

lv_linesc(10) type c.

  • Title

lwa_header-typ = c_h.

lwa_header-info = text-012.

append lwa_header to li_header.

clear lwa_header.

  • Date

lwa_header-typ = c_s.

lwa_header-key = c_date.

concatenate sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) into lwa_header-info. "todays date

append lwa_header to li_header.

clear: lwa_header.

  • Total No. of Records Selected

describe table i_final_table lines lv_lines.

lv_linesc = lv_lines.

concatenate text-013 lv_linesc

into lv_line separated by space.

lwa_header-typ = c_rb_a.

lwa_header-info = lv_line.

append lwa_header to li_header.

clear: lwa_header, lv_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = li_header.

endform. "top-of-page

&----


*& Form END_OF_PAGE

&----


form f_end_of_page.

data: lv_listwidth type i,

lv_pagepos(10) type c,

lv_page(10) type c.

write: sy-uline(50).

skip.

write:/40 sy-pagno .

endform. "END_OF_PAGE

&----


*& Form END_OF_LIST

&----


form f_end_of_list.

data: lv_listwidth type i,

lv_pagepos(10) type c,

lv_page(10) type c.

skip.

write:/40 sy-pagno .

endform. "END_OF_LIST

&----


*& Form F_F4_VARIANT_HELP

&----


  • SUB-ROUTINE f4_variant_help TO GET A F4 HELP FOR VARIANT

  • SELECTION AND DISPLAY DATA ACCORDINGLY

----


  • <--P_P_VAR text

----


form f_f4_variant_help using p_p_var.

call function 'REUSE_ALV_VARIANT_F4'

exporting

is_variant = wa_variant " export variant

i_save = c_rb_a " layout for all users

i_display_via_grid = c_x " grid view of variants

importing

es_variant = wa_i_variant " import variant

exceptions

not_found = 1

program_error = 2

others = 3.

if sy-subrc = 0.

  • PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD

p_p_var = wa_i_variant-variant.

endif.

endform. " F_F4_VARIANT_HELP

&----


*& Form F_GET_DEFAULT_VARIANT

&----


  • SUB-ROUTINE GET_DEFAULT_VARIANT TO PASS THE DEFAULT VARIANT

  • IF USER DOESN'T ENTERS ANY VALUE FOR THE VARIANT

----


  • <--P_P_VAR variant name

----


form f_get_default_variant using p_p_var.

call function 'REUSE_ALV_VARIANT_DEFAULT_GET'

exporting

i_save = c_rb_a

changing

cs_variant = wa_variant "variant name

exceptions

wrong_input = 1

not_found = 2

program_error = 3

others = 4.

  • IF DEFAULT VARIANT FOUND

if sy-subrc = 0.

  • PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD

p_p_var = wa_variant-variant.

endif.

endform. " F_GET_DEFAULT_VARIANT

&----


*& Form F_CHECK_VARIANT_EXISTENCE

&----


  • SUB-ROUTINE CHECK_VARIANT_EXISTENCE TO VALIDATE THE VARIANT

  • NAME ENTERED BY THE USER

  • IF VARIANT FOUND THEN EXECUTE

  • ELSE DISPLAY ERROR MESSAGE

----


  • <--P_P_VAR variant name

----


form f_check_variant_existence using p_p_var.

&----


  • ASSIGN THE VALUE OF THE VARIANT ENTERED BY USER TO THE

  • WORK AREA FIELD AND CHECK FOR ITS EXISTENCE

&----


wa_variant-variant = p_p_var.

&----


  • TO CHECK THE EXISTENCE FOR VARIANT CORRESPONDING TO

  • EXISTING VARIANT IF THE USER ENTERS SOME VALUE FOR

  • THE PARAMETER

&----


call function 'REUSE_ALV_VARIANT_EXISTENCE'

exporting

i_save = c_rb_a

changing

cs_variant = wa_variant " variant name

exceptions

wrong_input = 1

not_found = 2

program_error = 3

others = 4.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_eighteen.

endif.

endform. " CHECK_VARIANT_EXISTENCE

&----


*& Form F_DOWNLOAD_TO_FILE

&----


  • Form for downloading the table to presentation server file.

----


form f_download_to_file using p_path type string.

if p_path is initial.

message id 'ZSAMPLE_MSG_CLASS' type 'I' number c_fifteen.

endif.

call method cl_gui_frontend_services=>gui_download

exporting

filename = p_path

write_field_separator = c_x

changing

data_tab = i_final_table.

if sy-subrc = 0.

message id 'ZSAMPLE_MSG_CLASS' type 'W' number c_seventeen.

endif.

faisal_pc
Active Contributor
0 Kudos

Include z_sample_selection_screen

&----


*& SELECTION SCREEN *

&----


selection-screen begin of block b1 with frame.

select-options:s_vbeln for vbak-vbeln,

s_erdat for vbak-erdat.

parameters :p_vkorg type vbak-vkorg obligatory,

p_auart type vbak-auart obligatory.

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text-001.

parameters : rb_alv radiobutton group rad1 default 'X' user-command u1,

p_var type slis_vari modif id b,

rb_xls radiobutton group rad1,

p_path type string modif id a.

selection-screen end of block b2.

&----


*& AT SELECTION SCREEN *

&----


at selection-screen on p_vkorg.

select single vkorg

from tvko

into v_vkorg

where vkorg eq p_vkorg.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_one.

endif.

at selection-screen on p_auart.

select single auart

from tvak

into v_auart

where auart eq p_auart.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_four.

else.

*Authority check.tcode for maintain authorization objects is su21.

authority-check object 'V_VBAK_AAT'

id 'AUART' field p_auart

id 'ACTVT' field '03'.

if sy-subrc <> 0.

message id 'ZSAMPLE_MSG_CLASS' type 'E' number c_five.

endif.

endif.

at selection-screen on value-request for p_path.

*F4 Help for the Input file

call method cl_gui_frontend_services=>file_save_dialog

changing

filename = v_file

path = v_path

fullpath = p_path.

*To get the F4 help for the existing variants.

at selection-screen on value-request for p_var.

perform f_f4_variant_help using p_var.

*Pass the default variant name if user leaves the variant field as blank

at selection-screen on p_var.

if p_var eq ' '.

perform f_get_default_variant using p_var.

else.

perform f_check_variant_existence using p_var.

endif.

&----


*& AT SELECTION SCREEN OUTPUT *

&----


at selection-screen output.

if rb_alv = c_x.

loop at screen.

if screen-group1 = c_rb_a.

screen-active = 0.

modify screen.

endif.

endloop.

else.

loop at screen.

if screen-group1 = c_rb_b.

screen-active = 0.

modify screen.

endif.

endloop.

endif.

clear: p_var,

p_path.