Skip to Content
author's profile photo Former Member
Former Member

ALV

Hi experts.

My ALV output is coming like this :

VendorNumber VendorName CompanyCode Outstand value

0001 XXX Z010 10

0002 YYY Z010 20

0006 ZZZ Z020 30

0007 BBB Z010 40

If Company code is not selected in the Selection screen,then all the Company Codes data with selected Vendors will be gathered .So in the Report Output ,the Sum should be done for Outstanding value based on the each Company Code.

Plese help me .Point is surely rewarded.

Thanks,

Satya

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 16, 2008 at 05:19 AM

    Hi,

    Use this code.

    data: lt_sort type slis_t_sortinfo_alv,

    lw_sort type slis_sortinfo_alv.

    in fieldcat table.

    clear lw_fcat.

    lw_fcat-fieldname = 'OUTSTANDVALUE'.

    lw_fcat-seltext_l = 'Outstandind value'.

    lw_fcat-do_sum = 'X'.

    append lw_fcat to lt_fcat.

    and for sorting.

    clear lw_sort.

    lw_sort-spos = 1.

    lw_sort-fieldname = 'BUKRS' . "Company code

    LW_SORT-Up = 'X'.

    append lw_sort to lt_sort.

    clear lw_sort.

    lw_sort-spos = 3.

    lw_sort-fieldname = 'OUTSTANDVALUE'. "Out standing value

    LW_SORT-Up = 'X'.

    lw_sort-subtot = 'X'.

    append lw_sort to lt_sort.

    and pass this to resue_alv_grid_display function.

    eg

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    • 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 = lv_layout

    IT_FIELDCAT = lt_fcat[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = lt_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 = itab

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    regards,

    Santosh Thorat

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 16, 2008 at 05:46 AM

    Hi Satyanarayana,

    Try the below logic that wil helpful to u.check it once.Along with logic i will send a sample code for ur problem check it once ok..

    LOGIC:

    *SubTotal on the Field OUTSTAND VALUE

    wa_fieldcat-col_pos = '3'. "Column Position

    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal

    wa_fieldcat-fieldname = 'OUTSTAND VALUE'. "Field Name

    wa_fieldcat-do_sum = 'X'. "Sum

    wa_fieldcat- seltext_m = 'Net Value'. "Display Text

    APPEND wa_fieldcat TO gt_fieldcat.

    FORM sorting USING p_it_sortcat TYPE slis_t_sortinfo_alv.

    CLEAR wa_sortcat.

    wa_sortcat-fieldname = 'BUKRS'. "COMPANY CODE

    wa_sortcat-up ='X'.

    wa_sortcat-subtot = 'X'.

    APPEND wa_sortcat TO p_it_sortcat.

    endform.

    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 = gt_fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    it_sort = gt_sortcat

    • 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

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • I_HTML_HEIGHT_TOP =

    • I_HTML_HEIGHT_END =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = gt_salesorder

    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.

    SAMPLE PROGRAM:COPY THIS PRG AND EXECUTE IT OK

    &----


    *& Report YSALESORDER_ALV_SUBTOTALS *

    *& *

    &----


    *& DEVELOPER : KIRAN KUMAR.G *

    *& PURPOSE : DISPLAYING SUBTOTALS FOR A PARTICULAR SALES DOC NO *

    *& CREATION DT: 26/11/2007 *

    *& REQUEST : ERPK900035 *

    &----


    REPORT ysalesorder_alv_subtotals.

    ----


    • Type Pools

    ----


    TYPE-POOLS:slis.

    ----


    • Tables

    ----


    TABLES: vbak, "Sales Document: Header Data

    vbap. "Sales Document: Item Data

    ----


    • Global Structures

    ----


    DATA:gt_fieldcat TYPE slis_t_fieldcat_alv,

    wa_fieldcat TYPE slis_fieldcat_alv,

    gt_sortcat TYPE slis_t_sortinfo_alv,

    wa_sortcat LIKE LINE OF gt_sortcat.

    ----


    • Internal Table

    ----


    DATA: BEGIN OF gt_salesorder OCCURS 0,

    vbeln LIKE vbak-vbeln, " Sales Document Number

    posnr LIKE vbap-posnr, " Sales Doc Item

    netwr LIKE vbap-netwr, " Net Value

    END OF gt_salesorder.

    ----


    • SELECT OPTIONS

    ----


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

    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document Number.

    SELECTION-SCREEN END OF BLOCK b1.

    ----


    • Initialization

    ----


    INITIALIZATION.

    PERFORM initialization.

    ----


    • Start Of Selection

    ----


    START-OF-SELECTION.

    PERFORM field_catalog. "For Structure Creation

    PERFORM fetch_data. "Get the Data From DB Table

    PERFORM sorting USING gt_sortcat.

    ----


    • End Of Selection

    ----


    END-OF-SELECTION.

    PERFORM display_data.

    &----


    *& Form initialization

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM initialization .

    s_vbeln-sign = 'I'.

    s_vbeln-option = 'BT'.

    s_vbeln-low = '4969'.

    s_vbeln-high = '5000'.

    APPEND s_vbeln.

    ENDFORM. " initialization

    &----


    *& Form field_catalog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM field_catalog .

    REFRESH : gt_fieldcat.

    CLEAR : wa_fieldcat.

    wa_fieldcat-col_pos = '1'. "Column Position

    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table

    wa_fieldcat-fieldname = 'VBELN'. "Field Name

    wa_fieldcat-key = 'X'. "Blue Color

    wa_fieldcat-seltext_m = 'Sales Doc No'. "Display Text In Screen

    APPEND wa_fieldcat TO gt_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '2'. "Column Position

    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table Name

    wa_fieldcat-fieldname = 'POSNR'. "Field Name

    wa_fieldcat-seltext_m = 'Sales Doc Item'."Display Text In Screen

    APPEND wa_fieldcat TO gt_fieldcat.

    CLEAR wa_fieldcat.

    *SubTotal on the Field NETWR

    wa_fieldcat-col_pos = '3'. "Column Position

    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table

    wa_fieldcat-fieldname = 'NETWR'. "Field Name

    wa_fieldcat-do_sum = 'X'. "Sum

    wa_fieldcat-seltext_m = 'Net Value'. "Display Text In Screen

    APPEND wa_fieldcat TO gt_fieldcat.

    CLEAR wa_fieldcat.

    ENDFORM. " field_catalog

    &----


    *& Form sorting

    &----


    • text

    ----


    • -->P_IT_SORTCAT text

    ----


    FORM sorting USING p_it_sortcat TYPE slis_t_sortinfo_alv.

    CLEAR wa_sortcat.

    wa_sortcat-fieldname = 'VBELN'.

    wa_sortcat-up ='X'.

    wa_sortcat-subtot = 'X'.

    APPEND wa_sortcat TO p_it_sortcat.

    ENDFORM. " sorting

    &----


    *& Form display_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_data .

    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 = gt_fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    it_sort = gt_sortcat

    • 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

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • I_HTML_HEIGHT_TOP =

    • I_HTML_HEIGHT_END =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = gt_salesorder

    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_data

    &----


    *& Form fetch_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fetch_data .

    REFRESH : gt_salesorder.

    CLEAR : gt_salesorder.

    SELECT a~vbeln

    posnr

    b~netwr

    FROM vbak AS a

    INNER JOIN vbap AS b ON avbeln = bvbeln

    INTO TABLE gt_salesorder

    WHERE a~vbeln IN s_vbeln.

    ENDFORM. " fetch_data

    Reward points if helpful.

    Kiran Kumar.G.A

    Edited by: KIRAN KUMAR on Jan 16, 2008 6:47 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 16, 2008 at 05:19 AM

    sort the table based on company code before sending it to reuse FM

    or

    in the field catalog set field_catalog-sort = 'X'.

    for the field catalog of Outstand value field_catalog-dosum = 'X'.

    -


    and after your report is executed you can play with the layout and save it, with the sum value displaying. there is a SIGMA sign on the toolbar which does the SUM.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.