SORT-ALV

HI SAP
I WANT TO SORT FIRST 4 FIELDS IN ALV USING MACROS . I PASSED SORT[] TO 'REUSE_ALV_GRID_DISPLAY'. 
BUT ONLY  2 FIELDS ARE SORTED. CAN U CHECK THIS MACRO STATEMENT.
DEFINE MACROS1.
SORT-SPOS  = &1.
SORT-FIELDNAME = &2.
SORT-TABNAME = 'TT_ITAB'.
SORT-UP = 'X'.
APPEND SORT.
CLEAR SORT.
END-OF-DEFINITION.
MACROS1 '1' 'EBELN'.
MACROS1 '2' 'AEDAT'.
MACROS1 '3' 'LIFNR'.
MACROS1 '4' 'EKGRP'.
THANKS.

Hi
The macro is fine. If it has worked for 2 fields, then it should work for other 2. Just check if the field names are the same in the internal table.
Regards
Navneet

Similar Messages

  • Print Issue with Sorted ALV Grid

    Hi Team,
    I am using ALV display for my Program. Iam using REUSE_ALV_GRID_DISPLAY. Also i have a Sorting condition for my ALV grid. So iam filling the Sort table & passing it to the Function module. The data is displayed correctly with Sorting as required in the Output.
    Now the issue is with: Print from this ALV. When we try to print the data, The requirement is that the Print should be same as how it is displayed in the ALV. "Grouped Columns"..... But now, the Print is that all the data is filled in all the columns. But user wants the Print also to appear  same as it is shown in a Sorted ALV display.(With some similar column data missing in succeding sort columns until new entry starts)
    Please suggest a solution to acheive the same.
    Thanks & regards,
    Chaitanya

    Look at Q#19 in the note 1009650. Merging functionality is available only for ALV grid display.
    Related Note: 447055
    Work around would be to display the excel in the SAP window (Excel in Place)  and print it from Excel. Read the following thread to make the necessary settings to make it work. Download Report exactly same as seems with Layout set !!
    Edited by: Jeevan Sagar on Jan 19, 2012 12:38 AM

  • How to keep selection (or select) the row of SORTED ALV table?

    Dear Experts,
    I have WD ALV table with grouped and therefore sorted layout. I know that sorted ALV beahve differently.
    The problem is that if the values in cell is updated (setting attribute of selected element of context node bound to the ALV table), then the whole table is redrawn and selection disappears. It does not happen when layout of ALV is not sorted/grouped.
    I need somehow to select the ALV line again. Method MOV_To of IF_WD_CONTEXT_NODE for some reason is not working in sorted ALV (it selects element on node but not in ALV table). And in ALV Interface controller I also could not find anything usefull.
    Thanks.
    Best regards,
    Dmitry.

    Hallo Dmitry,
    See the sap note :1445428
    [https://service.sap.com/sap/support/notes/1445428|https://service.sap.com/sap/support/notes/1445428]
    Follow this thread which suggest a work around.
    [ALV Table set lead selection while sorting is enable for a column|ALV Table set lead selection while sorting is enable for a column]

  • Output of a "report_attribute_error_message" in a sorted ALV does not work!

    Hi all/SAP,
    in my thread editable ALV - how to throw an error message for a specific line & field I figured out, that the output of a "report_attribute_error_message" in the ON_DATA_CHECK event of an editable ALV does not work, if sorting is active for a column.
    Thanks to The specified item was not found. for reproducing this problem.
    A similar problem exists, using an aggregation of a column. This will lead to a runtime exception.
    I've found no fix in the OSS to this problem.
    So is there a way to use sorting together with the output of a "report_attribute_error_message"
    or if this is a bug, can/will this be fixed in the (near) future?
    Thanks,
    Andreas

    Hi,
    Yes, it doesnot work with those (RB,CB) UI elements...Have you checked for any note..I have also tried but no luck..
    Regards,
    Lekha.

  • TOP OF PAGE printing according to SORT - ALV main internal table

    Hi guys
    I manage to solve my previous issues but 1 minor problem here
    Lets say I have an itab which has 3 records
    Sales Order | Purchase No, | Distributor
    1                  |   123               | abc
    1                  |   123               | abc
    2                  |   456               | TGIF
    I'm using FM REUSE_ALV_BLOCK_LIST_APPEND to display the ALV
    its working for the main INTERNAL TABLE but  when it comes to top of page, it doesn't follow the sort
    I want it to print
    Sales Order: 1
    Purchase No: 123
    Distributor: abc
    TABLE 1
    Sales Order: 2
    Purchase No: 456
    Distributor: TGIF
    TABLE 2
    But now its printing
    Sales Order: 1
    Purchase No: 123
    Distributor: abc
    TABLE 1
    Sales Order: 1
    Purchase No: 123
    Distributor: abc
    TABLE 2
    Sales Order: 2
    Purchase No: 456
    Distributor: TGIF
    TABLE <empty table>
    My codes was working previously but its not longer the same.
      READ TABLE it_report INTO l_report INDEX SY-tabix
      WRITE: text-003,          "Sales Order Number
            AT 22 l_report-ebeln.
      WRITE: / text-004,        "Purchase Order Number
             AT 25 l_report-purch_no.
      WRITE: / text-005,        "Distributor Number
             AT 22 l_report-kunnr.
      WRITE: / text-006,        "Ship to Name
             AT 16 l_report-wename1.
      WRITE: / text-007,        "Order Date
             AT 14 l_report-vdate.
      WRITE: / text-008,        "Delivery Date
             AT 17 i_vdatu.
    Can anyone help me out here?  How do I make it print just like the SORT for ALV?

    Refresh the work areas then it work fine

  • Group Sort ALV

    Hi,
    Is it possible to group sort on ALV?
    it seems we are able to merge together several rows via sort but only on its field level.  is it possible to be a group field level?
    example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO.  Can we make the PO number as the first priority sorting without changing the position of the fields?

    c z wrote:
    Hi,
    >
    > Is it possible to group sort on ALV?
    >
    > it seems we are able to merge together several rows via sort but only on its field level.  is it possible to be a group field level?
    >
    > example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO.  Can we make the PO number as the first priority sorting without changing the position of the fields?
    If I have understood your requirement correctly, group sorting should be as simple as filling up the 'IT_SORT' parameter(REUSE_ALV_GRID_DISPLAY/REUSE_ALV_LIST_DISPLAY/CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY)
    as shown below: (please let me know if I have misunderstood your requirement).
    ls_sort-spos = '1'.
      ls_sort-fieldname = 'FIELD1'.
      ls_sort-up = 'X'.
      APPEND ls_sort TO it_sort.
      CLEAR ls_sort.
      ls_sort-spos = '2'.
      ls_sort-fieldname = 'FIELD2'.
      ls_sort-up = 'X'.
      APPEND ls_sort TO it_sort.
      CLEAR ls_sort.
    Even after displaying the ALV, columns can be group sorted by selecting all of them together(by dragging the cursor over all the columns that need to be sorted)
    -Rajesh.

  • Sorting ALV's

    somebody can tell me, what are, g_it_wa_sort-spos AND  g_it_wa_sort-group  for?
    I need to do a special sorting.
    Check this sample. If i have
    FIELD1     INVES-002
    FIELD1     INVES-002
    FIELD2     INVES-002
    FIELD2     INVES-002
    and i use g_it_wa_sort I get in my ALV
    FIELD1    INVES-002
    (EMPTY ROW)
    FIELD2
    (EMPTY ROW)
    but what i need is:
    FIELD1    INVES-002
    (EMPTY ROW)
    FIELD2    <b>INVES-002</b>
    (EMPTY ROW)
    Because, field has changed from FIELD1 to FIELD2
    Can anybody help me please?

    hi
    spos - Sort order
    for ex:
    DATA: it_sort TYPE slis_t_sortinfo_alv,
    wa_sort TYPE slis_sortinfo_alv,
    wa_sort-fieldname = 'BUKRS'.
    wa_sort-tabname = 'IT_SORT'.
    wa_sort-up = 'X'.
    APPEND wa_sort TO it_sort.
    wa_sort-fieldname = 'BELNR'.
    wa_sort-tabname = 'IT_SORT'.
    wa_sort-up = 'X'.
    APPEND wa_sort TO it_sort.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    is_layout = gs_layout
    it_fieldcat = ct_fieldcat
    it_sort = it_sort[]
    i_save = 'A'
    TABLES
    t_outtab = itab.
    **reward if helpful
    regards,
    madhu

  • Sorting ALV grid by clicking on header.

    Hey everyone.
    I've got a report displaying an ALV grid where I really don't want to have the toolbar for it showing, so i've taken that out. But I would like to be able to sort the data in the grid by clicking on a field in the header.
    I've seen this in some standard SAP programs, is it very easy to implement?
    Any help much appreciated,
    Cheers.

    Hi,
    Go through the following link.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    hope it helps.
    Regards
    Rajesh Kumar

  • Sort alv column

    I have an alv table.
    This is sorted ascending by the first column called "first" . I want to sort it descending by first colum.
    How can I do that?
    Thanks for help!!

    Hi Ezachiael,
    You need to use the create_sort_rule method of if_salv_wd_sort for achieving this sorting functionality. Refer to the code snippet below which am using inside the WDDOINIT method to sort the SEATSOCC field by descending order.
    Regards,
    Uday
    METHOD wddoinit .
    * Create component usage for alv component
      DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
      l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
      ENDIF.
    * Get config model
      DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
      l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
      DATA: l_value TYPE REF TO cl_salv_wd_config_table.
      l_value = l_ref_interfacecontroller->get_model( ).
    * set visible row count
      l_value->if_salv_wd_table_settings~set_visible_row_count( '5' ).
    * Sort rows by seatsocc descending
      DATA: lr_field  TYPE REF TO cl_salv_wd_field.
      lr_field = l_value->if_salv_wd_field_settings~get_field( 'SEATSOCC' ).
      lr_field->if_salv_wd_sort~create_sort_rule( sort_order =
      if_salv_wd_c_sort=>sort_order_descending ).
    ENDMETHOD.

  • Sorting  ALV  Table cells

    hi
    how to group the cells of alv table.
    where all the fields having same value should be displayed once and rest of the fields should contain the varying values.
    Edited by: chythanya on May 13, 2008 1:35 PM
    Edited by: chythanya on May 13, 2008 1:36 PM

    Hello,
    Please read these: [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1190424a-0801-0010-84b5-ef03fd2d33d9] at page 9 and [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40794172-b95a-2910-fb98-b86d8a0918b4].
    Regards,

  • Alv sorting

    hi
    need to sort alv data, but the entries are like header and item
    means first line is of header data and if has items then
          the items will be displayed starting from second line but some columns for all items
          will be empty (means header data at the top line refers)
    now second header data comes and then its items.
    in such case how to sort the ALV basing on the header number.
    while sorting all the items are going at the bottom since it has no header number in its line
      and header items are coming at the top
    how to sort these entries correctly

    Hi,
    Try this
    DATA : gt_sort TYPE slis_t_sortinfo_alv,
               wa_sort TYPE slis_sortinfo_alv.
    PERFORM fill_sort.               " Filling sort of REUSE_ALV_GRID_DISPALY
    FORM fill_sort .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-up = c_x.
      APPEND wa_sort TO gt_sort.
      CLEAR wa_sort.
    ENDFORM.                    " FILL_SORT
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
              i_callback_program = g_repid
              i_grid_title       = text-012
              is_layout          = wa_slis_layout
              it_sort            = gt_sort[]
              it_fieldcat        = gt_fieldcat[]
              i_save             = 'A'              
            TABLES
              t_outtab           = <fs_table>
            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.

  • Reading a ALV after sorting

    Hi all,
           I have a Alv grid display.After the ouput is shown
    suppose i have it ascending or descending.Now i want to get the sorted alv into my internal table .Bcoz when i double click a particular row it goes to the next screen with the contents of that particular line.Does any one know how to do that here i am using OOPS Alv.
    regards
    Ahasan

    Hi,
    You cannot directly get the SORTED table, but you get the SORT info and do the SORTING yourself, so that the internal table will be the same as that of the display.
    The method get_frontend_layout will give you the layout info and the method <b> GET_SORT_CRITERIA </b>, will give you the sort criteria applied by the user.
    The table parameter ET_SORT will have the name of the fields sorted. Then what you can do is
    SORT itab BY (FIELDNAME). FIELDNAME is from the ET_SORT table.
    Regards,
    Ravi
    Note : Please mark the helpful answers.

  • ALV: How to sort multiple columns?

    Hi all,
    Good morning!
    I have a requirement to sort multiple columns in ALV. I did a search and tried with following codes:
    data: lo_config_alv  type ref to cl_salv_wd_config_table.
    lo_config_alv->if_salv_wd_table_settings~set_multi_column_sort( value = abap_true ).
    But I still can not sort for multiple columns.
    Please guide me how to do that.
    Thanks,
    Khanh

    Hello,
    If you want to sort ALV by multiple fields, then you have to create sort rule for each field and set sort position for each field to specify the sequence in which you want to sort multiple columns.
    Here is a sample code:
    * Sort rows by PRICE descending
      DATA: lr_field1 TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule1 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field1 = lv_value->if_salv_wd_field_settings~get_field( 'PRICE' ).
      lr_field1->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
                                                   RECEIVING value = lr_rule1 ).
      lr_rule1->set_sort_position(  2 ). "set the sort position to 2
    * Sort rows by seatsmax descending
      DATA: lr_field2 TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule2 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field2 = lv_value->if_salv_wd_field_settings~get_field( 'SEATSMAX' ).
      lr_field2->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
                                                              RECEIVING value = lr_rule2 ).
      lr_rule2->set_sort_position( 1 ). "set the sort position to 1
    * Sort rows by seatsocc descending
      DATA: lr_field TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule3 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field = lv_value->if_salv_wd_field_settings~get_field( 'SEATSOCC' ).
      lr_field->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
      RECEIVING value = lr_rule3 ).
      lr_rule3->set_sort_position( 3 ). "set the sort position to 3
    In the above code, the sequence of sorting would be seatsmax price seatsocc
    If you dont specify the sort position, then the sequence of sorting would be the order in which the sort rules are created.
    In the above example, if we didnt set sort positions for the fields, then order would be price seatsmax seatsocc.
    Refer to this link for more info: https://cw.sdn.sap.com/cw/docs/DOC-33859
    Hope this helps!
    Regards,
    Srilatha

  • Query related to alv grid and sap script

    Hi All,
    I have a requirement where i should read the values which are selected on the alv grid list output and those values i need to display on the script(layout).
    Help me out guru's its an urgency...
    thanks in advance .
    regards
    ravi ganji

    Hi Ravi,
    I have done it exactly like your requirement. This program contains ALV and Smartform.
    But whatever may be, both are layouts and having driver program. So just finish your driver program and Script layout and then use this program.
    I have written this code to print contact letters from VA42. So, modify this code to insert your transaction code.
    Let me know if you have any questions.
    Here is the code.
    REPORT ILETTER MESSAGE-ID CM.
    TYPE POOLS (ALV)
      TYPE-POOLS:
                slis.
    Customized Types
      TYPES:
            BEGIN OF ty_cntrt,
              box(1)   TYPE c,
              kunnr    TYPE kunag,
              vbeln    TYPE vbeln_va,
              vbeln1   TYPE vbeln_va,
              vposn    TYPE posnr,
              vuntdat  TYPE vudat_veda,
              vbegdat  TYPE vbdat_veda,
              vdemdat  TYPE vddat_veda,
              venddat  TYPE vndat_veda,
            END   OF ty_cntrt,
          single line TYPES
            BEGIN OF ty_vkorg,
             vkorg    TYPE vkorg,
            END   OF ty_vkorg.
    Constants
      CONSTANTS:
         c_sform  TYPE char10             VALUE 'SMARTFORMS',
         c_tcode  TYPE sy-tcode           VALUE 'VA42',
         c_mode   TYPE c                  VALUE 'N',
         c_updat  TYPE c                  VALUE 'A',
         c_batch  TYPE sy-callr           VALUE 'BATCH',
         c_dclick TYPE char10             VALUE '&IC1'.
    Internal tables
      DATA: it_cntrt TYPE TABLE OF ty_cntrt,
            it_bdc   TYPE TABLE OF bdcdata,
            it_mesg  TYPE TABLE OF bdcmsgcoll,
            it_const TYPE TABLE OF /SIE/SSG_XCM_CUC,
            it_vkorg TYPE TABLE OF ty_vkorg.
    Work areas
      DATA: wa_cntrt TYPE ty_cntrt,
            wa_bdc   TYPE bdcdata,
            wa_const TYPE /SIE/SSG_XCM_CUC,
            w_vbak   TYPE vbak,
            w_veda   TYPE veda,
            w_xcm_pr TYPE /sie/ssg_xcm_pr,
            w_vkorg  TYPE ty_vkorg.
    Variables
      DATA: l_repid    TYPE sy-repid,
            l_vakey    TYPE vakey,
            l_variant  TYPE varid-variant,
            l_vbeln    TYPE i,
            l_vkorg    TYPE i,
            l_vkbur    TYPE i,
            l_vkgrp    TYPE i,
            l_ckappl(40)   TYPE c,
            l_ckschl(40)   TYPE c,
            l_cauart(40)   TYPE c.
    Program Constants
      DATA: c_kappl    TYPE kappl,
            c_kschl    TYPE kschl,
            c_auart    TYPE auart,
            c_repco    TYPE /sie/ssg_xcm_const,
            c_value    TYPE /sie/ssg_xcm_value.
    ALV data declarations
      DATA:
          gt_fieldcat  TYPE slis_t_fieldcat_alv,
          gt_tab_group TYPE slis_t_sp_group_alv,
          gs_layout    TYPE slis_layout_alv,
          gs_repid     TYPE sy-repid,
          gs_sort      TYPE TABLE OF slis_sortinfo_alv.
    Selection screen
      SELECTION-SCREEN BEGIN OF BLOCK indletter WITH FRAME TITLE text-001.
      skip one line
        SELECTION-SCREEN SKIP.
        SELECT-OPTIONS:
                     contract
                       so_vbeln FOR w_vbak-vbeln,
                     category
                       so_auart FOR w_vbak-auart NO-DISPLAY,
                     Sales Org
                       so_vkorg FOR w_vbak-vkorg OBLIGATORY,
                     Dis Channel
                       so_vtweg FOR w_vbak-vtweg,
                     Division
                       so_spart FOR w_vbak-spart,
                     Sales Group
                       so_vkgrp FOR w_vbak-vkgrp,
                     Sales Office
                       so_vkbur FOR w_vbak-vkbur OBLIGATORY,
                     Cancellation Procedure
                       so_vkues FOR w_veda-vkuesch OBLIGATORY,
                     Contract Signed Date
                       so_vuntd FOR w_veda-vuntdat,
                     created by
                       so_ernam FOR w_vbak-ernam,
                     Fixed Indexation formula
                       so_fnum  FOR w_xcm_pr-fnum OBLIGATORY.
      skip one line
        SELECTION-SCREEN SKIP.
      Indexation letter
        PARAMETERS: rb_index  RADIOBUTTON GROUP radi USER-COMMAND usr.
      Follow up report
        PARAMETERS: rb_follo  RADIOBUTTON GROUP radi.
      skip one line
        SELECTION-SCREEN SKIP.
      Manual processing checkbox
        PARAMETERS:    p_manpr AS CHECKBOX.
      SELECTION-SCREEN END   OF BLOCK indletter.
    Printer block
      SELECTION-SCREEN BEGIN OF BLOCK blk_par WITH FRAME TITLE text-002.
      Printer
        PARAMETERS:     p_print  LIKE nast-ldest DEFAULT 'LOCL' OBLIGATORY.
      SELECTION-SCREEN END OF BLOCK blk_par.
    User selection data validation
      AT SELECTION-SCREEN ON so_vkorg.
    Ragne for sales org
      RANGES: r_vkorg FOR vbak-vkorg.
      REFRESH: it_const, r_vkorg.
      CLEAR   wa_const.
    Proceed for execution only for Sales Orgs in /SIE/SSG_XCM_CUC
      LOOP AT so_vkorg.
       r_vkorg-sign = 'I'.
       r_vkorg-option = 'EQ'.
       r_vkorg-low    = so_vkorg-low.
       APPEND r_vkorg.
    Check Sales Org intervals entered in the selection screen
       IF NOT so_vkorg-high IS INITIAL.
    Get all Sales Org for interval
         SELECT vkorg FROM tvko INTO TABLE it_vkorg
           WHERE vkorg BETWEEN so_vkorg-low AND so_vkorg-high.
         IF sy-subrc = 0.
         Add all Sales org into one internal table
           LOOP AT it_vkorg INTO w_vkorg.
             r_vkorg-low = w_vkorg-vkorg.
             APPEND r_vkorg.
             CLEAR: w_vkorg.
           ENDLOOP.
         delete repeated records
           DELETE ADJACENT DUPLICATES FROM r_vkorg COMPARING low.
         ENDIF.
       ENDIF.
       CLEAR r_vkorg.
      ENDLOOP.
    Get Sales Org entries maintained in /SIE/SSG_XCM_CUC
      l_repid = sy-repid.
    Check Sales Org is maintained for Renewal Letter?
      LOOP AT r_vkorg.
      concatenate constant with Sales Org
        CONCATENATE 'INX_LETTER_CREATE_' r_vkorg-low INTO c_repco.
      Get constant
        SELECT SINGLE value
          FROM /sie/ssg_xcm_cuc
          INTO c_value
         WHERE repid = l_repid
           AND const = c_repco
           AND vkorg EQ so_vkorg-low.
      Check alerady maintained?
        IF sy-subrc <> 0 OR
          ( sy-subrc = 0 AND c_value <> 'X' ).
        Issue massage 'Sales Org no permitted for renewal Letter'.
          MESSAGE E012.
          CLEAR: c_repco, r_vkorg.
          EXIT.
        ENDIF.
        CLEAR: c_repco, r_vkorg.
      ENDLOOP.
      AT SELECTION-SCREEN.
    Read single Sales Org
       READ TABLE so_vkorg INDEX 1.
       IF sy-subrc = 0.
         CLEAR: l_ckappl, l_ckschl, l_cauart, c_kappl, c_kschl, c_auart.
       for application
         CONCATENATE 'INX_LETTER_V1_' so_vkorg-low INTO l_ckappl.
       for output type
         CONCATENATE 'INX_LETTER_Y6C4_' so_vkorg-low INTO l_ckschl.
       document type
         CONCATENATE 'INX_LETTER_AUART_' so_vkorg-low INTO l_cauart.
       Get application
         SELECT SINGLE value FROM /sie/ssg_xcm_cuc
           INTO c_kappl WHERE repid = sy-repid AND const LIKE l_ckappl.
       Get output type
         SELECT SINGLE value FROM /sie/ssg_xcm_cuc
           INTO c_kschl WHERE repid = sy-repid AND const LIKE l_ckschl.
       Get document type
         SELECT SINGLE value FROM /sie/ssg_xcm_cuc
           INTO c_auart WHERE repid = sy-repid AND const LIKE l_cauart.
       ENDIF.
    find no of Sales org entries entered in the selection screen
       DESCRIBE TABLE so_vkorg LINES l_vkorg.
    find no of Sales office entries entered in the selection screen
       DESCRIBE TABLE so_vkbur LINES l_vkbur.
    find no of Sales Group entries entered in the selection screen
       DESCRIBE TABLE so_vkgrp LINES l_vkgrp.
    Check if enterred more than one entry
       IF l_vkorg = 1 AND l_vkbur = 1.
         add Sales Org, Sales office, Sales group for key
         IF NOT so_vkgrp[] IS INITIAL.
           CONCATENATE so_vkorg-low so_vkbur-low so_vkgrp-low INTO l_vakey.
         ELSE.
           CONCATENATE so_vkorg-low so_vkbur-low '%' INTO l_vakey.
         ENDIF.
         CONDENSE l_vakey.
       Get printer name for selection.
         SELECT SINGLE ldest FROM nach INTO p_print
          WHERE kappl = c_kappl AND kschl = c_kschl AND vakey LIKE l_vakey.
       ENDIF.
    Manual processing is possible for Renewal Letter in advance only
      IF p_manpr = 'X' AND rb_follo = 'X'.
        MESSAGE E017.
      ENDIF.
    Main Processing
    START-OF-SELECTION.
      Check for the Follow up report
        IF rb_follo = 'X'.
        Call Follow up report with Selection criteria
          SUBMIT /SIE/SWE_XCM_INDEX_FOLLOWUP
           USING SELECTION-SET l_variant
            WITH so_vbeln IN so_vbeln
            WITH so_vkorg IN so_vkorg
            WITH so_vtweg IN so_vtweg
            WITH so_spart IN so_spart
            WITH so_vkgrp IN so_vkgrp
            WITH so_vkbur IN so_vkbur
            WITH so_vkues IN so_vkues
            WITH so_vuntd IN so_vuntd
            WITH so_ernam IN so_ernam
            WITH so_fnum  IN so_fnum
            WITH p_kappl  EQ c_kappl
            WITH p_kschl  EQ c_kschl
            WITH p_auart  EQ c_auart
          AND RETURN.
        ELSE.
        Process for Indexation Report
          gs_repid = sy-repid.
        Get data.
          PERFORM get_data.
        Filter data based on Siemens France rules
          PERFORM process_data.
        Check contract data is available for selection criteria
          IF NOT it_cntrt[] IS INITIAL.
          create ALV output header
            PERFORM alv_fieldcat USING gt_fieldcat[].
          create ALV layout
            PERFORM alv_layout CHANGING gs_layout.
          Sort ALV output
            PERFORM alv_sort.
          display filtered contract data
            PERFORM output_data.
          ELSE.
          Display a message 'No records found'.
            MESSAGE I011.
            EXIT.
          ENDIF.
        ENDIF.
    *&      Form  get_data
          Retrieve contracts data from tables
    -->  p1        text
    <--  p2        text
    FORM get_data.
    Get contract data from VBAK and VEDA.
      SELECT avbeln   aaudat   a~kunnr
             bvuntdat bvbegdat
             bvdemdat bvenddat
        INTO CORRESPONDING FIELDS OF TABLE it_cntrt
        FROM vbak AS a INNER JOIN veda AS b
          ON avbeln = bvbeln
       WHERE a~vbeln   IN so_vbeln
         AND a~auart   EQ c_auart
         AND a~vkorg   IN so_vkorg
         AND a~vtweg   IN so_vtweg
         AND a~spart   IN so_spart
         AND a~vkgrp   IN so_vkgrp
         AND a~vkbur   IN so_vkbur
         AND a~ernam   IN so_ernam
         AND b~vposn   = '000000'
         AND b~vkuesch IN so_vkues
         AND b~vuntdat IN so_vuntd.
    ENDFORM.                    " get_data
    *&      Form  process_data
          text
    -->  p1        text
    <--  p2        text
    FORM process_data.
    Internal tables
      DATA: l_nast   TYPE TABLE OF nast,
            it_pr    TYPE TABLE OF /sie/ssg_xcm_pr.
    Work areas
      DATA: w_nast   TYPE nast,
            wa_pr    TYPE /sie/ssg_xcm_pr.
    local Variables
      DATA: l_datum1 TYPE sy-datum,
            l_datum2 TYPE sy-datum,
            l_d3last TYPE sy-datum,
            l_d3next TYPE sy-datum.
    current date.
      l_datum1 = sy-datum.
    Calcuate date after 3 months.
      CALL FUNCTION 'DATE_CREATE'
        EXPORTING
          ANZAHL_MONATE        = 3
          DATUM_EIN            = l_datum1
        IMPORTING
          DATUM_AUS            = l_datum2.
      l_datum2 = l_datum2 - 1.
      SORT it_cntrt BY KUNNR VBELN.
    Get corresponding records from /SIE/SSG_XCM_PR.
      SELECT vbeln posnr fnum
          FROM /SIE/SSG_XCM_PR
          INTO CORRESPONDING FIELDS OF TABLE it_pr
           FOR ALL ENTRIES IN it_cntrt
         WHERE vbeln = it_cntrt-vbeln
          AND posnr = it_cntrt-vposn
           AND fnum IN so_fnum.
    clear workarea
      CLEAR wa_cntrt.
    filter contracts agaist the table /SIE/SSG_XCM_PR records.
      LOOP AT it_cntrt INTO wa_cntrt.
        CLEAR wa_pr.
      check contracts available in table /SIE/SSG_XCM_PR
        READ TABLE it_pr INTO wa_pr WITH KEY vbeln = wa_cntrt-vbeln.
        IF sy-subrc <> 0.
            DELETE it_cntrt.
            CLEAR wa_pr.
            CONTINUE.
        ELSEIF sy-subrc = 0 AND NOT wa_pr-fnum IN so_fnum.
      if not available, do not consider this contract
            DELETE it_cntrt.
            CLEAR wa_pr.
            CONTINUE.
        ENDIF.
         Dont consider contracts expires before today and after 3 months.
        IF wa_cntrt-vdemdat > l_datum1.   "current date
               IF wa_cntrt-vdemdat(6) > l_datum2(6). "AND   "after 3 months
               delete contract
                 DELETE it_cntrt.
                 CLEAR wa_cntrt.
                 CONTINUE.
               ENDIF.
        ELSE.
            DELETE it_cntrt.
            CLEAR wa_cntrt.
            CONTINUE.
        ENDIF.
      Is contract renewal letter has been sent already?
      Get all records from NAST to find letter sent?
        SELECT kappl objky kschl nacha datvr
          FROM NAST
          INTO CORRESPONDING FIELDS OF TABLE l_nast
         WHERE kappl = c_kappl
           AND objky = wa_cntrt-vbeln
           AND kschl = c_kschl
           AND nacha = '1'.
        IF sy-subrc = 0.
           sort renewal letter sent dates by latest is first
             SORT l_nast BY datvr DESCENDING.
           Get latest nast record
             READ TABLE l_nast INTO w_nast INDEX 1.
             IF sy-subrc = 0.
                IF p_manpr <> 'X'.  " ignore 3 month logic
                    l_d3next = wa_cntrt-vdemdat(06).
                    l_d3next+6(2) = '01'.
                  Calcuate date after 3 months.
                    CALL FUNCTION 'DATE_CREATE'
                      EXPORTING
                        ANZAHL_MONATE        = -3
                        DATUM_EIN            = l_d3next
                      IMPORTING
                        DATUM_AUS            = l_d3last.
                    l_d3last = l_d3last + 1.
                  Check letter already sent year equals current year
                    IF w_nast-datvr BETWEEN l_d3last AND wa_cntrt-vdemdat.
                     do not consider it
                       DELETE it_cntrt.
                       CLEAR: l_d3last, wa_cntrt, w_nast, l_d3next.
                       CONTINUE.
                    ENDIF.
                ENDIF.
             ENDIF.
        ENDIF.
      no leading zeros to contract
        WRITE wa_cntrt-vbeln TO wa_cntrt-vbeln1 NO-ZERO.
      modify internal table
        MODIFY it_cntrt FROM wa_cntrt.
        CLEAR: l_nast, w_nast.
      ENDLOOP.
    ENDFORM.                    " process_data
    *&      Form  output_data
          text
    -->  p1        text
    <--  p2        text
    FORM output_data.
    Display output in a ALV Grid
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
           I_CALLBACK_PROGRAM                = gs_repid
           I_CALLBACK_PF_STATUS_SET          = 'ALV_STATUS'
           I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
           IS_LAYOUT                         = gs_layout
           IT_FIELDCAT                       = gt_fieldcat
           IT_SORT                           = gs_sort
           I_SAVE                            = 'A'
         TABLES
           T_OUTTAB                          = it_cntrt
         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.                    " output_data
    *&      Form  alv_header
          text
    -->  p1        text
    <--  p2        text
    FORM alv_fieldcat USING gs_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: ls_fieldcat TYPE slis_fieldcat_alv.
    Sold-to Party header
      ls_fieldcat-col_pos = 1.
      ls_fieldcat-fieldname = 'KUNNR'.
      ls_fieldcat-seltext_m = 'Sold-to Party'.
      ls_fieldcat-outputlen = 14.
      ls_fieldcat-datatype  = 'CHAR'.
      ls_fieldcat-key       = 'X'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Contract number
      ls_fieldcat-col_pos = 2.
      ls_fieldcat-fieldname = 'VBELN'.
      ls_fieldcat-seltext_m = 'Contract Number'.
      ls_fieldcat-outputlen = 20.
      ls_fieldcat-datatype  = 'CHAR'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Contract Signed Date
      ls_fieldcat-col_pos = 3.
      ls_fieldcat-fieldname = 'VUNTDAT'.
      ls_fieldcat-seltext_m = 'Contract signed date'.
      ls_fieldcat-outputlen = 20.
      ls_fieldcat-datatype  = 'DATS'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Contract Start Date
      ls_fieldcat-col_pos = 4.
      ls_fieldcat-fieldname = 'VBEGDAT'.
      ls_fieldcat-seltext_m = 'Contract start date'.
      ls_fieldcat-outputlen = '20'.
      ls_fieldcat-datatype  = 'DATS'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Dismantling date
      ls_fieldcat-col_pos = 5.
      ls_fieldcat-fieldname = 'VDEMDAT'.
      ls_fieldcat-seltext_m = 'Dismantling date'.
      ls_fieldcat-outputlen = 14.
      ls_fieldcat-datatype  = 'DATS'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    ENDFORM.                    " alv_header
    *&      Form  alv_layout
          text
    -->  p1        text
    <--  p2        text
    FORM alv_layout USING ls_layout TYPE slis_layout_alv.
    No input
      ls_layout-no_input          = 'X'.
    Column width is flexible
    ls_layout-colwidth_optimize = 'X'.
      ls_layout-box_fieldname = 'BOX'.
      ls_layout-info_fieldname = 'LINE_COLOR'.
      ls_layout-zebra = 'X'.
      ls_layout-get_selinfos = 'X'.
      ls_layout-reprep = 'X'.
    ENDFORM.                    " alv_layout
    *&      Form  alv_status
          text
    -->  p1        text
    <--  p2        text
    FORM alv_status USING rt_extab TYPE slis_t_extab.
    GUI Status and Application Toolbar
      SET PF-STATUS '/SIE/SWE_XCM_INDEXLE'.
    ENDFORM.
    *&      Form  user_command
          text
    -->  p1        text
    <--  p2        text
    FORM user_command USING l_ucomm      LIKE sy-ucomm
                            l_selfield   TYPE slis_selfield.
      RANGES: r_kappl FOR nast-kappl,
              r_objky FOR nast-objky,
              r_kschl FOR nast-kschl,
              r_nacha FOR nast-nacha.
      DATA: l_jobname  TYPE TBTCJOB-JOBNAME,
            l_jobcount TYPE TBTCJOB-JOBCOUNT,
            l_repid    TYPE sy-repid,
            l_print_params TYPE PRI_PARAMS,
            l_arc_params   TYPE ARC_PARAMS,
            l_valid        TYPE c,
            l_retcode      TYPE sy-subrc,
            l_blines       TYPE i.
      CASE l_ucomm.
      Process button seleted
        WHEN c_sform.
        process selected records.
          LOOP AT it_cntrt INTO wa_cntrt.
             IF wa_cntrt-box = 'X'.
              place output type in the contract
                PERFORM bdc_output USING wa_cntrt
                                   CHANGING l_retcode.
                IF l_retcode = 0.
                add record for jobground job
                  r_objky-sign   = 'I'.
                  r_objky-option = 'EQ'.
                  r_objky-low    = wa_cntrt-vbeln.
                  APPEND r_objky.
                ENDIF.
                CLEAR: wa_cntrt, l_retcode, r_objky.
             ENDIF.
          ENDLOOP.
        WHEN c_dclick.
        set contract number id with the selected contract
          SET PARAMETER ID 'AUN' FIELD l_selfield-value.
          SET PARAMETER ID 'KTN' FIELD l_selfield-value.
        call va42 tcode when double click on contract
          CALL TRANSACTION c_tcode AND SKIP FIRST SCREEN.
      ENDCASE.
      DESCRIBE TABLE r_objky LINES l_blines.
    IF NOT r_objky[] IS INITIAL.
      IF l_blines > 0.
        Background job name.
          CONCATENATE 'XCM_INDEXATION' sy-uname '_' sy-uzeit
                 INTO l_jobname.
        Application
          r_kappl-sign   = 'I'.
          r_kappl-option = 'EQ'.
          r_kappl-low    = 'V1'.
          APPEND r_kappl.
        Message Type
          r_kschl-sign   = 'I'.
          r_kschl-option = 'EQ'.
          r_kschl-low    = c_kschl.
          APPEND r_kschl.
        Message transmission medium
          r_nacha-sign   = 'I'.
          r_nacha-option = 'EQ'.
          r_nacha-low    = '1'.
          APPEND r_nacha.
          l_repid = sy-repid.
        Print Parameters
          CALL FUNCTION 'GET_PRINT_PARAMETERS'
            EXPORTING
              DESTINATION                  = p_print
              MODE                         = c_batch
              NO_DIALOG                    = 'X'
              REPORT                       = l_repid
              EXPIRATION                   = 2
              IMMEDIATELY                  = 'X'
              NEW_LIST_ID                  = 'X'
            IMPORTING
              OUT_ARCHIVE_PARAMETERS       = l_arc_params
              OUT_PARAMETERS               = l_print_params
              VALID                        = l_valid
            EXCEPTIONS
              ARCHIVE_INFO_NOT_FOUND       = 1
              INVALID_PRINT_PARAMS         = 2
              INVALID_ARCHIVE_PARAMS       = 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.
        opening the job
          CALL FUNCTION 'JOB_OPEN'
            EXPORTING
              JOBNAME                = l_jobname
            IMPORTING
              JOBCOUNT               = l_jobcount
           EXCEPTIONS
             CANT_CREATE_JOB        = 1
             INVALID_JOB_DATA       = 2
             JOBNAME_MISSING        = 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.
        Job submit
          SUBMIT /sie/swe_xcm_index_rsnast00 TO SAP-SPOOL
                          USER sy-uname
                          WITH s_kappl IN r_kappl
                          WITH s_objky IN r_objky
                          WITH s_kschl IN r_kschl
                          WITH s_nacha IN r_nacha
                          WITH p_print  EQ p_print
             VIA JOB l_jobname NUMBER l_jobcount
             SPOOL PARAMETERS l_print_params
             WITHOUT SPOOL DYNPRO
             AND RETURN.
          IF sy-subrc <> 0.
          display message when error in scheduling background job
            MESSAGE E016 WITH 'Error scheduling Job'.
          ENDIF.
        Job close
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT                          = l_jobcount
              JOBNAME                           = l_jobname
              STRTIMMED                         = 'X'
           EXCEPTIONS
             CANT_START_IMMEDIATE              = 1
             INVALID_STARTDATE                 = 2
             JOBNAME_MISSING                   = 3
             JOB_CLOSE_FAILED                  = 4
             JOB_NOSTEPS                       = 5
             JOB_NOTEX                         = 6
             LOCK_FAILED                       = 7
             OTHERS                            = 8.
          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.
    *&      Form  bdc_output
          text
    -->  p1        text
    <--  p2        text
    FORM bdc_output USING    wa_cntrt  TYPE ty_cntrt
                    CHANGING l_retcode TYPE sy-subrc.
    DATA: l_nast TYPE TABLE OF nast,
           it_nast TYPE TABLE OF nast,
           w_nast TYPE nast,
           l_cellno(2) TYPE n,
           l_vbelv TYPE vbfa-vbelv,
           l_vbpa  TYPE vbpa,
           l_yes(1),
           l_temp(40) TYPE c,
           l_lines    TYPE i,
           l_lesscnt  TYPE i,
           l_less(1),
           l_lines1(2) TYPE n.
        REFRESH: it_nast, l_nast, it_bdc.
        CLEAR: l_nast, w_nast, l_yes, l_cellno,
               it_nast, l_nast, it_bdc.
        PERFORM dyn_scr USING 'SAPMV45A' '0102' 'X'.
          PERFORM dyn_fld USING 'VBAK-VBELN' wa_cntrt-vbeln.
          PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
        PERFORM dyn_scr USING 'SAPMV45A' '4001' 'X'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=HEAD'.
        PERFORM dyn_scr USING 'SAPMV45A' '4002' 'X'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=KDOK'.
        SELECT *
          FROM nast
          INTO CORRESPONDING FIELDS OF TABLE l_nast
         WHERE kappl = c_kappl
           AND objky = wa_cntrt-vbeln.
        IF sy-subrc = 0.
            SORT l_nast BY kschl vstat.
            DESCRIBE TABLE l_nast LINES l_lines.
            LOOP AT l_nast INTO w_nast.
                l_cellno = sy-tabix.
                IF w_nast-kschl = c_kschl AND w_nast-vstat = 0.
                  EXIT.
                ENDIF.
                IF w_nast-kschl > c_kschl OR
                   ( w_nast-kschl = c_kschl AND w_nast-vstat <> 0 ).
                   IF l_less = space.
                     l_cellno = l_cellno - 1.
                   ENDIF.
                   CLEAR l_less.
                  IF l_cellno = 0.
                     l_cellno = 1.
                  ENDIF.
                  l_lines = l_lines + 1.
                  l_lines1 = l_lines.
                  PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
                    CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.
                    CONDENSE l_temp.
                    PERFORM dyn_fld USING l_temp 'Y6C4'.
                    CLEAR: l_temp, l_lines, l_lines1.
                    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
                  EXIT.
                ELSEIF w_nast-kschl < c_kschl.
                  l_less = 'X'.
                  l_lesscnt = l_lesscnt + 1.
                ENDIF.
            ENDLOOP.
        ELSE.
            l_cellno = '01'.
            PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
              CONCATENATE 'DNAST-KSCHL(' l_cellno ')' INTO l_temp.
              CONDENSE l_temp.
              PERFORM dyn_fld USING l_temp 'Y6C4'.
              CLEAR l_temp.
              PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
        ENDIF.
        IF l_less = 'X'.
            l_lesscnt = l_lesscnt + 1.
                  l_cellno = l_lesscnt.
                  l_lines = l_lines + 1.
                  l_lines1 = l_lines.
                  PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
                    CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.
                    CONDENSE l_temp.
                    PERFORM dyn_fld USING l_temp 'Y6C4'.
                    CLEAR: l_temp, l_lines, l_lines1.
                    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
        ENDIF.
        PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
          CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.
          CONDENSE l_temp.
          PERFORM dyn_fld USING l_temp 'X'.
          CLEAR l_temp.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70P'.
        PERFORM dyn_scr USING 'SAPDV70A' '0101' 'X'.
          PERFORM dyn_fld USING 'NAST-LDEST' p_print.
          PERFORM dyn_fld USING 'NAST-DIMME' 'X'.
          PERFORM dyn_fld USING 'NAST-TDARMOD' '1'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.
        PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
          CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.
          CONDENSE l_temp.
          PERFORM dyn_fld USING l_temp 'X'.
          CLEAR l_temp.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70I'.
        PERFORM dyn_scr USING 'SAPDV70A' '0102' 'X'.
          PERFORM dyn_fld USING 'NAST-VSZTP' '1'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.
        PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70S'.
        CALL TRANSACTION c_tcode USING it_bdc
                                 MODE c_mode     "'N'
                                 UPDATE c_updat  "'A'
                                 MESSAGES INTO it_mesg.
        IF sy-subrc = 0.
          l_retcode = 0.
        ENDIF.
    ENDFORM.                    " bdc_output
    *&      Form  dyn_scr
          text
         -->P_0642   text
         -->P_0643   text
         -->P_0644   text
    FORM dyn_scr USING    P_0642
                          P_0643
                          P_0644.
        MOVE:  p_0642 TO wa_bdc-program,
               p_0643 TO wa_bdc-dynpro,
               p_0644 TO wa_bdc-dynbegin.
        APPEND wa_bdc TO it_bdc.
        CLEAR wa_bdc.
    ENDFORM.                    " dyn_scr
    *&      Form  dyn_fld
          text
         -->P_0654   text
         -->P_0655  text
    FORM dyn_fld USING    P_0654
                          P_0655.
       MOVE: p_0654 TO wa_bdc-fnam,
             p_0655 TO wa_bdc-fval.
       APPEND wa_bdc TO it_bdc.
       CLEAR wa_bdc.
    ENDFORM.                    " dyn_fld
    *&      Form  alv_sort
          text
    FORM alv_sort.
      DATA: wa_sortcat  TYPE slis_sortinfo_alv.
      WA_SORTCAT-SPOS      = 1.
      WA_SORTCAT-FIELDNAME = 'KUNNR'.
      WA_SORTCAT-UP        = 'X'.
      WA_SORTCAT-EXPA      = 'X'.
    Appending gd_sortcat-tabname
      APPEND WA_SORTCAT TO gs_sort.
      CLEAR wa_sortcat.
      WA_SORTCAT-SPOS      = 2.
      WA_SORTCAT-FIELDNAME = 'VBELN'.
      WA_SORTCAT-UP        = 'X'.
      WA_SORTCAT-EXPA      = 'X'.
    Appending gd_sortcat-tabname
      APPEND WA_SORTCAT TO gs_sort.
      WA_SORTCAT-SPOS      = 3.
      WA_SORTCAT-FIELDNAME = 'VUNTDAT'.
      WA_SORTCAT-UP        = 'X'.
      WA_SORTCAT-EXPA      = 'X'.
    Appending gd_sortcat-tabname
      APPEND WA_SORTCAT TO gs_sort.
    ENDFORM.                    " alv_sort

  • How can i use "GT_SORT"  in alv  ?

    hello  ,
    i need to sort alv report by some fields  .
    i use   :
    GT_SORT-FIELDNAME = 'FRGGR'.
    GT_SORT-TABNAME = 'G_TABNAME_ITEM'.
    GT_SORT-SPOS = 1.
    GT_SORT-UP = 'X'.
    GT_SORT-SUBTOT = 'X'.
    GT_SORT-GROUP = '*'.
    APPEND GT_SORT.
    the alv is "REUSE_ALV_HIERSEQ_LIST_DISPLAY"
    but i don't see the change  , what i doing wronge ?

    Hi dakota,
    what are the results of the forum search you di before posting the question?
    Regards,
    Clemens
    Expert Forums
    Forum Search
    Use the form below to search the forum content. You can choose to search all content or restrict it to certain forums or dates. Also, you can filter the results by a username or user ID.
    Search Forum Content
    Search Terms:        Search Tips
    Category or Forum:      
    Date Range:      
    Results Per Page:      
    Welcome, Clemens Li      Help
    Your Control Panel      Your Control Panel
    Your Reward Points      Your Reward Points
    Your Questions      Your Questions
    Search Results » Messages: 339 - Search Terms: GT_SORT      Sort by:
    Pages: 23 1 2 3 4 5 6 7 8 9 10
       1. Re: how can i use "GT_SORT" in alv ?
          Posted on: Jul 15, 2007 3:50 PM, by user: Kiran Sure(skk) -- Relevance: 100% -- Show all results within this thread
          Hi, GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE, GT_SORT-FIELDNAME = 'UOM'. GT_SORT-TABNAME = '1'. GT_SORT-SPOS = 1. GT_SORT-UP = 'X'. GT_SORT-SUBTOT = 'X'.
    Reward points ...   2. Re: "Totals" option in Hierarchical List
          Posted on: Feb 7, 2006 8:40 PM, by user: John Jakabcsin -- Relevance: 17% -- Show all results within this thread
          Vicky, The SORT table is the device that allows the ALV tree to paint in it's hierarchial fashion. Your source might look like this: FORM set_sorting TABLES gt_sort STRUCTURE lvc_s_sort. g ...
       3. Re: Regarding ALV Report
          Posted on: Mar 14, 2007 7:36 AM, by user: Azeem Mohammed -- Relevance: 15% -- Show all results within this thread
          GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE, GT_SORT-FIELDNAME = 'UOM'. GT_SORT-TABNAME = '1'. GT_SORT-SPOS = 1. GT_SORT-UP = 'X'. GT_SORT-SUBTOT = 'X'. Then in FCAT use parameter do ...
       4. Re: ALV display
          Posted on: Aug 31, 2006 1:33 AM, by user: Kishore Maddu -- Relevance: 10% -- Show all results within this thread
          in your example you can see passing sorting table GT_SORT to reuse_....grid function module... just copy that program to one z program and commet and gt_sort parameter and then check... please ...
       5. Re: How to remove horizontal lines in ALV_LIST
          Posted on: Feb 15, 2006 12:48 PM, by user: Hymavathi Oruganti -- Relevance: 10% -- Show all results within this thread
          just check whether in gt_sort if u have mentioned gs_sort-group = 'UL'
       6. Re: Problem Saving ALV Report
          Posted on: Feb 7, 2007 4:12 PM, by user: Clemens Li -- Relevance: 10% -- Show all results within this thread
          Hi Anwarul, parameter it_sort = gt_sort[] will overrirde the sort in the variant. Regards, Clemens ...
       7. Re: Subtotals in ALV
          Posted on: Dec 13, 2006 6:15 PM, by user: krk -- Relevance: 10% -- Show all results within this thread
          Hi You have gs-sort and gt_sort. Make sure which one you are passing and declare the type as for that FM LIST_Display. ...
       8. Re: ALG Grid Same values not grouped!
          Posted on: Mar 17, 2006 11:23 AM, by user: Kumar Prashanth -- Relevance: 9% -- Show all results within this thread
          set_table_for_first_display EXPORTING i_save = gv_save is_layout = gv_layout is_print = gv_print is_variant = gv_variant CH ...
       9. Re: Total amount in ALV report
          Posted on: Dec 12, 2005 9:41 PM, by user: Phani Kiran Nudurupati -- Relevance: 9% -- Show all results within this thread
          Hi Naren, Pass it this way in the structure. DATA: GT_SORT TYPE SLIS_T_SORTINFO_ALV, DATA: GS_SORT TYPE SLIS_SORTINFO_ALV. CLEAR GS_SORT. GS_SORT-FIELDNAME = 'EBELN'. "This should be the fie ...
      10. Re: ALV Subtotal
          Posted on: May 2, 2007 11:29 PM, by user: Alchemi -- Relevance: 8% -- Show all results within this thread
          I have this in one include program GT_SORT_OFFSET TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE, can i email u the code? ...
      11. Re: ALV Tree Problem
          Posted on: Mar 20, 2007 6:49 PM, by user: Christian CHOULET -- Relevance: 8% -- Show all results within this thread
          Hello aRs, Yes i'm sure KOSTL is available in WT_TEST. The problem is that when i another element in GT_SORT, this error appears... Thanks anyway ...
      12. Re: subtotal calculation in ALV
          Posted on: Nov 14, 2006 5:35 PM, by user: Narendran Muthukumaran -- Relevance: 8% -- Show all results within this thread
          Hi, 1) Create a sort internal table for you to do sub totaling based on the field change..In this example..I have created a sort internal table and it will sum for every change in the field VBELN. ...
      13. Re: ALV grid sort
          Posted on: Oct 4, 2006 1:22 PM, by user: sreejesh purapadiath -- Relevance: 7% -- Show all results within this thread
          set_table_for_first_display EXPORTING is_layout = gs_layout it_toolbar_excluding = gt_excl_func[] CHANGING it_outtab = i_final[] ...
      14. Re: ALV Print about subtotal
          Posted on: Dec 17, 2005 11:35 AM, by user: max bianchi -- Relevance: 7% -- Show all results within this thread
          Hi In the sort table you has to define the field for sorting and subtotal: DATA: LT_SORT TYPE LVC_S_SORT, GT_SORT TYPE LVC_T_SORT. LT_SORT-SPOS = 1. LT_SORT-FIELDNAME = . LT_SORT-UP ...
      15. Re: Subtotals text in ALV
          Posted on: Feb 14, 2006 11:53 AM, by user: Wenceslaus G -- Relevance: 7% -- Show all results within this thread
          To display subtotal text you have to create sort interface GT_SORT TYPE SLIS_T_SORTINFO_ALV, and GS_SORT-FIELDNAME = 'FIELD1'. GS_SORT-SPOS = 1. GS_SORT-UP = 'X'. GS_S ...
    Pages: 23 1 2 3 4 5 6 7 8 9 10

