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 Grid - Subtotal

Former Member
0 Likes
449

Hi All,

I am using ALV GRID's Sort catalog.

I want to display the subtotals which are greater than 10,000.

Is there any way in doing this.

Please guide me.

Thanks.

Albert

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
373

Hi albert,

Check this,

Step 1

Define an internal table of type SLIS_T_EVENT, and a work area of type SLIS_ALV_EVENT.

DATA: T_EVENT TYPE SLIS_T_EVENT,

W_EVENT TYPE SLIS_ALV_EVENT.

Step 2

Append AFTER-LINE-OUTPUT event to the internal table T_EVENT.

CLEAR W_EVENT.

W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.

W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.

APPEND W_EVENT TO T_EVENT.

Step 3

The totals are displayed in the output in the form AFTER_LINE_OUTPUT, which corresponds to the event AFTER_LINE_OUTPUT. The sub routine uses the parameter P_RS_LINEINFO, which contains settings for totals’ lines. The actual totals output is displayed using the WRITE ad FORMAT statements.

FORM AFTER_LINE_OUTPUT

USING P_RS_LINEINFO TYPE SLIS_LINEINFO.

  • Declaration Of Local Variables

DATA: L_SUCCESS TYPE WRBTR, "Total For Successful Entries

L_ERROR TYPE WRBTR, "Total For Unsuccessful Entries

L_COUNT TYPE I. "No. Of lines in table T_OUTPUT

  • Getting The No Of Lines In The Table T_OUTPUT

DESCRIBE TABLE T_OUTPUT LINES L_COUNT.

  • Displaying the totals after the last record of the Internal

  • Table T_OUTPUT

IF P_RS_LINEINFO-TABINDEX = L_COUNT.

  • Loop At The Internal Table T_OUTPUT

LOOP AT T_OUTPUT INTO W_OUTPUT.

IF W_OUTPUT-SFLAG = C_CHECKED.

  • Calculate Total For Unsuccessful Entries

L_ERROR = L_ERROR + W_OUTPUT-WRBTR.

ELSE.

  • Calculate Total For Successful Entries

L_SUCCESS = L_SUCCESS + W_OUTPUT-WRBTR.

ENDIF.

  • Clear The Work Area W_OUTPUT

CLEAR W_OUTPUT.

ENDLOOP.

  • Set The Format For The Total Line Display

ULINE AT (P_RS_LINEINFO-LINSZ). "Dynamic Line Size

FORMAT INTENSIFIED COLOR COL_TOTAL ON. "Setting the color

"For the total row

"As Yellow

WRITE : / SY-VLINE, "Vertical Line

TEXT-017, "Caption For Total

"Sum of Successful

"Entries

33 L_SUCCESS, "Total Of Successful

"Entries

C_USD. "Currency Type USD

POSITION P_RS_LINEINFO-LINSZ. "Dynamic Line Size

WRITE : SY-VLINE. "Vertical Line

ULINE AT (P_RS_LINEINFO-LINSZ). "Dynamic Line Size

WRITE : / SY-VLINE , "Vertical Line

TEXT-018, "Caption For Total

"Sum of Successful

"Entries

33 L_ERROR, "Total Of Unsuccessful

"Entries

C_USD. "Currency Type USD

POSITION P_RS_LINEINFO-LINSZ. "Dynamic Line Size

WRITE : SY-VLINE. "Vertical Line

FORMAT COLOR OFF. "Color Setting Off

ENDIF.

ENDFORM. "AFTER_LINE_OUTPUT

Step 4

The table T_EVENT is passed to the function 'REUSE_ALV_LIST_DISPLAY' while displaying the ALV Report.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = L_REPID "Program Name

IS_LAYOUT = W_LAYOUT "Layout of the Report

IT_FIELDCAT = T_FIELDCAT "Field Catalog for Report

IT_EVENTS = T_EVENT "For setting the events

TABLES

T_OUTTAB = T_OUTPUT "Report data Internal Table

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

Hi All,

I am using ALV GRID's Sort catalog.

