Distinct and sum in alv report

i have 6 row of 1 matnr
and i have to display only 1 with the sum of each field
example:
300032   3 4 1
300032   3 3 3
300032   2 2 2
i want
<b>300032   8 9 7</b>
how?
thanks.

Hi
Use Collect statament to append the record to output table.
DATA: BEGIN OF ITAB OCCURS 0,
        KEY
        FIELD1 TYPE I,
        FIELD2 TYPE I,
        FIELD3 TYPE I,
      END   OF ITAB.
ITAB-KEY = '300032'.
ITAB-FIELD1 = 3.
ITAB-FIELD2 = 4.
ITAB-FIELD3 = 1.
COLLECT ITAB.
ITAB-KEY = '300032'.
ITAB-FIELD1 = 2.
ITAB-FIELD2 = 2.
ITAB-FIELD3 = 2.
COLLECT ITAB.
ITAB-KEY = '300032'.
ITAB-FIELD1 = 3.
ITAB-FIELD2 = 3.
ITAB-FIELD3 = 3.
COLLECT ITAB.
Max
Message was edited by: max bianchi
Message was edited by: max bianchi

Similar Messages

  • SUM in ALV REPORT

    hi all
    i want a sum in alv report. but i have two company seling amount and both in one row. so if i want to sepret this both field means i want to leave one or two line between this two party. and want sum of this two party in same line.
    please help me out as soon as possible
    thanks

    Hi,
    I believe u shkd be having two company number on the out put of ALV list...
    U can use that feild & do a subtotal for AMOUNT grouping by company fields.
    U will be having a Sub-total button on ALV Grid output...
    Regards.
    Bhargava

  • Subtotals and Totals In ALV Report

    Hi Experts,
    I have a problem in my current scenario,
    I have 3 fields,
    KUNNR, WAERS, DMBTR.
    000001 USD         100.00
    000001 USD         200.00
    000002 USD         100.00
    000002 USD         400.00
    000002 EUR         300.00
    000002 EUR         100.00
    The above mentioned is the data I have in my internal table & in my ALV report as well, Which is fine...!
    Now I need Subtotals for each customer,
    Means for customer 000001 The subtotal is 300 (USD)
    Means for customer 000002 The subtotal is 500 (USD)
    Means for customer 000002 The subtotal is 400 (EUR)
    At the end I need grand totals.
    USD 800
    EUR 400.
    Currently My field catalog is given below.
        FIELDCATALOG-COL_POS     = COL_POS.
        FIELDCATALOG-FIELDNAME   = 'DMBTR'.
        FIELDCATALOG-SELTEXT_M   = TEXT-106.
        FIELDCATALOG-DO_SUM      = 'X'.
        APPEND FIELDCATALOG TO FIELDCATALOG.
        CLEAR  FIELDCATALOG.
    what else I need to do for getting individual subtotals by currency and customers.
    Thanks & regards,
    Dileep .C

    Hi Deelip,
    FOR TOTAL:
    there is a property of fieldcatalog, that is do_sum.
    USE COED LIKE:
    PERFORM fieldcat USING:
    '1' 'KUNNR' 'I_MARD' 'CUSTOMER NO' ,
    '2' 'DMBTR' 'I_MARD' 'CURRENCY' ,
    FORM fieldcat USING value(p_0029)
    value(p_0030)
    value(p_0031)
    value(p_0032)
    wa_fieldcat-col_pos = p_0029.
    wa_fieldcat-fieldname = p_0030.
    wa_fieldcat-tabname = p_0031.
    wa_fieldcat-reptext = p_0032.
    wa_fieldcat-do_sum = 'X'.
    APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM. " FIELDCAT
    in final output you will get the total of currency field.
    FOR SUB TOTAL:
    decleare: i_sort type standard table of slis_sortinfo_alv,
              wa_sort type slis_t_sortinfo_alv.
    wa_sort-spos = '1'.
    wa_sort-fieldname = 'KUNNR'.
    wa_sort-tablename = 'i_final'
    wa_sort-up = 'x'
    wa_sort-subtot = 'X'.
    wa_sort-spos = '2'.
    wa_sort-fieldname = 'WAERS'.
    wa_sort-tablename = 'i_final'
    wa_sort-up = 'x'
    wa_sort-subtot = 'X'.
    append wa_tab to i_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    it_fieldcat = it_fieldcat
    it_sort = i_sort
    Hope this can solve your pbs.
    Regards,
    Tutun

  • Trouble trying to replicate GROUP BY/DISTINCT and SUM in PowerPivot with DAX

    I have the following records table (ignore the commas)
    unqPath, Channel, PathLength, UnqPathLength
    8726, direct, 2, 2
    8726, direct, 2, NULL
    8726, organic, 1, 1
    28364, paid, 2, 2
    28364, display, 2, NULL
    287364, email, 4, 4
    287364, email, 4, NULL
    287364, direct, 4, NULL
    287364, email, 4, NULL
    Each record (unqPath) can have multiple channels. For each record I have Path length which is the number of channels associated with that record (this was achieved in SQL doing a count and partitioning it over record name). I have also created another column
    called UnqPathLength where I list the PathLength for each record only once (on the row associated with the 1st channel)
    In PowerPivot, I want to sum the PathLength of all records where a certain channel appears. So direct appears in 2 records which have Path Lengths 2 and 4 respectively so I'd like to have 6 for that.
    I have tried everything from using summarise, distinct but the path length is almost always double counted when the same channel appears twice in the same record. Also tried using unqPathLength (figured this would help with the duplicate counting) but it
    only works when the channel is on the same row and returns incorrect results.
    Here are some of my efforts
    # pathLengthChannel:=
    SUMX(
    SUMMARIZE(
    'query',
    'query'[unqPath],
    'query'[channel],
    'query'[pathLength],
    "pathLengthChannel0",
    SUM('query'[pathLength])
    ),[pathLengthChannel0]
    )OR# pathLengthChannel:=SUMX(
        DISTINCT([unqPath]),
        SUM('query'[pathLength])
    Any ideas would be greatly appreciated. Many thanks.

    This should work assuming that whenever the unqPath and channel are the same that the pathLength is too:
    =SUMX(
    SUMMARIZE(
    query,
    query[unqPath],
    query[Channel],
    "Path",
    MAX(query[PathLength])
    [Path]

  • Subtotal and total in alv report

    hi,
    i have an ALV REPORT,displaying the fields such as po item(ekpo-menge).but i am unable to perform total and sub total,it gives me a information message 'total cannot b performed'.
      can any one help me, how to total and subtotal.

    Hi,
    Please go through the following links. I am sure it will help you.
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=20386">http://www.sapfans.com/forums/viewtopic.php?t=20386</a>
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=85191">http://www.sapfans.com/forums/viewtopic.php?t=85191</a>
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=88401">http://www.sapfans.com/forums/viewtopic.php?t=88401</a>
    Please reward helpful answer.
    Regards,
    Amit Mishra

  • Preview and Download in ALV report blank

    Dear All,
    I have a problem. When user preview and download to local save (txt, xls, etc) from report in ALV format, user get blank preview and blank file.
    I use 2 FM.
    1st i use FM REUSE_ALV_LIST_LAYOUT_INFO_GET to get fieldcat because user want to download after customize the layout (example default there are 5 field then user hide 2 field so only 3 field are displayed and downloaded).
    2nd I use FM REUSE_ALV_GRID_DISPLAY to display as ALV format. and user can download via download button default in ALV format.
    so, anyone.. could u help me ??
    Thanks

    Hi,
    ok I generaeted the fieldcatalog for the above and try to execute as this as I described above
    i am giving the code just check it.
    type-pools SLIS.
    data : lv_vbeln type vbak-vbeln.
    select-options : so_vbeln for lv_vbeln.
    initialization.
    so_vbeln-low = '4970'.
    so_vbeln-high = '4975'.
    append so_vbeln.
    data : lt_fcat type SLIS_T_FIELDCAT_ALV,
           ls_fcat like line of lt_fcat.
    types : begin of ty_vbak,
             vbeln type vbak-vbeln,
             erdat type vbak-erdat,
             erzet type vbak-erzet,
             ernam type vbak-ernam,
           end of ty_vbak.
    data : lt_vbak type standard table of ty_vbak,
           ls_vbak type ty_vbak.
    data : ls_variant like DISVARIANT.
    data : ls_layo type  SLIS_LAYOUT_ALV.
    start-of-selection.
    perform getvbak.
    if sy-subrc eq 0.
    perform displayvbak.
    endif.
    FORM GETVBAK .
    select vbeln erdat erzet ernam from vbak
      into table lt_vbak
      where vbeln in so_vbeln.
    ENDFORM.                    " GETVBAK
    FORM DISPLAYVBAK .
    clear ls_fcat.
    ls_fact-fieldname = 'VBELN'.
    ls_fcat-colpos = 1.
    ls_fcat-seltext_m = 'Sales No'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    clear ls_fcat.
    ls_fact-fieldname = 'ERDAT'.
    ls_fcat-colpos = '2'.
    ls_fcat-seltext_m = 'Date'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    clear ls_fcat.
    ls_fact-fieldname = 'ERZET'.
    ls_fcat-colpos = '3'.
    ls_fcat-seltext_m = 'Time'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    clear ls_fcat.
    ls_fact-fieldname = 'ERNAM'.
    ls_fcat-colpos = '4'.
    ls_fcat-seltext_m = 'Created By'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IS_LAYOUT                         = ls_layo
       IT_FIELDCAT                       = lt_fcat[]
       I_SAVE                            = 'X'
       IS_VARIANT                        = ls_variant
      TABLES
        T_OUTTAB                          = lt_vbak[].
    ENDFORM.                    " DISPLAYVBAK
    Thanks & Regards,
    Raghunadh K

  • Custom tool bar for sorting and summing in alv grid

    what is the function module to use the tool bar in the alv output screen which has - summing , sorting and other button above the alv grid control.

    It is part of the class CL_GUI_ALV_GRID. Have a look at this class, especially the methods within this class, and search for 'SORT' or 'TOTAL' using the button with 'Binoculars' icon.

  • Layout change and save for ALV report

    Hi,
    I ahve created R3 report in which report has been displayed using ALV grid, I am able to change the layout as I can see the layout -> change option in settings menu, but save and choose option is disabled.
    Please advise how to enable layoutr save and choose option for ALV grid.
    Thanks,
    Piyush

    Hi,
    According to sap help you need authorization to save Layout
    [ALV -Layout|http://help.sap.com/saphelp_sm32/helpdata/en/82/839d37664e4d45e10000009b38f8cf/content.htm]
    To save layouts for all users, you need the authorization S_ALV_LAYO with activity 23 as of Release 4.6C. You can only go to the layout administration if you have this authorization.
    You must maintain the authorization object S_ALV_LAYO using the user administration.
    If you would like to use or save the Excel view in your layout, you also require the additional authorization S_BDS_DS with activity 01,02,03,06,30; CLASSNAME ALVLAYOUTTEMPLATES and CLASSTYPE OT.
    Furthermore, there are applications that have their own authorization checks installed.
    In some ALV lists, you can only save user-specific layouts. In these cases, the indicator "user-specific" is active , on a grey background and unable to be changed. This is related to the parameter I_SAVE. This controls which options you have to save the layout.
    To be able to define default layouts, the parameter I_DEFAULT must have the value 'X'.
    Notes 409190 and 601803 also provide further information on authorizations.

  • Editing rows and columns in alv reports in webdynpro abap

    how edit row and columns in webdynpro abap ?
    can i add colors to salv repotrs for below and above range of values  how ?
    if possible send source code for it.............

    hi
    check out this link for editing the columns of ALV
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0155eb5-b6ce-2b10-3195-d9704982d69b
    check out for this thread as well for coloring ALV
    Coloring of selected table cells: Ideas wanted
    regards,
    amit

  • S.screen and abap oo--alv report

    i see all the example here but there is not s.screen before whyyy???
    there is an example with s.screen

    Hi,
    this is example for S.Screen. in OO alv.
    below is the Code.
    and I am specifying variants on s.screen
    Material ............     100-100   to 100-200
    Plant................      1000    to 2000
    BOM Usage............  1  to 1
    BOM status...........    01  to   01
    BOM category........   D    to     P
    *                           T Y P E S                                 *
    TYPES:
    * Material Data
      BEGIN OF type_mast,
        matnr LIKE mast-matnr,             " Material Number
        werks LIKE mast-werks,             " Plant
        stlan LIKE mast-stlan,             " BOM Usage
        stlnr LIKE mast-stlnr,             " Bill of material
        stlal LIKE mast-stlal,             " Alternative BOM
      END OF type_mast,
    * Material Description Data
      BEGIN OF type_makt,
        matnr LIKE makt-matnr,             " Material Number
        maktx LIKE makt-maktx,             " Material Description
      END OF type_makt,
    * BOM Header Data
      BEGIN OF type_stko,
        stlty LIKE stko-stlty,             " BOM category
        stlnr LIKE stko-stlnr,             " Bill of material
        stlal LIKE stko-stlal,             " Alternative BOM
        datuv LIKE stko-datuv,             " Valid-From Date
        bmeng LIKE stko-bmeng,             " Base Quantity
        stktx LIKE stko-stktx,             " Alternative BOM Text
        stlst LIKE stko-stlst,             " BOM status
      END OF type_stko,
    * BOM Text Data
      BEGIN OF type_stzu,
        stlty LIKE stzu-stlty,             " BOM category
        stlnr LIKE stzu-stlnr,             " Bill of material
        ztext LIKE stzu-ztext,             " BOM text
       END OF type_stzu,
    * BOM Item Data
      BEGIN OF type_stpo,
        stlty LIKE stpo-stlty,             " BOM category
        stlnr LIKE stpo-stlnr,             " Bill of material
        idnrk LIKE stpo-idnrk,             " BOM component
        postp LIKE stpo-postp,             " Item Category(BOM)
        posnr LIKE stpo-posnr,             " BOM Item Number
        menge LIKE stpo-menge,             " Component quantity
       END OF type_stpo,
    * Output Data
       BEGIN OF type_output,
        werks LIKE mast-werks,             " Plant
        matnr LIKE mast-matnr,             " Material Number
        maktx LIKE makt-maktx,             " Material Description
        stlnr LIKE mast-stlnr,             " Bill of material
        stlan LIKE mast-stlan,             " BOM Usage
        stlal LIKE mast-stlal,             " Alternative BOM
        stlty LIKE stko-stlty,             " BOM category
        datuv LIKE stko-datuv,             " Valid-From Date
        bmeng LIKE stko-bmeng,             " Base Quantity
        stktx LIKE stko-stktx,             " Alternative BOM Text
        stlst LIKE stko-stlst,             " BOM status
        idnrk LIKE stpo-idnrk,             " BOM component
        postp LIKE stpo-postp,             " Item Category(BOM)
        posnr LIKE stpo-posnr,             " BOM Item Number
        menge LIKE stpo-menge,             " Component quantity
        ztext LIKE stzu-ztext,             " BOM text
       END OF type_output.
    *                            D A T A                                   *
    DATA:
      w_matnr TYPE mara-matnr,             " Material Number
      w_werks TYPE mast-werks,             " Plant
      w_stlan TYPE mast-stlan,             " BOM Usage
      w_stlst TYPE stko-stlst,             " BOM status
      w_stlty TYPE stko-stlty,             " BOM category
      w_container TYPE REF TO cl_gui_custom_container,
      w_alv_grid  TYPE REF TO cl_gui_alv_grid,
      ok_code     LIKE sy-ucomm.
    *                  I N T E R N A L   T A B L E S                      *
    DATA:
    * Material Data
      i_mast          TYPE STANDARD TABLE OF type_mast,
      wa_mast         TYPE type_mast,
    * Material Description Data
      i_makt          TYPE STANDARD TABLE OF type_makt,
      wa_makt         TYPE type_makt,
    * BOM Header Data
      i_stko          TYPE STANDARD TABLE OF type_stko,
      wa_stko         TYPE type_stko,
    * BOM Text Data
      i_stzu          TYPE STANDARD TABLE OF type_stzu,
      wa_stzu         TYPE type_stzu,
    * BOM Item Data
      i_stpo          TYPE STANDARD TABLE OF type_stpo,
      wa_stpo         TYPE type_stpo,
    * Output table
      i_output        TYPE STANDARD TABLE OF type_output,
      wa_output       TYPE type_output,
    * Field Catalog table
    it_fcat      TYPE lvc_t_fcat,         " Internal table for field catal
    wa_fcat      TYPE lvc_s_fcat.         " Work area for field catalog
    *                 S E L E C T I O N     S C R E E N                   *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-ss1.
    SELECT-OPTIONS:
      s_matnr FOR w_matnr,           " Material Number
      s_werks FOR w_werks OBLIGATORY," Plant
      s_stlan FOR w_stlan,           " BOM Usage
      s_stlst FOR w_stlst,           " BOM status
      s_stlty FOR w_stlty.           " BOM category
    SELECTION-SCREEN END OF BLOCK b1.
    *               A T   S E L E C T I O N   S C R E E N                  *
    AT SELECTION-SCREEN.
      PERFORM f010_validate_material.
      PERFORM f020_validate_plant.
      PERFORM f030_validate_bom_usage.
      PERFORM f040_validate_bom_status.
      PERFORM f050_validate_bom_category.
    *                S T A R T   O F   S E L E C T I O N                  *
    START-OF-SELECTION .
      PERFORM f210_fetch_bom_link_data.
      PERFORM f220_fetch_material_des_data.
      PERFORM f230_fetch_bom_header_data.
      PERFORM f240_fetch_bom_text.
      PERFORM f250_fetch_bom_item_data.
    *                  E N D   O F   S E L E C T I O N                    *
    END-OF-SELECTION.
      PERFORM f600_populate_data.
      PERFORM f650_field_catlog.
      CALL SCREEN 100.
    *&      Form  f010_validate_material                                  *
    *       --Validate Material                                           *
    FORM f010_validate_material .
    * Validate Material
      IF s_matnr IS NOT INITIAL.
        SELECT matnr
          INTO w_matnr
          FROM mara
         UP TO 1 ROWS
         WHERE matnr IN s_matnr.
        ENDSELECT.
        CHECK sy-subrc NE 0.
        SET CURSOR FIELD 'S_MATNR'.
        MESSAGE e210.                      " Invalid Material
      ENDIF.                               " IF s_matnr IS NOT INITIAL.
    ENDFORM.                               " f010_validate_material
    *&      Form  f020_validate_plant                                     *
    *       - Validate Plant                                              *
    FORM f020_validate_plant .
    * Validate Plant
      SELECT  werks
        INTO w_werks
        FROM t001w
        UP TO 1 ROWS
        WHERE werks IN s_werks.
      ENDSELECT.
      CHECK sy-subrc NE 0.
      SET CURSOR FIELD 'S_WERKS'.
      MESSAGE e220.                        " Invalid Plant
    ENDFORM.                               " f020_validate_plant
    *&      Form  f030_validate_BOM_usage                                 *
    *       -Validate BOM Usage                                           *
    FORM f030_validate_bom_usage .
    * Validate BOM Usage
      IF s_stlan IS NOT INITIAL.
        SELECT stlan
          INTO w_stlan
          FROM t416
          UP TO 1 ROWS
          WHERE stlan IN s_stlan.
        ENDSELECT.
        CHECK sy-subrc NE 0.
        SET CURSOR FIELD 'S_STLAN'.
        MESSAGE e230.                      " Invalid BOM Usage
      ENDIF.                               " IF s_stlan IS NOT INITIAL.
    ENDFORM.                               " f030_validate_BOM_usage
    *&      Form  f040_validate_BOM_status
    *       - Validate BOM Status
    FORM f040_validate_bom_status .
    * Validate BOM Status
      IF s_stlst IS NOT INITIAL.
        SELECT  stlst
          INTO w_stlst
          FROM t415s
          UP TO 1 ROWS
          WHERE stlst IN s_stlst.
        ENDSELECT.
        CHECK sy-subrc NE 0.
        SET CURSOR FIELD 'S_STLST'.
        MESSAGE e240.                      " Invalid BOM Status
      ENDIF.                               " IF s_stlst IS NOT INITIAL
    ENDFORM.                               " f040_validate_BOM_status
    *&      Form  f050_validate_BOM_category                              *
    *       -Validate BOM Category                                        *
    FORM f050_validate_bom_category .
    * Validate BOM Category
      IF s_stlty IS NOT INITIAL.
        SELECT  stlty
          INTO w_stlty
          FROM stko
          UP TO 1 ROWS
          WHERE stlty IN s_stlty.
        ENDSELECT.
        CHECK sy-subrc NE 0.
        SET CURSOR FIELD 'S_STLTY'.
        MESSAGE e250.                      " Invalid BOM Category
      ENDIF.                               " IF s_stlty IS NOT INITIAL.
    ENDFORM.                               " f050_validate_BOM_category
    *&      Form  f210_fetch_bom_link_data                                *
    *       - Fetch Material BOM Link data                                *
    FORM f210_fetch_bom_link_data .
    * Fetch Material BOM Link data
      SELECT matnr                         " Material Number
             werks                         " Plant
             stlan                         " BOM Usage
             stlnr                         " Bill of material
             stlal                         " Alternative BOM
        INTO TABLE i_mast
        FROM mast
       WHERE matnr IN s_matnr
         AND werks IN s_werks.
      IF sy-subrc NE 0.
        MESSAGE s200.                      " No Data Found
      ENDIF.                               " IF sy-subrc NE 0.
      SORT i_mast BY matnr werks.
    ENDFORM.                               " f200_fetch_bom_link_data
    *&      Form  f220_fetch_material_des_data                            *
    *       -Fetch Material Description data                              *
    FORM f220_fetch_material_des_data .
      SELECT matnr
             maktx
        INTO TABLE i_makt
        FROM makt
         FOR ALL ENTRIES IN i_mast
       WHERE matnr EQ i_mast-matnr.
      IF sy-subrc NE 0.
        MESSAGE s200.                      " No Data Found
      ENDIF.                               " IF sy-subrc NE 0.
      SORT i_makt BY matnr.
    ENDFORM.                               " f200_fetch_material_des_data
    *&      Form  f230_fetch_bom_header_data                              *
    *       - Fetch BOM Header data                                       *
    FORM f230_fetch_bom_header_data .
    * Fetch BOM Header data
      SELECT stlty                         " BOM category
             stlnr                         " Bill of material
             stlal                         " Alternative BOM
             datuv                         " Valid-From Date
             bmeng                         " Base Quantity
             stktx                         " Alternative BOM Text
             stlst                         " BOM status
        INTO TABLE i_stko
        FROM stko
        FOR ALL ENTRIES IN i_mast
      WHERE stlnr EQ i_mast-stlnr
      AND   stlty IN s_stlty
      AND   stlst IN s_stlst.
      IF sy-subrc NE 0.
        MESSAGE s200.                      " No Data Found
      ENDIF.                               " IF sy-subrc NE 0.
      SORT i_stko BY stlty stlst.
    ENDFORM.                               " f200_fetch_bom_header_data
    *&      Form  f240_fetch_bom_text                                     *
    *      - Fetch BOM text Data                                          *
    FORM f240_fetch_bom_text .
    *  DATA:
    *    i_stko_temp LIKE TABLE OF wa_stko.
    *  i_stko_temp = i_stko.
    *  SORT i_stko_temp BY stlty stlnr.
    *  DELETE ADJACENT DUPLICATES FROM i_stko_temp
    *    COMPARING stlty stlnr.
    *  SELECT stlty                         " BOM category
    *         stlnr                         " Bill of material
    *         ztext                         " BOM text
    *    INTO TABLE i_stzu
    *    FROM stzu
    *     FOR ALL ENTRIES IN i_stko_temp
    *   WHERE stlty EQ i_stko_temp-stlty
    *     AND stlnr EQ i_stko_temp-stlnr.
    *  DATA:
    *    i_stzu_temp    LIKE TABLE OF wa_stzu.
      SELECT stlty                         " BOM category
             stlnr                         " Bill of material
             ztext                         " BOM text
        INTO TABLE i_stzu
        FROM stzu
         FOR ALL ENTRIES IN i_stko
       WHERE stlty EQ i_stko-stlty
         AND stlnr EQ i_stko-stlnr.
      IF sy-subrc NE 0.
        MESSAGE s200.                      " No Data Found
      ENDIF.                               " IF sy-subrc NE 0.
    ENDFORM.                               " f200_fetch_bom_text
    *&      Form  f250_fetch_bom_item_data                                *
    *       - Fetch BOM Item data                                         *
    FORM f250_fetch_bom_item_data .
    * Fetch BOM Header data
      SELECT stlty                         " BOM category
             stlnr                         " Bill of material
             idnrk                         " BOM component
             postp                         " Item Category(BOM)
             posnr                         " BOM Item Number
             menge                         " Component quantity
        INTO TABLE i_stpo
        FROM stpo
         FOR ALL ENTRIES IN i_stko
       WHERE stlty EQ i_stko-stlty
         AND stlnr EQ i_stko-stlnr.
      IF sy-subrc NE 0.
        MESSAGE s200.                      " No Data Found
      ENDIF.                               " IF sy-subrc NE 0.
    ENDFORM.                               " f200_fetch_bom_item_data
    *&      Form  f600_populate_data                                       *
    *       - Displaying the data                                         *
    FORM f600_populate_data .
    *  SORT i_stko.
    *  SORT i_mast.
    *  DELETE ADJACENT DUPLICATES FROM i_mast.
      LOOP AT i_stpo INTO wa_stpo.
        CLEAR wa_output.
        READ TABLE i_stko INTO wa_stko WITH KEY stlnr = wa_stpo-stlnr
                                                stlty = wa_stpo-stlty
                                                BINARY SEARCH.
    *    CHECK sy-subrc eq 0.
        READ TABLE i_stzu INTO wa_stzu WITH KEY stlnr = wa_stko-stlnr
                                                stlty = wa_stko-stlty
                                                BINARY SEARCH.
    *    CHECK sy-subrc Eq 0.
        READ TABLE i_mast INTO wa_mast WITH KEY stlnr = wa_stko-stlnr
                                                BINARY SEARCH.
    *    CHECK sy-subrc Eq 0.
        READ TABLE i_makt INTO wa_makt WITH KEY matnr = wa_mast-matnr
                                                BINARY SEARCH.
    *    CHECK sy-subrc Eq 0.
        MOVE:
          wa_stpo-idnrk TO wa_output-idnrk,
          wa_stpo-postp TO wa_output-postp,
          wa_stpo-posnr TO wa_output-posnr,
          wa_stpo-menge TO wa_output-menge,
          wa_stko-stlty TO wa_output-stlty,
          wa_stko-datuv TO wa_output-datuv,
          wa_stko-bmeng TO wa_output-bmeng,
          wa_stko-stktx TO wa_output-stktx,
          wa_stko-stlst TO wa_output-stlst,
          wa_stzu-ztext TO wa_output-ztext,
          wa_mast-werks TO wa_output-werks,
          wa_mast-matnr TO wa_output-matnr,
          wa_makt-maktx TO wa_output-maktx,
          wa_mast-stlnr TO wa_output-stlnr,
          wa_mast-stlan TO wa_output-stlan,
          wa_mast-stlal TO wa_output-stlal.
        APPEND wa_output TO i_output.
      ENDLOOP.                             " LOOP AT i_stpo
    ENDFORM.                               " f600_display_data
    *&      Form  f650_field_catlog                                       *
    *       -Fill Field Catalog                                           *
    FORM f650_field_catlog .
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-ref_table = 'MAST'.
      wa_fcat-ref_field = 'WERKS'.
      wa_fcat-col_pos   = 1.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_table = 'MAST'.
      wa_fcat-ref_field = 'MATNR'.
      wa_fcat-col_pos   = 2.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-ref_table = 'MAKT'.
      wa_fcat-ref_field = 'MAKTX'.
      wa_fcat-col_pos   = 3.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'STLTY'.
      wa_fcat-ref_table = 'STKO'.
      wa_fcat-ref_field = 'STLTY'.
      wa_fcat-col_pos   = 4.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'STLAN'.
      wa_fcat-ref_table = 'MAST'.
      wa_fcat-ref_field = 'STLAN'.
      wa_fcat-col_pos   = 5.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'STLNR'.
      wa_fcat-ref_table = 'MAST'.
      wa_fcat-ref_field = 'STLNR'.
      wa_fcat-col_pos   = 6.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'STLAL'.
      wa_fcat-ref_table = 'MAST'.
      wa_fcat-ref_field = 'STLAL'.
      wa_fcat-col_pos   = 7.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'STKTX'.
      wa_fcat-ref_table = 'STKO'.
      wa_fcat-ref_field = 'STKTX'.
      wa_fcat-col_pos   = 8.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'DATUV'.
      wa_fcat-ref_table = 'STKO'.
      wa_fcat-ref_field = 'DATUV'.
      wa_fcat-col_pos   = 9.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'BMENG'.
      wa_fcat-ref_table = 'STKO'.
      wa_fcat-ref_field = 'BMENG'.
      wa_fcat-col_pos   = 10.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'STLST'.
      wa_fcat-ref_table = 'STKO'.
      wa_fcat-ref_field = 'STLST'.
      wa_fcat-col_pos   = 11.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'IDNRK'.
      wa_fcat-ref_table = 'STPO'.
      wa_fcat-ref_field = 'IDNRK'.
      wa_fcat-col_pos   = 12.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'POSTP'.
      wa_fcat-ref_table = 'STPO'.
      wa_fcat-ref_field = 'POSTP'.
      wa_fcat-col_pos   = 13.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'POSNR'.
      wa_fcat-ref_table = 'STPO'.
      wa_fcat-ref_field = 'POSNR'.
      wa_fcat-col_pos   = 14.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'MENGE'.
      wa_fcat-ref_table = 'STPO'.
      wa_fcat-ref_field = 'MENGE'.
      wa_fcat-col_pos   = 15.
      APPEND wa_fcat TO it_fcat.
      wa_fcat-fieldname = 'ZTEXT'.
      wa_fcat-ref_table = 'STZU'.
      wa_fcat-ref_field = 'ZTEXT'.
      wa_fcat-col_pos   = 16.
      APPEND wa_fcat TO it_fcat.
    ENDFORM.                               " f650_field_catlog
    *&      Module  STATUS_0100  OUTPUT                                   *
    *       -Calling Function Module                                      *
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'BACK'.
    *  SET TITLEBAR 'xxx'.
      IF w_container IS INITIAL.
    *    IF cl_gui_alv_grid=>offline( ) IS INITIAL.
        CREATE OBJECT w_container
          EXPORTING
    *      PARENT                      =
            container_name              = 'CUSTOM'
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      REPID                       =
    *      DYNNR                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                               " IF sy-subrc <> 0.
      ENDIF.
      CREATE OBJECT w_alv_grid
        EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
          i_parent          = w_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
        EXCEPTIONS
          error_cntl_create = 1
          error_cntl_init   = 2
          error_cntl_link   = 3
          error_dp_create   = 4
          OTHERS            = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.                             " IF sy-subrc <> 0.
    *  ENDIF.
      CALL METHOD w_alv_grid->set_table_for_first_display
    *   EXPORTING
    *    I_BUFFER_ACTIVE               =
    *    I_BYPASSING_BUFFER            =
    *    I_CONSISTENCY_CHECK           =
    *     i_structure_name              = 'WA_OUTPUT'
    *    IS_VARIANT                    =
    *    I_SAVE                        =
    *    I_DEFAULT                     = 'X'
    *    IS_LAYOUT                     =
    *    IS_PRINT                      =
    *    IT_SPECIAL_GROUPS             =
    *    IT_TOOLBAR_EXCLUDING          =
    *    IT_HYPERLINK                  =
    *    IT_ALV_GRAPHICS               =
    *    IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = i_output
          it_fieldcatalog               = it_fcat
    *    IT_SORT                       =
    *    IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.                               " IF sy-subrc <> 0.
    ENDMODULE.                             " STATUS_0100 OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT                              *
    *       - Leave Program                                               *
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.                             " CASE ok_code
      CLEAR ok_code.
    ENDMODULE.                             " USER_COMMAND_0100  INPUT
    thanks,
    Reward if helpful,
    Brijesh

  • Distinct and Sum

    Hi,
    I am trying to build an oracle query that would simplify my life.
    I have table labtrans which contains fields regularhrs ( float ) , premiumhrs (float ) , craft ( varchar ) and wonum ( varchar ) . Craft is the type of labor and wonum is the key.
    The fact is that there are a lot of possible craft for a single wonum. I would like to sum all premiumhrs and regularhrs for EACH craft. Which means that if MANUSE come 10 times, I only want ONE line of MANUSE with the sum of all his premiumhrs and the sum of regularhrs.
    Is it even possible ??
    my current query is : select L.transdate, L.regularhrs, L.premiumpayhours, L.payrate, L.craft, L.linecost, L.gldebitacctdep from LABTRANS L where L.refwo = '$WONUM'
    Thanks

    I would like to sum all premiumhrs and regularhrs for EACH craft. Which means that if MANUSE come 10 times, I only want ONE line of MANUSE with the sum of all his premiumhrs and the sum of regularhrs.
    If I understand correctly if there are 10 records for MANUSE_1 and within the 10 MANUSE_1 records there are 3 records for CRAFT1, three for CRAFT2, and 4 for CRAFT3 you want the output to be:
    MANUSE_1
    CRAFT1 | 40 regular hours | 10 premium hours
    CRAFT2 | 5 regular hours | 0 premium hours
    CRAFT3 | 19 regular hours | 4 premium hours
    Is this correct?
    If you want script out the some records from your table and email them to me and I can give you an example.
    Edited by: jmurch on Sep 23, 2010 9:57 AM

  • Writing Subtotal and Grandtotal in ALV Report

    Dear All,
    I have a requirement that instead of  *  and  **  in Subtotal and Grandtotal, I will require to write text "Subtotal" and "Grandtotal" written. Can you please help me out?
    Thanks and regards,
    Atanu

    HI
    http://help.sap.com/saphelp_sm32/helpdata/en/ee/b99d37e188a049e10000009b38f8cf/content.htm
    Use "Subtotal_text" in events table.
    here GTOTAL is field in itab on which we sortindf data, and use your own field on which field u want to sort...
    refresh gt_event.
    clear gw_event.
    call function 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    i_list_type = 0
    IMPORTING
    et_events = gt_event.
    Subtotal
    read table gt_event with key name = slis_ev_subtotal_text into gw_event.
    if sy-subrc = 0.
    move 'SUBTOTAL_TEXT' to gw_event-form.
    append gw_event to gt_event.
    endif.
    form subtotal_text using uw_subtot_line type ty_main
    uv_subtottxt type slis_subtot_text. "#EC CALLED
    if uv_subtottxt-criteria = 'GTOTAL'.
    uv_subtottxt-display_text_for_subtotal = 'TOTAL'.
    endif.
    *FORM build_sort .
    refresh gt_sort.
    gw_sort-spos = 1.
    gw_sort-fieldname = 'GTOTAL'.
    gw_sort-tabname = 'GT_MAIN'.
    gw_sort-up = 'X'.
    gw_sort-subtot = 'X'.
    APPEND gw_sort TO gt_sort.
    CLEAR gw_sort.

  • ALV - need to sum values of internal table and display in ALV

    I have data in internal table as:
    Material     date     sum1     sum2
    Mat_A     19990101     4     4
    Mat_A     20080501     3     0
    Mat_A     20080601     2     0
    Mat_B     19990101     2     0
    Mat_B     20080601     5     5
    Required output is :
    Material     qty1     qty2     19990101     20080501     20080601
    Mat_A     432     4     4     3     2
    Mat_B     2+5     5     2           5
    Thinking of using ALV to pass the internal table and display as classical report (and also to save as excel spreadsheet).
    Counting your help on the following questions:
    1) How to accomplish the sum in ALV report? Can ALV FM do that or one has to use ABAP to compute the sum from the given internal table?
    2) Mat_A can have more date values. Here it got 3 distinct date values 19990101, 20080601, 20080501. If it has say 5 date values, how to create the ALV date columns (from 3 to 5 date columns) dynamically?
    Thanks for the help.

    for the sum inalv we use generally..
    it_fieldcat-do_sum = 1.
    check this examples...
    http://www.****************/Tutorials/ALV/Subtotals/text.htm
    *& Report  ZTEST_ALV_PERC_13317
    REPORT  ztest_alv_perc_13317.
    TYPE-POOLS: slis.
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE slis_fieldcat_alv,
          it_events TYPE slis_t_event,
          wa_events TYPE slis_alv_event,
          it_sort TYPE slis_t_sortinfo_alv,
          wa_sort TYPE slis_sortinfo_alv,
          l_layout TYPE slis_layout_alv.
    TYPES: BEGIN OF ty_itab,
            field1(10),
            qty1 TYPE i,
            qty2 TYPE i,
            qty3 TYPE i,
            dummy TYPE c,
          END OF ty_itab.
    DATA: itab TYPE STANDARD TABLE OF ty_itab WITH  HEADER LINE,
    itab1 TYPE ty_itab.
    START-OF-SELECTION.
      itab-field1 = 'FIRST'.
      itab-qty1 = 2.
      itab-qty2 = 1.
      itab-qty3 = 5.
      itab-dummy = 10.
      APPEND itab.
      itab-field1 = 'FIRST'.
      itab-qty1 = 2.
      itab-qty2 = 1.
      itab-qty3 = 5.
      itab-dummy = 10.
      APPEND itab.
      itab-field1 = 'FIRST'.
      itab-qty1 = 2.
      itab-qty2 = 1.
      itab-qty3 = 5.
      itab-dummy = 10.
      APPEND itab.
      wa_fieldcat-col_pos = 1.
      wa_fieldcat-fieldname = 'FIELD1'.
      wa_fieldcat-tabname = 'ITAB'.
      APPEND wa_fieldcat TO it_fieldcat.
      wa_fieldcat-col_pos = 2.
      wa_fieldcat-fieldname = 'QTY1'.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-do_sum = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      wa_fieldcat-col_pos = 3.
      wa_fieldcat-fieldname = 'QTY2'.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-do_sum = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      wa_fieldcat-col_pos = 4.
      wa_fieldcat-fieldname = 'QTY3'.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-do_sum = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      wa_fieldcat-col_pos = 5.
      wa_fieldcat-fieldname = 'DUMMY'.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-do_sum = 'X'.
      wa_fieldcat-no_out = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
       CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_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.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program           = sy-repid
         it_fieldcat                    = it_fieldcat
        TABLES
          t_outtab                       = itab
    EXCEPTIONS
       program_error                  = 1
       OTHERS                         = 2
      IF sy-subrc <> 0.
      ENDIF.

  • What are events in ALV report and explain how sorting is done  alv report

    events in alv report and sorting in alv report
    Moderator Message: Search before posting.
    Edited by: kishan P on Dec 21, 2011 11:13 AM

    Hi Raja,
    <<content and links removed by moderator>>
    PavanKumar.G
    Edited by: kishan P on Dec 21, 2011 11:12 AM

  • Some doubts in alv report

    how can i page breakin alv report ?
    what are the types of variants and events in alv report?
    how to hide field in alv?
    how to change standard pf status in alv reports?
    plz give me sample program for how to use variants in alv?
    <THREAD LOCKED. Please stop asking interview questions. There is already a lot of information out there, refer to the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] on how to ask a good question and learn to search>
    Edited by: Mike Pokraka on Oct 15, 2008 4:52 PM

    how can i page breakin alv report ?
    - Yes... using NEW-PAGE
    what are the types of variants and events in alv report?
    - DATA: g_variant LIKE disvariant.
    - DATA: gt_eventos          TYPE slis_t_event.
    how to hide field in alv?
    - When you define the field catalog mark this field ls_fieldcat-no_out = 'X'.
    how to change standard pf status in alv reports?
    CLEAR ls_extab.
    ls_extab-fcode = 'ZASSIG'.
    APPEND ls_extab TO extab.
    SET PF-STATUS 'Z09_STATUS' EXCLUDING extab.

