ALV to spool

Hello,
I am running in foreground a report that, in the end, displays an ALV grid.
I would like to save data from ALV into a spool format when running the program in foreground , not only display it on screen.
I know that this cand be done using a badi or bapi  FM but I don't know which it is...
Any help?
Thank you.

Hi ,
No need to go for any BADI .
if you  schedule your program  in Background than it will automatically generate spool .
For the please add below code into your program :
tables : SSCRFIELDS .
AT SELECTION-SCREEN .
  CASE sscrfields-ucomm .
    WHEN  'BAKGR' .                 PROGRAM HAS TO BE EXECUTE IN BACKGROUND
      SSCRFIELDS-UCOMM = 'SJOB'.
Before this just create a button for execute program in Backgorund on selection screen . So when
user click on that button this program will show you the screen to schudle prog in background .
BAKGR :  is the user command of the button created on screen .
Your  prob will solve definately .
Regards ,
Nilesh Jain .

Similar Messages

  • How to send an ALV to Spool

    Dear all,
    Could you please help, my requirement is to send an ALV report as a PDF attachement to a list of email address. My plan is to send the ALV to spool and read it from there and email it. However I have a problem in as much as the ALV is not being sent to spool, furthermore I also get print dialog popup when running the report. Can you please help, i am using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY and  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF' I have browsed here and there are several questions on this topic but they do not address the issue of sending the file to the spool. The partial code is below
    DATA:i_t001 TYPE t001 OCCURS 0,
         pdf    LIKE tline OCCURS 0,
         g_spool   TYPE tsp01-rqident,
         g_program TYPE sy-repid VALUE sy-repid.
    TYPE-POOLS:slis.
    DATA: w_print TYPE slis_print_alv,
          w_print_ctrl TYPE alv_s_pctl.
    PARAMETERS: p_file TYPE string.
    INITIALIZATION.
      p_file = 'H:\TEST_gh.pdf'.
    START-OF-SELECTION.
      rp-def-time-period.
      help1 = behrs DIV 24.
      bdate = ldate - help1.
      help1 = behrs MOD 24.
      help2 = ltime(2) - help1.
      IF help2 LT 0.
        bdate = bdate - 1.
        btime = ltime.
        btime(2) = 24 + help2.
      ELSE.
        btime = ltime.
        btime(2) = help2.
      ENDIF.
      pn-begps = ldate - 1.
      pn-endps = ldate.
    GET pernr.
      loop at p0007 where begda le ldate and endda ge ldate.  "
      endloop.                                              
    * überprüft Arbeitszeitplanregel
    * CHECK schkz.
      CHECK p0007-schkz IN schkz.
      CHECK p0007-zterf IN zterf.        
      CALL FUNCTION 'HR_SEL_STAT_CHECK'
           EXPORTING
                get_pernr    =  pernr-pernr
                get_ldate    =  ldate
                get_bdate    =  bdate
                get_btime    =  btime
                get_psp_flag =  psp_flag
                get_ltime    =  ltime
    *    IMPORTING
    *         NO_PERMIT    =
           TABLES
                get_p0000    =  p0000
                get_p0001    =  p0001
                get_p0002    =  p0002
                get_p0050    =  p0050
                get_p0007    =  p0007
                data_tab     =  data_tab.
    *   End-of-Selection                                                   *
    END-OF-SELECTION.
      loop at data_tab into ls_data_tab.
        ls_data_tab-total_records = '1'.
        ls_data_tab-kostl = p0001-kostl.
        Append ls_data_tab to lt_data_tab.
      endloop.
      DESCRIBE TABLE data_tab LINES lines.
      CALL FUNCTION 'HR_GET_ERROR_LIST'
        TABLES
          error      = errors
          errortexts = errortexts
        EXCEPTIONS
          no_errors  = 1
          OTHERS     = 2.
      IF lines EQ 0 AND sy-subrc EQ 1.
        MESSAGE i050.
        STOP.
      ENDIF.
      LOOP AT errors.
        READ TABLE data_tab WITH KEY errors-pernr.
        IF sy-subrc EQ 0.
          DELETE data_tab INDEX sy-tabix.
        ENDIF.
      ENDLOOP.
      g_repid = sy-repid.
    * fill field catalog for output
      PERFORM fill_fcat USING  fcat
                               g_repid.
    * Listheader
      PERFORM fill_header USING header_alv_wa
                                header_alv.
      FIELD-SYMBOLS <lwa_fcat> like line of fcat.
      LOOP AT fcat ASSIGNING <lwa_fcat>.
        IF <lwa_fcat>-fieldname = 'TOTAL_RECORDS'.
          <lwa_fcat>-do_sum    = 'X'.
        ENDIF.
      ENDLOOP.
    *Right, sort the table and produce sub totals
      wa_sort-spos      = 18.
      wa_sort-fieldname = 'KOSTL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      append wa_sort to it_sort.
    * Layout for REUSE_ALV_GRID_DISPLAY
      s_layout-colwidth_optimize = 'X'.
      s_layout-zebra             = 'X'.
      s_layout-no_author         = 'X'.
    w_print-print = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = g_repid
        "      i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command = 'USER_COMMAND'  
          i_callback_top_of_page  = 'TOP_OF_PAGE'
          is_layout               = s_layout           
          it_fieldcat             = fcat
          it_sort                 = it_sort
          i_save                  = 'A'                       
          i_structure_name        = MY_STRUCTURE'
          is_print                = w_print
        TABLES
          t_outtab                = lt_data_tab
        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.
      ELSE.
    ***=====================================================================*
        g_spool = sy-spono.
        CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid = g_spool
          TABLES
            pdf         = pdf.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ELSE.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename = p_file
              filetype = 'BIN'
            TABLES
              data_tab = pdf.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ELSE.
            CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
              EXPORTING
                i_callback_program      = g_repid
              "      i_callback_pf_status_set = 'SET_PF_STATUS'
                i_callback_user_command = 'USER_COMMAND'  
                i_callback_top_of_page  = 'TOP_OF_PAGE'
                is_layout               = s_layout           
                it_fieldcat             = fcat
                it_sort                 = it_sort
                i_save                  = 'A'                 
                i_structure_name        = MY_STRUCTURE'
              TABLES
                t_outtab                = lt_data_tab
              EXCEPTIONS
                program_error           = 1.
                ENDIF.
          endif.
        endif.

    Hi Andy ,
    write this code before calling "CONVERT_ABAPSPOOLJOB_2_PDF"
    CALL FUNCTION 'SET_PRINT_PARAMETERS'
         EXPORTING
           destination = 'LOCL' " Printer
           layout      = 'X_65_512/2' "Format "X_65_255
           line_count  = '65' "Line Count
           line_size   = '1024'. "Line Size
    Regards ,
    Yogendra Bhaskar

  • ALV grid - spool

    Hi
    I have a alv grid display. when i run the report in background, i am able to see that a spool number is generated but i dont know how to check whether what is inside the spool is same as in ALV.

    here is FM i used
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       i_callback_program                = report_id
      i_callback_top_of_page            = 'LIST_HEADING'
      is_layout                         = i_layout
       it_fieldcat                       = i_fieldcat
      TABLES
        t_outtab                          = ALV_OUT[]
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2

  • Alv to spool to pdf to mail

    hi all,
         I am having a single alv report  which should run in background & generate spool and after data convert the spool to pdf and send to mail. I want all these in a single alv report & it should be schedule in background.
    First I copied the ALV report code then after I used the FM CONVERT_ABAPSPOOLJOB_2_PDF,
    SO_DOCUMENT_SEND_API1 subsequently.
    I have done so but the spool is not getting generated for my ALV.
    I want help

    Hi,
    I have output multiple ALV lists to spool using the following procedure. OO ALV is displayed during foreground, but not in background. I hope your standards permit that.
    Code: Select all
    form print_data.
      data: l_repid  like sy-repid,
            t_events type slis_alv_event occurs 0 with header line.
      if cb_srpls = '' and cb_cnsmt = ''.
        exit.
      endif.
      l_repid = sy-repid.
      g_usage_disp_var-report = l_repid.
      g_usage_disp_var-variant = p_usglyt.
      g_srpls_disp_var-report = l_repid.
      g_srpls_disp_var-variant = p_srplyt.
    When the report was run in background, we display the ALV list two
    times. One time for consumption and another time for surplus. In
    order to accomplish that, we display the second list during the
    END-OF-LIST event of the first list. Depending on which list the user
    want displayed, this logic becomes little tricky.
      if sy-batch = 'X'.
        if cb_srpls = 'X'.            "We want surplus to be displayed
          if cb_cnsmt = 'X'.          "We want the consumption also
            t_events-name = slis_ev_end_of_list.
            t_events-form = 'DISPLAY_SURPLUS_LIST'.
            append t_events.
          else.
            perform display_surplus_list.
          endif.
        endif.
        if cb_cnsmt = 'X'.
          call function 'REUSE_ALV_LIST_DISPLAY'
               exporting
                    i_callback_program = l_repid
                    i_structure_name   = 'ZSS_MAT_SURPLUS1'
                    i_save             = 'X'
                    is_variant         = g_usage_disp_var
                    it_events          = t_events[]
               tables
                    t_outtab           = t_usage_catg.
          if sy-subrc <> 0.
            exit.
          endif.
        endif.
      else.
        call screen '0100'.
      endif.
    endform.                    " print_data
          FORM display_surplus_list                                     *
    form display_surplus_list.
      data: l_layout type slis_layout_alv.
      l_layout-list_append    = 'X'.
      l_layout-colwidth_optimize = 'X'.
      call function 'REUSE_ALV_LIST_DISPLAY'
           exporting
                i_structure_name = 'ZTM_MAT_SURPLUS'
                i_save           = 'X'
                is_layout        = l_layout
                is_variant       = g_srpls_disp_var
           tables
                t_outtab         = t_surplus.
      if sy-subrc <> 0.
        exit.
      endif.
    endform.
    Regards,
    Jagadish

  • ALV to spool display half report

    Hi ,
    I have generated ALV report which is working fine on foreground but when I execute this report in the background it shows half (some columns are missing) in the generated spool. I need to execute this report in background due to large amount of data. Is this due to the size exceeding more than 255 chars ?
    If yes, is there any solution ?

    Hi,
    You have to configure the printer settings, consult basis people for the same. Also refer to the note as below:
    ALV print : Print formatting in the background
    SAP Note Number: 674348 
    Symptom
    Wen you execute a report in the background with a preset printer, a default format is always transferred. In general, this format is too small for the ALV and the table is therefore truncated during printing.
    If you would like to change this behavior, you have two options:
    1. The format can be changed subsequently either directly in the print dialog box or in the spool display.
    2. If you wish the list width to be recalculated, this modification must be implemented in the ALV.
    Other terms
    ALV Grid Control (CL_GUI_ALV_GRID), REUSE_ALV_GRID_DISPLAY, ALV print: Background, print, print formatting, format, ALV background: Background processing, in the background
    Reason and Prerequisites
    A print format that was transferred in the background was set as default.
    Implementing note 669744 is a prerequisite.
    Solution
    Implement the source code corrections in accordance with the correction instructions. Then remove the * character in the following lines:
        else.  "Modifikation
         call function 'UNSET_PRINTPARAMETER'      "Y9CK042107
               exporting
                    name = 'LAYOUT'
                   in_parameters = rs_pri_params
               importing
                    out_parameters = rs_pri_params.
    This note cannot be implemented using the Note Assistant. Customers must take this modification into consideration when implementing updates at a later stage.
    Hope it helps.
    Lokesh

  • ALV TO SPOOL TO PRINT

    Hi all ,
    i would like to know how we will convert alv list (using REUSE_ALV_LIST_DISPLAY) output to the spool and from there to the printer ,But that program should runs in the background only,Not in the frontend.
    Please any sample code or atleast any URL'S
    Please it is very very urgent.........
    Thanks in advance..
    SRIHASA.

    Hi SRIHASA,
    If you are running the report in BG, The Output (ALV) automatically genereate the spool request number. if you want to print the spl.request, based on the request number you get the print out.
    if you are not getting the spool request, Pass the print parameter to the ALV FM.
    Reward if found helpful.
    Regards,
    Boobalan Suburaj

  • ALV GRID SPOOL PDF EMAIL

    Hello,
    I'm getting frustrated with a ALV issue.
    My report creates a ALV grid which I'm able to print to spool, afterwards create a PDF and finally send to a specific email adress with the PDF attached.
    What I'm wondering is, why when calling 'REUSE_ALV_GRID_DISPLAY' I'm getting this print parameter dialog.
    Moreover calling function 'SET_PRINT_PARAMETERS' has no effect to the parameters showing in the dialog?!
    As I finally want to run this report within a scheduled job I do not want that popup.
    I now read the forum entires for half a day, tried almost everything, but without success.
    Maybe someone can help with my code?
    * Declaration section
    DATA: itab_feldkatalog   TYPE   slis_t_fieldcat_alv,
          wa_feldkatalog     TYPE   line of slis_t_fieldcat_alv,
          gs_layout          TYPE   slis_layout_alv,
          gs_print           TYPE   SLIS_PRINT_ALV.
    *   output as PDF eMail
        g_repid = sy-repid.
        CALL FUNCTION 'SET_PRINT_PARAMETERS'
          EXPORTING
    *        destination   = 'LOCL'      " Printer
            layout        = 'X_65_200'  " Format
            line_count    = '65'        " Line Count
            line_size     = '200'       " Line Size
            in_parameters = gs_print-print_ctrl-pri_params.
    *   Print parameters
        gs_print-print              = 'X'.
        gs_print-prnt_title         = 'X'.
        gs_print-no_coverpage       = 'X'.
        gs_print-no_print_listinfos = 'X'. 
        gs_print-no_print_selinfos = 'X'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program     = g_repid
            i_callback_top_of_page = 'TOP_OF_PAGE_SETUP'     
            I_GRID_TITLE           = 'Risk MM Report'
            I_SAVE                 = 'A'
            IT_FIELDCAT            = itab_feldkatalog
            is_layout              = gs_layout
            IS_VARIANT             = is_variant
            IS_PRINT               = gs_print
          TABLES
            T_OUTTAB               = t_inv_cond.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        perform pdf_email.  " create PDF and send by email
    Thanks a lot!

    Thanks for your help.
    This modifications solved my problem!
        CALL FUNCTION 'GET_PRINT_PARAMETERS'
          EXPORTING
            immediately            = ' '
            line_size              = 220
            release                = 'X'
            mode                   = 'CURRENT'
            no_dialog              = 'X'
          IMPORTING
            out_parameters         = gs_print-print_ctrl-pri_params
            valid                  = gv_valid
          EXCEPTIONS
            archive_info_not_found = 1
            invalid_print_params   = 2
            invalid_archive_params = 3
            OTHERS                 = 4.
        NEW-PAGE PRINT ON PARAMETERS gs_print-print_ctrl-pri_params NO DIALOG.
    *   Print parameters
        gs_print-print              = 'X'.
        gs_print-prnt_title         = 'X'.
        gs_print-no_coverpage       = 'X'.
        gs_print-no_print_listinfos = 'X'.  " display no listinfos
        gs_print-no_print_selinfos  = 'X'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program     = g_repid
            i_callback_top_of_page = 'TOP_OF_PAGE_SETUP'       " Ref. to form
            I_GRID_TITLE           = 'Risk MM Report'
            I_SAVE                 = 'A'
            IT_FIELDCAT            = itab_feldkatalog
            is_layout              = gs_layout
            IS_VARIANT             = is_variant
            IS_PRINT               = gs_print
          TABLES
            T_OUTTAB               = t_inv_cond.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        NEW-PAGE PRINT OFF.

  • ALV and SPOOL

    Hi:
    I have a report that show the results with an ALV (REUSE_ALV_HIERSEQ_LIST_DISPLAY), but when I run it in background appears a first page with Data statistics (Head records passed, Items records passed).
    Is there anyway to hide the Data statistics in a Spool Request??? (remember, it only appears if i run the report in background)
    Thanks in advance.
    David

    Hi David,
    Take a look at parameter IS_PRINT of function module REUSE_ALV_HIERSEQ_LIST_DISPLAY. You can switch off several options for printing.
    Regards,
    John.

  • How to send a mail more than 255 characters in PDF format

    Hi Experts
    I am facing a problem sending an ALV list spool as an email attachment in PDF format. Here my problem is spool has morethan 255 characters, so the contents are trukated after 255.
    I am using the FM "SO_NEW_DOCUMENT_ATT_SEND_API1" to send the email. Please give any good suggestion.
    Thanks in advance
    Praveen

    Hi,
    <li>After converting spool to PDF using CONVERT_ABAPSPOOLJOB_2_PDF, need to use below function module
    <li>Use SX_TABLE_LINE_WIDTH_CHANGE to convert line width to 255 chars.
       CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
          EXPORTING
            line_width_src              = 134
            line_width_dst              = 255
          TABLES
            content_in                  = i_pdf
            content_out                 = l_attachment
          EXCEPTIONS
            err_line_width_src_too_long = 1
            err_line_width_dst_too_long = 2
            err_conv_failed             = 3
            OTHERS                      = 4.
        IF sy-subrc NE 0.
          MESSAGE s000(0k) WITH 'Conversion Failed'.
          EXIT.
        ENDIF.
    Thanks
    Venkat.O

  • Appending zeros in MATNR

    Hi,
    I facing an issue in which MATNR (MSEG-MATNR) is not getting printed in ALV in spool. To solve it i tried by appending 0s in MATNR. I appended 13 zeros to make 12270 value of 18 characters. It got printed with two leading zeros, then i tried by appending 12 zeros it got printed with one leading zero, then i added 11 zeros it got printed without any leading zero, as i keep on reducing zeros from 13 to 12 to 11 to 10 to 9 number of digits also goes on decreasing from 0012270 to 012270 to 12270 to 2270 and so on to nothing. Can any one explain this abnormality.
    Regards,
    Ap.

    Hi,
    try Function-Module CONVERSION_EXIT_ALPHA_INPUT to set the MATNR into the internal format.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = lv_matnr
        IMPORTING
          output = lv_matnr.
    Best Regards Stefan

  • Spool not getting generated in OO ALV report

    Hi,
    I developed a report in which we are giving output in same selection screen through OO ALV.
    But,when we are scheduling that report in background,spool is not getting generated.
    Waiting for your reply.
    BR,
    Praveen

    Hi Aparna,
    I tried NEW-PAGE PRINT ON.
    I am pasting source code extract below:
       IMPORT DATA = ME->IT_FINAL2 FROM MEMORY ID SY-CPROG.
        FREE MEMORY ID SY-CPROG.
        CHECK ME->IT_FINAL2 IS NOT INITIAL.
        CHECK LO_DOCK IS INITIAL.
        CREATE OBJECT LO_DOCK
          EXPORTING
            REPID = SY-REPID
            DYNNR = SY-DYNNR
            RATIO = 70
            SIDE  = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_BOTTOM
            NAME  = 'DOCK_CONT'.
        IF SY-SUBRC NE 0.
          MESSAGE 'Error in Docking Control' TYPE 'S'.
        ENDIF.
        IF LO_ALV IS INITIAL.
          TRY.
              LO_CONT ?= LO_DOCK.
              CALL METHOD CL_SALV_TABLE=>FACTORY
                EXPORTING
                  LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
                  R_CONTAINER    = LO_CONT
                  CONTAINER_NAME = 'DOCK_CONT'
                IMPORTING
                  R_SALV_TABLE   = LO_ALV
                CHANGING
                  T_TABLE        = ME->IT_FINAL2.
            CATCH CX_SALV_MSG.
          ENDTRY.
      CLEAR LR_COLUMN.
          TRY.
              LR_COLUMNS = LO_ALV->GET_COLUMNS( ).
              LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'KSCHL' ).
              LR_COLUMN->SET_LONG_TEXT( 'Cond.Type' ).
    CATCH CX_SALV_NOT_FOUND.
          ENDTRY.
    NEW-PAGE PRINT ON.
            LO_ALV->DISPLAY( ).
            NEW-PAGE PRINT OFF.
    I am not getting spool list while executing it in background.
    BR,
    Praveen

  • Eliminate page heading in the spool of ALV report

    Hi,
    We are running the ALV report in the background, and when we view the spool
    the page heading and the column heading is displayed for all the pages, Is there some way to
    eliminate this.
    The download from the on-line exec is fine,but the download from the spool includes the column
    headings for each page. Is there some way to check if the ALV report is run in the batch mode
    and to disable the heading from Page 2 to N.
    Appreciate any input.
    Thank you
    Lalitha

    Hi,
    I need to avoid the column headings also, I need the heading in the first page, but not on the subsequent pages.
    Is there any setting in the ALV function modules to prevent this ?
    So wanted to know if there is some setting to accomplish that.
    Thank you
    Lalitha

  • ALV report display online and generate in spool

    Dear expert,
    I have created an ALV report. I want to run this report online. After executed, the report is displayed. After display this report, I also want to generate the output report in the spool. Is there any way to do this? Thank you.
    I have tried to use submit...to SAP Spool. in this way, it will generate the spool, but it will not display the report online. I want it both display online and generate a spool.

    well forget yout the new-page print on thingie, since you use ALV.
    if you had a write list this trick would be cool since you just could do following:
    Do 2 times.
      if sy-index GT 1.
        new page print on.
      endif.
      loop at itab into wa.
        write stuff....
      endloop.
      if sy-index GT 1.
        new page print off.
      endif.
    enddo.
    /edit arrrgh forgot to write further...
    with your ALV you could process a write list as well after displaying but you will have layout differences between your display and your spool then and i dont think that this is what you want/need.
    you could however after display process your programm a second time, in background task and give it a printer where to print to. Since ALV wont get executed in background task you will get a spool instead.
    Edited by: Florian Kemmer on Sep 15, 2010 2:40 PM

  • Alv show in report but when see in spool (after run background job) there i

    my program have some error when i run result alv show in report but when see in spool (after run background job) there is no data, (other program can see result in spool)
    Please help
    here is some example of my program
    ********************************declare internal table*****************************
    internal table output for BDC
    data : begin of t_output occurs 0,
    bukrs type anla-bukrs,
    anln1 type anla-anln1,
    anln2 type anla-anln2,
    zugdt type anla-zugdt,
    result(70) type c,
    end of t_output.
    *****get data from loop********************************
      loop at t_anla.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  INPUT  = t_anla-anln1
             IMPORTING
                  OUTPUT = t_anla-anln1.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  INPUT  = t_anla-anln2
             IMPORTING
                  OUTPUT = t_anla-anln2.
    check record is correct or not
        select single bukrs anln1 anln2 zugdt
        into w_output
        from anla
        where bukrs = t_anla-bukrs and
        anln1 = t_anla-anln1 and
        anln2 = t_anla-anln2
       zugdt = '00000000'
    if record is correct
        if sy-subrc = 0 and w_output-zugdt = '00000000'.
          w_output-bukrs = t_anla-bukrs.
          w_output-anln1 = t_anla-anln1.
          w_output-anln2 = t_anla-anln2.
          w_output-result = 'Yes : this asset can delete'.
          append w_output to t_output.
    if record is not correct
        elseif sy-subrc = 0 and w_output-zugdt <> '00000000'.
    there is error record  this asset have value already
          v_have_error = 'X'.
          w_output-bukrs = t_anla-bukrs.
          w_output-anln1 = t_anla-anln1.
          w_output-anln2 = t_anla-anln2.
          w_output-result = 'Error : this asset have value already'.
          append w_output to t_output.
        else.
    there is error record this asset donot exist in table anla
          v_have_error = 'X'.
          w_output-bukrs = t_anla-bukrs.
          w_output-anln1 = t_anla-anln1.
          w_output-anln2 = t_anla-anln2.
          w_output-result = 'Error : this asset doest not exist'.
          append w_output to t_output.
        endif.
    *end of check record is correct or not
        clear w_output.
      endloop.
    ******************************show data in ALV***************************************************
    show data from file in ALV
      perform display_report_ALV.
    *&      Form  display_report_ALV
    form display_report_ALV.
      DATA: LT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
          LT_EVENTS TYPE SLIS_T_EVENT,
          LV_REPID LIKE SY-REPID.
      PERFORM ALV_DEFINE_FIELD_CAT USING LT_FIELD_CAT.
      PERFORM ALV_HEADER_BUILD USING T_LIST_TOP_OF_PAGE[].
      PERFORM ALV_EVENTTAB_BUILD USING LT_EVENTS[].
      LV_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM = LV_REPID
                IT_FIELDCAT        = LT_FIELD_CAT
                I_SAVE             = 'A'
                IT_EVENTS          = LT_EVENTS[]
           TABLES
                T_OUTTAB           = t_output
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
      IF SY-SUBRC NE 0.
        WRITE: / 'Return Code : ', SY-SUBRC,
          'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
      ENDIF.
    endform.
    *&      Form  alv_define_field_cat
          text
         -->P_LT_FIELD_CAT  text
    FORM ALV_DEFINE_FIELD_CAT USING  TB_FCAT TYPE SLIS_T_FIELDCAT_ALV.
      DATA: WA_FIELDCAT LIKE LINE OF TB_FCAT,
        LV_COL_POS TYPE I.
      DEFINE FIELD_CAT.
        CLEAR WA_FIELDCAT.
        ADD 1 TO LV_COL_POS.
        WA_FIELDCAT-FIELDNAME = &1.
        WA_FIELDCAT-REF_TABNAME = &2.
        WA_FIELDCAT-COL_POS = LV_COL_POS.
        WA_FIELDCAT-KEY = &3.
        WA_FIELDCAT-NO_OUT = &4.
        WA_FIELDCAT-REF_FIELDNAME = &5.
        WA_FIELDCAT-DDICTXT = 'M'.
        IF NOT &6 IS INITIAL.
          WA_FIELDCAT-SELTEXT_L = &6.
          WA_FIELDCAT-SELTEXT_M = &6.
          WA_FIELDCAT-SELTEXT_S = &6.
        ENDIF.
        WA_FIELDCAT-DO_SUM = &7.
        WA_FIELDCAT-OUTPUTLEN = &8.
        APPEND WA_FIELDCAT TO TB_FCAT.
      END-OF-DEFINITION.
      FIELD_CAT  'BUKRS'  'ANLA'     'X' '' 'BUKRS' 'Company Code' '' ''.
      FIELD_CAT  'ANLN1'  'ANLA'     'X' '' 'ANLN1' 'Asset Number' '' ''.
      FIELD_CAT  'ANLN2'  'ANLA'     'X' '' 'ANLN2' 'Asset Sub Number' '' ''.
    FIELD_CAT  'ATEXT'   'T5EAE'     'X' '' 'ATEXT' 'Result' '' ''.
      FIELD_CAT  'RESULT'  ''     'X' '' 'RESULT' 'RESULT' '' ''.
    ENDFORM.                    " alv_define_field_cat

    Hi,
    Check this code..
    FORM display_report_alv.
      DATA: lt_field_cat TYPE slis_t_fieldcat_alv,
      lt_events TYPE slis_t_event,
      lv_repid LIKE sy-repid.
      PERFORM alv_define_field_cat USING lt_field_cat.
      PERFORM alv_header_build USING t_list_top_of_page[].
      PERFORM alv_eventtab_build USING lt_events[].
      lv_repid = sy-repid.
      IF sy-batch EQ 'X'.  ----> " System Field for Backgroud..if Background use list display
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program = lv_repid
            it_fieldcat        = lt_field_cat
            i_save             = 'A'
            it_events          = lt_events[]
          TABLES
            t_outtab           = t_output
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ELSE.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program = lv_repid
            it_fieldcat        = lt_field_cat
            i_save             = 'A'
            it_events          = lt_events[]
          TABLES
            t_outtab           = t_output
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ENDIF.
      IF sy-subrc NE 0.
        WRITE: / 'Return Code : ', sy-subrc,
        'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
      ENDIF.
    ENDFORM.                    "display_report_ALV

  • ALV report run In background gives 2 spool numbers

    Hi ,
    The ALV report which I am running in Background gives me 2 spool numbers after the Job is created in sm37.
    I am just executing my ALV report by running it in backgroung procressing, but I get 2 spool one has all the correct data of the ALV and 1 blank spool is created.
    I have Passed the followin parameter to my ALV FM.
      lwa_print-no_change_print_params = 'X'.
      lwa_print-no_print_listinfos = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program       = sy-repid
         i_callback_pf_status_set = 'SET_PF_STATUS'
         i_callback_user_command  = 'USER_COMMAND'
         i_default                = space
         is_layout                = t_layout
         is_print                 = lwa_print
         it_fieldcat              = t_fieldcat
       TABLES
         t_outtab                 = t_final
       EXCEPTIONS
         program_error            = 1
         OTHERS                   = 2.
    Unable to find the reason why I get 2 spool created for it?
    Thanks
    Ritesh

    Hi venkatesh,
    Thanks for the reply.
    I tried that also but issue was due to a SKIP statement called in the program and due to which a new spool which was blank was called.
    The issue is resolved.
    Thanks
    Solanki Ritesh

