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

alv report

Former Member
0 Likes
503

Hi..,

Iam tyring to print sub total text using alv grid display.. Iam getting runtime error.. like ...

Error Analysis:

Shor text of error message :

long text of error message :

Technical information about the message :

message class.... "0k".

Number..............000.

variable 1.......... " "

variable 2.......... " "

variable 3............ " "

variable4........... " "

How can i solve this ? will anybody suggest me...

Regards,

Pratima.M

Hi..,

Iam tyring to print sub total text using alv grid display.. Iam getting runtime error.. like ...

Error Analysis:

Shor text of error message :

long text of error message :

Technical information about the message :

message class.... "0k".

Number..............000.

variable 1.......... " "

variable 2.......... " "

variable 3............ " "

variable4........... " "

How can i solve this ? will anybody suggest me...

Regards,

Pratima.M

4 REPLIES 4
Read only

arpit_shah
Contributor
0 Likes
478

Can you post the code for this...

Read only

0 Likes
478

Hi..,

types : begin of itab1,

vbeln type vbap-vbeln,

posnr type vbap-posnr,

netpr type vbap-netpr,

d,

end of itab1.

data : wa type standard table of itab1 initial size 0 ,

fcat type slis_t_fieldcat_alv with header line,

t_events type slis_t_event,

w_title type lvc_title,

x_layout type slis_layout_alv , "OCCURS 0 ,"with header line,

t_sort type slis_t_sortinfo_alv,

i_sort type slis_sortinfo_alv,

t_heading type slis_t_listheader.

select-options : s_vbeln for vbap-vbeln.

start-of-selection.

select vbeln posnr netpr from vbap into table wa where vbeln in s_vbeln.

end-of-selection.

perform fcat.

perform event using t_events.

perform display.

&----


*& Form fcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fcat .

refresh t_sort[].

clear x_layout.

fcat-col_pos = '1'.

fcat-fieldname = 'VBELN'.

fcat-ref_tabname = 'VBAP'.

fcat-tabname = 'WA'.

append fcat.

clear fcat.

fcat-col_pos = '2'.

fcat-fieldname = 'POSNR'.

fcat-ref_tabname = 'VBAP'.

fcat-tabname = 'WA'.

append fcat.

clear fcat.

fcat-col_pos = '3'.

fcat-fieldname = 'NETPR'.

fcat-ref_tabname = 'VBAP'.

fcat-tabname = 'WA'.

fcat-do_sum = 'X'.

append fcat.

clear fcat.

i_sort-spos = '1'.

i_sort-fieldname = 'VBELN'.

i_sort-tabname = 'WA'.

i_sort-up = 'X'.

i_sort-group = 'UL'.

append i_sort to t_sort.

i_sort-spos = '2'.

i_sort-fieldname = 'D'.

i_sort-tabname = 'WA'.

i_sort-up = 'X'.

i_sort-group = 'UL'.

i_sort-subtot = 'X'.

append i_sort to t_sort.

endform. " fcat

&----


*& Form event

&----


  • text

----


  • -->P_T_eventS text

----


form event using p_t_events type slis_t_event.

data: x_event type line of slis_t_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = p_t_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.

x_event-name = slis_ev_top_of_page.

x_event-form = 'TOP'.

append x_event to p_t_events.

x_event-name = slis_ev_subtotal_text.

x_event-form = 'SUBTOTAL'.

append x_event to p_t_events.

endform. " event

form top using t_heading type slis_t_listheader.

data: x_heading type slis_listheader.

clear t_heading.

clear x_heading.

x_heading-typ = 'H'.

x_heading-info = ' Bevcon Wayors Pvt. Ltd. '.

append x_heading to t_heading.

clear x_heading.

x_heading-typ = 'S'.

x_heading-info = sy-repid.

append x_heading to t_heading.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_heading[]

i_logo = 'ENJOYSAP_LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

endform.

form subtotal using i_subtotal type slis_subtot_text.

data: keyword like dd03p-reptext,

