Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV DUMP

Hi

Can you plz check my code i am getting a dump unable to convert to number i am trying to enable a check box in alv grid check field catalogue column i giving gx_fcat-checkbox = 'X', i am getting dump because of this ..

REPORT zalv_demo_pg.

TYPE-POOLS slis.

TYPES:BEGIN OF ty_vbak,

vbeln TYPE vbeln_va,

auart TYPE auart,

netwr TYPE netwr_ak,

waerk TYPE waerk,

vkorg TYPE vkorg,

END OF ty_vbak.

TYPES:BEGIN OF ty_vbap,

vbeln TYPE vbeln_va,

posnr TYPE posnr_va,

matnr TYPE matnr,

netwr1 TYPE netwr_ap,

END OF ty_vbap.

TYPES:BEGIN OF ty_grid,

sel(1),

vbeln TYPE vbeln_va,

posnr TYPE posnr_va,

matnr TYPE matnr,

netwr1 TYPE netwr_ap,

auart TYPE auart,

netwr TYPE netwr_ak,

waerk TYPE waerk,

vkorg TYPE vkorg,

END OF ty_grid.

DATA:svbeln TYPE vbak-vbeln,

gx_vbak TYPE ty_vbak,

gx_vbap TYPE ty_vbap,

gt_vbak TYPE STANDARD TABLE OF ty_vbak,

gt_vbap TYPE STANDARD TABLE OF ty_vbap,

gx_grid TYPE ty_grid,

gt_grid TYPE STANDARD TABLE OF ty_grid.

*Data declarations for Field Catalogue.

DATA: gx_fcat TYPE slis_fieldcat_alv, "work area

gt_fcat TYPE slis_t_fieldcat_alv. "Internal table

*Data declarations for Sorting Field Catalogue.

DATA: gx_sort TYPE slis_sortinfo_alv, "work area

gt_sort TYPE slis_t_sortinfo_alv. "Internal table

  • Data declarations for Event table

DATA: gx_event TYPE slis_alv_event, "Work Area

gt_event TYPE slis_t_event. "Internal table

  • Data declarations for Page header

DATA: gx_head TYPE slis_listheader, "Work area

gt_head TYPE TABLE OF slis_listheader. "Internal table

*DATA declarations for check box and layout

*DATA : layout TYPE slis_layout_alv.

*

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.

SELECT-OPTIONS s_vbeln FOR svbeln.

PARAMETERS : p_posnr TYPE vbap-posnr.

SELECTION-SCREEN END OF BLOCK blk.

PERFORM get_data.

PERFORM build_catalogue.

*PERFORM sort_fields.

PERFORM events.

PERFORM header.

PERFORM alv_grid.

  • In the layout set give the name of the field

  • whose checkbox will be created ( SEL as it has 1 char only )

*layout-box_fieldname = 'SEL'.

START-OF-SELECTION.

&----


*& Form get_data

&----


FORM get_data .

SELECT vbeln

auart

netwr

waerk

vkorg

FROM vbak

INTO TABLE gt_vbak

WHERE vbeln IN s_vbeln.

IF sy-subrc EQ 0.

ENDIF.

*

  • SELECT vbeln

  • posnr

  • matnr

  • FROM vbap

  • INTO TABLE gt_vbap

  • WHERE vbeln IN s_vbeln AND

  • posnr = p_posnr.

*

*

*

  • IF sy-subrc EQ 0.

*

  • ENDIF.

SELECT vbeln

posnr

matnr

netwr

FROM vbap

INTO TABLE gt_vbap

FOR ALL ENTRIES IN gt_vbak

WHERE vbeln = gt_vbak-vbeln.

SORT gt_vbap.

SORT gt_vbak.

DELETE ADJACENT DUPLICATES FROM gt_vbap.

DELETE ADJACENT DUPLICATES FROM gt_vbak.

IF sy-subrc EQ 0.

ENDIF.

LOOP AT gt_vbap INTO gx_vbap.

LOOP AT gt_vbak INTO gx_vbak.

gx_grid-vbeln = gx_vbap-vbeln.

gx_grid-posnr = gx_vbap-posnr.

gx_grid-matnr = gx_vbap-matnr.

gx_grid-netwr1 = gx_vbap-netwr1.

gx_grid-auart = gx_vbak-auart.

gx_grid-netwr = gx_vbak-netwr.

gx_grid-waerk = gx_vbak-waerk.

gx_grid-vkorg = gx_vbak-vkorg.

