Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

display report using ALV Grid

Former Member
0 Likes
2,559

Hi folks,

I have a task of reporting the data on ALVGrid. The report program runs fine and is showing up on the ABAP Editor screen, however the data is not displaying in the ALV Grid format. I need to know what am I missing?

I have the FM CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_buffer_active = ' '

i_callback_program = g_repid

I_CALLBACK_PF_STATUS_SET = cua_exit

I_CALLBACK_USER_COMMAND = ucomm_exit

it_fieldcat = alv_fc[]

  • is_variant = gs_variant

i_save = 'A'

it_events = gt_events[]

is_layout = gs_layout

is_print = gs_print

  • i_screen_start_column = start_column

  • i_screen_start_line = start_line

  • i_screen_end_column = end_column

  • i_screen_end_line = end_line

TABLES

t_outtab = error_alv

EXCEPTIONS

program_error = 1

OTHERS = 2.

I have also included the PBO and PAI event code too, but did not work.

I am looking at an different ALV report developed that shows the data in ALV Grid and what i find is it calls a program dynamically SAPLSLVC_FULLSCREEN that my program does not.

What does this mean?

Thanks in advance,

VG

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
2,522

Hi Vinu,

I think your mistake is here

I_CALLBACK_PF_STATUS_SET = cua_exit

I_CALLBACK_USER_COMMAND = ucomm_exit

here names should be passed like 'CUA_EXIT' and 'UCOMM_EXIT' in capital letters.

I guess that you function will return sys-ubrc ne 0. Check this,

Also skipp i_callback_program = g_repid as it doens't have to be provided but sometimes creates confusions and mistakes.

Hope this will help you

Marcin

Hi folks,

I have a task of reporting the data on ALVGrid. The report program runs fine and is showing up on the ABAP Editor screen, however the data is not displaying in the ALV Grid format. I need to know what am I missing?

I have the FM CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_buffer_active = ' '

i_callback_program = g_repid

I_CALLBACK_PF_STATUS_SET = cua_exit

I_CALLBACK_USER_COMMAND = ucomm_exit

it_fieldcat = alv_fc[]

  • is_variant = gs_variant

i_save = 'A'

it_events = gt_events[]

is_layout = gs_layout

is_print = gs_print

  • i_screen_start_column = start_column

  • i_screen_start_line = start_line

  • i_screen_end_column = end_column

  • i_screen_end_line = end_line

TABLES

t_outtab = error_alv

EXCEPTIONS

program_error = 1

OTHERS = 2.

I have also included the PBO and PAI event code too, but did not work.

I am looking at an different ALV report developed that shows the data in ALV Grid and what i find is it calls a program dynamically SAPLSLVC_FULLSCREEN that my program does not.

What does this mean?

Thanks in advance,

VG

15 REPLIES 15
Read only

MarcinPciak
Active Contributor
0 Likes
2,523

Hi Vinu,

I think your mistake is here

I_CALLBACK_PF_STATUS_SET = cua_exit

I_CALLBACK_USER_COMMAND = ucomm_exit

here names should be passed like 'CUA_EXIT' and 'UCOMM_EXIT' in capital letters.

I guess that you function will return sys-ubrc ne 0. Check this,

Also skipp i_callback_program = g_repid as it doens't have to be provided but sometimes creates confusions and mistakes.

Hope this will help you

Marcin

Read only

0 Likes
2,522

Hi marcin,

Thanks for the response. I have passed the value 'CUA_EXIT' and 'UCOMM_EXIT' int the two variables

cua_exit and ucomm_exit.

It did not work.

Thanks,

VG

Read only

0 Likes
2,522

Hi,

You can't pass them throughout variables. This would require dynamic evaluation what's inside, as during start of program, system doesn't know these variables content.

Pass the names directly


I_CALLBACK_PF_STATUS_SET = 'CUA_EXIT'
I_CALLBACK_USER_COMMAND = 'UCOMM_EXIT'

Regards

Marcin

Read only

0 Likes
2,522

Hi,

I changed it. Even then it did not work. This time the report that displayed on the ABAP editor screen before also did not show up. I am unable to find where the problem is?

