Subtotal in Dynamic ALV

Hi,
Please tell how to perform Subtotal in dynamic ALV Report.
Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
Thanks.

Hi,
Please tell how to perform Subtotal in dynamic ALV Report.
Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
Thanks.

Similar Messages

  • Subtotal Text in Dynamic ALV

    I have faced the problem with Subtotal Text in Dynamic ALV.
    I don't know why it is not get into "FORM subtotal_text " .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = sy-repid
       IS_LAYOUT                        = gw_layout
         it_fieldcat                    = gi_fieldcat[]
         it_sort                        = gi_sort[]
         it_events                      = gi_events
        TABLES
          t_outtab                       = <gi_dyntable>
       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.
    and
    *&      Form  subtotal_text
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM subtotal_text USING  p_total type ref to data
                             p_subtottxt_info TYPE slis_subtot_text.
      break-point.
    ENDFORM.                    " alv_subtotal
    Thanks in advance

    I put the form name to gi_events
    *&      Form  event_build
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM event_build .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = gi_events.
      READ TABLE gi_events WITH KEY name = 'SUBTOTAL_TEXT' INTO gw_events.
      IF sy-subrc = 0.
        MOVE 'SUBTOTAL_TEXT' TO gw_events-form.
        MODIFY gi_events FROM gw_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " event_build

  • How to get subtotal value in ALV list display

    Hi all,
    How to give condition on the value of subtotal line in ALV list display,
    i.e.if value of subtotal of plan quantity = actual quantity (in red oval) it should show the message
    'ON TIME DELIVERY' else it should not show messagee.In my case(shown in red oval) its
    showing for each subtotal value. I know how to change the subtotal text but i want to change
    with respect to value of the subtotal.(plz refer attachment)
    Any input regard to this will be achieved great.
    Many thanks in advance.
    samadhan shinde.

    Hi Samadhan,
    I am awaiting for solution for this problem.....but as i think dynamically displaying sub total based on
    matching actual quantity and planned quantity is bit complicated.
    My idea is to display matched quantities in one block and unmatched  quantities in another. I mean using blocked list.
    awaiting suggestions.
    regards,

  • How to add sum in dynamic alv ?

    hello ,
    i create dynamic alv , by using FIELD-SYMBOLS ,
    but my columns are char type , and the SUM an SUBTOTAL
    not work .
    how i can tern the internal table that build with char
    columns to be numeric (like BSIK-WRBTR)?

    FIRST OF ALL THANKS  , BUT ....  ))
    NOW THE LINE OF THE SUM DISPLAY AS THE FIRST LINE AND
    ALL OTHER LINE AFTER IT )) .
    HOW CAN I TERN IT TO BE NORMAL ( IN BUTTOM ) ? .
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          I_STRUCTURE_NAME = 'YAG_ST_FOR_SPLITE_PER_VEND'
        CHANGING
          CT_FIELDCAT      = LT_FIELDCATALOG[].
      DESCRIBE TABLE LT_FIELDCATALOG LINES LIN6 .
      LIN6 = LIN6 + 1 .
      LOOP AT IT_SPLITE_COLUMNE .
        LS_ALV_CAT-FIELDNAME = IT_SPLITE_COLUMNE-FIELD_NAME.
        LS_ALV_CAT-REF_FIELD = IT_SPLITE_COLUMNE-FIELD_NAME.
        LS_ALV_CAT-COL_POS   = LIN6.
        LS_ALV_CAT-DATATYPE   = 'QUAN'.
        LS_ALV_CAT-DO_SUM     = 'X'.
        LS_ALV_CAT-TABNAME   = 'IT_SPLIT_FOR_REP'.
        APPEND LS_ALV_CAT TO LT_FIELDCATALOG.
        LIN6 = LIN6 + 1 .
      ENDLOOP.

  • Passing the Total/Subtotal Text in ALV

    Hi All,
    I would like to know is there any chance with ALV to pass Total/Subtotal Text.
    PS:I'm not looking for the text ls_layout-totals_text = 'Grand Total'.
    ls_layout-subtotals_text = 'SubTotal'.
    What i'm looking for is In My below Output:
    112365               TDS Windsor Sequencing                           
    112365               TDS Windsor Sequencing                           
    112365               TDS Windsor Sequencing                           
    * Total  <Group text>  "Here My   total amount is showing                                                         
    112313               Operations and Engineering                       
    * Total   <Group text>      "Here My   total amount is showing                                                         
    112363               DCX Windsor                                      
    * Total      <Group text>            "Here My   total amount is showing                                                                               
    ** Subtotal <Group text>   "Here My  "SUB total" amount is showing of above three totals
    I've <Group text> in My Final ALV one of field, but need to show at the place of <Group text> in above output.
    PS:And For Totals/Subtotals i'm using standard function of ALV by passing IT_SORT(which is in Reuse_Alv..FM)
    Any Hints?
    Thank You,
    Cheers,
    Amit.

    Hi Amit,
      Please check this example..I used the event BEFORE_LINE_OUTPUT to populate the subtotal texts
    dynamically..Used the Field-symbols technique to populate the subtotals text...Hope this is what you
    are looking for.
    TYPE-POOLS: slis,kkblo.
    DATA: BEGIN OF wa,
            vbeln TYPE vbeln,
            posnr TYPE posnr,
            matnr TYPE matnr,
            netpr TYPE netpr,
            waerk TYPE waerk,
            text  TYPE char20,
          END OF wa.
    DATA: BEGIN OF wa_vbak,
            vbeln TYPE vbeln,
          END OF wa_vbak.
    DATA: i_event   TYPE slis_t_event,
          t_sort    TYPE slis_t_sortinfo_alv,
          s_sort    TYPE LINE OF slis_t_sortinfo_alv,
          l_s_event TYPE LINE OF slis_t_event.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_layout       TYPE slis_layout_alv.
    DATA: v_repid        TYPE syrepid.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    DATA: itab1          LIKE TABLE OF wa.
    DATA: itab           LIKE TABLE OF wa_vbak.
    START-OF-SELECTION.
    * Field catalog populate.
      s_fieldcatalog-col_pos = '1'.
      s_fieldcatalog-fieldname = 'VBELN'.
      s_fieldcatalog-rollname = 'VBELN'.
      s_fieldcatalog-outputlen = '12'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '2'.
      s_fieldcatalog-fieldname = 'POSNR'.
      s_fieldcatalog-rollname = 'POSNR'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '3'.
      s_fieldcatalog-fieldname = 'MATNR'.
      s_fieldcatalog-rollname = 'MATNR'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '4'.
      s_fieldcatalog-fieldname = 'NETPR'.
      s_fieldcatalog-ref_tabname = 'VBAP'.
      s_fieldcatalog-ref_fieldname = 'NETPR'.
      s_fieldcatalog-do_sum = 'X'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
    * Get vbak
      SELECT vbeln UP TO 100 ROWS
      FROM
      vbak
      INTO TABLE itab.
      IF NOT itab[] IS INITIAL.
    * Get vbap
        SELECT vbeln posnr matnr netpr waerk arktx
        FROM vbap
        INTO TABLE itab1
        FOR ALL ENTRIES IN itab
        WHERE vbeln = itab-vbeln.
      ENDIF.
      v_repid = sy-repid.
    * Build sort internal table.
      s_sort-spos      = '1'.
      s_sort-fieldname = 'VBELN'.
      s_sort-tabname  = 'ITAB1'.
      s_sort-up = 'X'.
      s_sort-subtot = 'X'.
      s_sort-group = 'UL'.
      APPEND s_sort TO t_sort.
    * Get alv events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 2
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    * Before line output.
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = 'BEFORE_LINE_OUTPUT'.
      IF sy-subrc = 0.
        MOVE 'BEFORE_LINE_OUTPUT' TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.
    * Populate dummy text.
      s_layout-subtotals_text = 'Dummy'.
    * Init
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = v_repid.
    * Append
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                  = s_layout
          it_fieldcat                = t_fieldcatalog
          i_tabname                  = 'ITAB1'
          it_events                  = i_event
          it_sort                    = t_sort
        TABLES
          t_outtab                   = itab1
        EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 2
          OTHERS                     = 3.
    * Display
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    *&      Form  BEFORE_LINE_OUTPUT
    *       text
    *      -->GS_LINEINFO  text
    FORM before_line_output USING gs_lineinfo TYPE kkblo_lineinfo.
      FIELD-SYMBOLS: <fs_layout>  TYPE kkblo_layout.
      ASSIGN ('(SAPLKKBL)GT_STACK-IS_LAYOUT') TO <fs_layout>.
      CHECK sy-subrc = 0.
    * Check if it is subtotal line.
      CHECK gs_lineinfo-subtot = 'X'.
    * Get the text
      READ TABLE itab1 INTO wa INDEX gs_lineinfo-sumindex.
      IF sy-subrc = 0.
        <fs_layout>-subtotals_text = wa-text.
      ENDIF.
    ENDFORM.                    "BEFORE_LINE_OUTPUT
    Thanks
    Naren

  • Subtotal in Blocked ALV

    Hi All,
    I am facing the problem in displaying the subtotal in Blocked ALV.
    My requirement is, I need to display the subtotals in 3 lines like below.
    for ex:
    subtotal:          7 <above total>
                          (5)<coming from someother field>
                           2
    from the above: 7 is total of that column.
                              5 is coming from some other field.
                              2 is substraction of above 2.
    Could anyone please help me in the above.
    Many thanks in advance.
    Regards,
    venkat.

    Hi Vaibhav,
    Thanks for your response.
    and one thing here in my above example is,  the value  5 is neither total nor subtotal. its just a different value coming from some other field.
    only the 7 is total of that column.
    and if I write that logic manually, It may not able display as the position of that column is around 500. because write statment may display upto 252nd position in the output, I guess.
    thank you very much.
    Regards,
    Venkat.
    Edited by: venkat reddy on Jan 18, 2010 8:45 PM

  • How to display a row after a subtotal field in ALV Grid

    Hi All,
    My requirement is to print a extra row with values and constant text after printing subtotal values in ALV Grid.
    e.g.      TOTAL      12.23       ---> Subtotal field
                 Tax            5.2         ---> extra row after subtotal field.
    Please help me....
    Thanks in advance.
    Regards
    Ajay

    Hi
    You can try using INSERT <WA> OR INSERT INITIAL LINE .
    fill the wa with tax value.
    INSERT  <wa> into table < internal table > 
    A row will be inserted into internal table with the values.
    Try this  and let me know.
    Thanks
    Hariharan

  • Problem in Data Display in Dynamic ALV Report

    Hi all,
    I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
    REPORT  zdynamic_test                           .
    *REPORT  ztest_notepad.
    *& Declarations
    *Type-pools
    TYPE-POOLS: slis.
    *TABLES
    TABLES: zjpack_base.
    *Types
    TYPES:
          ty_fcat      TYPE lvc_s_fcat,
          ty_fcatalog  TYPE slis_fieldcat_alv.
    *Work areas
    DATA:
          wa_fcat      TYPE ty_fcat,
          wa_fcatalog  TYPE ty_fcatalog.
    *Internal tables
    DATA:
          it_fcat      TYPE STANDARD TABLE OF ty_fcat,
          it_fcatalog  TYPE STANDARD TABLE OF ty_fcatalog.
    *Type reference
    DATA:
          it_dyn_tab   TYPE REF TO data,
          wa_newline   TYPE REF TO data.
    *INTERNAL TABLE
    DATA: BEGIN OF it_itab OCCURS 0.
            INCLUDE STRUCTURE zjpack_base.
    DATA: END OF it_itab.
    *Filed symbols
    FIELD-SYMBOLS:
          <gt_table>   TYPE STANDARD TABLE,
          <fs_dyntable>,
          <fs_fldval>  TYPE ANY,
          <l_field>    TYPE ANY.
    *Variables
    DATA:
          l_fieldname  TYPE lvc_s_fcat-fieldname,
          l_tabname    TYPE lvc_s_fcat-tabname,
          l_fieldtext  TYPE lvc_s_fcat-seltext,
          l_index      TYPE char2.
    "Selection-screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
    SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
    SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
    SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
    SELECTION-SCREEN END OF BLOCK b1.
    PARAMETERS:
             p_colms   TYPE i.
    *& start-of-selection.
    START-OF-SELECTION.
      PERFORM select_data.
      PERFORM build_fieldcat.
      PERFORM create_dynamic_table.
    DO 20 TIMES.
       DO p_colms TIMES.
         l_index = sy-index.
         CONCATENATE 'FIELD' l_index INTO l_fieldname.
         ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
         <l_field> = sy-index.
       ENDDO.
       INSERT <fs_dyntable> INTO TABLE <gt_table>.
    ENDDO.
      LOOP AT it_itab.
        l_index = sy-tabix.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
        <l_field> = it_itab-matnr.
        INSERT <fs_dyntable> INTO TABLE <gt_table>.
      ENDLOOP.
      LOOP AT it_fcat INTO wa_fcat.
        PERFORM fieldcatalog1 USING: wa_fcat-fieldname
                                      wa_fcat-tabname
                                      wa_fcat-seltext.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_NOTEPAD'
          it_fieldcat        = it_fcatalog
        TABLES
          t_outtab           = <gt_table>.
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat .
    CLEAR: l_fieldname,
            l_tabname,
            l_fieldtext,
            l_index.
    DO  p_colms TIMES.
       CLEAR l_index.
       l_index = sy-index.
       CONCATENATE 'FIELD' l_index INTO l_fieldname.
       CONCATENATE 'Field' l_index INTO l_fieldtext.
       l_tabname = '<GT_TABLE>'.
       PERFORM fieldcatalog USING: l_fieldname
                                   l_tabname
                                   l_fieldtext.
    ENDDO.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  CREATE_DYNAMIC_TABLE
    FORM create_dynamic_table .
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_dyn_tab.
      ASSIGN it_dyn_tab->* TO <gt_table>.
    Create dynamic work area and assign to FS
      CREATE DATA wa_newline LIKE LINE OF <gt_table>.
      ASSIGN wa_newline->* TO <fs_dyntable>.
    ENDFORM.                    " CREATE_DYNAMIC_TABLE
    *&      Form  FIELDCATALOG
    FORM fieldcatalog USING field table f_txt.
      wa_fcat-fieldname = field.
      wa_fcat-tabname   = table.
      wa_fcat-seltext = f_txt.
      APPEND wa_fcat TO it_fcat.
      CLEAR  wa_fcat.
    ENDFORM.                    " FIELDCATALOG
    *&      Form  FIELDCATALOG1
    FORM fieldcatalog1 USING field table f_txt.
      wa_fcatalog-fieldname = field.
      wa_fcatalog-tabname   = table.
      wa_fcatalog-seltext_m = f_txt.
      APPEND wa_fcatalog TO it_fcatalog.
      CLEAR  wa_fcatalog.
    ENDFORM.                    " FIELDCATALOG1
    *&      Form  SELECT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM select_data .
    DATA: v_srlno TYPE i.
      SELECT matnr charg blqty
      INTO CORRESPONDING FIELDS OF it_itab
      FROM zjpack_base
      WHERE matnr IN s_matnr
      AND   charg IN s_charg
      AND   fdate IN s_fdate.
        COLLECT it_itab.
      ENDSELECT.
    v_srlno.
    LOOP AT it_itab.
       v_srlno = v_srlno + 1.
    ENDLOOP.
      CLEAR: l_fieldname,
              l_tabname,
              l_fieldtext,
              l_index.
    1st Field
    l_index = sy-tabix.
      CONCATENATE 'FIELD' '1' INTO l_fieldname.
      l_fieldtext = 'MATNR'.
      l_tabname = '<GT_TABLE>'.
      PERFORM fieldcatalog USING: l_fieldname
                                  l_tabname
                                  l_fieldtext.
    Other fields
      LOOP AT it_itab.
        CLEAR l_index.
        l_index = sy-tabix + 1.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
        l_tabname = '<GT_TABLE>'.
        PERFORM fieldcatalog USING: l_fieldname
                                    l_tabname
                                    l_fieldtext.
      ENDLOOP.
    Please guide me how my problem will solve.
    Thanks & Regards
    Nirmal

    Hi all, I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
    *& Report  ZDYNAMIC_TEST                                               *
    REPORT  zdynamic_test                           .
    *REPORT  ztest_notepad.
    *& Declarations
    *Type-pools
    TYPE-POOLS: slis.
    *TABLES
    TABLES: zjpack_base.
    *Types
    TYPES:
          ty_fcat      TYPE lvc_s_fcat,
          ty_fcatalog  TYPE slis_fieldcat_alv.
    *Work areas
    DATA:
          wa_fcat      TYPE ty_fcat,
          wa_fcatalog  TYPE ty_fcatalog.
    *Internal tables
    DATA:
          it_fcat      TYPE STANDARD TABLE OF ty_fcat,
          it_fcatalog  TYPE STANDARD TABLE OF ty_fcatalog.
    *Type reference
    DATA:
          it_dyn_tab   TYPE REF TO data,
          wa_newline   TYPE REF TO data.
    *INTERNAL TABLE
    DATA: BEGIN OF it_itab OCCURS 0.
            INCLUDE STRUCTURE zjpack_base.
    DATA: END OF it_itab.
    *Filed symbols
    FIELD-SYMBOLS:
          <gt_table>   TYPE STANDARD TABLE,
          <fs_dyntable>,
          <fs_fldval>  TYPE ANY,
          <l_field>    TYPE ANY.
    *Variables
    DATA:
          l_fieldname  TYPE lvc_s_fcat-fieldname,
          l_tabname    TYPE lvc_s_fcat-tabname,
          l_fieldtext  TYPE lvc_s_fcat-seltext,
          l_index      TYPE char2.
    "Selection-screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
    SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
    SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
    SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
    SELECTION-SCREEN END OF BLOCK b1.
    PARAMETERS:
             p_colms   TYPE i.
    *& start-of-selection.
    START-OF-SELECTION.
      PERFORM select_data.
      PERFORM build_fieldcat.
      PERFORM create_dynamic_table.
    *  DO 20 TIMES.
    *    DO p_colms TIMES.
    *      l_index = sy-index.
    *      CONCATENATE 'FIELD' l_index INTO l_fieldname.
    *      ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
    *      <l_field> = sy-index.
    *    ENDDO.
    *    INSERT <fs_dyntable> INTO TABLE <gt_table>.
    *  ENDDO.
      LOOP AT it_itab.
        l_index = sy-tabix.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
        <l_field> = it_itab-matnr.
        INSERT <fs_dyntable> INTO TABLE <gt_table>.
      ENDLOOP.
      LOOP AT it_fcat INTO wa_fcat.
        PERFORM fieldcatalog1 USING: wa_fcat-fieldname
                                      wa_fcat-tabname
                                      wa_fcat-seltext.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_NOTEPAD'
          it_fieldcat        = it_fcatalog
        TABLES
          t_outtab           = <gt_table>.
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat .
    *  CLEAR: l_fieldname,
    *         l_tabname,
    *         l_fieldtext,
    *         l_index.
    *  DO  p_colms TIMES.
    *    CLEAR l_index.
    *    l_index = sy-index.
    *    CONCATENATE 'FIELD' l_index INTO l_fieldname.
    *    CONCATENATE 'Field' l_index INTO l_fieldtext.
    *    l_tabname = '<GT_TABLE>'.
    *    PERFORM fieldcatalog USING: l_fieldname
    *                                l_tabname
    *                                l_fieldtext.
    *  ENDDO.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  CREATE_DYNAMIC_TABLE
    FORM create_dynamic_table .
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_dyn_tab.
      ASSIGN it_dyn_tab->* TO <gt_table>.
    * Create dynamic work area and assign to FS
      CREATE DATA wa_newline LIKE LINE OF <gt_table>.
      ASSIGN wa_newline->* TO <fs_dyntable>.
    ENDFORM.                    " CREATE_DYNAMIC_TABLE
    *&      Form  FIELDCATALOG
    FORM fieldcatalog USING field table f_txt.
      wa_fcat-fieldname = field.
      wa_fcat-tabname   = table.
      wa_fcat-seltext = f_txt.
      APPEND wa_fcat TO it_fcat.
      CLEAR  wa_fcat.
    ENDFORM.                    " FIELDCATALOG
    *&      Form  FIELDCATALOG1
    FORM fieldcatalog1 USING field table f_txt.
      wa_fcatalog-fieldname = field.
      wa_fcatalog-tabname   = table.
      wa_fcatalog-seltext_m = f_txt.
      APPEND wa_fcatalog TO it_fcatalog.
      CLEAR  wa_fcatalog.
    ENDFORM.                    " FIELDCATALOG1
    *&      Form  SELECT_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM select_data .
    *  DATA: v_srlno TYPE i.
      SELECT matnr charg blqty
      INTO CORRESPONDING FIELDS OF it_itab
      FROM zjpack_base
      WHERE matnr IN s_matnr
      AND   charg IN s_charg
      AND   fdate IN s_fdate.
        COLLECT it_itab.
      ENDSELECT.
    *  v_srlno.
    *  LOOP AT it_itab.
    *    v_srlno = v_srlno + 1.
    *  ENDLOOP.
      CLEAR: l_fieldname,
              l_tabname,
              l_fieldtext,
              l_index.
    * 1st Field
    *  l_index = sy-tabix.
      CONCATENATE 'FIELD' '1' INTO l_fieldname.
      l_fieldtext = 'MATNR'.
      l_tabname = '<GT_TABLE>'.
      PERFORM fieldcatalog USING: l_fieldname
                                  l_tabname
                                  l_fieldtext.
    * Other fields
      LOOP AT it_itab.
        CLEAR l_index.
        l_index = sy-tabix + 1.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
        l_tabname = '<GT_TABLE>'.
        PERFORM fieldcatalog USING: l_fieldname
                                    l_tabname
                                    l_fieldtext.
      ENDLOOP.
    ENDFORM.                    " SELECT_DATA

  • Dynamic ALV and cl_abap_structdescr Create method

    Hi
    In the process of creation of Dynamic ALV, as I have char_name and char_descr fields, I have to use char_descr as column header of ALV because char_name which has entries something like DVS_******(that do not make any sense to user). I am facing 2 problems here using the scenario above.
    1. char_descr contains characters like '[', ']', ' /', '.', space which are invalid characters for method cl_abap_structdescr=>create(). How to handle scenario like this?
    2. assign (lv_value) to <value>.
            if sy-subrc = 0.
              <value> = ls_bapi_char_value-charvalue.
              if <value> is assigned.
                move ls_bapi_char_value-charvalue to <value>.
    where-> concatenate '<table_dyn_wa>-' ls_bapi_char-char_descr into lv_value
                   <value> type any
                  <table_dyn_wa>- is dynamic table with structure created with cl_abap_tabledescr=>create( p_line_type = stru_type )
    with above code for few fields data is being assigned and for few sy-subrc = 4. The table from where I am reading the field contains char_name associated with it and not char_descr. For the fields whose char_name and char_descr matches exactly, ALV displays data for it.
    How to resolve the issue so that I could get all the data?
    Let me know if further details are needed.
    Thanks, in advance
    Trupti
    Edited by: TRUPTI KALLURWAR on Jul 9, 2010 7:08 PM

    Hello Srikanth,
    CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE( ) uses the GENERATE SUBROUTINE POOL technique to create the dynamic internal tables.
    And as per the SAP documentation,
    In an internal mode, a maximum of 36 temporary subroutine pools may be created.
    Source: [http://help.sap.com/abapdocu_702/en/abapgenerate_subroutine_pool.htm]
    Btw why are you crating 36 dynamic internal table? That's way too far-fetched even for the RTTC classes
    BR,
    Suhas

  • Problem in Dynamic ALV - inserting values in proper field of a table.

    Hi gurus,
    As per the user requirement I need to create a dynamic alv report. The fields will be display according to the period entered.
    I have already build the alv and it is working fine. But My questio is how can I append data into internal table in its proper field.
    suppose I have enter period 1 to 3 in selection screen. Then my table structure will be
    JAN |  FEB | MAR
    Upto this is is working fine, fields are generated dynamically , but how can I insert data only in perticular field.
    like
    itab-JAN = 001.
    itab-FEB = 002.
    itab-MAR = 003.
    append itab
    JAN |  FEB | MAR
    001    002   003
    Please give me a solution of that. waiting for reply.

    hI,
    loop at <dyn_table> assigning <wa>.
    lv_count = 001.
    *perform get_short_tet of month in a varibale say lv_var
    assign component LV_VAR of structure <wa> to <dyn_field1>.
    <dyn_field1> = lv_count.
    lv_count = lv_count + 1.
    endloop.
    Regards,
    mrunal
    Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:53 AM
    Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:54 AM

  • SUBTOTAL TEXT IN ALV GRID

    HI ALL,
    could any one  send me how to display the subtotal Text  in ALV grid output with code sample.
    with thanks.
    kannan

    hi,
    means u want to print some text instead of star ( coming in subtotal) ?
    If so than try like,
    *& Report  ZALV_LIST
    REPORT  zalv_list.
    TABLES : mseg.
    TYPE-POOLS : slis.
    DATA : BEGIN OF itab OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab.
    DATA : BEGIN OF itab1 OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab1.
    DATA : t_fcat TYPE slis_t_fieldcat_alv,
           t_eve TYPE slis_t_event,
           t_subtot TYPE slis_t_sortinfo_alv,
           subtot LIKE LINE OF t_subtot,
           wa_fcat LIKE LINE OF t_fcat,
           gd_layout    TYPE slis_layout_alv.
    DATA : gt_menge LIKE mseg-menge,
           st_menge LIKE mseg-menge.
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : doc FOR mseg-mblnr.
    SELECTION-SCREEN : END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cat USING t_fcat.
      PERFORM build_eve.
      PERFORM build_layout.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM display.
    *&      Form  build_cat
          text
         -->TEMP_FCAT  text
    FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-seltext_m = 'Material Doc.'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MENGE'.
      wa_fcat-seltext_m = 'Quantity'.
    wa_fcat-do_sum = 'Y'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    subtot-spos = 1.
    subtot-fieldname = 'MBLNR'.
    subtot-tabname = 'ITAB'.
    subtot-up = 'X'.
    subtot-group = 'X'.
    subtot-subtot = 'X'.
    subtot-expa = 'X'.
    APPEND subtot TO t_subtot.
    ENDFORM.                    "build_cat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA : wa_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        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.
      READ TABLE t_eve WITH KEY name =  slis_ev_top_of_page
                             INTO wa_eve.
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE' TO wa_eve-form.
        APPEND wa_eve TO t_eve.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  build_layout
          text
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-info_fieldname =      'LINE_COLOR'.
      gd_layout-subtotals_text = 'Sub Total'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  get_data
          text
    FORM get_data.
      SELECT mblnr matnr werks menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
      WHERE mblnr IN doc.
      SORT itab BY mblnr.
      LOOP AT itab.
        AT NEW mblnr.
          LOOP AT itab WHERE mblnr = itab-mblnr.
            st_menge = st_menge + itab-menge.
            itab1-mblnr = itab-mblnr.
            itab1-matnr = itab-matnr.
            itab1-werks = itab-werks.
            itab1-menge = itab-menge.
            APPEND itab1.
          ENDLOOP.
          itab1-mblnr = 'Sub_Total'.
          itab1-matnr = ''.
          itab1-werks = ''.
          itab1-menge = st_menge.
          itab1-line_color = 'C710'.
          APPEND itab1.
          itab1-line_color = ''.
          CLEAR st_menge.
        ENDAT.
      ENDLOOP.
      LOOP AT itab.
        gt_menge = gt_menge + itab-menge.
      ENDLOOP.
      itab1-mblnr = 'Total'.
      itab1-matnr = ''.
      itab1-werks = ''.
      itab1-menge = gt_menge.
      itab1-line_color = 'C310'.
      APPEND itab1.
    ENDFORM.                    "get_data
    *&      Form  display
          text
    FORM display.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = 'ZALV_LIST'
         is_layout                      = gd_layout
         it_fieldcat                    = t_fcat
        it_sort                        = t_subtot
         it_events                      = t_eve
        TABLES
          t_outtab                       = itab1
    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
    *&      Form  top_of_page
          text
    FORM top_of_page.
      WRITE:/ 'Data'.
    ENDFORM.                    "top_of_page
    reward if useful....
    Edited by: Dhwani shah on Dec 20, 2007 1:20 PM

  • Problem in print out of Dynamic ALV

    Hi ,
    I am using dynamic ALV to address a requirement. The ALV is working fine and the output is also coming corretly, even in spool.
    But if the width of dynamic table exceeds a limit, then nothing is coming in the print out.
    If anyone has faced similar problem or knows how to tackle this problem, please advise what can be done here.
    Thanks,
    Sonal

    Hi,
    Can you try to increase field with to maximun as per your requirement.
    Regards,
    Sai

  • Color Cell in Dynamic ALV

    Hi all
    i try to put color in the dynamic alv, but i become a dump message
    Runtime Errors         OBJECTS_MOVE_NOT_SUPPORTED
    Date and Time          28.10.2010 08:46:49
    Short text
         Conversion of type "h" to type "g" not supported.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLSLVC" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    Error analysis
         You attempted to move one data object to another.
         This is not possible here because the conversion of a data object
         of type "h" to type "g" is not supported.
    my code implementation looks like
      method validate_order_deli.
        data ls_scol        type lvc_s_scol.
        data ls_colo        type lvc_s_colo.
        data ls_aoc_percent type zsd_aoc_percent.
        data lf_deliv       type lifmg.
        data lf_db_percent  type f.
        data lf_calc_perc   type f.
        refresh et_color.
        select single *
          from zsd_aoc_percent
          into corresponding fields of ls_aoc_percent
          where acin = 'X'.
        if sy-subrc <> 0.
          exit.
        endif.
        lf_db_percent = ls_aoc_percent-percent.
    *    ls_scol-fname = if_fieldname.
        ls_scol-fname = 'MATNR'.
        if if_deliv <> 0.
          me->calc_amour_unit(
            exporting
              if_matnr  = if_matnr
              if_amount = if_deliv
              if_input  = if_deliv_unit
              if_output = if_order_unit
            importing
              ef_amount = lf_deliv
          lf_calc_perc = ( lf_deliv * 100 ) / if_order.
          if lf_calc_perc < lf_db_percent.
            ls_colo-col = cl_gui_resources=>list_col_positive.
          else.
            ls_colo-col = cl_gui_resources=>list_col_negative.
          endif.
          ls_scol-color = ls_colo.
          append ls_scol to et_color.
        else.
          exit.
        endif.
      endmethod.                    "validate_order_deli
      method add_color_field.
        data ls_fcat type lvc_s_fcat.
        ls_fcat-fieldname = 'COLOR'.
        ls_fcat-ref_field = 'COLTAB'.
        ls_fcat-ref_table = 'CALENDAR_TYPE'.
        append ls_fcat to ct_fcat.
      endmethod.                    "add_color_field
          ls_lvc_s_layo-cwidth_opt = 'X'.
          ls_lvc_s_layo-ctab_fname  = 'COLOR'.
    i don't no, what's wrong...
    thx for help

    *&      Form  generate_alv
    *       text
    form generate_alv.
      field-symbols <lt_any_table> type any table.
      if lrf_gui_custom_container is initial.
        create object lrf_gui_custom_container
          exporting
            container_name = lf_container.
        create object lrf_gui_alvgrid
          exporting
            i_parent = lrf_gui_custom_container.
        ls_lvc_s_layo-cwidth_opt = 'X'.
        ls_lvc_s_layo-ctab_fname  = 'COLOR'.
        check sy-subrc = 0.
        call method lrf_gui_alvgrid->set_table_for_first_display
             exporting
    *             i_buffer_active               =
    *             i_bypassing_buffer            =
    *             i_consistency_check           =
    *             i_structure_name              = 'ZAM_CELL_COLOR'
    *             is_variant                    = ls_disvariant
    *             i_save                        = 'A'
    *             i_default                     = 'X'
               is_layout                     = ls_lvc_s_layo
    *             is_print                      =
    *             it_special_groups             =
    *             it_toolbar_excluding          =
    *             it_hyperlink                  =
    *             it_alv_graphics               =
    *             it_except_qinfo               =
    *             ir_salv_adapter               =
              changing
                it_outtab                     = <gt_table>
                it_fieldcatalog               = gt_dyn_fcat
    *             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.
      endif.
    endform.                    "generate_alv
    *&      Module  STATUS_0100  OUTPUT
    *       text
    module status_0100 output.
      set pf-status 'ZAM_CELL_STATUS'.
      set titlebar 'ZAM_CELL_TIT'.
      perform generate_alv.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    module user_command_0100 input.
      data lf_okcode type syucomm.
      call method cl_gui_cfw=>dispatch.
      lf_okcode = ok_code.
      case lf_okcode.
        when 'EXIT'.
          set screen 0.
          leave screen.
        when 'CANCEL'.
          leave program.
        when 'BACK'.
          set screen 0.
          leave screen..
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT

  • To activate total & subtotal button in ALV by class

    Hi,
    Kindly suggest how to activate total & subtotal button in ALV by class. I have used layout configuration by lvc_s_layo.
    gs_layout type lvc_s_layo.
    Ashutosh Kumar

    Dears,
    Do_SUM is not available in gs_layout type lvc_s_layo.
    Its working only in function module REUSE_ALV_LIST_DISPLAY.
    How to use in class ALV.
    FORM SUB_CREATE_FIELDCATALOG .
    THIS BELOW FIELD IS EDITABLE
    PERFORM APPEND_FIELDCAT USING:'MATNR'
                                  'Material No.'
                                  'CHAR'
                                  '30'
    PERFORM APPEND_FIELDCAT USING:'MATKL'
                                  'DOCUMENT TYPE'
                                  'CHAR'
                                  '10'
    PERFORM APPEND_FIELDCAT USING:''
                                  'CHAR'
                                  '4'
                                  'C610'
          PERFORM APPEND_FIELDCAT USING:'NTGEW'
                                  'NET WT'
                                  'P'
                                  '10'
                                  'C610'
                                  'X'.
        PERFORM APPEND_FIELDCAT USING:'VOLTO'
                                  'VOLUME'
                                  'P'
                                  '10'
                                  'C610'
                                  'X'.
         PERFORM APPEND_FIELDCAT USING:'VPREH'
                                  'COST'
                                  'P'
                                  '10'
                                  'C610'
    ENDFORM.                    " SUB_CREATE_FIELDCATALOG
    *&      FORM  APPEND_FIELDCAT
          TEXT
         -->P_0116   TEXT
         -->P_0117   TEXT
         -->P_0118   TEXT
         -->P_0119   TEXT
         -->P_0120   TEXT
         -->P_10     TEXT
    FORM APPEND_FIELDCAT  USING    P_114
                                   P_115
                                   P_116
                                   P_117
                                   P_118
                                   P_119.
      CLEAR GT_FIELDCAT_LVC.
      GT_FIELDCAT_LVC-FIELDNAME = P_114.
      GT_FIELDCAT_LVC-COLTEXT = P_115.
      GT_FIELDCAT_LVC-DATATYPE = P_116.
      GT_FIELDCAT_LVC-OUTPUTLEN    = P_117.
      GT_FIELDCAT_LVC-EMPHASIZE = P_118.
      GT_FIELDCAT_LVC-do_sum = P_119.
       append gt_fieldcat_lvc.

  • I want  to create dynamic ALV report

    Hi great abapers,
    I want  to create dynamic ALV report.Please help me.
    Regards,
    Billa

    Hi,
    Please check the code below:
    REPORT YMMR_PALLET_OVERVIEW MESSAGE-ID Y_MESSAGE_0001.
    Short description:
    To Display and sum up the Quantity of scanned materials on pallet for*
    each Shipment number for the Packaging Materials. *
    TYPE-POOLS : SLIS.
    TABLES: YYLE0003. " Scanned SSCC No.
    --Structure Declaration--
    Structure for Shipment No. and Date.
    TYPES : BEGIN OF T_VTTK_TAB ,
    TKNUM LIKE VTTK-TKNUM, " Shipment number
    ERDAT LIKE VTTK-ERDAT, " created Date
    END OF T_VTTK_TAB .
    Structure for Shipment No., Packaging Materials and Date.
    TYPES: BEGIN OF T_ITAB2,
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P,
    ERDAT LIKE YYLE0003-ERDAT, " created Date
    COUNT TYPE I,
    END OF T_ITAB2.
    Structure for Shipment No. and Packaging Materials.
    TYPES: BEGIN OF T_ITAB3,
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P, " Quantity
    END OF T_ITAB3.
    --Internal table Declaration--
    *Internal tables for the above Declared structures
    DATA: G_VTTK_TAB TYPE TABLE OF T_VTTK_TAB,
    G_ITAB5_TAB TYPE TABLE OF T_ITAB2,
    G_ITAB4_TAB TYPE TABLE OF T_ITAB3,
    G_ITAB3_TAB TYPE TABLE OF T_ITAB2. "#EC NEEDED
    *Internal table Holding Shipment No.and quantity
    DATA: BEGIN OF G_TOTAL_TAB OCCURS 0 ,
    TKNUM TYPE YYLE0003-TKNUM, " Shipment number
    QUANTITY TYPE P,
    COUNT TYPE I,
    END OF G_TOTAL_TAB .
    *Internal table for selection screen data
    DATA: BEGIN OF G_SCANDATA_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    EXIDV TYPE EXIDV, " External Handling Unit
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    END OF G_SCANDATA_TAB.
    DATA: BEGIN OF ST_SCANDATA_TAB,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    EXIDV TYPE EXIDV, " External Handling Unit
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    END OF ST_SCANDATA_TAB.
    DATA: BEGIN OF G_SCANDATA_COUNT_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    COUNT TYPE I,
    END OF G_SCANDATA_COUNT_TAB.
    DATA: L_COUNT TYPE I.
    *Internal table for Packaging Materials and quantity
    DATA: BEGIN OF G_ITAB6_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P, " Quantity
    END OF G_ITAB6_TAB.
    *- Field catalog
    DATA: L_ALV_CAT1_TAB TYPE TABLE OF LVC_S_FCAT.
    --Work area Declaration--
    DATA: WA_VTTK TYPE T_VTTK_TAB,
    WA_ITAB3 TYPE T_ITAB2,
    WA_ITAB5 TYPE T_ITAB2,
    WA_ITAB4 TYPE T_ITAB3,
    WA_ITAB1 LIKE G_SCANDATA_TAB,
    WA_ALV_CAT1 LIKE LINE OF L_ALV_CAT1_TAB.
    ----Variable Defnition -
    DATA: G_CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    G_ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
    G_CONTAINER_0100 TYPE SCRFNAME VALUE 'LIST',
    G_MYLAYOUT TYPE LVC_S_LAYO, "#EC NEEDED
    G_WA TYPE REF TO DATA.
    DATA: G_VAR TYPE I, " No of records
    G_VAR1 TYPE CHAR20. " Variable
    --field symbols Declaration--
    FIELD-SYMBOLS : <F_FS> TYPE TABLE,
    <F_FS3> TYPE ANY,
    <F_FS4> TYPE ANY,
    <F_FS5> TYPE ANY,
    <F_WA> TYPE ANY,
    <F_FS15> TYPE ANY,
    <F_FS16> TYPE SY-DATUM,
    <F_FS2> TYPE T_ITAB2,
    <F_FS6> TYPE ANY,
    <F_FS7> TYPE ANY,
    <F_FS12> TYPE ANY,
    <F_FS13> TYPE ANY.
    --Selection Parameters--
    SELECTION-SCREEN: BEGIN OF BLOCK BLCK01 WITH FRAME TITLE TEXT-000.
    "Select options
    SELECT-OPTIONS :
    S_TKNUM FOR YYLE0003-TKNUM , " Shipment number
    S_YYREF FOR YYLE0003-YY_REFERENCE, " Packing reference
    S_YYREFT FOR YYLE0003-YY_REFTP, " Reference type
    S_EXIDV FOR YYLE0003-EXIDV, " External HU
    S_MATNR FOR YYLE0003-MATNR, " Material number
    S_VBELN FOR YYLE0003-VBELN, " SD number
    S_POSNR FOR YYLE0003-POSNR, " Item number
    S_LGTOR FOR YYLE0003-LGTOR, " Door for Wr Hs No
    S_VHILM FOR YYLE0003-VHILM, " Packaging Mat
    S_YYMEIN FOR YYLE0003-YY_MEINH, " Indicator for UOM
    S_QUANTI FOR YYLE0003-QUANTITY, " Quantity
    S_YCHECK FOR YYLE0003-YYCHECKED, " Destination_door
    S_STATUS FOR YYLE0003-STATUS, " Packing status
    S_STASHI FOR YYLE0003-STATUSSHIPTO, " Status on ship-to
    S_LOADTR FOR YYLE0003-LOADTRUCK, " Load truck
    S_ERDAT FOR YYLE0003-ERDAT , " Date
    S_ERZET FOR YYLE0003-ERZET, " Entry time
    S_AEDAT FOR YYLE0003-AEDAT, " Last changed on
    S_ERNAM FOR YYLE0003-ERNAM, " Name of Person
    S_AEZET FOR YYLE0003-AEZET, " Time last change
    S_AENAM FOR YYLE0003-AENAM. " Name of person
    SELECTION-SCREEN: END OF BLOCK BLCK01.
    --INITIALIZATION--
    INITIALIZATION.
    Clear the variables and workarea
    CLEAR :G_VAR,
    G_VAR1,
    WA_VTTK,
    WA_ITAB3,
    WA_ITAB5,
    WA_ITAB4,
    WA_ITAB1,
    WA_VTTK,
    WA_ITAB3,
    WA_ITAB5,
    WA_ITAB4,
    WA_ITAB1.
    --AT SELECTION-SCREEN--
    AT SELECTION-SCREEN.
    To validate the data entered in selection screen
    PERFORM SUB_VALIDATE.
    --START-OF-SELECTION--
    START-OF-SELECTION.
    *To fetch the data from table yyle0003
    PERFORM GET_INPUT_DATA.
    *To create the Dynamic Field Catalog
    PERFORM GET_FIELDCAT.
    To populate the data to final table
    PERFORM GET_FINAL_DATA.
    MODULE status_0100 OUTPUT *
    MODULE STATUS_0100 OUTPUT.
    *set title bar and PF status.
    SET PF-STATUS 'ZVKS'.
    SET TITLEBAR 'ZVKS'.
    CHECK SY-UCOMM IS INITIAL.
    SORT G_SCANDATA_TAB BY TKNUM VHILM.
    *Create object for Custom container
    CREATE OBJECT G_CUSTOM_CONTAINER_0100
    EXPORTING
    CONTAINER_NAME = G_CONTAINER_0100
    EXCEPTIONS
    CNTL_ERROR = 1
    CNTL_SYSTEM_ERROR = 2
    CREATE_ERROR = 3
    LIFETIME_ERROR = 4
    LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    *Create object for ALV grid
    CREATE OBJECT G_ALV_GRID_0100
    EXPORTING I_PARENT = G_CUSTOM_CONTAINER_0100.
    G_MYLAYOUT-GRID_TITLE = 'Display Scanning data'.
    *Call method for table Display
    CALL METHOD G_ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
    CHANGING
    IT_OUTTAB = <F_FS>
    IT_FIELDCATALOG = L_ALV_CAT1_TAB
    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.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    User Interaction
    MODULE USER_COMMAND_0100 INPUT.
    CALL METHOD CL_GUI_CFW=>DISPATCH.
    *To exit , back or cancel
    CASE SY-UCOMM.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
    LEAVE PROGRAM.
    WHEN OTHERS.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Form get_input_data
    This sub routine will get the data from yyle0003 table.
    FORM GET_INPUT_DATA.
    CONSTANTS: C_DOT TYPE C VALUE '.',
    C_CHAR TYPE C VALUE 'D'.
    CLEAR G_SCANDATA_TAB.
    Get the data from yyle0003
    SELECT VHILM " Packaging Materials
    EXIDV " External Handling Unit
    TKNUM " Shipment number
    QUANTITY " Quantity
    FROM YYLE0003
    INTO TABLE G_SCANDATA_TAB
    WHERE TKNUM IN S_TKNUM " Shipment number
    AND YY_REFERENCE IN S_YYREF " Packing reference
    AND YY_REFTP IN S_YYREFT " Reference type
    AND EXIDV IN S_EXIDV " External Handling Unit
    AND MATNR IN S_MATNR " Material number
    AND VBELN IN S_VBELN " SD number
    AND POSNR IN S_POSNR " Item number
    AND LGTOR IN S_LGTOR " Door for warehouse No
    AND VHILM IN S_VHILM " Packaging Materials
    AND YY_MEINH IN S_YYMEIN " Indicator for UOM
    AND QUANTITY IN S_QUANTI " Quantity
    AND YYCHECKED IN S_YCHECK " Destination_door
    AND STATUS IN S_STATUS " Packing status
    AND STATUSSHIPTO IN S_STASHI " Status on ship-to
    AND LOADTRUCK IN S_LOADTR " Load truck
    AND ERDAT IN S_ERDAT " Date
    AND ERZET IN S_ERZET " Entry time
    AND AEDAT IN S_AEDAT " Last changed on
    AND ERNAM IN S_ERNAM " Name of Person
    AND AEZET IN S_AEZET " Time last change
    AND AENAM IN S_AENAM. " Name of person
    If VHILM contains any Decimal '.', replace it with D
    LOOP AT G_SCANDATA_TAB.
    REPLACE C_DOT WITH C_CHAR INTO G_SCANDATA_TAB-VHILM.
    IF SY-SUBRC = 0.
    MODIFY G_SCANDATA_TAB TRANSPORTING VHILM.
    ENDIF.
    CLEAR G_SCANDATA_TAB.
    ENDLOOP.
    *To get the Shipment No Creation date from VTTK.
    SELECT TKNUM
    ERDAT
    FROM VTTK
    INTO TABLE G_VTTK_TAB
    WHERE TKNUM IN S_TKNUM.
    SORT G_SCANDATA_TAB BY VHILM EXIDV. "TKNUM VHILM.
    *To get the repeatition of Pacakaging material for each Shipment.
    *--- to find the count of packaging materials under each shipment
    LOOP AT G_SCANDATA_TAB.
    READ TABLE G_SCANDATA_TAB INTO ST_SCANDATA_TAB INDEX SY-TABIX.
    AT END OF EXIDV.
    L_COUNT = L_COUNT + 1.
    MOVE-CORRESPONDING ST_SCANDATA_TAB TO G_SCANDATA_COUNT_TAB.
    G_SCANDATA_COUNT_TAB-COUNT = L_COUNT.
    CLEAR: ST_SCANDATA_TAB, L_COUNT.
    COLLECT G_SCANDATA_COUNT_TAB.
    ENDAT.
    CLEAR : G_SCANDATA_TAB.
    ENDLOOP.
    ENDFORM. " get_input_data
    *& Form sub_validate
    *This subroutine will validate the data eneterd in the selection screen
    FORM SUB_VALIDATE.
    *Varaiable declaration for Shipment number
    DATA: L_TKNUM TYPE YYLE0003-TKNUM."#EC NEEDED " Shipment number
    *- Condition will not qualify all primary key (IDENT)
    SELECT TKNUM FROM YYLE0003 UP TO 1 ROWS
    INTO L_TKNUM "wa_scandata
    WHERE TKNUM IN S_TKNUM " Shipment number
    AND YY_REFERENCE IN S_YYREF " Packing reference
    AND YY_REFTP IN S_YYREFT " Reference type
    AND EXIDV IN S_EXIDV " External Handling Unit
    AND MATNR IN S_MATNR " Material number
    AND VBELN IN S_VBELN " SD number
    AND POSNR IN S_POSNR " Item number
    AND LGTOR IN S_LGTOR " Door for warehouse No
    AND VHILM IN S_VHILM " Packaging Materials
    AND YY_MEINH IN S_YYMEIN " Indicator for UOM
    AND QUANTITY IN S_QUANTI " Quantity
    AND YYCHECKED IN S_YCHECK " Destination_door
    AND STATUS IN S_STATUS " Packing status
    AND STATUSSHIPTO IN S_STASHI " Status on ship-to
    AND LOADTRUCK IN S_LOADTR " Load truck
    AND ERDAT IN S_ERDAT " Date
    AND ERZET IN S_ERZET " Entry time
    AND AEDAT IN S_AEDAT " Last changed on
    AND ERNAM IN S_ERNAM " Name of Person
    AND AEZET IN S_AEZET " Time last change
    AND AENAM IN S_AENAM. " Name of person
    ENDSELECT.
    IF SY-SUBRC <> 0.
    MESSAGE E987 . " No data found for these selection criterias
    ENDIF.
    ENDFORM. " sub_validate
    *& Form get_fieldcat
    Preparing Field catalog
    FORM GET_FIELDCAT.
    DATA: L_REF TYPE REF TO DATA,
    L_I TYPE I. " Variable
    CONSTANTS: C_CENTER TYPE C VALUE 'C'. " Center Justified
    LOOP AT G_SCANDATA_TAB INTO WA_ITAB1.
    MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB3.
    APPEND WA_ITAB3 TO G_ITAB3_TAB.
    MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB4.
    COLLECT WA_ITAB4 INTO G_ITAB4_TAB.
    *To sum up the qunatity field for each TKNUM.
    AT END OF TKNUM.
    SUM.
    MOVE WA_ITAB1-TKNUM TO G_TOTAL_TAB-TKNUM.
    MOVE WA_ITAB1-QUANTITY TO G_TOTAL_TAB-QUANTITY .
    APPEND G_TOTAL_TAB.
    CLEAR G_TOTAL_TAB.
    ENDAT.
    CLEAR : WA_ITAB1,
    WA_ITAB3,
    WA_ITAB4.
    ENDLOOP.
    *--- Begin of change - SKR.EXT - EBDK986377
    SORT G_ITAB4_TAB BY TKNUM.
    *--- End of change - SKR.EXT - EBDK986377
    LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
    MOVE-CORRESPONDING WA_ITAB4 TO WA_ITAB5.
    MOVE-CORRESPONDING WA_ITAB4 TO G_ITAB6_TAB.
    *---- to get the count
    READ TABLE G_SCANDATA_COUNT_TAB WITH KEY TKNUM = WA_ITAB5-TKNUM
    VHILM = WA_ITAB5-VHILM.
    IF SY-SUBRC EQ 0.
    WA_ITAB5-COUNT = G_SCANDATA_COUNT_TAB-COUNT.
    ENDIF.
    APPEND WA_ITAB5 TO G_ITAB5_TAB.
    COLLECT G_ITAB6_TAB.
    ENDLOOP.
    CLEAR : WA_ITAB3.
    SORT G_ITAB4_TAB BY TKNUM VHILM.
    DELETE ADJACENT DUPLICATES FROM G_ITAB4_TAB COMPARING VHILM.
    *To get the Number of fields to be displayed
    DESCRIBE TABLE G_ITAB4_TAB LINES G_VAR.
    L_I = '3'.
    *Field catalog
    WA_ALV_CAT1-FIELDNAME = 'TKNUM'(002).
    WA_ALV_CAT1-COL_POS = 1.
    WA_ALV_CAT1-COLTEXT ='ShipmentNo.'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR : WA_ALV_CAT1.
    WA_ALV_CAT1-FIELDNAME = 'ERDAT'(003).
    WA_ALV_CAT1-COL_POS = 2.
    WA_ALV_CAT1-COLTEXT ='Creation_Date.'(005).
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR : WA_ALV_CAT1.
    Create field catalog for each of VHILM
    LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
    IF G_VAR >= 1.
    CONDENSE WA_ITAB4-VHILM NO-GAPS.
    WA_ALV_CAT1-FIELDNAME = WA_ITAB4-VHILM. "l_fieldname.
    WA_ALV_CAT1-COL_POS = L_I.
    WA_ALV_CAT1-COLTEXT = WA_ITAB4-VHILM.
    WA_ALV_CAT1-JUST = C_CENTER. "'C'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR WA_ALV_CAT1.
    L_I = L_I + 1.
    ENDIF.
    *TOTAL-last column in the field catalog
    AT LAST.
    WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
    WA_ALV_CAT1-COL_POS = L_I.
    WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
    WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR WA_ALV_CAT1.
    ENDAT.
    SORT L_ALV_CAT1_TAB BY FIELDNAME.
    *Non of the field name should not get repeated
    DELETE ADJACENT DUPLICATES FROM L_ALV_CAT1_TAB.
    ENDLOOP.
    SORT L_ALV_CAT1_TAB BY COL_POS.
    *Creating Dynamic Internal table
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
    IT_FIELDCATALOG = L_ALV_CAT1_TAB
    IMPORTING
    EP_TABLE = L_REF.
    Assigning the Dynamic field Catalog to field symbol.
    ASSIGN L_REF->* TO <F_FS>.
    CREATE DATA G_WA LIKE LINE OF <F_FS>.
    ASSIGN G_WA->* TO <F_WA>.
    DELETE ADJACENT DUPLICATES FROM <F_FS> COMPARING ALL FIELDS.
    ENDFORM. " get_fieldcat
    *& Form display_data
    FORM GET_FINAL_DATA.
    *variable declaration
    DATA: L_TOTAL TYPE I, " Row wise total
    L_FILL TYPE I, " Count
    L_TOT TYPE I. " Grand total
    *To get the TOTAL qunatity in the last line of out put.
    LOOP AT G_ITAB6_TAB.
    CLEAR WA_ITAB5.
    WA_ITAB5-TKNUM = 'TOTAL'(004).
    WA_ITAB5-ERDAT = SPACE.
    MOVE-CORRESPONDING G_ITAB6_TAB TO WA_ITAB5 .
    LOOP AT G_SCANDATA_COUNT_TAB WHERE VHILM = G_ITAB6_TAB-VHILM.
    WA_ITAB5-COUNT = WA_ITAB5-COUNT + G_SCANDATA_COUNT_TAB-COUNT.
    ENDLOOP.
    APPEND WA_ITAB5 TO G_ITAB5_TAB.
    CLEAR WA_ITAB5.
    ENDLOOP.
    DESCRIBE TABLE G_ITAB5_TAB LINES L_TOT.
    *>>>>>>>>
    ****To get total qunatity of all TKNUM
    LOOP AT G_TOTAL_TAB .
    L_TOTAL = L_TOTAL + G_TOTAL_TAB-QUANTITY.
    ENDLOOP.
    *>>>>>>>>
    *To assign ERDAT to g_itab5_tab
    LOOP AT G_ITAB5_TAB INTO WA_ITAB5 .
    READ TABLE G_VTTK_TAB INTO WA_VTTK WITH KEY TKNUM = WA_ITAB5-TKNUM.
    IF SY-SUBRC = 0.
    WA_ITAB5-ERDAT = WA_VTTK-ERDAT.
    MODIFY G_ITAB5_TAB FROM WA_ITAB5 TRANSPORTING ERDAT.
    ENDIF.
    ENDLOOP.
    *Assigning value in each field to respective Field symbols.
    LOOP AT G_ITAB5_TAB ASSIGNING <F_FS2>.
    CLEAR G_TOTAL_TAB-QUANTITY.
    ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_FS2> TO <F_FS6>.
    ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_WA> TO <F_FS7>.
    <F_FS7> = <F_FS6>.
    CONDENSE <F_FS2>-VHILM NO-GAPS.
    ASSIGN COMPONENT 'VHILM' OF STRUCTURE <F_FS2> TO <F_FS3>.
    ASSIGN COMPONENT 5 OF STRUCTURE <F_FS2> TO <F_FS4>.
    MOVE <F_FS3> TO G_VAR1.
    ASSIGN COMPONENT G_VAR1 OF STRUCTURE <F_WA> TO <F_FS5>.
    <F_FS5> = <F_FS4>.
    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_FS2> TO <F_FS16>.
    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_WA> TO <F_FS15>.
    WRITE <F_FS16> TO <F_FS15> .
    Inorder not to display the date '00/00/000',
    if there is no DATE .
    IF ( <F_FS15> CP '00/*' )
    OR ( <F_FS15> CP '00.*' )
    OR ( <F_FS15> CP '00-*' ).
    <F_FS15> = SPACE.
    ELSEIF ( <F_FS15> CO ' / /' )
    OR ( <F_FS15> CO ' . .' )
    OR ( <F_FS15> CO ' - -' ) .
    <F_FS15> = SPACE.
    ENDIF.
    READ TABLE G_TOTAL_TAB WITH KEY TKNUM = <F_FS6>.
    IF SY-SUBRC = 0.
    ASSIGN G_TOTAL_TAB-QUANTITY TO <F_FS12>.
    ASSIGN COMPONENT 'COUNT' OF STRUCTURE <F_FS2> TO <F_FS12>.
    ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
    <F_FS13> = <F_FS13> + <F_FS12>.
    L_TOTAL = L_TOTAL + <F_FS12>.
    ENDIF.
    L_FILL = L_FILL + 1.
    IF L_FILL = L_TOT.
    ASSIGN L_TOTAL TO <F_FS12>.
    ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
    <F_FS13> = <F_FS12>.
    ENDIF.
    AT END OF <F_FS2>-TKNUM.
    APPEND <F_WA> TO <F_FS>.
    CLEAR <F_WA>.
    ENDAT.
    ENDLOOP.
    CLEAR: <F_FS6>,
    <F_FS7>,
    <F_WA>.
    *Call the screen where Custom container is defined
    CALL SCREEN 0100.
    ENDFORM. " display_data
    Regards
    Kannaiah

Maybe you are looking for

  • Purchase requisition got deleted in the sales order..

    Hi All, I got stuck up with an issue in AFS. The issue is that after creating a P.O with the help of a TAB order,the user has assigned a rejection reason at the item level in the sales order. Then again the rejection reason was removed and now the pu

  • Text input - how set an automated space after each word?

    When typing in text and using the qwerty assisted text - how can i get it to automatically add a space after each word? My Droid original did that automatically... Thanks

  • "Other" storage taking up all my HD space

    My HD space is being taken up by "other".  I believe this to be caused by an iMail application problem related to recovered mail being stored somewhere on my HD.  I've had problem with sending and receiving emails from day one and often times receive

  • Prebooking workflows in LSO ...?

    Hi All, We are using ECC 6.0, Portal 7.0 SP12, Bussiness package myERP 2005 (1.0), Webdynpro ESS 600, LSO Backend 600, LSO FE 600. We are facing critical issue in terms of prebooking a training event. In LSO there are no workflow involved for the pre

  • OA Framework error when running the test_fwktutorial.jsp file? Please Help?

    Exception Details. oracle.apps.fnd.framework.OAException: Application: FND, Message Name: SYSTEM-ERROR. Tokens: MESSAGE = Io exception: The Network Adapter could not establish the connection; (Could not lookup message because there is no database con