Problem Saving ALV Report

Hi
I have this ALV Report when I run and change the layout (add/remove column and add column for sorting) it works fine but when i come back i get the change columns but it doesn't save the sorting options that i made.
Here is my Code
*& Report  ZAKTIME                                                     *
*& AKABIR             02/06/2007         New Report for Cluster B2     *
REPORT  ZAKTIME no standard page heading message-id zw line-size 255.
*                Dictionary tables/structures
tables: pa0007, PA0002.
DATA: IT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE,
         IT_ZL TYPE PC2BF OCCURS 0 WITH HEADER LINE,
         IT_PT TYPE PDCPT OCCURS 0 WITH HEADER LINE,
        IT_ALP TYPE PC20E OCCURS 0 WITH HEADER LINE,
         IT_C1 TYPE PC25X OCCURS 0 WITH HEADER LINE,
        IT_PSP TYPE PC2BA OCCURS 0 WITH HEADER LINE.
* Global ALV Data Declarations
type-pools slis.
DATA:  BEGIN OF tgetbuff occurs 0,
x(10),
     END OF tgetbuff.
include rpcxB200.
INCLUDE RPTBAL01.
* infotypes: 0001.     "Org. Zuordnung
Data: TempHours LIKE PC2BF-BEGUZ,
      even type i value 0.
data: begin of hd,
      struc like dd03l-tabname,
      end of hd.
DATA: BEGIN OF REC OCCURS 0,
      PERNR LIKE PERNR-PERNR,
      SSN   Like pa0002-perid,
      NAME(25),
      TYPE(1),
      WRKS LIKE PC2BA-TPROG,
      DATE(10),
      STIME(8),
      ETIME(8),
      HOURS  LIKE PC2BF-BEGUZ,
      PNUMB  LIKE PC20E-PRAKN,
      PID    LIKE PC20E-PRAKZ,
      UNIT   LIKE PC20E-ANZHL,
      VALU   LIKE PC20E-BWGRL,
      AMOUNT LIKE PC20E-BETRG,
      XPAYID LIKE PC20E-AUFKZ,
      CCNTR  LIKE PC25X-KOSTL,
      CCODE  LIKE PC25X-BUKRS,
      AUFNR  LIKE PC25X-AUFNR,
      KTEXT  LIKE CAUFV-KTEXT,
      LGART  LIKE PC2BF-LGART,
      LGTXT  LIKE T512T-LGTXT,
      STER   LIKE PDCPT-BTERM,
      ETER   LIKE PDCPT-ETERM.
DATA: END OF REC.
data:
    begin of x_sortinfo_alv occurs 0,
      spos                  like alvdynp-sortpos,
      fieldname             type slis_fieldname,
      tabname               type slis_fieldname,
      up                    like alvdynp-sortup,
      down                  like alvdynp-sortdown,
      group                 like alvdynp-grouplevel,
      subtot                like alvdynp-subtotals,
      comp(1)               type c,
      expa(1)               type c,
      obligatory(1)         type c,
    end   of x_sortinfo_alv,
    v_variant        like disvariant,
    v_repid          like sy-repid,
    v_save(1)        type c,
    lv_sortseq       type i,
    s_title(20),     "Maximum selection field description 20 bytes.
    fieldcat         type slis_t_fieldcat_alv,
    ls_line          type slis_listheader,
    gd_layout        type slis_layout_alv,
    gt_sort          type slis_t_sortinfo_alv,
    ls_sort          type slis_sortinfo_alv,
    events           type slis_t_event,
    list_top_of_page type slis_t_listheader,
    top_of_page      type slis_formname value 'TOP_OF_PAGE',
    v_exit(1)               type c.
constants:
  alv_slis_formname       type slis_formname value 'ALV_USER_COMMAND',
  c_yes                   like space value 'X',
  c_no                    like space value space.
DATA: BEGIN OF E_NAME,
      NACHN LIKE PA0002-NACHN,
      VORNA LIKE PA0002-VORNA.
DATA: END OF E_NAME.
* define selection screen
selection-screen begin of block elmo with frame title text-001.
selection-screen begin of line.
   selection-screen comment 1(22) text-005.
   select-options  opt4 for pa0007-schkz.
selection-screen end of line.
parameters:   debg_lst as checkbox default 'X'.
selection-screen end of block elmo.
selection-screen begin of block blk2 with frame title text-002.
PARAMETERS: p_vari like disvariant-variant.
selection-screen end   of block blk2.
*  Form  Initialization
initialization.
clear: REC.
refresh: REC.
  v_repid = sy-repid.
  v_save = 'A'.
  clear v_variant.
  v_variant-report = v_repid.
* Get default variant
  alv_variant = v_variant.
  call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
    exporting
      i_save     = v_save
    changing
      cs_variant = alv_variant
    exceptions
      not_found  = 2.
  if sy-subrc = 0.
    p_vari = alv_variant-variant.
  endif.
*                       At Selection-Screen event (value help)
at selection-screen on value-request for p_vari.
  perform f4_for_variant.
*                       At Selection-Screen event (check input data)
at selection-screen on p_vari.
  if p_vari <> space.
    v_variant-report  = v_repid.
    v_variant-variant = p_vari.
    call function 'REUSE_ALV_VARIANT_SELECT'
      EXPORTING
        i_dialog            = c_no
        it_default_fieldcat = field_tab[]
        i_layout            = gs_layout
      CHANGING
        cs_variant          = v_variant.
    if sy-subrc <> 0.
      call function 'REUSE_ALV_VARIANT_SELECT'
        EXPORTING
          i_dialog            = c_yes
          it_default_fieldcat = field_tab[]
          i_layout            = gs_layout
        CHANGING
          cs_variant          = v_variant.
    endif.
  endif.
*                       main logic
TOP-OF-PAGE.
START-OF-SELECTION.
        GET PERNR.
        RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
* process the data according to the payroll area
   IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
      AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
      AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
        PERFORM RETRIEVE_Time.
    ENDIF.
END-OF-SELECTION.
    Perform call_alv.
*======================================================================*
*                        forms                                         *
*======================================================================*
FORM RETRIEVE_Time.
DATA: date_modified(10), V_STIME(8), V_ETIME(8).
DATA: Flag(1),
      v_lgtxt like T512T-LGTXT,
      v_ktext like caufv-ktext,
      v_WRKS LIKE PC2BA-TPROG.
CALL FUNCTION 'HR_PAYROLL_PERIODS_GET'
EXPORTING
  get_begda = PNPBEGDA
  get_endda = PNPENDDA
TABLES
  get_periods = it_t549q
EXCEPTIONS
  no_period_found = 1
  no_valid_permo = 2.
  CHECK sy-subrc = 0.
LOOP AT it_t549q.
  FLAG = 0.
  CALL FUNCTION 'HR_TIME_RESULTS_GET'
   EXPORTING
     get_pernr = PERNR-PERNR
     get_pabrj = it_t549q-pabrj
     get_pabrp = it_t549q-pabrp
   TABLES
     GET_TBUFF     = TGETBUFF
     get_zl  = it_zl
     get_pt  = it_PT
     get_alp = it_ALP
     get_c1  = it_C1
     get_psp = it_psp
   EXCEPTIONS
     no_period_specified = 1
     wrong_cluster_version = 2
     no_read_authority = 3
     cluster_archived = 4
     technical_error = 5.
  LOOP AT it_zl.
    IF it_ZL-DATUM >= PNPBEGDA AND it_ZL-DATUM <= PNPENDDA.
* Include PSP Data if Exists.
      LOOP AT IT_PSP.
        IF it_psp-ZMODN IN OPT4 AND it_zl-DATUM EQ it_psp-DATUM.
            MOVE it_psp-ZMODN TO REC-WRKS.
            FLAG = 1.
            Move:
              Pernr-Pernr To REC-PERNR,
                      'Z' To REC-TYPE,
              it_ZL-LGART TO REC-LGART,
              it_ZL-ANZHL TO REC-HOURS.
            perform get_ssn.
            perform get_wage_type_text using REC-LGART v_lgtxt.
            move v_lgtxt to REC-LGTXT.
            CONCATENATE it_zl-DATUM+4(2) '/' it_zl-DATUM+6(2) '/' it_zl-DATUM(4) INTO date_modified.
            IF it_ZL-BEGUZ <> ''.
              CONCATENATE it_ZL-BEGUZ(2) ':' it_ZL-BEGUZ+2(2) ':' it_ZL-BEGUZ+4(2) INTO V_STIME.
            ELSE.
              V_STIME = ''.
            ENDIF.
            IF it_ZL-ENDUZ <> ''.
              CONCATENATE it_ZL-ENDUZ(2) ':' it_ZL-ENDUZ+2(2) ':' it_ZL-ENDUZ+4(2) INTO V_ETIME.
            ELSE.
              V_ETIME = ''.
            ENDIF.
            Move:
                 date_modified To REC-DATE,
                       V_STIME To REC-STIME,
                       V_ETIME To REC-ETIME.
* Include ALP Data if Exists else include Blanks.
              MOVE:
                      '' TO REC-UNIT,
                      '' TO REC-PNUMB,
                      '' TO REC-PID,
                      '' TO REC-VALU,
                      '' TO REC-AMOUNT,
                      '' TO REC-XPAYID.
            IF it_ZL-ALZNR GT 0.
              LOOP AT IT_ALP.
                IF it_zl-ALZNR EQ it_ALP-ALZNR.
                  MOVE:
                      it_ALP-ANZHL TO REC-UNIT,
                      it_ALP-PRAKN TO REC-PNUMB,
                      it_ALP-PRAKZ TO REC-PID,
                      it_ALP-BWGRL TO REC-VALU,
                      it_ALP-BETRG TO REC-AMOUNT,
                      it_ALP-AUFKZ TO REC-XPAYID.
                ENDIF.
              ENDLOOP.
            ENDIF.