Thanks

VG

Read only

0 Likes
2,522

Could you please paste your entire code here. Place it in tags please.

Thanks

Marcin

Read only

0 Likes
2,522

Hi,

The problem is with the FM REUSE_ALV_GRID_DISPLAY, I found that the SAPSLVScreen that paints the ALV report is called within this FM. It seems the function module is not executed, I confirmed that with couple of break points within the FM, the program is not stopping at those breakpoints.

It has to do with the parameters then, do I need to declare few more parameters like i_screen_start_column, start_line ?

Thanks,

VG

Read only

0 Likes
2,522

The problem is not inside the function but outside it. Do you have subroutines defined which you are using in i_callback_pf_status_set and i_callback_user_command . See my code below. Subroutine name for GUI status must have interfave like USING ft_extab TYPE slis_t_extab. and user command subroutine interface like USING f_ucomm TYPE sy-ucomm ls_selfield TYPE slis_selfield


*&---------------------------------------------------------------------*
*&  Include           ZDEPY_PRO_IN_UT_ALV_PMI
*&---------------------------------------------------------------------*
FORM alv_prepare.
  PERFORM alv_fieldcat_prepare    USING it_alv_fieldcat[].
  PERFORM alv_event_build         USING it_alv_events[].
  PERFORM alv_header_build        USING it_alv_listheader[].
  PERFORM alv_layout_prepare      USING wa_alv_layout.
  PERFORM alv_sort_info_prepare   USING it_alv_sortinfo[] wa_alv_sort.
ENDFORM.                    "ALV_PREPARE


*&---------------------------------------------------------------------*
*&      Form  alv_fieldcat_prepare
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM alv_fieldcat_prepare USING ft_fieldcat TYPE slis_t_fieldcat_alv.
  DATA: ls_fieldcat TYPE slis_fieldcat_alv.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'ICON'.
  ls_fieldcat-seltext_s   = 'Status'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  ls_fieldcat-icon        = 'X'.
  ls_fieldcat-key         = 'X'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'BUKRS'.
  ls_fieldcat-ref_tabname = 'PME01'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  ls_fieldcat-key         = 'X'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'WERKS'.
  ls_fieldcat-ref_tabname = 'PME01'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  ls_fieldcat-key         = 'X'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'BTRTL'.
  ls_fieldcat-ref_tabname = 'PME01'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  ls_fieldcat-key         = 'X'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'PERNR'.
  ls_fieldcat-ref_tabname = 'PME01'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  ls_fieldcat-key         = 'X'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'VWTNR'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  ls_fieldcat-seltext_s   = 'Adm. no'.
  ls_fieldcat-seltext_l   = 'Administration number'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'KASIS'.
  ls_fieldcat-seltext_s   = 'Kasis'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'PERIOD'.
  ls_fieldcat-seltext_s   = 'Period'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'AMOUNT'.
  ls_fieldcat-seltext_s   = 'Amount'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
*  ls_fieldcat-cfieldname  = 'BETPE'.
  ls_fieldcat-do_sum      = 'X'.
  APPEND ls_fieldcat TO ft_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MESS'.
  ls_fieldcat-seltext_s   = 'Message'.
  ls_fieldcat-tabname     = 'IT_ERROR'.
  APPEND ls_fieldcat TO ft_fieldcat.

ENDFORM.                    "alv_fieldcat_prepare

*&---------------------------------------------------------------------*
*&      Form  alv_layout_prepare
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FS_LAYOUT  text
*----------------------------------------------------------------------*
FORM alv_layout_prepare USING fs_layout TYPE slis_layout_alv.
  fs_layout-colwidth_optimize = 'X'.
  fs_layout-totals_text = 'Total'.
  fs_layout-info_fieldname = 'ROWCOLOR'.
  fs_layout-no_vline = 'X'.
  fs_layout-no_hline = 'X'.
  fs_layout-window_titlebar = 'List for trade union contibution'.
  fs_layout-box_fieldname  = 'SELROW'.
*  fs_layout-prnt_title = 'X'.

  fs_layout-subtotals_text  = ''.
  fs_layout-totals_text     = ''.
  fs_layout-no_sumchoice    = 'X'.
  fs_layout-no_subchoice    = 'X'.