criteria_text(255) type c,

max_len like dd03p-outputlen,

display_text_for_subtotal(255) type c.

if i_subtotal-criteria = 'D'.

  • i_subtotal-display_text_for_subtotal = text(010).

move 'SUBtotal' to i_subtotal-display_text_for_subtotal.

"here you need to do some calculations and assing the data

"back to total line

endif.

endform.

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'SY-REPID'

  • 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 = fcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = t_sort[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = t_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 = wa

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

Regards,

Pratima.M

Read only

Former Member
0 Likes
478

Hi,

I am not sure of subtotal text in alv grid you can search scn for this I have rectified your code for dump and displayed it in list for total text.....


TYPE-POOLS : slis.
TABLES :vbap.
TYPES : BEGIN OF itab1,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
netpr TYPE vbap-netpr,
d,
END OF itab1.
DATA : wa TYPE STANDARD TABLE OF itab1 INITIAL SIZE 0 WITH HEADER LINE,
fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
l_layout TYPE slis_layout_alv,
t_events TYPE slis_t_event,
w_title TYPE lvc_title,
x_layout TYPE slis_layout_alv , 
t_sort TYPE slis_t_sortinfo_alv,
i_sort TYPE slis_sortinfo_alv,
t_heading TYPE slis_t_listheader.

SELECT-OPTIONS : s_vbeln FOR vbap-vbeln.

START-OF-SELECTION.
  SELECT  vbeln posnr netpr FROM vbap UP TO 20 ROWS INTO TABLE wa  WHERE vbeln IN s_vbeln.

END-OF-SELECTION.

END-OF-SELECTION.
  PERFORM fcat.
  PERFORM event USING t_events.
  PERFORM display.
*&---------------------------------------------------------------------
*& Form fcat
*&---------------------------------------------------------------------

* text

*----------------------------------------------------------------------
* --> p1 text
* <-- p2 text

*----------------------------------------------------------------------
FORM fcat .

  l_layout-totals_text = 'your test field'. " for text field.....
  l_layout-subtotals_text = 'subtotal text'. " for subtotal text field.....



  REFRESH t_sort[].
  CLEAR x_layout.

  fcat-col_pos = '1'.
  fcat-fieldname = 'VBELN'.
  fcat-ref_tabname = 'VBAP'.
  fcat-tabname = 'WA'.
  APPEND fcat.
  CLEAR fcat.

  fcat-col_pos = '2'.
  fcat-fieldname = 'POSNR'.
  fcat-ref_tabname = 'VBAP'.
  fcat-tabname = 'WA'.
  APPEND fcat.
  CLEAR fcat.

  fcat-col_pos = '3'.
  fcat-fieldname = 'NETPR'.
  fcat-ref_tabname = 'VBAP'.
  fcat-tabname = 'WA'.
  fcat-do_sum = 'X'.
  APPEND fcat.
  CLEAR fcat.

  i_sort-spos = '1'.
  i_sort-fieldname = 'VBELN'.
  i_sort-tabname = 'WA'.
  i_sort-up = 'X'.
  i_sort-group = 'UL'.
  APPEND i_sort TO t_sort.

*  i_sort-spos = '2'.    " due to this you are getting dump
*  i_sort-fieldname = 'D'.
*  i_sort-tabname = 'WA'.
*  i_sort-up = 'X'.
*  i_sort-group = 'UL'.
*  i_sort-subtot = 'X'.
*  append i_sort to t_sort.

ENDFORM. " fcat
*&---------------------------------------------------------------------
*& Form event
*&---------------------------------------------------------------------

* text

*----------------------------------------------------------------------

* -->P_T_eventS text

*----------------------------------------------------------------------
FORM event USING p_t_events TYPE slis_t_event.

  DATA: x_event TYPE LINE OF slis_t_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type     = 0
    IMPORTING
      et_events       = p_t_events
    EXCEPTIONS
      list_type_wrong = 1
      OTHERS          = 2.
  IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.
  x_event-name = slis_ev_top_of_page.
  x_event-form = 'TOP'.
  APPEND x_event TO p_t_events.

  x_event-name = slis_ev_subtotal_text.
  x_event-form = 'SUBTOTAL'.
  APPEND x_event TO p_t_events.

ENDFORM. " event

*&---------------------------------------------------------------------*
*&      Form  top
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->T_HEADING  text
*----------------------------------------------------------------------*
FORM top USING t_heading TYPE slis_t_listheader.

  DATA: x_heading TYPE slis_listheader.

  CLEAR t_heading.
  CLEAR x_heading.
  x_heading-typ = 'H'.
  x_heading-info = ' Bevcon Wayors Pvt. Ltd. '.
  APPEND x_heading TO t_heading.

  CLEAR x_heading.
  x_heading-typ = 'S'.
  x_heading-info = sy-repid.
  APPEND x_heading TO t_heading.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
  it_list_commentary = t_heading[]
  i_logo = 'ENJOYSAP_LOGO'

* I_END_OF_LIST_GRID =
* I_ALV_FORM =

  .

ENDFORM.                    "top

*&---------------------------------------------------------------------*
*&      Form  subtotal
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->I_SUBTOTAL text
*----------------------------------------------------------------------*
FORM subtotal USING i_subtotal TYPE slis_subtot_text.

  DATA: keyword LIKE dd03p-reptext,
  criteria_text(255) TYPE c,
  max_len LIKE dd03p-outputlen,
  display_text_for_subtotal(255) TYPE c.

  IF i_subtotal-criteria = 'D'.

* i_subtotal-display_text_for_subtotal = text(010).

    MOVE 'SUBtotal' TO i_subtotal-display_text_for_subtotal.
    "here you need to do some calculations and assing the data
    "back to total line
  ENDIF.

ENDFORM.                    "subtotal
*&---------------------------------------------------------------------
*& Form DISPLAY
*&---------------------------------------------------------------------

* text

*----------------------------------------------------------------------

* --> p1 text
* <-- p2 text

*----------------------------------------------------------------------
FORM display .

*  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
*  EXPORTING
*
**    * I_INTERFACE_CHECK = ' '
**    * I_BYPASSING_BUFFER = ' '
**    * I_BUFFER_ACTIVE = ' '
*
*  i_callback_program = 'SY-REPID'
*i_callback_html_top_of_page = 'TOP '
**    * I_CALLBACK_PF_STATUS_SET = ' '
**    * I_CALLBACK_USER_COMMAND = ' '
**    * I_CALLBACK_TOP_OF_PAGE = ' '
*
**    * I_CALLBACK_HTML_END_OF_LIST = ' '
**    * I_STRUCTURE_NAME =
**    * I_BACKGROUND_ID = ' '
**    * I_GRID_TITLE =
**    * I_GRID_SETTINGS =
*
*
*  it_fieldcat = fcat[]
**
**    * IT_EXCLUDING =
**    * IT_SPECIAL_GROUPS =
*
*  it_sort =
*
**    * IT_FILTER =
**    * IS_SEL_HIDE =
**    * I_DEFAULT = 'X'
**    * I_SAVE = ' '
**    * IS_VARIANT =
*
*  it_events = t_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 = wa[]
*
*      EXCEPTIONS
*       program_error = 1
*       OTHERS = 2
*
*  .
*  IF sy-subrc NE 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_LIST_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ' '
     i_callback_program             = 'SY-REPID'
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   I_STRUCTURE_NAME               =
  is_layout                        = l_layout
     it_fieldcat                    = fcat[]
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
     it_sort                        = t_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
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
    TABLES
      t_outtab                       = wa
* 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. " DISPLAY

Regards

Debarshi

Read only

Former Member
0 Likes
478

Hi,

In the reuse_alv_event we can use only some forms only for subtotal we have the form SUBTOTAL_TEXT and for top of page we have TOP_OF_PAGE.

Please use above forms .

Regards

Srihari