Saving ALV Report tree to pdf

Is it possible to save ALV Report Tree to pdf for all versions (old & new) of SAP? If yes, then what is the way to save the ALV tree to pdf in different versions, which also includes BW & APO systems? The ALV tree also includes some hotspots, if that also matters in some way !!

Hi
call this function module
CONCATENATE l_fullpath '.rtf' INTO l_fullpath.
CALL FUNCTION 'GUI_DOWNLOAD'
__EXPORTING
____filename = l_fullpath
____filetype = 'ASC'
____write_field_separator = 'X'
__TABLES
____data_tab = lt_tree.
Where lt_tree content looks like this :
COL1__________COL2
Parent1________(initial)
(initial)_________child1_1
(initial)_________child1_2
Parent2________(initial)
(initial)_________child2_1
etc...

Similar Messages

  • Regarding excel download from ALV report tree

    Hi Experts,
    I have a ALV report tree program. In that i need the functionality to download report output in excel file.
    Can any body suggest how can i achieve download to excel functionality in it.
    Any useful suggestion will be appreciated.
    Thanks in advance,
    Akash

    The data for the tree exist in the NODE table in a different format. So, even you download that table, it will not be downloaded in the TREE format. So, the user will not be able to understand the data unlike the case of a ALV GRID.
    Whether it is a TREE / GRID, ultimately its the data of a internal table, that gets downloaded. But in case a TREE, we don't have the data in a straight forward way . i thnk it is not possible . i am not sure too for this .

  • 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 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.

  • Saving a report as a PDF file - missing bitmaps

    Reports 6.0.8.11.3 - Oracle 8.0.5
    I have reports that include graphic logos displayed into REPEATING FRAMES - they are stored into long raw fields, and the format specified for the frames in the reports is OLE2.
    ALL IS OK AS LONG AS I PREVIEW AND PRINT THE REPORTS AS USUAL.
    If I specify FORMAT=PDF and try to save a PDF file copy of those reports, they are perfect, but the logos are missing.
    I tried to specify an IMAGE format for the repeating frames, but the problem persists and I get an "unsupported data type" error message.
    Is there a workaround? Sadly, I must use the PDF format, so I ask Your help to know whether there is a way to include raster graphics into a PDF generated by Oracle Reports.
    Thank You so much.

    Hi Cesare,
    From the on-line help, PDF Restrictions:
    "OLE objects are ignored when generating PDF or HTML, but space is reserved for these objects in the output."
    However, raster images are supported if they come from a file or the database. So, if you have actual image files, you can include them by reading them in from file. See the help topic on "image" for all the various options for including images in a report, dynamically or statically.
    regards,
    Stewart

  • While saving alv report to local file(excel) OA number not coming fully..

    HI,
    actually in my aliv report output OA no contains 10 characters (0010100276) but after saving into local file (excel) , it appearing in excel file only 7 characters(1010027) any one plz tell what is the reason how we rectify it.......
    with regards
    Ganesh.

    Hello Ganesh,
    When you export the file from SAP to your PC, select "unconverted" radio button.  Enter a file name and path, then save it with a text file (.txt) extension.  Then do the following steps on your PC.
      1.  Open the Excel application.
      2.  Open the text file in the application.  The system will automatically open the text import wizard.
      3.  Select "Fixed Width", then press next pushbutton.
      4.  After you parse the columns, press next pushbutton.
      5.  Go to the column where you want to keep leading zeros.  Select "Text" in the "Column data format" box.
    Kind Regards,
    Rae Ellen Woytowiez
    Edited by: Rae Ellen Woytowiez on Mar 8, 2011 4:27 PM

  • Download ALV report to PDF with Lights

    Hi,
    I have a requirement wherein, when i download ALV report to PDF which has Lights in the first column.  My problem is these lights are not displayed instead i get the following in the PDF
    PDF o/p:
    XOO RED SIGNAL
    OXO YELLOW SIGNAL
    OOX GREEN SIGNAL
    Please let me know how to get the lights in the PDF o/p
    Thanks & Regards,
    Sandhya

    Hi Sandhya,
    U can convert any type of display(SF,ALV) to PDF.....
    User Program rstxpdft4 to convert it first the O/P need to be converted into spool.
    cheers,
    Naveen.

  • How to show alv report in tree structure

    hi all,
    how to show data or create a alv report in tree structure.
    thanks in advance.
    Harsha

    Hi Harsha,
    Its done using FM 'RS_TREE_CONSTRUCT'
    and FM for displaying the tree:  'RS_TREE_LIST_DISPLAY'
    Thanks
    Shrila

  • How to download a Block List based ALV report to PDF file?

    Hi Everyone,
    I need to display a report in block list alv format using REUSE_ALV_BLOCK_LIST_DISPLAY... I have done this. But my problem comes next.
    1. I need to download this report to a pdf file in the user given directory - in presentation server. How can I download this in PDF format.
    2. My report has TOP_OF_LIST and END_OF_LIST events. The body of the report contains a table with some material data. There should be 1 table for each material no. There are around 50 records for each material no. So I am looping at the material no. and calling REUSE_ALV_BLOCK_LIST_APPEND.
    Now my problem is that I should have only 20 records in each page. How can I determine this? How do I put a page-break?
    Please anyone help me.

    Hi Anwesha
    You can send the report output to spool using the IS_PRINT parameter of REUSE_ALV_BLOCK_LIST_DISPLAY FM. Then read the spool number generated and pass it to CONVERT_ABAPSPOOLJOB_2_PDF to get the pdf content which could be downloaded to presentation server.
    The splitting of records on count could be done by calling above method with different internal table filtered as per your requirement.
    Regards
    Ranganath

  • Saving reports output in PDF or Excel

    Hello, I am in the process of developing some oracle reports to run over the web. My question is. When the reports are run over the web how can I save the output in either PDF or Excel. The reports will be called from
    a form with parameters passed. I am also having a problem whem the output is shown in htlm it is wrapped. Is there away to stop this data wrapping process from happening?
    Thanks,
    Morris

    Hi Ratheesh,
    In a previuos posted message I've suggested to Carla close exactly the same you did after. And also did'nt worked.Anyway, just for your info.
    Dear Carlangas (as we say in Mexico, with no offense)
    Here is a workaround for you...
    As I'm not a JSP expert developer in my case I will do next
    It seems we are facing a problem with the DESFORMAT=PDF and report out parameter for your jsp report and requiere a jsp/reports experienced developer help or further investigation. I'm not saying it's not possible to generate a PDF output from a jsp report, but for the moment nobody has said how to.
    I believe you saved your report in jsp format because you need your users review the report previuosly they may print it.
    I also suppose you have a form with a magic button from where you launch your report.
    Well I will call your existing button PREVIUOS or will add a nice gif icon and will create another one called PRINT or with a pretty printer .gif icon. This new button will call a RDF version of your report. As you have read is very easy to create PDF format/output report in RDF format.
    Also your will need negotiate presentation with your customer. As you must know reports output in a Paper report, PDF, jsp formats are not always exactly the same because they are not simply the same.
    Hope this help you. In the meantime you will save time for your investigation for a future release of your report.

  • Create a ALV report with fields editable and  entry to be saved in ztable

    Hello Experts,
    I have created the ALV report which has two of the fields editable. Now whenever user puts an entry in the ALV it has to be saved in the ZTABLE.
    The report is displayed with editable fields but i'm not sure what has to be written in the 'USER COMMAND' subroutine to save the entries in ztable.
    Please see my code belwo:-
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'ALV_USER_COMM'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               it_events               = gt_events
               is_print                = gd_prntparams
                 i_save                  = 'X'
               is_variant              = z_template
           TABLES
                t_outtab                = it_bg2
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
    Thanks,
    Naveen
    Edited by: jaikrishna on Sep 4, 2010 8:13 AM

    Hi,
    I have worked on similar requirement. You can do that on sy-ucomm value only and you have to call a FM and a method. For that end user has to click on a button which you need to create in the application toolbar. Say that button function code is 'SAVE'. Write the following code in your user command :
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
            RS_SELFIELD TYPE SLIS_SELFIELD.
    *Code to reflect the changes done in the internal table
      DATA : REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
      DATA: L_VALID TYPE C.
      IF REF_GRID IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            E_GRID = REF_GRID.
      ENDIF.
      IF NOT REF_GRID IS INITIAL.
        CALL METHOD REF_GRID->CHECK_CHANGED_DATA
          IMPORTING
            E_VALID = L_VALID.
      ENDIF.
      CASE SY-UCOMM.
        WHEN 'SAVE'.
    *Data will come with the edited values from ALV
    *Here you write your code to save entries into Z table
    ENDCASE.
    ENDFORM. "USER_COMMAND
    Thanks & Regards,
    Rock.

  • Crystal Report Export to PDF with Group Tree Bookmarks

    Dear Forum
    I have created a Crystal Report aspx page with an export function of the report to pdf. So far all has been successful, except form one little annoying this. The report does export to a pdf file and it does create bookmarks based on the group tree, BUT when opening the pdf file the bookmarks hiest point which should be the file name is the really long temp file name with .rpt as an extension. I have looked every where to try to get it to write the filename to the bookmark hierarchy without success.
    I come you you all for any form of help to solve this issue.
    My code is below
    CrystalDecisions.Shared.ExportOptions export_options = new ExportOptions();
                export_options.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                string ext = ".pdf";
                string reportName = "Filename";
                CrystalDecisions.Shared.PdfFormatOptions pdfOptions = new PdfFormatOptions();
                pdfOptions.CreateBookmarksFromGroupTree = true;
                export_options.ExportFormatOptions = pdfOptions;
                report.ExportToHttpResponse(export_options, Response, true, reportName);
                Response.Clear();
                Response.Buffer= true;
                Response.End();
    Below is an image of the output
    Any and all help is greatly appreciated

    Using the search box in the top right corner and entering the search string 'bookmark pdf crystal', the very 1st KBA is:
    1331152 - Report exported to PDF format with bookmarks displays the bookmarks as report name plus a GUID
    Please see if this resolves the issue for you.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • ALV Report to PDF

    Hi,
    Need help on ALV ..am a newbie on this...I have created the source code but i cant proceed with the below requirement
    The report will be generated in ALV ,
    1. executed in a background job
    2.  spool to be converted in a PDF
    3. PDF to be save in SAP directory
    4. PDF file to be  sent other server ( outside SAP)
    I have completed the coding for the alv report but put to stop coz of the 4 requirements above..
    Need your expertise advise here.. Many thanks in advance.
    ========================
    REPORT  ZSD_REPORT.
    TABLES: VBAK,
      KNA1,
      VBPA,
      PA0001,
      T001.
    DATA: T_VBELN    LIKE VBAK-VBELN.
    DATA: T_VGBEL    LIKE VBAK-VGBEL.
    DATA: IT_VBAK1   LIKE VBAK   OCCURS 0 WITH HEADER LINE.
    DATA: IT_VBAK2   LIKE VBAK   OCCURS 0 WITH HEADER LINE,
          IT_KNA1    LIKE KNA1   OCCURS 0 WITH HEADER LINE,
          IT_VBPA    LIKE VBPA   OCCURS 0 WITH HEADER LINE,
          IT_VBPA1   LIKE VBPA   OCCURS 0 WITH HEADER LINE,
          IT_PA0001  LIKE PA0001 OCCURS 0 WITH HEADER LINE,
          IT_PA00011 LIKE PA0001 OCCURS 0 WITH HEADER LINE.
    type-pools: slis.                                 "ALV Declarations
    TYPES: BEGIN OF IT_VBAK,
      VBELN       TYPE VBAK-VBELN,
      VGBEL       TYPE VBAK-VGBEL,
      ZZ_PROBEZ   TYPE VBAK-ZZ_PROBEZ,
      ZK_PERNR    TYPE VBPA-PERNR,
      ZT_PERNR    TYPE VBPA-PERNR,
      VDATU       TYPE VBAK-VDATU,
      ZZ_PROJ_LOC TYPE VBAK-ZZ_PROJ_LOC,
      NAME1       TYPE KNA1-NAME1,
      GV_PC       TYPE PA0001-ENAME,
      GV_PM       TYPE PA0001-ENAME,
      ZZ_COMP_02  TYPE VBAK-ZZ_COMP_02,
    END OF IT_VBAK.
    DATA: IT_VBAK TYPE STANDARD TABLE OF IT_VBAK WITH HEADER LINE.
    DATA: IS_VBAK TYPE STANDARD TABLE OF IT_VBAK WITH HEADER LINE.
    DATA: WA_VBAK TYPE STANDARD TABLE OF IT_VBAK WITH HEADER LINE.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
    SELECTION-SCREEN BEGIN OF BLOCK PSP WITH FRAME TITLE TEXT-001.
    PARAMETERS P_AUART  LIKE VBAK-AUART DEFAULT 'ZSSO'.
    PARAMETERS P_VKORG  LIKE VBAK-VKORG DEFAULT '2700'.
    PARAMETERS P_STATUS LIKE VBAK-ZZ_COMP_02.
    *SELECT-OPTIONS SO_ERDAT LIKE VBAK-ERDAT DEFAULT SY-DATUM.
    SELECTION-SCREEN END OF BLOCK PSP.
    SELECT * INTO TABLE IT_VBAK1 FROM VBAK
             WHERE AUART EQ P_AUART
             AND   VKORG EQ P_VKORG
             AND   ZZ_COMP_02 EQ P_STATUS.
    IF NOT IT_VBAK1[] IS INITIAL.
    SORT IT_VBAK1 BY VBELN.
    LOOP AT IT_VBAK1.
    SELECT SINGLE * FROM KNA1
                    INTO IT_KNA1
                    WHERE KUNNR = IT_VBAK1-KUNNR.
    SELECT SINGLE * FROM VBPA
                    INTO IT_VBPA
                    WHERE VBELN = IT_VBAK1-VBELN
                    AND PARVW = 'ZK'.
    SELECT SINGLE * FROM PA0001
                    INTO IT_PA0001
                    WHERE PERNR = IT_VBPA-PERNR.
    SELECT SINGLE * FROM VBPA
                    INTO IT_VBPA1
                    WHERE VBELN = IT_VBAK1-VBELN
                    AND PARVW = 'ZT'.
    SELECT SINGLE * FROM PA0001
                    INTO IT_PA00011
                    WHERE PERNR = IT_VBPA1-PERNR.
              T_VBELN      = IT_VBAK1-VBELN.
              T_VGBEL      = IT_VBAK1-VGBEL.
              SHIFT T_VBELN LEFT DELETING LEADING '0'.
              SHIFT T_VGBEL LEFT DELETING LEADING '0'.
              MOVE T_VBELN                 TO IT_VBAK-VBELN.
              MOVE T_VGBEL                 TO IT_VBAK-VGBEL.
              MOVE IT_VBAK1-ZZ_PROBEZ      TO IT_VBAK-ZZ_PROBEZ.
              MOVE IT_VBPA-PERNR           TO IT_VBAK-ZK_PERNR.
              MOVE IT_VBPA1-PERNR          TO IT_VBAK-ZT_PERNR.
               APPEND IT_VBAK.
            ENDLOOP.
    ELSE.
      WRITE: /'No Record Exists'.
    ENDIF.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform build_events.
    perform build_print_params.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
      fieldcatalog-fieldname   = 'VBELN'.
      fieldcatalog-seltext_m   = 'Order No.'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'VGBEZ'.
      fieldcatalog-seltext_m   = 'Quotation Ref.'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NAME1'.
      fieldcatalog-seltext_m   = 'Customer'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          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).
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = IT_VBAK
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM DATA_RETRIEVAL.
    ENDFORM.
    Form  TOP-OF-PAGE                                                 *
    ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          ld_title(100) type c,
          ld_title2(200) type c,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c,
          it_logo(10) type c.
         LD_TITLE = 'SD REPORT'.
      wa_header-typ  = 'H'.
      wa_header-info =  ld_title.
      append wa_header to t_header.
      clear wa_header.
    wa_header-typ  = 'A'.
    wa_header-info = t_line.
    append wa_header to t_header.
    clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary  = t_header.
    endform.
          FORM USER_COMMAND                                          *
          --> R_UCOMM                                                *
          --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
      Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'VBELN'.
        Read data table, using index of row user clicked on
         READ TABLE IT_VBAK INTO WA_VBAK INDEX rs_selfield-tabindex.
        Set parameter ID for transaction screen field
          SET PARAMETER ID 'AUN' FIELD WA_VBAK-VBELN.
        Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    *&      Form  BUILD_EVENTS
          Build events table
    form build_events.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = gt_events[].
      read table gt_events with key name =  slis_ev_end_of_page
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_PAGE' to ls_event-form.
        append ls_event to gt_events.
      endif.
        read table gt_events with key name =  slis_ev_end_of_list
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_LIST' to ls_event-form.
        append ls_event to gt_events.
      endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
          Setup print parameters
    form build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    =============================
    She

    Hi SHE,
    Check the attached sample code for more details. Hope this helps.#
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT 'she @company.com',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT 'she @company.com',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    * Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    * Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount  LIKE tbtcm-jobcount,
          gd_jobname   type btcjob,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error     TYPE sy-subrc,
          gd_reciever  TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    * Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    *** Alternative way could be to submit another program and store spool
    *** id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
    *        to sap-spool
    *        spool parameters   %_print
    *        archive parameters %_print
    *        without spool dynpro
    *        and return.
    * Get spool id from program called above
    *  IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    *  perform send_email using p_email2.
    ENDFORM.
    *       FORM send_email                                               *
    *  -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    *  CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    * If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.

  • Displaying an ALV report using a saved layout.

    Dear friends
    In ALV report there are 2 standard buttons.
    One says "select Layout CTRLF9" and another one says "Save Layout CTRLF10".
    Using this I can select the layout and save it using some variable.
    Now I want to create a field in the main screen so that when
    I enter this saved name  and run  the ALV report, it should show
    report using the layout I entered selected (which was saved earlier).
    Where will this variable get saved and how can i access this and make it
    display using this layout.
    Any feed back will be greatly appreciated.
    Thanks
    Ram

    Hi Ram,
    Try this code..
    BR
    Rakesh
    **// INITIALIZATION.
    initialization.
      perform initialize_variables.
    **// AT SELECTION-SCREEN.
    at selection-screen.
      if p_vari is initial.
        variant_init.
      endif.
      perform check_email.
    at selection-screen on value-request for p_vari.
      alv_f4_for_variant.                                       "#EC
    at selection-screen on p_vari.
      alv_pai_of_selection_screen.
                                  M A C R O S                            *
    define variant_init.
      clear: disvariant,
             vartext.
      if v_pgm is initial.
        disvariant-report     = sy-cprog.
      else.
        disvariant-report     = v_pgm.
      endif.
    end-of-definition.
    define alv_f4_for_variant.
      variant_init.
      call function 'REUSE_ALV_VARIANT_F4'
           exporting
                is_variant = disvariant
                i_save     = xsave
           importing
                e_exit     = i_exit
                es_variant = disvariant
           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.
      elseif i_exit = space.
        p_vari  = disvariant-variant.
        vartext = disvariant-text.
        refresh i_dynpread.
        i_dynpread-fieldname  = 'VARTEXT'.
        i_dynpread-fieldvalue = disvariant-text.
        append i_dynpread.
        call function 'DYNP_VALUES_UPDATE'
             exporting
                  dyname     = v_pgm
                  dynumb     = '1000'
             tables
                  dynpfields = i_dynpread.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                  with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
      else.
        variant_init.
      endif.
    end-of-definition.
    define alv_pai_of_selection_screen.
      if not p_vari is initial.
        move p_vari to disvariant-variant.
        call function 'REUSE_ALV_VARIANT_EXISTENCE'
             exporting
                  i_save     = xsave
             changing
                  cs_variant = disvariant.
        vartext = disvariant-text.
      else.
        variant_init.
      endif.
    end-of-definition.

  • Can any ALV report be converted to PDF with same look and fill

    Dear All,
    I have a requirement of converting one ALV report to PDF/HTML format and then send it via mail without disturbing the look and fill of the report. Can anyone please help me out?
    Thanks and regards,
    Atanu

    Hi ,
    You can dsave it in  HTML format .  
    when you are in ALV  output . just press control +P.  then the output will send to spool request. note down that spool request number  and go to SP01 transaction there give the spool  request number and you will get the screen with small icon of your output. Just click on the icon  then you will see the output . then select the menu path as below.
    Spoolrequest-> Forward-> Save to local
    here you will see the options to save..  (HTML, Spread sheet,clip board and Rich text formats)
    Reward if useful..
    Thanks.
    Nageswar

Maybe you are looking for

  • How can i get my apps back?

    I had a 4th generation ipod touch that i bought apps on through the app store, but it broke so i bought another but now i cant figure out how to get the apps back. I tried going to the app store, then to purchased (using the same account) but in the

  • Simon Greener's Morton Key Clustering in Oracle Spatial

    Hi folks, Apologies for the rambling.  With mattyschell heading for greener open source big apple pastures I am looking for new folks to bounce ideas and code off.  I was thinking this week about the discussion last autumn over spatial clustering. ht

  • Bullet colour In Word 2010/2013

    Can I change the colour of the bullet for a paragraph style?  I want the bullet to be a different colour to the text.  e.g. Blue bullet and grey text.

  • Printing to Xerox 4150 fails

    Printing to th XEROX workcenter is not possible due tot "filter" prblems. The fliter fails. Couls anyone give me a clue on how tot solve the problem. My Xerox drivers are updated already. Kind regards!

  • JWS log location?

    Hi, I am running a jnlp from my Tomcat server and the web start seems to crash immediately bringing down the java console with it. Is there a place that webstart logs info about what went wrong? Thanks.