ENDFORM.                    "alv_layout_prepare

*&---------------------------------------------------------------------*
*&      Form  alv_sort_info_prepare
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FT_SORT    text
*      -->FS_SORT    text
*----------------------------------------------------------------------*
FORM alv_sort_info_prepare  USING   ft_sort TYPE slis_t_sortinfo_alv
                                    fs_sort TYPE slis_sortinfo_alv.
  "BUKRS
  CLEAR fs_sort.
  fs_sort-spos = '01'.
  fs_sort-fieldname = 'BUKRS'.
  fs_sort-tabname = 'IT_ERROR'.
  fs_sort-up = 'X'.
  fs_sort-subtot = 'X'.
  APPEND fs_sort TO ft_sort.

  CLEAR fs_sort.
  fs_sort-spos = '02'.
  fs_sort-fieldname = 'WERKS'.
  fs_sort-tabname = 'IT_ERROR'.
  fs_sort-up = 'X'.
  fs_sort-subtot = 'X'.
  APPEND fs_sort TO ft_sort.

  CLEAR fs_sort.
  fs_sort-spos = '03'.
  fs_sort-fieldname = 'BTRTL'.
  fs_sort-tabname = 'IT_ERROR'.
  fs_sort-up = 'X'.
  fs_sort-subtot = 'X'.
  APPEND fs_sort TO ft_sort.


ENDFORM.                    "alv_sort_info_prepare

*&---------------------------------------------------------------------*
*&      Form  alv_event_build
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FT_EVENTS  text
*----------------------------------------------------------------------*
FORM alv_event_build USING ft_alv_events TYPE slis_t_event.
  DATA: ls_event TYPE slis_alv_event.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = ft_alv_events.

  READ TABLE ft_alv_events WITH KEY name = slis_ev_subtotal_text
                       INTO ls_event.
  IF sy-subrc = 0.
    MOVE slis_ev_subtotal_text TO ls_event-form.
    APPEND ls_event TO ft_alv_events.
  ENDIF.

  READ TABLE ft_alv_events WITH KEY name = slis_ev_user_command
                       INTO ls_event.
  IF sy-subrc = 0.
    MOVE slis_ev_user_command  TO ls_event-form.
    APPEND ls_event TO ft_alv_events.
  ENDIF.

ENDFORM.                    "alv_event_build

*&---------------------------------------------------------------------*
*&      Form  alv_header_build
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FT_LISTHEADER  text
*----------------------------------------------------------------------*
FORM alv_header_build USING ft_listheader TYPE slis_t_listheader.
  DATA: ls_head TYPE slis_listheader,
        l_begda(10) TYPE c,
        l_endda(10) TYPE c,
        l_period(21) TYPE c,
        l_sys(20) TYPE c,
        l_comc TYPE t001-butxt,
        l_date(10) TYPE c.

  WRITE: pn-begda TO l_begda DD/MM/YYYY,
         pn-endda TO l_endda DD/MM/YYYY.

  CONCATENATE l_begda '-' l_endda INTO l_period.
  CONCATENATE sy-sysid '/' sy-mandt '/' sy-uzeit INTO l_sys.
  WRITE sy-datum TO l_date DD/MM/YYYY.

  SELECT SINGLE butxt FROM t001 INTO l_comc
         WHERE bukrs EQ pa_comc.

  ls_head-typ = 'H'.   "Header in alv
  ls_head-info = l_comc.
  APPEND ls_head TO ft_listheader.

  CLEAR ls_head.
  ls_head-typ  = 'S'.
  ls_head-key  = 'Period:'.
  ls_head-info = l_period.
  APPEND ls_head TO ft_listheader.

  ls_head-typ  = 'S'.
  ls_head-key  = 'Program name:'.
  ls_head-info = sy-repid.
  APPEND ls_head TO ft_listheader.

  ls_head-typ  = 'S'.
  ls_head-key  = 'Date:'.
  ls_head-info = l_date.
  APPEND ls_head TO ft_listheader.

  ls_head-typ  = 'S'.
  ls_head-key  = 'User:'.
  ls_head-info = sy-uname.
  APPEND ls_head TO ft_listheader.

  ls_head-typ  = 'S'.
  ls_head-key  = 'System:'.
  ls_head-info = l_sys.
  APPEND ls_head TO ft_listheader.