Maybe you are looking for

  • "Could not be copied because an error occured. There is not enough memory."

    Hello, I recently got an iPad 64gb. And have since been loading all of my Comic backups onto it (Via Cloudreaders). I've got 32.5gb used and 26.4gb Free. Every 20-30 issues or so I get an error that says "Comic book name here" cannot be copied becaus

  • How to create dropdown or drilldown in dashboard ?

    All i have this requirement to create a dashboard that has a drilldown or dropdown list for a list of reports Example -Sales Department     - sales by region        - U.S        - Asia        - Europe    - Sales Per Period       - Quarter       - mon

  • AirPlay is working on Wi-Fi and/or Bluetooth networks

    I have got any wi-fi AirPlay enabled device yet. Today, I use my Bluetooth earphones and discover the AirPlay icon on the iPod app. It seems the AirPlay icon replaces the Bluetooth icon on iPod playback control panel. There are two options: iPhone an

  • Convert quantiy

    Hi friends, How to convert the quantity field value into words. For example let my quantity field value is 12.12 I need to convert this to twelve point twelve. .How to do this. Can I use the function module spell amount for quantity? I tried but I di

  • Memory leak in Real-Time caused by VISA Read and Timed Loop data nodes? Doesn't make sense.

    Working with LV 8.2.1 real-time to develop a host of applications that monitor or emulate computers on RS-422 busses.   The following screen shots were taken from an application that monitors a 200Hz transmission.  After a few hours, the PXI station