* Include C1 Data if Exists Else Include Blanks.
             MOVE:
                  '' TO REC-CCODE,
                  '' TO REC-CCNTR,
                  '' To REC-AUFNR,
                  '' TO REC-KTEXT.
            IF it_ZL-C1ZNR GT 0.
              LOOP AT IT_C1.
                IF it_zl-C1ZNR EQ it_c1-C1ZNR.
                  MOVE:
                      it_C1-BUKRS TO REC-CCODE,
                      it_C1-KOSTL TO REC-CCNTR,
                      it_C1-AUFNR To REC-AUFNR.
                  perform get_service_order_text using REC-AUFNR v_ktext.
                  move v_ktext to rec-ktext.
                ENDIF.
              ENDLOOP.
            ENDIF.
          APPEND REC.
* ENDIF FOR the IF on IT_PSP
        ENDIF.
      ENDLOOP.
* ENDIF FOR the IF on Date Check
    ENDIF.
* ENDLOOP ON IT_ZL
  ENDLOOP.
  LOOP AT it_pt.
    IF it_PT-LDATE >= PNPBEGDA AND it_PT-LDATE <= PNPENDDA.
* Include PSP Data if Exists.
      LOOP AT IT_PSP.
        IF IT_PSP-ZMODN IN OPT4 AND it_pt-LDATE EQ it_psp-DATUM.
          MOVE it_psp-ZMODN TO REC-WRKS.
          FLAG = 1.
          Move:
            Pernr-Pernr To REC-PERNR,
            'P' to REC-TYPE,
            it_pt-BTERM TO REC-STER,
            it_pt-ETERM TO REC-ETER.
          perform get_ssn.
          CONCATENATE it_pt-LDATE+4(2) '/' it_pt-LDATE+6(2) '/' it_pt-LDATE(4) INTO date_modified.
          IF it_pt-BEGTM NE ''.
             CONCATENATE it_pt-BEGTM(2) ':' it_pt-BEGTM+2(2) ':' it_pt-BEGTM+4(2) INTO V_STIME.
          ELSE.
             V_STIME = ''.
          ENDIF.
          IF it_pt-ENDTM NE ''.
             CONCATENATE it_pt-ENDTM(2) ':' it_pt-ENDTM+2(2) ':' it_pt-ENDTM+4(2) INTO V_ETIME.
          ELSE.
             V_ETIME = ''.
          ENDIF.
          Move:
                date_modified To REC-DATE,
                V_STIME To REC-STIME,
                V_ETIME To REC-ETIME.
          TempHours = ''.
          IF it_pt-BEGTM LT it_pt-ENDTM.
              TempHours = it_pt-ENDTM(4) - it_pt-BEGTM(4).
              TempHours = TempHours / 100.
          ENDIF.
          MOVE:
                TempHours TO REC-HOURS,
                       '' TO REC-LGART,
                       '' TO REC-LGTXT,
                       '' TO REC-UNIT,
                       '' TO REC-PNUMB,
                       '' TO REC-PID,
                       '' TO REC-VALU,
                       '' TO REC-AMOUNT,
                       '' TO REC-XPAYID,
                       '' TO REC-CCODE,
                       '' TO REC-CCNTR,
                       '' TO REC-AUFNR,
                       '' TO REC-KTEXT.
          APPEND REC.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDLOOP.
  IF FLAG = 0 AND debg_lst = 'X'.
     Move:
          Pernr-Pernr To REC-PERNR,
                   '' To REC-TYPE,
                   '' TO REC-DATE,
                   '' TO REC-STIME,
                   '' TO REC-ETIME,
                   '' TO REC-LGART,
                   '' TO REC-LGTXT,
                   '' TO REC-HOURS,
                   '' TO REC-UNIT,
                   '' TO REC-PNUMB,
                   '' TO REC-PID,
                   '' TO REC-VALU,
                   '' TO REC-AMOUNT,
                   '' TO REC-XPAYID,
                   '' TO REC-CCODE,
                   '' TO REC-CCNTR,
                   '' To REC-AUFNR,
                   '' To REC-KTEXT,
                   '' TO REC-STER,
                   '' TO REC-ETER.
     perform get_ssn.
     PERFORM LOAD_SHIFT using v_WRKS.
     Move v_WRKS TO REC-WRKS.
     IF REC-WRKS IN OPT4.
       APPEND REC.
     ENDIF.
  ENDIF.
ENDLOOP.
ENDFORM.                            " RETRIEVE_PAYROLL
*  CALL_ALV
form call_alv.
*  v_repid = sy-repid.
  perform build_field_catalog using field_tab[].
  perform build_eventtab      using events[].
  perform comment_build       using header_alv[].
  perform build_sorttab       using gt_sort[].
  perform build_layout.
*  v_variant-variant = '/TEST3'.
* Call ABAP List Viewer
  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      it_fieldcat             = field_tab[]
      i_structure_name        = 'REC'
      i_callback_program      = v_repid
      is_variant              = v_variant
      it_events               = events[]
      it_sort                 = gt_sort[]
      i_save                  = v_save
      is_layout               = gd_layout
    tables
      t_outtab                 = REC
    exceptions
      program_error            = 1
      others                   = 2.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog USING pt_fieldcat type
                               slis_t_fieldcat_alv.
  clear: fieldcat, pt_fieldcat[].    refresh: fieldcat.
  data:  ls_fieldcat type slis_fieldcat_alv.
  ls_fieldcat-tabname        =                'REC'.
  ls_fieldcat-edit           =                ' '.
    ls_fieldcat-fieldname      =                'PERNR'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'PERNR'.
    ls_fieldcat-seltext_l      =                'Employee #'.
    ls_fieldcat-outputlen      =                15.
    ls_fieldcat-no_sum         = 'X'.           "Don't use field for totals
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'NAME'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'NAME'.
    ls_fieldcat-seltext_l      =                'Employee Name'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'TYPE'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'TYPE'.
    ls_fieldcat-seltext_m      =                'Type'.
    ls_fieldcat-outputlen      =                4.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'DATE'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'DATE'.
    ls_fieldcat-seltext_l      =                'Date'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'WRKS'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'WRKS'.
    ls_fieldcat-seltext_m      =                'Daily Sch'.
    ls_fieldcat-outputlen      =                10.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'STIME'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'STIME'.
    ls_fieldcat-seltext_l      =                'Start Time'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'ETIME'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'ETIME'.
    ls_fieldcat-seltext_l      =                'End Time'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'HOURS'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'HOURS'.
    ls_fieldcat-seltext_s      =                'Hours'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'PNUMB'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'PNUMB'.
    ls_fieldcat-seltext_l      =                'Premium #'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'PID'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'PID'.
    ls_fieldcat-seltext_l      =                'Premium Id'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'UNIT'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'UNIT'.
    ls_fieldcat-seltext_s      =                'Unit'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'VALU'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'VALU'.
    ls_fieldcat-seltext_s      =                'Valuation Basis'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'AMOUNT'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'AMOUNT'.
    ls_fieldcat-seltext_s      =                'Amount'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'XPAYID'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'XPAYID'.
    ls_fieldcat-seltext_s      =                'Extra Pay ID'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'CCNTR'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'CCNTR'.
    ls_fieldcat-seltext_l      =                'Cost Center'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'CCODE'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'CCODE'.
    ls_fieldcat-seltext_l      =                'Company Code'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'AUFNR'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'AUFNR'.
    ls_fieldcat-seltext_l      =                'Service Number'.
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'KTEXT'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'KTEXT'.
    ls_fieldcat-seltext_l      =                'Service Number Text'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'LGART'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'LGART'.
    ls_fieldcat-seltext_l      =                'Wage Type'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'LGTXT'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'LGTXT'.
    ls_fieldcat-seltext_l      =                'Wage Type Text'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'STER'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'STER'.
    ls_fieldcat-seltext_l      =                'Starting Terminal'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname      =                'ETER'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'ETER'.
    ls_fieldcat-seltext_l      =                'Ending Terminal'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-edit           =                ' '.
endform.
* BUILD_EVENTTAB
form build_eventtab using events type slis_t_event.
* Registration of events to happen during list display
  data: tmp_event type slis_alv_event.
  call function 'REUSE_ALV_EVENTS_GET'
    exporting
      i_list_type = 0
    importing
      et_events   = events.
  read table events with key name = slis_ev_top_of_page into tmp_event.
   if sy-subrc = 0.
     move top_of_page to tmp_event-form.
     append tmp_event to events.
   endif.
endform.
* COMMENT_BUILD
form comment_build using pt_top_of_page type slis_t_listheader.
  data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
  clear: ls_line, pt_top_of_page.
  ls_line-typ  = 'H'.
  data pnpfrom(10).
  data pnpto(10).
  data: print_date(10).
  data: print_time(10).
  d1 = PNPBEGDA+6(2).          d2 = PNPENDDA+6(2).
  m1 = PNPBEGDA+4(2).          m2 = PNPENDDA+4(2).
  y1 = PNPBEGDA+2(2).          y2 = PNPENDDA+2(2).
  concatenate m1 '/' d1 '/' y1 into pnpfrom.
  concatenate m2 '/' d2 '/' y2 into pnpto.
  d1 = sy-datum+6(2).          d2 = sy-uzeit+2(2).
  m1 = sy-datum+4(2).          m2 = sy-uzeit+0(2).
  y1 = sy-datum+2(2).          y2 = sy-uzeit+4(2).
  concatenate m1 '/' d1 '/' y1 into print_date.
  concatenate m2 ':' d2 ':' y2 into print_time.
  ls_line-info = sy-repid.
  append ls_line to pt_top_of_page.
  concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
  into ls_line-info separated by space.
  append ls_line to pt_top_of_page.
  ls_line-info = 'BGM INDUSTRIES, INC.'.
  append ls_line to pt_top_of_page.
  concatenate 'Supply Period:' pnpfrom 'to' pnpto
  into ls_line-info separated by space.
  append ls_line to pt_top_of_page.