ENDFORM.                    "alv_header_build

*-----------------------------------------------------------------*
* This form is executed by dynamic call, it has to be named       *
* like this, use this FM to add header to alv                     *
* The function uses internal table typed slis_t_listheader        *
* and displays icon, just as a facility;)                         *
* To prepare alv header use the subroutine above                  *
*-----------------------------------------------------------------*
FORM top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
     EXPORTING
*           i_logo             = 'HTMLCNTL_TESTHTM2_SAPLOGO'
          i_logo             = 'ENJOYSAP_LOGO'
          it_list_commentary = it_alv_listheader.
ENDFORM.                    "alv_top_of_page_display

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->F_UCOMM      text
*      -->LS_SELFIELD  text
*----------------------------------------------------------------------*
FORM user_command USING f_ucomm TYPE sy-ucomm
                        ls_selfield TYPE slis_selfield.
  IF f_ucomm = '$ERR'.  "Error button
    PERFORM alv_display TABLES it_error.
  ELSEIF f_ucomm = '$COR'.  "Correct button
    PERFORM alv_display TABLES it_correct.
  ELSEIF f_ucomm = '$ALL'.  "All button
    PERFORM prepare_overview_table.
    PERFORM alv_display TABLES it_tmp.
  ENDIF.
ENDFORM.                    "USER_COMMAND

*&---------------------------------------------------------------------*
*&      Form  SET_PF_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FT_EXTAB   text
*----------------------------------------------------------------------*
FORM set_pf_status USING ft_extab TYPE slis_t_extab.
  SET PF-STATUS 'ALV_STATUS'.
ENDFORM.                    "SET_PF_STATUS
*&---------------------------------------------------------------------*
*&      Form  alv_display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM alv_display TABLES ft_alv_outtab STRUCTURE s_ee_data.
  DATA: l_repid TYPE sy-repid.
  l_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = l_repid
     i_callback_pf_status_set          = 'SET_PF_STATUS'
     i_callback_user_command           = 'USER_COMMAND'
     i_callback_top_of_page            = 'TOP_OF_PAGE'
     is_layout                         = wa_alv_layout
     it_fieldcat                       = it_alv_fieldcat[]
     it_sort                           = it_alv_sortinfo[]
     i_default                         = 'X'
     i_save                            = 'A'
     it_events                         = it_alv_events[]
    TABLES
      t_outtab                          = ft_alv_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.

ENDFORM.                    "alv_display

 PERFORM alv_display TABLES some_internal_table_with_data.

It would be nice to see yours anyway. Could you please provide your entre program code.

Regards

Marcin

Edited by: Marcin Pciak on Feb 4, 2009 7:18 PM

Read only

0 Likes
2,522

Hi,

The code related to ALV programming,

          • /code

SET PF-STATUS 'ALVLIST'.

loop at error from 2.

error_alv-pernr = error-pernr.

error_alv-empname = error-empname.

error_alv-paystartdate = error-paystartdate.

error_alv-payenddate = error-payenddate.

error_alv-amount = error-amount.

error_alv-warning = error-warning.

append error_alv.

clear error_alv.

endloop.

gs_layout-colwidth_optimize = 'X'.

          • get the field catalog for alv