APPEND gx_grid TO gt_grid.

ENDLOOP.

ENDLOOP.

ENDFORM. " get_data

&----


*& Form build_catalogue

&----


FORM build_catalogue .

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'SEL'.

gx_fcat-seltext_l = 'CHECKBOX'.

gx_fcat-edit = 'X'.

gx_fcat-checkbox = 'X'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'VBELN'.

gx_fcat-seltext_l = 'Sales Doc'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'POSNR'.

gx_fcat-seltext_l = 'Item'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'MATNR'.

gx_fcat-seltext_l = 'Mat no'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'NETWR1'.

gx_fcat-seltext_l = 'NET price item'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'AUART'.

gx_fcat-seltext_l = 'Sale doc typ'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'NETWR'.

gx_fcat-seltext_l = 'Net price'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'WAERK'.

gx_fcat-seltext_l = 'Currency'.

APPEND gx_fcat TO gt_fcat.

gx_fcat-tabname = 'GT_GRID'.

gx_fcat-fieldname = 'VKORG'.

gx_fcat-seltext_l = 'Sales Org'.

APPEND gx_fcat TO gt_fcat.

ENDFORM. " build_catalogue

&----


*& Form alv_grid

&----


FORM alv_grid .

  • CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  • EXPORTING

    • I_CALLBACK_PROGRAM = ' '

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

    • IT_FIELDCAT =

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • 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

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

  • TABLES

  • t_outtab =

    • 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.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'ALV_PAGE_HEADER '

  • IS_LAYOUT = layout

it_fieldcat = gt_fcat

  • it_sort = gt_sort

it_events = gt_event

TABLES

t_outtab = gt_grid

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. " alv_grid

&----


*& Form sort_fields

&----


*FORM sort_fields .

  • gx_sort-spos = 1.

  • gx_sort-fieldname = 'VBELN'.

  • gx_sort-tabname = 'GT_SORT'.

  • gx_sort-up = 'X'.

    • gx_sort-subtot = 'X'.

  • APPEND gx_sort TO gt_sort.

*

  • gx_sort-spos = 2.

  • gx_sort-fieldname = 'POSNR'.

  • gx_sort-tabname = 'GT_SORT'.

  • gx_sort-up = 'X'.

    • gx_sort-subtot = 'X'.

  • APPEND gx_sort TO gt_sort.

*

*ENDFORM. " sort_fields

&----


*& Form events

&----


FORM events .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = gt_event

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

READ TABLE gt_event

INTO gx_event

WITH KEY name = slis_ev_top_of_page.

IF sy-subrc EQ 0.

gx_event-form = 'ALV_PAGE_HEADER'.

MODIFY gt_event FROM gx_event INDEX sy-tabix.

ENDIF.

ENDFORM. " events

&----


*& Form header

&----


FORM header .

gx_head-typ = 'H'.

gx_head-info = 'SALES DOCUMENT REPORT'.

APPEND gx_head TO gt_head.

gx_head-typ = 'A'.

gx_head-info = sy-uname.

APPEND gx_head TO gt_head.

gx_head-typ = 'A'.

gx_head-info = sy-sysid.

APPEND gx_head TO gt_head.

gx_head-typ = 'A'.

WRITE sy-datum TO gx_head-info.

APPEND gx_head TO gt_head.

gx_head-typ = 'A'.

WRITE sy-uzeit TO gx_head-info.

APPEND gx_head TO gt_head.

ENDFORM. " header

&----


*& Form alv_page_header

&----


FORM alv_page_header."EC CALLED

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_head.

ENDFORM. "alv_page_header

Former Member
Former Member replied

Hello Manu

It is always the same mess with manually created fieldcatalogues.

" All fields are found in VBAK:
TYPES:BEGIN OF ty_grid,
sel(1),
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
matnr TYPE matnr,
netwr1 TYPE netwr_ap,
auart TYPE auart,
netwr TYPE netwr_ak,
waerk TYPE waerk,
vkorg TYPE vkorg,

END OF ty_grid.

Replace this part of the coding with the automatic generation using fm LVC_FIELDCATALOG_MERGE (i_structurename = 'VBAK').

Delete all record in GT_FCAT you do not need or, even better, just hide them using LS_FCAT-TECH = 'X'.

Why do you need a separate column as checkbox?

Just set GS_LAYOUT-SEL_MODE = 'A' and you automatically have a MARK column at the left side of the ALV grid.

Regards

Uwe

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question