endform.
*       Build layout for ALV grid report
form build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
  gd_layout-info_fieldname    = 'LINE_COLOR'.
endform.                    " BUILD_LAYOUT
* TOP_OF_PAGE
form top_of_page.
  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
       i_logo             = 'Z_BGLOGO'
       it_list_commentary = header_alv.
endform.
*&      Form  build_sorttab
*       Set up the sorting for the report.
form build_sorttab using pt_sort type slis_t_sortinfo_alv.
  clear lv_sortseq.
  perform build_sort tables pt_sort changing ls_sort.
  ls_sort-fieldname = 'PERNR'.
  ls_sort-subtot    = 'X'.
  append ls_sort to pt_sort.
  ls_sort-subtot    = ' '.
  perform build_sort tables pt_sort changing ls_sort.
  ls_sort-fieldname = 'NAME'.
  ls_sort-subtot    = 'X'.
  append ls_sort to pt_sort.
  ls_sort-subtot    = ' '.
endform.                    " build_sorttab
*  Use to add another sort field.
form build_sort
  tables   pt_sort
  changing ls_sort structure x_sortinfo_alv.
  clear ls_sort.
  add 1 to lv_sortseq.
  ls_sort-spos = lv_sortseq.
  ls_sort-up = 'X'.
  ls_sort-tabname = 'REC'.
endform.                    "build_sort
*}   INSERT
*&      Form  GET_SSN & EMP Name
*       text
FORM GET_SSN.
    SELECT SINGLE * FROM PA0002 WHERE PERNR = PERNR-PERNR.
    IF SY-SUBRC EQ 0.
        MOVE: PA0002-PERNR TO REC-SSN,
              PA0002-VORNA TO E_NAME-VORNA,
              PA0002-NACHN TO E_NAME-NACHN.
        CONDENSE E_NAME.
        MOVE: E_NAME TO REC-NAME.
    ENDIF.
ENDFORM.                    " GET_SSN
*   Form  GET_WAGE_TYPE_TEXT
form get_wage_type_text using rec-LGART p_v_lgtxt.
  select single LGTXT from T512T into p_v_lgtxt
                        where LGART = rec-LGART.
endform.                    " GET_WAGE_TYPE_TEXT
*   Form  GET_SERVICE_ORDER_TEXT
form get_service_order_text using rec-AUFNR p_v_ktext.
  select single ktext from caufv into p_v_ktext
                      where aufnr = rec-aufnr.
endform.                    " GET_SERVICE_ORDER_TEXT
*&      Form  LOAD_SHIFT
*       text
FORM LOAD_SHIFT USING V_WRKS.
    SELECT SINGLE * FROM PA0007 WHERE PERNR = REC-PERNR.
    IF SY-SUBRC EQ 0.
       MOVE: PA0007-SCHKZ TO V_WRKS.
    ENDIF.
ENDFORM.
*&      Form  f4_for_variant
form f4_for_variant.
  call function 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = v_variant
      i_save     = v_save
    IMPORTING
      e_exit     = v_exit
      es_variant = alv_variant
    EXCEPTIONS
      not_found  = 2.
  if sy-subrc = 2.
    message id sy-msgid type 'S' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  else.
    if v_exit = space.
      p_vari = alv_variant-variant.
    endif.
  endif.
endform.                    " f4_for_variant
Please help. I will reward Points for the right answers.
Thanks

Ok found the problem at last
    ls_fieldcat-fieldname      =                'PERNR'.
    ls_fieldcat-ref_tabname    =                'REC'.
    ls_fieldcat-ref_fieldname  =                'PERNR'.
    ls_fieldcat-seltext_l      =                'Employee #'.
    ls_fieldcat-outputlen      =                15.
    ls_fieldcat-no_sum         = 'X'.           "Don't use field for totals
    ls_fieldcat-datatype       =                'NUMC'.
    append ls_fieldcat to pt_fieldcat.
    clear ls_fieldcat.
In my build catalog i was clearing every field using the
  clear ls_fieldcat.
which was some how clearing the sortings...
SO commented them out and it works.