Maybe you are looking for

  • Can't get ANYTHING to work!!  Help NEW to iPod

    I bought an ipod nano off of ebay. nice deal, but of course battery life couldn't be guranteed. when unit arrived i didn't know how to turn on ,but i must have hit the correct button because it came on. i then had children issues and when i came back

  • [ANN] Oracle JDeveloper 10g production is now available for download.

    It's probably worth a mention in this forum too ;-) In case you haven't notice we have just released Oracle JDeveloper 10g production with a many new features that makes it the ideal Java tools for Oracle Application Server users. Check it out at: ht

  • Why does my ipad keep quitting?

    My ipad2 keeps quitting applications after about 40 seconds, I've tried doing a hard reboot. I've also taken the ipad back to new set up, however it still continues to quit. Does anyone know how to resolve this issue?

  • Solution Manager : TC SOLUTION_TRANSFER , Solution Import Error

    Hi All, I am trying to export a Solution from one Solution Manager to Another. I have exported the Solution from System A using TC: SOLUTION_TRANSFER , a solution.zip file was generated , now when I get to system B and was trying to import the soluti

  • IPSEC between Netscreen SSG-140 and Cisco 3640 Router

    The symptoms are that the NS will try to build the IKE session and time out. Even with the Cisco debugging enabled I get no IKE nor IPSEC SA trying to build on the 3640. What am I doing wrong or what can I try? Enclosed is the configuration and a bri