clear alv_fc[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

*i_program_name = sy-repid

i_structure_name = alv_ddic1

*i_inclname = sy-repid

CHANGING

ct_fieldcat = alv_fc[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

if sy-subrc <> 0.

message e007(hrben00listreports).

endif.

        • get events

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = gt_events[].

read table gt_events with key name = slis_ev_top_of_page.

if sy-subrc = 0.

move g_formname to gt_events-form.

append gt_events.

endif.

gS_PRINT-NO_PRINT_LISTINFOS = 'X'.

gS_PRINT-NO_PRINT_SELINFOS = 'X'.

          • display ALV

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_buffer_active = ' '

i_callback_program = g_repid

I_CALLBACK_PF_STATUS_SET = cua_exit

I_CALLBACK_USER_COMMAND = ucomm_exit

it_fieldcat = alv_fc[]

  • is_variant = gs_variant

i_save = 'A'

it_events = gt_events[]

is_layout = gs_layout

is_print = gs_print

  • i_screen_start_column = start_column

  • i_screen_start_line = start_line

  • i_screen_end_column = end_column

  • i_screen_end_line = end_line

TABLES

t_outtab = error_alv

EXCEPTIONS

program_error = 1

OTHERS = 2.

*endif.

ENDFORM.

/code....

Thanks for the help,

VG

Read only

0 Likes
2,522

Hi,

Thanks, you might be right. How should I set up ALV_STATUS and in my case it is ALVLIST, it asked for interface objects. How should I go about it?

VG

Read only

0 Likes
2,522

I tweaked your code and is working fine


REPORT z_test2.

TYPE-POOLS slis.

DATA: alv_fc TYPE slis_t_fieldcat_alv,   "fieldcatalog table
      gt_events    TYPE slis_t_event WITH HEADER LINE.         "events

DATA: gs_layout TYPE slis_layout_alv,         "alv layout structure
      gs_print type SLIS_PRINT_ALV.

gs_print-no_print_listinfos = 'X'.
gs_print-no_print_selinfos = 'X'.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
  EXPORTING
    i_list_type = 0
  IMPORTING
    et_events   = gt_events[].
READ TABLE gt_events WITH KEY name = slis_ev_top_of_page.
IF sy-subrc = 0.
  MOVE 'TOP-OF-PAGE' TO gt_events-form.
  APPEND gt_events.
ENDIF.


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    i_structure_name       = 'DDIC_STRUCTURE'     "give DDIC structure name here i.e. 'SFLIGHT'
  CHANGING
    ct_fieldcat            = alv_fc[]
  EXCEPTIONS
    inconsistent_interface = 1
    program_error          = 2
    OTHERS                 = 3.

IF sy-subrc NE 0.
  MESSAGE e007(hrben00listreports).
ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
    i_buffer_active          = ' '
    i_callback_program       = sy-repid
    i_callback_pf_status_set = 'CUA_EXIT'
    i_callback_user_command  = 'UCOMM_EXIT'
    it_fieldcat              = alv_fc[]
    i_save                   = 'A'
    it_events                = gt_events[]
    is_layout                = gs_layout
    is_print                 = gs_print
  TABLES
    t_outtab                 = error_alv
  EXCEPTIONS
    program_error            = 1
    OTHERS                   = 2.


"set status
FORM CUA_EXIT USING ft_extab TYPE slis_t_extab.
  SET PF-STATUS 'ALVLIST'.
ENDFORM.                    

"your PAI
FORM ucomm_exit   USING f_ucomm TYPE sy-ucomm
                        ls_selfield TYPE slis_selfield.
  IF f_ucomm = ...  "react here
  ENDIF.
ENDFORM.                    

Regards

Marcin

Read only

0 Likes
2,522

Hi,

I declared the interface objects, status, menu and other items that are linked to ALVLIST. Do I need to declare some screen elements here?

I need some assistance here.

Thanks,

VG

Read only

0 Likes
2,522

No, you just design your desired application toolbar (buttons) and menu entries. This forms GUI status (yours ALVLIST) which you activate and that's it. No relationship with the screen elements there is needed.

If you are not sure which options you need just set standard GUI status with


SET PF-STATUS space.

I hope you can finally reach the point you wanted. If so please close the thread.

Thanks and regards

Marcin

Read only

Former Member
0 Likes
2,522

Hi vinu,

the program name give it as sy-repid.

in the field catlog give the field name in capital letters.

u will get the output.

Read only

Former Member
0 Likes
2,522

Dear Vinu,

Instead of using this FM CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

you use this FM CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

see this is helping or not..

Regards,

Vijay

Read only

0 Likes
2,522

Hi Marcin,

I got it. Thanks a lot for the help. really apprecaite it. Shall award the points.

VG