Similar Messages

  • Problem in ALV report

    Hi Friends,
    I have the following 2 problems in ALV report
    1) Logo is not getting displayed in the report.
    2) When i click on the Purchase order number in the report  the interactive report is not working,i am not able to see report of First interactive level.
    can you help it out friends.
    Thanks and regards
    Dinesh
    REPORT  YSDBALV1
    tables: ekko , ekpo .
    type-pools: slis .
    Table for Display Header
    data:i_header type slis_t_listheader with header line.
    *Fieldcat Declaration
    data:fieldcatalog type slis_T_fieldcat_alv  WITH HEADER LINE.
    *Table of Events
    data:i_event type slis_t_event with header line .
    For Layout
    data:i_layout type slis_layout_alv .
    data: text(30) .
    *Internal Table Declaration
    data: begin of it_final occurs 0 ,
          ebeln like ekko-ebeln ,           "Purchasing Document No.
          bedat like ekko-bedat ,           "Purchasing Document Date
          matnr like ekpo-matnr ,           "Material No.
          netwr like ekpo-netwr ,         "Net Order Value in PO Currancy
          meins like ekpo-meins ,           "UOM
          chk(1) ,
          light(1) ,
          change like ekpo-menge ,
          end of it_final .
    **select option Declaration
    selection-screen begin of block block.
    select-options: s_ebeln for ekko-ebeln  .
    selection-screen end of block block .
    selection-screen begin of block block1 .
    parameters:grid radiobutton group r .
    parameters:list radiobutton group r .
    selection-screen end of block block1 .
    at selection screen
    at selection-screen .
    select single * from ekko where ebeln in s_ebeln .
    if sy-subrc <> 0 .
       message e000(8I) WITH 'No Data Exists' .
    endif .
    start-of-selection .
    if grid = 'X' .
    perform get_data .
    perform event using i_event[] .
    perform field using fieldcatalog[] .
    perform layout using i_layout .
    perform grid_display .
    endif .
    *&      Form  get_data
          text
    -->  p1        text
    <--  p2        text
    form get_data .
    *DATA Retrieval from tables
    SELECT EKKO~EBELN
           EKKO~BEDAT
           EKPO~EBELP
           EKPO~MATNR
           EKPO~NETWR
           EKPO~MEINS
           EKPO~MENGE
           EKPO~BPRME
           INTO CORRESPONDING FIELDS OF  table IT_FINAL
           FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
           WHERE EKKO~EBELN IN S_EBELN.
           APPEND IT_FINAL.
    endform.                    " get_data
    *Getting the Event for Top of Page display.
    *&      Form  event
          text
         -->P_I_event[]  text
    form event  using    p_i_event type slis_t_event.
      clear p_i_event .
      refresh p_i_event .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = p_i_event
    EXCEPTIONS
       LIST_TYPE_WRONG       = 1
       OTHERS                = 2
    read table p_i_event with key name = slis_ev_top_of_page into i_event.
          if sy-subrc = 0.
                 move 'TOP_OF_PAGE_PO' to i_event-form.
                 modify p_i_event from i_event index sy-tabix transporting form.
          endif.
          clear i_event.
    endform.                    " event
    *Display Top-of –Page Details and Logo
    form top_of_page_po .
           clear i_header .
           refresh i_header .
           write sy-datum to text.
           i_header-typ = 'H'.
           i_header-info = 'PURCHASE OREDER DETAILS'.
           append i_header.
          *Logo Display
          CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
                 EXPORTING
                     it_list_commentary       = i_header[]
                     I_LOGO                   = 'ENJOYSAPLOGO'.
    endform .
    *Field Catalog Append
    *&      Form  field
          text
         -->P_fieldCATALOG[]  text
    form field using  p_fieldcatalog type slis_t_fieldcat_alv.
         clear fieldcatalog.
          fieldcatalog-fieldname   = 'EBELN'.
          fieldcatalog-seltext_m   = 'Purchase Order No'.
          fieldcatalog-col_pos     = 1.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'BEDAT'.
          fieldcatalog-seltext_m   = 'PO Date'.
          fieldcatalog-col_pos     = 2.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'MATNR'.
          fieldcatalog-seltext_m   = 'Material No'.
          fieldcatalog-col_pos     = 4.
          fieldcatalog-outputlen   = 20.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'NETWR'.
          fieldcatalog-seltext_m   = 'Net Value '.
          fieldcatalog-col_pos     = 5.
          fieldcatalog-outputlen   = 20.
          fieldcatalog-do_sum = 'X'.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'MEINS'.
          fieldcatalog-seltext_m   = 'Units'.
          fieldcatalog-col_pos     = 6.
          fieldcatalog-outputlen   = 4.
          append fieldcatalog .
          clear fieldcatalog.
    endform.                    " field
    *&      Form  layout
          text
    form layout  using    p_i_layout TYPE SLIS_LAYOUT_ALV .
    i_layout-zebra  = 'X'.
        i_layout-lights_fieldname = 'LIGHT'.
        i_layout-lights_tabname = 'IT_FINAL'.
        i_layout-box_fieldname = 'CHK'.
        i_layout-box_tabname  = 'IT_FINAL'.
        i_layout-edit = ' '.
    endform.
    *To display Buttons in the MENU BAR if needed
    FORM SET_PO_PF_STATUS USING  P_I_EXTAB TYPE
                     SLIS_T_EXTAB.
                     SET PF-STATUS 'MENUPO'.
      ENDFORM.
    *Event for Interactive display of ALV report
    form USER_COMMAND  using r_ucomm like sy-ucomm
                             rs_selfield type slis_selfield .
      if r_ucomm = '&IC1'.
      READ TABLE IT_FINAL  index   rs_selfield-tabindex.
      write:/ IT_FINAL-ebeln.
      endif.
    endform .
    *Parameters of FM  REUSE_ALV_GRID_DISPLAY
    *&      Form  grid_display
          text
    -->  p1        text
    <--  p2        text
    form grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM                = SY-REPID
       I_CALLBACK_PF_STATUS_SET          = 'SET_PO_PF_STATUS'
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
        IS_LAYOUT                         = I_LAYOUT
        IT_FIELDCAT                       = FIELDCATALOG[]
        IT_EVENTS                         = I_EVENT[]
      TABLES
        t_outtab                          = IT_FINAL.
    endform.                    " grid_display

    *& Report  YSDBALV1
    REPORT  YSDBALV1.
    tables: ekko , ekpo .
    type-pools: slis .
    Table for Display Header
    data:i_header type slis_t_listheader with header line.
    *Fieldcat Declaration
    data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.
    *Table of Events
    data:i_event type slis_t_event with header line ,
         wa_event type line of slis_t_event.
    For Layout
    data:i_layout type slis_layout_alv .
    data: text(30) .
    *Internal Table Declaration
    data: begin of it_final occurs 0 ,
    ebeln like ekko-ebeln , "Purchasing Document No.
    bedat like ekko-bedat , "Purchasing Document Date
    matnr like ekpo-matnr , "Material No.
    netwr like ekpo-netwr , "Net Order Value in PO Currancy
    meins like ekpo-meins , "UOM
    chk(1) ,
    light(1) ,
    change like ekpo-menge ,
    end of it_final .
    **select option Declaration
    selection-screen begin of block block.
    select-options: s_ebeln for ekko-ebeln .
    selection-screen end of block block .
    selection-screen begin of block block1 .
    parameters:grid radiobutton group r .
    parameters:list radiobutton group r .
    selection-screen end of block block1 .
    at selection screen
    at selection-screen .
    select single * from ekko where ebeln in s_ebeln .
    if sy-subrc <> 0 .
    message e000(8I) WITH 'No Data Exists' .
    endif .
    start-of-selection .
    if grid = 'X' .
    perform get_data .
    perform event using i_event[] .
    perform field using fieldcatalog[] .
    perform layout using i_layout .
    perform grid_display .
    endif .
    *& Form get_data
    text
    --> p1 text
    <-- p2 text
    form get_data .
    *DATA Retrieval from tables
    SELECT EKKO~EBELN
    EKKO~BEDAT
    EKPO~EBELP
    EKPO~MATNR
    EKPO~NETWR
    EKPO~MEINS
    EKPO~MENGE
    EKPO~BPRME
    INTO CORRESPONDING FIELDS OF table IT_FINAL
    FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
    WHERE EKKO~EBELN IN S_EBELN.
    APPEND IT_FINAL.
    endform. " get_data
    *Getting the Event for Top of Page display.
    *& Form event
    text
    -->P_I_event[] text
    form event using p_i_event type slis_t_event.
    clear p_i_event .
    refresh p_i_event .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = p_i_event.
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2.
    read table p_i_event with key name = slis_ev_top_of_page into wa_event.
    if sy-subrc = 0.
    move 'TOP_OF_PAGE_PO' to i_event-form.
    modify p_i_event from i_event index sy-tabix transporting form.
    endif.
    clear i_event.
    endform. " event
    *Display Top-of –Page Details and Logo
    form top_of_page_po .
    clear i_header .
    refresh i_header .
    write sy-datum to text.
    i_header-typ = 'H'.
    i_header-info = 'PURCHASE OREDER DETAILS'.
    append i_header.
    *Logo Display
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_header[]
    I_LOGO = 'ENJOYSAP_LOGO'.
    endform .
    *Field Catalog Append
    *& Form field
    text
    -->P_fieldCATALOG[] text
    form field using p_fieldcatalog type slis_t_fieldcat_alv.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order No'.
    fieldcatalog-col_pos = 1.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'BEDAT'.
    fieldcatalog-seltext_m = 'PO Date'.
    fieldcatalog-col_pos = 2.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material No'.
    fieldcatalog-col_pos = 4.
    fieldcatalog-outputlen = 20.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'NETWR'.
    fieldcatalog-seltext_m = 'Net Value '.
    fieldcatalog-col_pos = 5.
    fieldcatalog-outputlen = 20.
    fieldcatalog-do_sum = 'X'.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Units'.
    fieldcatalog-col_pos = 6.
    fieldcatalog-outputlen = 4.
    append fieldcatalog .
    clear fieldcatalog.
    endform. " field
    *& Form layout
    text
    form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .
    i_layout-zebra = 'X'.
    i_layout-lights_fieldname = 'LIGHT'.
    i_layout-lights_tabname = 'IT_FINAL'.
    i_layout-box_fieldname = 'CHK'.
    i_layout-box_tabname = 'IT_FINAL'.
    i_layout-edit = ' '.
    endform.
    *To display Buttons in the MENU BAR if needed
    FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE
    SLIS_T_EXTAB.
    SET PF-STATUS 'MENUPO'.
    ENDFORM.
    *Event for Interactive display of ALV report
    form USER_COMMAND using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield .
    if r_ucomm = '&IC1'.
    READ TABLE IT_FINAL index rs_selfield-tabindex.
    set parameter id 'VL1' field it_final-ebeln.
    call transaction 'ME23N'.
    endif.
    endform .
    *Parameters of FM REUSE_ALV_GRID_DISPLAY
    *& Form grid_display
    text
    --> p1 text
    <-- p2 text
    form grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    IS_LAYOUT = I_LAYOUT
    IT_FIELDCAT = FIELDCATALOG[]
    IT_EVENTS = I_EVENT[]
    TABLES
    t_outtab = IT_FINAL.
    endform. " grid_display
    Regards,
    Rusidar S.

  • Importing problems in alv report (stored versions)

    HI ALL, i have;
    DATA gt_results TYPE sp_data_type OCCURS 0 WITH HEADER LINE .
    FORM X .
    EXPORT gt_results TO DATABASE sp_ver_dat ID INDXKEY.
    ENDFORM .
    FORM Y .
    IMPORT gt_results  FROM DATABASE sp_ver_dat ID INDXKEY.
    ENDFORM .
    I coded this for storing alv datas as a version . Suppose i executed "form x" in 2008. After 1 year later, i would like to see this 2008 record. But my internal table type (sp_data_type) was changed (This change is obligatory). In example new 2 fields were added and 1 field was deleted. In spite of this, i have an error when i am attempting to run "form y"  because clustered data in database does not fit gt_results anymore. 
    How can i run such old stored versions of this alv report? How should i design this subroutines so there will be no problems even if internal table type frequently change in future..?
    I am expecitng your suggestions..
    Thanks..

    I think this is good solution for the versions which we will be created .  Unfortunately there is no way to save (excute) old versions in which structure of internal table  has changed  many times. We have to handle them manually..
    It means, we can save future but not past.. 
    ISN'T IT?
    Thanks all

  • Problems in ALV Report

    Hi all,
    I have a Problem with the ALV report felated to FI Data. Where in the Selection screen I have two fields Commitment Item, Fund Center and Fiscal Year. When i am executing the report it is printing correctly.
    The Problem is that when i give a commitment which is not related to the Fund Center It is displaying all the records.
    That is nothing but it is displaying all the data where the data of the selection screen is not in the internal table.
    instead i should display a message that the Commitment item is not related to Fund Center. and the ALV Should not print any values. How do i achieve this?
    Please help me in solving the problem. Rewards will be awarded.
    Message was edited by:
            sravan varanasi

    Hi,
    Here is a small ex.
    SELECT mtart mtbez FROM t134t
      INTO CORRESPONDING FIELDS OF TABLE it_t134t
      WHERE mtart IN so_mtart AND spras = 'EN'.
      IF sy-subrc = 0.
        *********PERFORM display   
      ELSE.
        MESSAGE ID 'Selection error' TYPE 'E' NUMBER '0040'.
      ENDIF.
    Hope useful.
    Regards
    Harish.

  • Problem in alv report output

    Hi friends,
    i have created alv report .no problem of getting output . but i m getting question mark in the standard menu. it is displaying 10 question mark (sub menu has print preview etc), edit ,question marks(ABC Analysis) ,question marks (abap list viewer etc ), settings ,system , help.
    i don't want these question marks. how to candle this.i haven't moved to test or production , but iwant  to know  in development  why it is coming..
    if any one knows please let me know.
    thanks and regards,
    kani.

    The Problem is with some GUI inconsistency.
    to overcome there are 2 solutions.
    1. You need to run a program Which i don't remember exactly.
    2. Using the Status event.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
        it_fieldcat        = it_fieldcat
    I_CALLBACK_PF_STATUS_SET = 'STATUS'  "important
        it_sort            = it_sort
      TABLES
        t_outtab           = it_data
      EXCEPTIONS
        program_error      = 1.
    form status using extab tyoe slis_t_extab.
    "This status you can set using the program SAPLKKBL
    " go to se41 transaction, enter the program name SAPLKKBL
    "status as STANDARD , and click the Button Copy status
    "Now in the popup for Option to enter your program name and
    "press ok, then save and activate the status
    "now come here and activate the code and test now..
    set pf-status 'STANDARD' excluding extab.
    endform.

  • Filter Function problems on ALV report. [Resolved]

    Hi,
    I developed an ALV report by using function as below:
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM = G_REPID
    *            I_CALLBACK_PF_STATUS_SET = status_set
    *            I_CALLBACK_USER_COMMAND  = USER_COMMAND
                  I_STRUCTURE_NAME = 'T_BSIK'
                  IS_LAYOUT        = GS_LAYOUT
                  IT_FIELDCAT      = GT_FIELDCAT[]
             TABLES
                  T_OUTTAB    = TAB_BSIK.
    And this ALV custom report is referenced from standard function FBL5N.
    After i completed this report, i made an comparision of FBL5N and my custom report.
    When I apply the filter function, for example, on the document type, I cannot input 2 characters in the document type field under the filter function. The field length is only 1 character. Similar case results on the field document date.
    While the standard function FBL5N works very nice.
    What should i do to make the filter function of my own ALV report as the same as the standard function FBL5N do?
    Thanks in advance.
    Lala
    Message was edited by:
            Hoo lala

    Oh, i found where the problem is...
    add below 2 statements, then the question is resolved.
      LS_FIELDCAT-ref_fieldname = ****
      LS_FIELDCAT-ref_tabname = ***
    FORM FIELDCAT_INIT tables RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-COL_POS   =  3.
      LS_FIELDCAT-FIELDNAME = 'BLART'.
      LS_FIELDCAT-TABNAME   = 'TAB_BSIK'.
      LS_FIELDCAT-SELTEXT_L = 'Document Type'.
      LS_FIELDCAT-ref_fieldname = 'BLART'.
      LS_FIELDCAT-ref_tabname = 'BSIK'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    endform.
    Fine now.
    Lala

  • While Saving ALV report in Local File getting error

    Hello Experts,
    Did one alv report.
    Getting output properly , but while saving(downloading) the output result getting Dump from system.
    Runtime Errors         GETWA_NOT_ASSIGNED
    Short text
         Field symbol has not yet been assigned.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLKKBL" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    NOT GETTING WHERE EXACTLY IT IS WRONG....
    Please suggest the solution..
    Thanks in advance

    Usually this is due to wrong fieldcatalog, or inconsistenecy between field catalog, internal table or some fields of the layout (bselect box or lights for example) -> The FIRST thing to do is the execution of [The Consistency Check|http://help.sap.com/saphelp_470/helpdata/en/d6/23253963143e6ae10000000a11402f/frameset.htm], then correct the program to adjust field catalog or layout.
    Regards,
    Raymond

  • Problem with ALV Report Column

    Hi
    I have ALV report that got tons of columns and most of them are showing correctly. But there are two or three where i have a do sum checked got a small problem. The HEADING of the columns says NUMBER instead of its column name...
    Look at my code:
      ls_fieldcat-fieldname      =      'ETIME'.
      ls_fieldcat-ref_tabname    =      'REC'.
      ls_fieldcat-ref_fieldname  =      'ETIME'.
      ls_fieldcat-seltext_s      =      'ET      '.
      ls_fieldcat-seltext_m      =      'Et Tm           '.
      ls_fieldcat-seltext_l      =   'End Time             '.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-fieldname      =                'HOURS'.
      ls_fieldcat-ref_tabname    =                'PC2BF'.
      ls_fieldcat-ref_fieldname  =                'ANZHL'.
      ls_fieldcat-seltext_s      =                'Hrs    '.
      ls_fieldcat-seltext_m      =                'Hors '.
      ls_fieldcat-seltext_l      =                'Hours'.
      ls_fieldcat-decimals_out = 2.
      ls_fieldcat-no_zero = 'X'.
      ls_fieldcat-datatype = 'DEC'.
      ls_fieldcat-do_sum = 'X'.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-no_zero = ''.
      ls_fieldcat-datatype = ''.
      ls_fieldcat-outputlen = ''.
      ls_fieldcat-do_sum = ''.
      ls_fieldcat-decimals_out = ''.
      ls_fieldcat-fieldname = ''.
      ls_fieldcat-fieldname      =                'PNUMB'.
      ls_fieldcat-ref_tabname    =                'PC20E'.
      ls_fieldcat-ref_fieldname  =                'PRAKN'.
      ls_fieldcat-seltext_s      =                'P#     '.
      ls_fieldcat-seltext_m      =     'Pre #       '.
      ls_fieldcat-seltext_l      =   'Premium #           '.
      ls_fieldcat-datatype       =                'NUMC'.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-datatype       = ''.
    The column with Hours is showing NUMBER with the total sum but the column before and after that shows correctly.
    I have tried taken out the
    <b> ls_fieldcat-do_sum = 'X'.</b>
    Then its shows correctly but i need it to do the sum.
    Is there anything i need to do in order to show the columns correctly?
    Please help. <b><REMOVED BY MODERATOR></b>. thanks
    Message was edited by:
            Anwarul Kabir
    Message was edited by:
            Anwarul Kabir
    Message was edited by:
            Alvaro Tejada Galindo

    here is the whole program. you can upload this run it for your self if that helps in any way...
    *& Report  ZHEADCOUNT       *
    REPORT  ZHEADCOUNT no standard page
    heading message-id zw line-size 255.
    *       Dictionary tables/structures
    tables: teven,
            ZSHIFTS,
            ZHEADCT.
    * Global ALV Data Declarations
    type-pools slis.
    include: rpcxB200, RPTBAL01.
    DATA: BEGIN OF REC OCCURS 0,
      PERNR LIKE TEVEN-PERNR,
      LDATE LIKE TEVEN-LDATE,
      LTIME LIKE TEVEN-LTIME,
      SATZA LIKE TEVEN-SATZA,
      TERID LIKE TEVEN-TERID,
      PLANS LIKE TEVEN-PLANS.
    DATA: END OF REC.
    data:
      begin of x_sortinfo_alv occurs 0,
          spos                  like alvdynp-sortpos,
          fieldname             type slis_fieldname,
          tabname               type slis_fieldname,
          up                    like alvdynp-sortup,
          down                  like alvdynp-sortdown,
          group                 like alvdynp-grouplevel,
          subtot                like alvdynp-subtotals,
          comp(1)               type c,
          expa(1)               type c,
          obligatory(1)         type c,
        end   of x_sortinfo_alv,
        d                like scal-indicator,  
        v_variant        like disvariant,
        v_repid          like sy-repid,
        v_save(1)        type c,
        lv_sortseq       type i,
        s_title(20),    
        fieldcat         type slis_t_fieldcat_alv,
        ls_line          type slis_listheader,
        gd_layout        type slis_layout_alv,
        gt_sp_group      type slis_t_sp_group_alv,
        gt_sort          type slis_t_sortinfo_alv,
        ls_sort          type slis_sortinfo_alv,
        events           type slis_t_event,
        list_top_of_page type slis_t_listheader,
        top_of_page      type slis_formname value 'TOP_OF_PAGE',
        v_exit(1)        type c,
        v_pdsnr like assob-pdsnr,
        ls_fieldcat type slis_t_fieldcat_alv.
    constants:
      alv_slis_formname       type slis_formname value 'ALV_USER_COMMAND',
      c_yes                   like space value 'X',
      c_no                    like space value space,
      c_dev LIKE  sy-sysid VALUE 'DEV',
      c_device(4) TYPE c   VALUE 'LOCL'.
    * define selection screen
    selection-screen begin of block elmo with frame title text-001.
    selection-screen begin of line.
    selection-screen comment 1(30) text-002.
    select-options  p_terid for TEVEN-TERID.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(30) text-003.
    select-options p_shift for ZSHIFTS-DWS.
    selection-screen end of line.
    selection-screen end of block elmo.
    selection-screen begin of block blk2 with frame title text-004.
    PARAMETERS: p_vari like disvariant-variant.
    selection-screen end   of block blk2.
    *  Form  Initialization
    initialization.
      v_repid = sy-repid.
      v_save = 'A'.
      clear v_variant.
      v_variant-report = v_repid.
    * Get default variant
      alv_variant = v_variant.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = v_save
        CHANGING
          cs_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 0.
        p_vari = alv_variant-variant.
      endif.
    *  At Selection-Screen event (value help)
    at selection-screen on value-request for p_vari.
      perform f4_for_variant.
    *  At Selection-Screen event (check input data)
    at selection-screen on p_vari.
      if p_vari <> space.
        v_variant-report  = v_repid.
        v_variant-variant = p_vari.
        call function 'REUSE_ALV_VARIANT_SELECT'
          EXPORTING
            i_dialog            = c_no
            it_default_fieldcat = field_tab[]
            i_layout            = gs_layout
          CHANGING
            cs_variant          = v_variant.
        if sy-subrc <> 0.
          call function 'REUSE_ALV_VARIANT_SELECT'
            EXPORTING
              i_dialog            = c_yes
              it_default_fieldcat = field_tab[]
              i_layout            = gs_layout
            CHANGING
              cs_variant          = v_variant.
        endif.
      endif.
    *                       main logic
    TOP-OF-PAGE.
    START-OF-SELECTION.
    GET PERNR.
      RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
    * process the data according to the payroll area
      IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
         AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
         AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
        PERFORM RETRIEVE_Time.
      ENDIF.
    END-OF-SELECTION.
      Perform call_alv.
    *==================================*
    *=================================*
    FORM RETRIEVE_Time.
    Clear: REC.
           Select * from teven where PERNR EQ PERNR-PERNR
                                 AND TERID IN p_terid
                                 AND LDATE >= PNPBEGDA
                                 AND LDATE <= PNPENDDA.
                MOVE:
                     TEVEN-PERNR TO REC-PERNR,
                     TEVEN-LDATE TO REC-LDATE,
                     TEVEN-LTIME TO REC-LTIME,
                     TEVEN-SATZA TO REC-SATZA,
                     TEVEN-TERID TO REC-TERID,
                     TEVEN-PLANS TO REC-PLANS.
                APPEND REC.
           endselect.
    ENDFORM.                            " RETRIEVE_PAYROLL
    *  CALL_ALV
    form call_alv.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
      perform build_layout.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = v_repid
          i_callback_user_command = 'ALV_USER_COMMAND'
          i_structure_name        = 'REC'
          it_fieldcat             = field_tab
          it_special_groups       = gt_sp_group
          it_sort                 = gt_sort
          i_save                  = v_save
          is_variant              = v_variant
          it_events               = events
          is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
    endform.                    "call_alv
    * BUILD_FIELD_CATALOG
    form build_field_catalog USING pt_fieldcat type
                                   slis_t_fieldcat_alv.
    *  data:  ls_fieldcat type slis_fieldcat_alv.
      clear: fieldcat, pt_fieldcat[].
      data : l_tabname type slis_tabname. " Table Name
       l_tabname = 'REC'.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
          i_program_name = v_repid
          i_internal_tabname = l_tabname
          i_inclname = v_repid
        changing
          ct_fieldcat = ls_fieldcat
        exceptions
          inconsistent_interface = 1
          program_error = 2
          others = 3.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
    *    append ls_fieldcat to pt_fieldcat.
      endif.
    endform.                    "build_field_catalog
    * BUILD_EVENTTAB
    form build_eventtab using events type slis_t_event.
    * Registration of events to happen during list display
      data: tmp_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = events.
      read table events with key name = slis_ev_top_of_page into tmp_event.
      if sy-subrc = 0.
        move top_of_page to tmp_event-form.
        append tmp_event to events.
      endif.
    endform.                    "build_eventtab
    * COMMENT_BUILD
    form comment_build using pt_top_of_page type slis_t_listheader.
      data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
      clear: ls_line, pt_top_of_page.
      ls_line-typ  = 'H'.
      data pnpfrom(10).
      data pnpto(10).
      data: print_date(10).
      data: print_time(10).
      d1 = PNPBEGDA+6(2).          d2 = PNPENDDA+6(2).
      m1 = PNPBEGDA+4(2).          m2 = PNPENDDA+4(2).
      y1 = PNPBEGDA+2(2).          y2 = PNPENDDA+2(2).
      concatenate m1 '/' d1 '/' y1 into pnpfrom.
      concatenate m2 '/' d2 '/' y2 into pnpto.
      ls_line-info = sy-repid.
      append ls_line to pt_top_of_page.
      concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
      ls_line-info = 'BGM INDUSTRIES, INC.'.
      append ls_line to pt_top_of_page.
      concatenate 'Period:' pnpfrom 'to' pnpto
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
    endform.                    "comment_build
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
    *  gd_layout-totals_text       = 'Totals'(255).
    *  gd_layout-info_fieldname    = 'LINE_COLOR'.
    endform.                    " BUILD_LAYOUT
    * TOP_OF_PAGE
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'Z_BGLOGO'
          it_list_commentary = header_alv.
    endform.                    "top_of_page
    *&      Form  build_sorttab
    *       Set up the sorting for the report.
    form build_sorttab using pt_sort type slis_t_sortinfo_alv.
      clear lv_sortseq.
      perform build_sort tables pt_sort changing ls_sort.
      ls_sort-fieldname = 'PERNR'.
      ls_sort-subtot    = 'X'.
    endform.                    " build_sorttab
    *  Use to add another sort field.
    form build_sort
      tables   pt_sort
      changing ls_sort structure x_sortinfo_alv.
      clear ls_sort.
      add 1 to lv_sortseq.
      ls_sort-spos = lv_sortseq.
      ls_sort-up = 'X'.
      ls_sort-tabname = 'REC'.
    endform.                    "build_sort
    *&      Form  f4_for_variant
    form f4_for_variant.
      call function 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = v_variant
          i_save     = v_save
        IMPORTING
          e_exit     = v_exit
          es_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 2.
        message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        if v_exit = space.
          p_vari = alv_variant-variant.
        endif.
      endif.
    endform.
    Message was edited by:
            Anwarul Kabir

  • Download problems in ALV report in ECC 6.0

    Hello All,
    While downloading ALV report to excel/txt by standard method.(Export> Local File> Spreadsheet)
    I am facing an issue where I am getting 2 decimal places to a figure.
    Where I do not require zeros if not necessary.
    Eg. If the amnt is 200 then currently its showing like 200.00 but  I want it like 200 only.
    The type is char only.
    Kindly please advice me how to overcome this problem.
    Thanks,
    Yogesh.

    Hi Yogesh,
    ALV behaves inconsistent: I used excel inplace function and got exactly what you required, even worse: In the grid, I have always 3 decimal places, in excel I got a maximum of 2 decimal places, one if there was only one and none if in grid it was .000.
    No obvous solution.
    You could create the grid cells as strings and remove all trailing zeros.
    Regards,
    Clemens

  • Getting problem with ALV reports

    I am trying to set lock on columns in alv report so that when i scroll right the columns will stay fix. The code is
    REPORT ZBPALV.
    type-pools SLIS.
    data: w_fcat type slis_fieldcat_alv,
    t_fcat type slis_t_fieldcat_alv.
    w_fcat-fieldname = 'kunnr'.
    w_fcat-seltext_m = 'Customer'.
    w_fcat-key = 'x'.
    append w_fcat to t_fcat.
    data: begin of ty_kna1 occurs 100,
    kunnr type kunnr,
    end of ty_kna1.
    select kunnr from kna1 into table ty_kna1.
    *loop at ty_kna1.
    *write: ty_kna1-kunnr.
    *endloop.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = ' '
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS =
    IS_LAYOUT =
    IT_FIELDCAT = t_fcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = ty_kna1
    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.
    i came to know from a thread that w_fcat-key = 'x' will use for setting locks in fieldset.But its changing color which is right.Can i know how to fix the columns in alv report.
    Thanks in advance

    Hi
    KEY attribute displays your column output in Blue Color but it will not act as a fixed column.
    Try setting the FIX_COLUMN parameter = 'X'. Generally this is set along with the key fields just to make the output look similar to SAP standard table output.
    Hope this solves your problem.
    Enjoy SAP.
    Rajasekhar

  • Problem in alv report coumn header in the background while using salv

    Hi  all,
            now i am working on  alv report for this i have used salv i mean oops alv ,So here i am facing one issue while executing the report  in background
            the report column headers are not displaying properly as it is displaying in front end.
           In the back ground it is always displaying column header as data element field label short text. i have written a code to pick the long text
           but it is working fine if run the report in the frontend where as in the backgroiund it is always displaying short text but it is wrong.
    here i am attaching the output screen shots in front end and background.

    Hi Satish,
    I have tried this scenario with Reuse ALV grid 1st i found the same issue as u said in background job,
    then i set in field catalog as,
    wa_fcat-ddictxt = 'L'. Now its working fine. L stands for long text.
    Before...
    After...
    For LVC u can try the below fields in fieldcatlog.
    COLDDICTXT = 'L'.
    SELDDICTXT = 'L'

  • Problem in ALV report printing

    Hi,
    I am facing issue while printing the ALV report. The no. of columns in output are dynamic.
    System is giving the printout for 9 columns . If no. of columns are increasing than its printing only one line with garbage values.
    Can anybody help to fix this issue. We need print of 27 (3 static + 24 dynamic (for 12 months)) columns in one go.
    Thanks in advance,
    Vijeta
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Jun 9, 2009 9:30 AM

    Hi
    The font size depends on the format you've choosen for the print.
    The abap list arranges the page as grid: colunmXrow.
    Every colunm of a page means a character.
    If you use the standard format X_65_200, it means you're page is arranged for 65 row and 200 colunm:
    that means the size of a character is optimized to can print 200 chararcter in a A4 page.
    If you use the standard format X_65_132 it means you're page is arranged for 65 row and132 colunm:
    that means the size of a character is optimized to can print 132 chararcter in a A4 page.
    So that mean the size of format X_65_132 will be bigger than X_65_200, because in the same space (page A4) it needs to write 132 char instead of 200.
    If your report print NN char, u should use the format wiith number colunm is closer to NN.
    If there isn't a format or u use the first available format or u create a new one by trx SPAD.
    Max

  • Excel option problem in ALV report output.

    Hi,
    In the output of the ALV report, if I click the Microsoft excel button, the following error is occured.
    "View cannot be switched: Product is not installed or integration is not active".
    We are using SAP GUI 7 and patch level 12.
    Please advice what shall be done to overcome this.

    Hi
    Try this.....
    Open Excel, go to Tool->Macros-->Security
    And you will see a window, Make sure that the two options at the bottom of the window are checked. Save all, close window and try again.
    And when excel asks about enable or not macros always select enable macros.
    Hope this helps.....

  • Problem in ALV report o/p to Excel

    Hi to all
    I have developed an ALV report, which is showing correct display and out put.
    But when I am downloading it to excel, o/p is not coming in proper way. Fields are misplaced from there actual place and not in readable condition.
    Please guide me..
    Regards
    Anubhav

    Hello Lakshmiraj
    I am sending you the coding of my ALV report program.
    Please check.
    REgards
    Anubhav
    *& Report  YRMR033_AMENDMENT_ORDER_LIST
    *& DEVELOPER : ANUBHAV GUPTA
    *& DATE : 21.03.2008
    *&  REPORT DESCRIPTION : REPORT TO DISPLAY  AMENDMENTS IN PURCDHASE ORDERS
                            WITH OLD VALUES AND NEW VALUES.
    REPORT YRMR033_AMENDMENT_ORDER_LIST LINE-SIZE 132 NO STANDARD PAGE HEADING
    LINE-COUNT 065(001)
    MESSAGE-ID VR.
    TABLES: DD04T,
    CDHDR,
    CDPOS,
    DD03L,
    DD41V,
    T685T,
    VBPA,
    TPART,
    KONVC,
    EKKO.
    TABLES : NAST,  LFA1,ekpo.
    SELECT-OPTIONS: "XUDATE FOR nast-erdat OBLIGATORY, "Created on date
                    XUDATE FOR CDHDR-UDATE OBLIGATORY, "Amendment date
                    S_EKGRP FOR EKKO-EKGRP,
                    s_lifnr for ekko-lifnr.
    SELECTION-SCREEN SKIP.
    DATA: WFLAG,
    WCHANGENR LIKE CDHDR-CHANGENR.
    DATA: INDTEXT(60) TYPE C.
    DATA: BEGIN OF ICDHDR OCCURS 50.
            INCLUDE STRUCTURE CDHDR.
    DATA: END OF ICDHDR.
    DATA: BEGIN OF ICDSHW OCCURS 50.
            INCLUDE STRUCTURE CDSHW.
    DATA: END OF ICDSHW.
    DATA: BEGIN OF EKKEY,
    EBELN LIKE EKET-EBELN,
    EBELP LIKE EKET-EBELP,
    ETENR LIKE EKET-ETENR,
    END OF EKKEY.
    DATA: BEGIN OF ITAB OCCURS 50,
    BEGIN OF EKKEY,
    EBELN LIKE EKET-EBELN,
    EBELP LIKE EKET-EBELP,
    ETENR LIKE EKET-ETENR,
    END OF EKKEY,
    ebeln like ekko-ebeln,
    ebelp like ekpo-ebelp,
    CHANGENR LIKE CDHDR-CHANGENR,
    UDATE LIKE CDHDR-UDATE,
    UTIME LIKE CDHDR-UTIME,
    USERNAME LIKE CDHDR-USERNAME,
    CHNGIND LIKE CDSHW-CHNGIND,
    FNAME LIKE CDSHW-FNAME,     "ADDED BY ANUBHAV
    FTEXT LIKE CDSHW-FTEXT,
    OUTLEN LIKE CDSHW-OUTLEN,
    F_OLD LIKE CDSHW-F_OLD,
    F_NEW LIKE CDSHW-F_NEW,
    END OF ITAB.
    DATA : BEGIN OF ITAB1 OCCURS 0,
            EBELN LIKE EKET-EBELN,
            bedat like ekko-bedat,
            EBELP LIKE EKET-EBELP,
            txz01 like ekpo-txz01,
            lifnr like ekko-lifnr,
            name1 like lfa1-name1,
            UDATE LIKE CDHDR-UDATE,
            FTEXT LIKE CDSHW-FTEXT,
            F_OLD LIKE CDSHW-F_OLD,
           ekgrp like ekko-ekgrp,
           F_NEW LIKE CDSHW-F_NEW,
           CHANGENR LIKE CDHDR-CHANGENR,
    UTIME LIKE CDHDR-UTIME,
    USERNAME LIKE CDHDR-USERNAME,
    CHNGIND LIKE CDSHW-CHNGIND,
    FNAME LIKE CDSHW-FNAME,     "ADDED BY ANUBHAV
    OUTLEN LIKE CDSHW-OUTLEN,
    AMDNO TYPE CHAR4,
    END OF ITAB1.
    DATA: OLD_OBJECTID LIKE CDHDR-OBJECTID.
          INTERNAL TABLES
    ----"modification
    DATA: BEGIN OF I_NAST OCCURS 0,
           OBJKY TYPE NAST-OBJKY,
           ERDAT TYPE NAST-ERDAT,
           KAPPL TYPE NAST-KAPPL,
           KSCHL TYPE NAST-KSCHL,
           PARVW TYPE NAST-PARVW,
           PARNR TYPE NAST-PARNR,
           ERUHR TYPE NAST-ERUHR,
           AMDNO TYPE CHAR4,
           EBELN TYPE EKKO-EBELN,
          END OF I_NAST.
    DATA : I_NAST1 LIKE TABLE OF I_NAST WITH HEADER LINE.
    DATA: BEGIN OF I_TAB OCCURS 0,
           OBJKY TYPE NAST-OBJKY,
           ERDAT TYPE NAST-ERDAT,
           KAPPL TYPE NAST-KAPPL,
           KSCHL TYPE NAST-KSCHL,
           PARVW TYPE NAST-PARVW,
           PARNR TYPE NAST-PARNR,
           ERUHR TYPE NAST-ERUHR,
          END OF I_TAB.
    DATA: INDEX TYPE I.
    TYPE-POOLS : SLIS.
              ALV Declarations                                          *
    DATA: W_REPID            LIKE      SY-REPID,
          P_I_FIELDCAT       TYPE      SLIS_T_FIELDCAT_ALV,
          P_I_HEADING        TYPE      SLIS_T_LISTHEADER,
          I_LAYOUT           TYPE      SLIS_LAYOUT_ALV,
          I_EVENTS           TYPE      SLIS_T_EVENT,
          I_HEADING          TYPE      SLIS_T_LISTHEADER.
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          SR TYPE I.
    INITIALIZATION----
    INITIALIZATION.
      CLEAR I_NAST.
      CLEAR I_TAB.
      REFRESH I_NAST.
      REFRESH I_TAB.
    AT SELECTIN SCREEN----
    AT SELECTION-SCREEN.
    PERFORM DATA_VALIDATION.
    TOP OF PAGE----
    TOP-OF-PAGE.
    PERFORM TOP_OF_PAGE.
    END OF PAGE----
    END-OF-PAGE.
    START OF SELECTION----
    START-OF-SELECTION.
      PERFORM BUILD_COMMENT  USING I_HEADING.
      PERFORM EVENT_BUILD CHANGING I_EVENTS.
      SELECT * FROM EKKO . " WHERE EBELN IN XEBELN AND
    *LIFNR IN XLIFNR.
        CLEAR CDHDR.
        CLEAR CDPOS.
        CDHDR-OBJECTCLAS = 'EINKBELEG'.
        CDHDR-OBJECTID = EKKO-EBELN.
        PERFORM GETCHGDOCS.
      ENDSELECT.
      DELETE ITAB WHERE ( FNAME NE 'NETPR'
                       AND FNAME NE 'NETWR'
                       AND FNAME NE 'MENGE' ).
      loop at itab.
        read table itab.
        itab-ebeln = itab-ekkey+0(10).
        itab-ebelp = itab-ekkey+11(4).
        modify itab.
      endloop.
      LOOP AT ITAB.
        MOVE-CORRESPONDING ITAB TO ITAB1.
        APPEND ITAB1.
      ENDLOOP.
      LOOP AT ITAB1.
        SELECT OBJKY ERDAT KAPPL KSCHL PARVW PARNR ERUHR
         FROM NAST
         INTO CORRESPONDING FIELDS OF TABLE I_NAST
         WHERE OBJKY = ITAB1-EBELN
           AND KAPPL = 'EF'
           AND KSCHL = 'ZNEU'
           AND PARVW = 'LF'
           AND SPRAS = SY-LANGU.
        IF SY-SUBRC NE 0.
          DELETE ITAB1.
        ENDIF.
        LOOP AT I_NAST.
          MOVE-CORRESPONDING I_NAST TO I_NAST1.
          APPEND I_NAST1.
        ENDLOOP.
      ENDLOOP.
      SORT I_NAST1 BY OBJKY ASCENDING ERDAT DESCENDING ERUHR DESCENDING.
      DELETE ADJACENT DUPLICATES FROM I_NAST1 COMPARING OBJKY.
    * Select data from TABLE NAST to get ebeln before selected date
      IF I_NAST1[] IS NOT INITIAL.
        SELECT OBJKY ERDAT KAPPL KSCHL PARVW PARNR ERUHR
        FROM NAST
        INTO CORRESPONDING FIELDS OF TABLE I_TAB
        FOR ALL ENTRIES IN I_NAST1
        WHERE OBJKY =  I_NAST1-OBJKY
          AND ERDAT <= I_NAST1-ERDAT
          AND PARNR =  I_NAST1-PARNR
          AND KAPPL =  'EF'
          AND KSCHL =  'ZNEU'
          AND PARVW =  'LF'
          AND SPRAS = SY-LANGU.
      ENDIF.
    Logic to get no of amendments for one po
      LOOP AT I_NAST1.
        CLEAR INDEX.
        LOOP AT I_TAB WHERE OBJKY = I_NAST1-OBJKY.
          INDEX = INDEX + 1.
        ENDLOOP.
        I_NAST1-AMDNO = INDEX - 1.
        I_NAST1-EBELN = I_NAST1-OBJKY.
        MODIFY I_NAST1 TRANSPORTING AMDNO EBELN.
      ENDLOOP.
    *LOOP AT I_NAST1.
    *READ TABLE ITAB1 WITH KEY EBELN = I_NAST1-EBELN.
    *IF SY-SUBRC = 0.
    *ITAB1-AMDNO = I_NAST1-AMDNO.
    *MODIFY ITAB1 TRANSPORTING AMDNO .
    *ENDIF.
    *ENDLOOP.
    DELETE I_NAST1 WHERE AMDNO = 0. "ADDED BY ANUBHAV
    LOOP AT ITAB1.
    READ TABLE I_NAST1 WITH KEY EBELN = ITAB1-EBELN.
    IF SY-SUBRC NE 0.
    DELETE ITAB1.
    ENDIF.
    ENDLOOP.
      loop at itab1.
        select single *
                                  from ekko
                                  into  ekko
                                  where ebeln = itab1-ebeln.
        if sy-subrc = 0.
          itab1-bedat = ekko-bedat.
          itab1-lifnr = ekko-lifnr.
          itab1-ekgrp = ekko-ekgrp.
          modify itab1.
        endif.
      endloop.
      DELETE ITAB1 WHERE EKGRP NOT IN S_EKGRP.
      DELETE ITAB1 WHERE LIFNR NOT IN S_LIFNR.
      loop at itab1.
        select single *
                      from lfa1
                      into lfa1
                      where lifnr = itab1-lifnr.
        if sy-subrc = 0.
          itab1-name1 = lfa1-name1.
          modify itab1.
        endif.
      endloop.
      loop at itab1.
        select single *
                      from ekpo
                      into ekpo
                      where ebeln = itab1-ebeln
                      and  ebelp = itab1-ebelp.
        if sy-subrc = 0.
          itab1-txz01 = ekpo-txz01.
          modify itab1.
        endif.
      endloop.
      sort itab1 by udate descending ebeln ebelp.
    building field catelogue
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'EBELN'.
      WA_FIELDCAT-SELTEXT_L  = 'PO NO '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'BEDAT'.
      WA_FIELDCAT-SELTEXT_L  = 'PO DATE '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'EBELP'.
      WA_FIELDCAT-SELTEXT_L  = 'Item No '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'TXZ01'.
      WA_FIELDCAT-SELTEXT_L  = 'Item Description'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'LIFNR'.
      WA_FIELDCAT-SELTEXT_L  = 'Vendor NO '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'Itab1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'NAME1'.
      WA_FIELDCAT-SELTEXT_L  = 'Vendor Name'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'UDATE'.
      WA_FIELDCAT-SELTEXT_L  = 'Amendment Date'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'FTEXT'.
      WA_FIELDCAT-SELTEXT_l  = 'Change Field Description'.
      WA_FIELDCAT-just = 'L'.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'F_OLD'.
      WA_FIELDCAT-SELTEXT_L  = 'Old Value '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      ADD 1 TO SR.
      WA_FIELDCAT-COL_POS    = SR.
      WA_FIELDCAT-ROW_POS    = 1.
      WA_FIELDCAT-TABNAME    = 'ITAB1'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-FIELDNAME  = 'F_NEW'.
      WA_FIELDCAT-JUST       = 'L' .
      WA_FIELDCAT-SELTEXT_L  = 'New Value '.
      APPEND WA_FIELDCAT TO P_I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      DATA : L_REPID TYPE  SYREPID,
             L_REPID1 LIKE DISVARIANT.
      L_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
         I_BUFFER_ACTIVE                   = 'X'
         I_CALLBACK_PROGRAM                = L_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
         IS_LAYOUT                         = I_LAYOUT
         IT_FIELDCAT                       = P_I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         I_SAVE                            = 'X'
         IS_VARIANT                        = L_REPID1
         IT_EVENTS                         = I_EVENTS
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = 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.
    *&      Form  GETCHGDOCS
          text
    FORM GETCHGDOCS.
      CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
        EXPORTING
          DATE_OF_CHANGE    = CDHDR-UDATE
          OBJECTCLASS       = CDHDR-OBJECTCLAS
          OBJECTID          = CDHDR-OBJECTID
          TIME_OF_CHANGE    = CDHDR-UTIME
          USERNAME          = CDHDR-USERNAME
        TABLES
          I_CDHDR           = ICDHDR
        EXCEPTIONS
          NO_POSITION_FOUND = 1
          OTHERS            = 2.
      CHECK SY-SUBRC EQ 0.
      DELETE ICDHDR WHERE CHANGE_IND EQ 'I'.
      CHECK NOT ICDHDR[] IS INITIAL.
      LOOP AT ICDHDR.
        CHECK ICDHDR-UDATE IN XUDATE.
       CHECK ICDHDR-USERNAME IN XNAME.
        CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
          EXPORTING
            CHANGENUMBER      = ICDHDR-CHANGENR
          IMPORTING
            HEADER            = CDHDR
          TABLES
            EDITPOS           = ICDSHW
          EXCEPTIONS
            NO_POSITION_FOUND = 1
            OTHERS            = 2.
        CHECK SY-SUBRC EQ 0.
        DELETE ICDSHW WHERE ( CHNGIND NE 'U' OR TABNAME NE 'EKPO' ).
        LOOP AT ICDSHW.
          CHECK ICDSHW-TEXT_CASE EQ SPACE.
          MOVE-CORRESPONDING ICDSHW TO ITAB.
          MOVE-CORRESPONDING ICDHDR TO ITAB.
          MOVE ICDSHW-TABKEY+3 TO ITAB-EKKEY.
          APPEND ITAB.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.                    "GETCHGDOCS
    *&      Form  BUILD_COMMENT
          text
         -->P_I_HEADING  text
    FORM BUILD_COMMENT  USING  P_I_HEADING TYPE SLIS_T_LISTHEADER.
      DATA: WA_LINE TYPE SLIS_LISTHEADER,
              TEXT1(50) TYPE C,
              TEXT2(40) TYPE C,
              W_DATE1(10) TYPE C,
              W_DATE2(10) TYPE C.
      CONCATENATE ' CHAMBAL FERTILISERS AND CHEMICALS LIMITED' ' ' INTO TEXT1.
      WA_LINE-TYP  = 'H'.
      WA_LINE-INFO = TEXT1.
      APPEND WA_LINE TO P_I_HEADING.
      CLEAR TEXT1.
      CONCATENATE ' AMENDED ORDERS' ' ' INTO TEXT1.
      WA_LINE-TYP  = 'S'.
      WA_LINE-INFO = TEXT1.
      APPEND WA_LINE TO P_I_HEADING.
      write xudate-low to w_date1 DD/MM/YYYY .
      write xudate-high to w_date2 DD/MM/YYYY .
      concatenate 'PERIOD FROM : ' W_DATE1 ' TO ' W_DATE2 INTO TEXT2 SEPARATED BY SPACE.
      WA_LINE-TYP = 'S'.
      WA_LINE-INFO = TEXT2.
      APPEND WA_LINE TO P_I_HEADING.
    ENDFORM.                    " build_comment
    *&      Form  EVENT_BUILD
          text
         -->P_I_EVENTS text
    FORM EVENT_BUILD  CHANGING P_I_EVENTS  TYPE SLIS_T_EVENT.
      DATA: W_EVENT TYPE SLIS_ALV_EVENT.
      CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = P_I_EVENTS.
      READ TABLE P_I_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO W_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO W_EVENT-FORM.
        APPEND W_EVENT TO P_I_EVENTS.
      ENDIF.
    ENDFORM.                    " event_build
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE .
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_HEADING
          I_LOGO             = 'CFCLLOGO'.
    ENDFORM.                    " top_of_page

  • Printing problem in ALV report.

    Hi,
    I have made an ALV report using 'REUSE_ALV_LIST_DISPLAY' FM. There are 18 coloumns in this report which i want to print in A4 paper. Thses all coloumns are printing but the font size is too small and also printing start from left most i.e. no margin for FILING. How to increase font size and left margin for filing. Kindly suggest.
    Regards,
    Rajesh Vasudeva

    Hi
    The font size depends on the format you've choosen for the print.
    The abap list arranges the page as grid: colunmXrow.
    Every colunm of a page means a character.
    If you use the standard format X_65_200, it means you're page is arranged for 65 row and 200 colunm:
    that means the size of a character is optimized to can print 200 chararcter in a A4 page.
    If you use the standard format X_65_132 it means you're page is arranged for 65 row and132 colunm:
    that means the size of a character is optimized to can print 132 chararcter in a A4 page.
    So that mean the size of format X_65_132 will be bigger than X_65_200, because in the same space (page A4) it needs to write 132 char instead of 200.
    If your report print NN char, u should use the format wiith number colunm is closer to NN.
    If there isn't a format or u use the first available format or u create a new one by trx SPAD.
    Max

Maybe you are looking for

  • Disappearing lines in PDF

    Customer supplied me with a "print-ready" PDF and it's in my dropbox folder: http://db.tt/xxI9Go4h The map streets supposedly have lines adjacent to the names, but the PDF doesn't show them on my Mac, Acro Pro XI as well as Ily CS6 when I open the PD

  • Is it possible to tell the resolution of images in a PDF?

    I'm curious if there's a way to figure out what resolution the photographs in a PDF are saved at. I receive lots of ads from different designers. Occasionally some designer has used a low-res image in an ad, but I don't find this out until I get the

  • Status of Purch Req

    Hi, On SAP release 46C the processing status of a purchase requisition is not updated during the creation of a contract. When I create a contract WK from a PR NB, the staus of Purch Req display only "Contract Created" but not displays the details of

  • SSL error using Neutron API and CLI directly on controller nodes

    VIO 1.0 + NSX + vSphere 6.0 I am trying to execute the following segment of code: 139         credentials = get_credentials() 140         neutron = client.Client('2.0', 141                                 username=credentials['username'], 142        

  • Moving average price as on date

    Dear All, Can any one tell me how can I find a moving average price of a material on a particular date? Suppose I want to know what was the moving average price on 15/12/2007? What is the t.code? thanks & regards, Ramesh Balivada