Maybe you are looking for

  • BAPI -for Creating EXCISE INVOICE AT DEPOT  tcode 'J1IG

    Hi All, Is there any  BAPI for Excise Invoice Creation at depot Tcode is J1IG Thanks, Satishreddy

  • Struts - Hibernate

    Hi, I am currently working on a small (for me quite large) project with Struts. Some basic Information I am quite new to J2ee applications but decided to work with Struts, because there are more references of tutorials and I have little experience in

  • [SOLVED] Did pacman -Syu and now gdm, gnome, and pacman won't work

    Hi everyone, I did a search for my problem, but cannot find the solution. Basically, I updated my computer this morning and as soon as the packages got installed my computer crashed. I am using another computer right now. These were the packages that

  • Copying PDF data to context

    Hi, I am working on Web Dynpro  Java (SP 13) offline forms. User has to fill the form offline and upload it. Data will be copied to web dynpro  application. I am using WDInteractiveFormHelper.transferPDFDataIntoContext method for coping data. If the

  • CS5 Master Collection Mac - Where's Acrobat Pro

    I downloaded the CS5 Master Collection trial for the Mac, which doesn't have Acrobat Pro in the Trial. I purchased the license, but Acrobat Pro is still nowhere to be found. Do I have to download it separately and enter the code again? (Are there any