Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert ALV to PDF

Former Member
0 Kudos

Hi ABAPers,

As an requirement I need to convert ALV into an PDF.

Could you please guide to achieve the same.

Thanks,

niTin

7 REPLIES 7

Former Member
0 Kudos

Hi Nitin,

Create a spool job of the ALV output and convert that spool into PDF using FM CONVERT_ABAPSPOOLJOB_2_PDF.

If you want more on this then pls revert.

0 Kudos

Hi ,

I need to send this PDF as an attachment to an email after converting the PDF from ALV.

can it be done thr spool request.

thanks

Hi Nitin,

<li> ALV output as PDF possible.

REPORT  zvenkat_download_alvoutput.
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 = 'C:\venkat.pdf'.
"START-OF-SELECTION.
START-OF-SELECTION.
  SELECT * FROM t001 INTO TABLE i_t001 UP TO 100 ROWS.
  w_print-print = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = g_program
      i_structure_name   = 'T001'
      is_print           = w_print
    TABLES
      t_outtab           = i_t001.
  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_program
            i_structure_name   = 'T001'
          TABLES
            t_outtab           = i_t001.    "is_print = w_print
      ENDIF.
    ENDIF.

  ENDIF.

<li> After PDF conversion, you can send mail that PDF as an attachment. for that use SO_NEW_DOCUMENT_ATT_SEND_API1 function module.

Thanks

Venkat.O

Former Member
0 Kudos

Hi Nitin,

First convert the ALV o/p to spool, then take the spool no use Report RSTXPDFT4 to convert it to PDF.

Amitava

Former Member
0 Kudos

Hi Nitin,

define the tline ( SAPscript: Text ) as follows.

DATA: itable_pdf TYPE TABLE OF tline WITH HEADER LINE,

at first call the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' by passing the spool no and you will get the pdf data in the internal table.

EXPORTING

src_spoolid = spool_no

TABLES

PDF = itable_pdf

now call the follwing FM

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = v_string " data : v_string type string default 'testpdffile.pdf'.

FILETYPE = 'BIN'

tables

data_tab = itable_pdf

Thanks,

Abhishek

Former Member
0 Kudos

Hi,

Refer the following code...


get the spool number
* Declaration of local variables.
DATA:
LV_RQ2NAME LIKE TSP01-RQ2NAME.
 
CONCATENATE SY-REPID+0(8)
SY-UNAME+0(3)
INTO LV_RQ2NAME SEPARATED BY '_'.
* Get the spool number.
SELECT * FROM TSP01 WHERE RQ2NAME = LV_RQ2NAME
ORDER BY RQCRETIME DESCENDING.
V_RQIDENT = TSP01-RQIDENT.
EXIT.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR V_RQIDENT.
ENDIF


hope this helps

Regards

RItesh J