I want to display the subtotals which are greater than 10,000.

Is there any way in doing this.

Please guide me.

Thanks.

Albert

2 REPLIES 2
Read only

Former Member
0 Likes
374

Hi albert,

Check this,

Step 1

Define an internal table of type SLIS_T_EVENT, and a work area of type SLIS_ALV_EVENT.

DATA: T_EVENT TYPE SLIS_T_EVENT,

W_EVENT TYPE SLIS_ALV_EVENT.

Step 2

Append AFTER-LINE-OUTPUT event to the internal table T_EVENT.

CLEAR W_EVENT.

W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.

W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.

APPEND W_EVENT TO T_EVENT.

Step 3

The totals are displayed in the output in the form AFTER_LINE_OUTPUT, which corresponds to the event AFTER_LINE_OUTPUT. The sub routine uses the parameter P_RS_LINEINFO, which contains settings for totals’ lines. The actual totals output is displayed using the WRITE ad FORMAT statements.

FORM AFTER_LINE_OUTPUT

USING P_RS_LINEINFO TYPE SLIS_LINEINFO.

  • Declaration Of Local Variables

DATA: L_SUCCESS TYPE WRBTR, "Total For Successful Entries

L_ERROR TYPE WRBTR, "Total For Unsuccessful Entries

L_COUNT TYPE I. "No. Of lines in table T_OUTPUT

  • Getting The No Of Lines In The Table T_OUTPUT

DESCRIBE TABLE T_OUTPUT LINES L_COUNT.

  • Displaying the totals after the last record of the Internal

  • Table T_OUTPUT

IF P_RS_LINEINFO-TABINDEX = L_COUNT.

  • Loop At The Internal Table T_OUTPUT

LOOP AT T_OUTPUT INTO W_OUTPUT.

IF W_OUTPUT-SFLAG = C_CHECKED.

  • Calculate Total For Unsuccessful Entries

L_ERROR = L_ERROR + W_OUTPUT-WRBTR.

ELSE.

  • Calculate Total For Successful Entries

L_SUCCESS = L_SUCCESS + W_OUTPUT-WRBTR.

ENDIF.

  • Clear The Work Area W_OUTPUT

CLEAR W_OUTPUT.

ENDLOOP.

  • Set The Format For The Total Line Display

ULINE AT (P_RS_LINEINFO-LINSZ). "Dynamic Line Size

FORMAT INTENSIFIED COLOR COL_TOTAL ON. "Setting the color

"For the total row

"As Yellow

WRITE : / SY-VLINE, "Vertical Line

TEXT-017, "Caption For Total

"Sum of Successful

"Entries

33 L_SUCCESS, "Total Of Successful

"Entries

C_USD. "Currency Type USD

POSITION P_RS_LINEINFO-LINSZ. "Dynamic Line Size

WRITE : SY-VLINE. "Vertical Line

ULINE AT (P_RS_LINEINFO-LINSZ). "Dynamic Line Size

WRITE : / SY-VLINE , "Vertical Line

TEXT-018, "Caption For Total

"Sum of Successful

"Entries

33 L_ERROR, "Total Of Unsuccessful

"Entries

C_USD. "Currency Type USD

POSITION P_RS_LINEINFO-LINSZ. "Dynamic Line Size

WRITE : SY-VLINE. "Vertical Line

FORMAT COLOR OFF. "Color Setting Off

ENDIF.

ENDFORM. "AFTER_LINE_OUTPUT

Step 4

The table T_EVENT is passed to the function 'REUSE_ALV_LIST_DISPLAY' while displaying the ALV Report.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = L_REPID "Program Name

IS_LAYOUT = W_LAYOUT "Layout of the Report

IT_FIELDCAT = T_FIELDCAT "Field Catalog for Report

IT_EVENTS = T_EVENT "For setting the events

TABLES

T_OUTTAB = T_OUTPUT "Report data Internal Table

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

Read only

0 Likes
373

Hi Sreekanth,

Thanks for your time.

If you have any material regarding ALV ,then please send the same to this ID.

[email protected]

thanks,

Albert