cancel
Showing results for 
Search instead for 
Did you mean: 

Saving the Smartform in PDF or any other format from print preview screen

Former Member
0 Kudos

Hi Gurus

Is there any way to save a smartform output as a file (preferably pdf) from the print preview screen?

The customer wants to save the file from that screen itself and want to avoid multiple steps.

To Add on to it, I am using HRFORMS. That means, I would not be able to write any code in the driver program as it is system generated on each server whenever you activate the HRFORMS.

Hence, although I know about the function module "HR_IT_DISPLAY_WITH_PDF" which can be used to convert the output of the smartforms to pdf in print preview, I cannot use it in the driver program as it is not editable.

Any suggestions/solutions would be appreciated.

Thanks

sapper.

Edited by: d sappanese on Aug 9, 2011 5:52 PM

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor
0 Kudos

Hi Sapper,

Did you try the PDF! function code? It has to be entered in the command field of the smart form print preview screen. It converts the smart form to PDF and displays it using the default PDF viewer, from there you can download the file (or print it).

Sandra

Former Member
0 Kudos

Hi Sandra.

Thanks and You are just awsome. I have been working with smartforms since so many years and did not know about this.

I achieved this in a different way. Enhanced a standard class and called the pdf prview FM to do this.

Now, I directly get the smartform print prview in adobe layout.

Thanks,

sapper.

Former Member
0 Kudos

Hi Sandra,

I have created a program with PO number as input and ib print preview screen I have entered PDF in but I am not able to save it. Could you help me.Any additonal settings to be done.

BR

Dep

Hi Sandra,

I missed the exclamation mark(!) now I am able to download!!.

Edited by: DeepakNandikanti on Aug 16, 2011 7:55 AM

Edited by: DeepakNandikanti on Aug 16, 2011 9:17 AM

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

got it!!

BR

Dep

Edited by: DeepakNandikanti on Aug 16, 2011 9:20 AM

Former Member
0 Kudos

Hi,

Refer to below smaple code :

call this FORM popup_save after you have called smartform output.

*&---------------------------------------------------------------------*
*&      Form  POPUP_SAVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM popup_save .
CASE sy-ucomm.
  WHEN 'SBAC'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      TITLEBAR              = 'Title POPUP_TO_CONFIRM'
      TEXT_QUESTION         = 'Click Cancel to Exit'
      TEXT_BUTTON_1         = 'OK'
      ICON_BUTTON_1         = 'ICON_CHECKED'
      TEXT_BUTTON_2         = 'CANCEL'
      ICON_BUTTON_2         = 'ICON_CANCEL'
      DISPLAY_CANCEL_BUTTON = ' '
      POPUP_TYPE            = 'ICON_MESSAGE_ERROR'
    IMPORTING
      ANSWER                = ANS.
  IF ANS = 2.
    LEAVE PROGRAM.
  ELSE.
*   Write your program to download to PDF.
  ENDIF.
  WHEN 'SEXI'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      TITLEBAR              = 'Title POPUP_TO_CONFIRM'
      TEXT_QUESTION         = 'Click Cancel to Exit'
      TEXT_BUTTON_1         = 'OK'
      ICON_BUTTON_1         = 'ICON_CHECKED'
      TEXT_BUTTON_2         = 'CANCEL'
      ICON_BUTTON_2         = 'ICON_CANCEL'
      DISPLAY_CANCEL_BUTTON = ' '
      POPUP_TYPE            = 'ICON_MESSAGE_ERROR'
    IMPORTING
      ANSWER                = ANS.
  IF ANS = 2.
    LEAVE PROGRAM.
  ELSE.
*   Write your program to download to PDF.    
  WHEN 'SCAN'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      TITLEBAR              = 'Title POPUP_TO_CONFIRM'
      TEXT_QUESTION         = 'Click Cancel to Exit'
      TEXT_BUTTON_1         = 'OK'
      ICON_BUTTON_1         = 'ICON_CHECKED'
      TEXT_BUTTON_2         = 'CANCEL'
      ICON_BUTTON_2         = 'ICON_CANCEL'
      DISPLAY_CANCEL_BUTTON = ' '
      POPUP_TYPE            = 'ICON_MESSAGE_ERROR'
    IMPORTING
      ANSWER                = ANS.
  IF ANS = 2.
    LEAVE PROGRAM.
  ELSE.
*   Write your program to download to PDF.    
  WHEN OTHERS.
ENDCASE.
ENDFORM.                    " POPUP_SAVE

Former Member
0 Kudos

Thanks Deepak. But the question is , where do I write this code? As mentioned before, I cannot do any changes in the driver program.

Former Member
0 Kudos

Hi,

In smartforms > under Global Definitions > Form Rotuines Just copy paste below code.

I hevent tried below code you just give a try you never know you might get a solution.

*&---------------------------------------------------------------------*
*&      Form  POPUP_SAVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM popup_save .
DATA ans type c.  " Important
* Put a BREAK_POINT here to see whether control comes here
CASE sy-ucomm.
  WHEN 'SBAC'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      TITLEBAR              = 'Title POPUP_TO_CONFIRM'
      TEXT_QUESTION         = 'Click Cancel to Exit'
      TEXT_BUTTON_1         = 'OK'
      ICON_BUTTON_1         = 'ICON_CHECKED'
      TEXT_BUTTON_2         = 'CANCEL'
      ICON_BUTTON_2         = 'ICON_CANCEL'
      DISPLAY_CANCEL_BUTTON = ' '
      POPUP_TYPE            = 'ICON_MESSAGE_ERROR'
    IMPORTING
      ANSWER                = ANS.
  IF ANS = 2.
    LEAVE PROGRAM.
  ELSE.
*   Write your program to download to PDF.
  ENDIF.
  WHEN 'SEXI'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      TITLEBAR              = 'Title POPUP_TO_CONFIRM'
      TEXT_QUESTION         = 'Click Cancel to Exit'
      TEXT_BUTTON_1         = 'OK'
      ICON_BUTTON_1         = 'ICON_CHECKED'
      TEXT_BUTTON_2         = 'CANCEL'
      ICON_BUTTON_2         = 'ICON_CANCEL'
      DISPLAY_CANCEL_BUTTON = ' '
      POPUP_TYPE            = 'ICON_MESSAGE_ERROR'
    IMPORTING
      ANSWER                = ANS.
  IF ANS = 2.
    LEAVE PROGRAM.
  ELSE.
*   Write your program to download to PDF.    
  ENDIF.  
  WHEN 'SCAN'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
      TITLEBAR              = 'Title POPUP_TO_CONFIRM'
      TEXT_QUESTION         = 'Click Cancel to Exit'
      TEXT_BUTTON_1         = 'OK'
      ICON_BUTTON_1         = 'ICON_CHECKED'
      TEXT_BUTTON_2         = 'CANCEL'
      ICON_BUTTON_2         = 'ICON_CANCEL'
      DISPLAY_CANCEL_BUTTON = ' '
      POPUP_TYPE            = 'ICON_MESSAGE_ERROR'
    IMPORTING
      ANSWER                = ANS.
  IF ANS = 2.
    LEAVE PROGRAM.
  ELSE.
*   Write your program to download to PDF.    
  ENDIF.  
  WHEN OTHERS.
ENDCASE.
ENDFORM.                    " POPUP_SAVE

BR

Dep

Former Member
0 Kudos

Hi,

What you could do is when you review the smartform and click on back or exit or cancel button call a 'POP UP' with information to 'save the smartform as PDF or not'.

So this way you can acheive your requirement.

BR

Dep

aidan_black
Active Contributor
0 Kudos

Hi,

You can use report RSTXPDFT4 to convert the spool number to a PDF file.

Regards,

Aidan

Former Member
0 Kudos

Hi Aidan,

Thanks for the response. But as I said, The customer wants to download the form staying on the print preview screen.

They don't want another program for downloading.

Regards,

sapper.

0 Kudos

you can use this code

data: wa_OTF_DATA TYPE TSFOTF.

CALL FUNCTION GV_FMNAME

EXPORTING

CONTROL_PARAMETERS = wa_CONTROL

OUTPUT_OPTIONS = wa_OUTOPTIONS

USER_SETTINGS = SPACE

GS_HEAD = wa_HEAD

GS_DATA = wa_FORM

GV_COMPANY = v_COMP_NAME

GV_CHECK = wa_QMEL-MAWERK

T_MOREDEF = v_MOREDEF

GV_LANGU = T_LANGU

IMPORTING

JOB_OUTPUT_INFO = wa_JOB_OUT.

IF SY-SUBRC = 0.

wa_OTF_DATA = wa_JOB_OUT-OTFDATA[].

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'

EXPORTING

I_OTF = wa_OTF_DATA[]

EXCEPTIONS

CONVERT_OTF_TO_PDF_ERROR = 1

CNTL_ERROR = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDIF.

Former Member
0 Kudos

Hi Rajat

Thanks for the response. But, as I said, I cannot change the driver program. Any clue if I can write the code in any enhancement point or some other place?

Regards,

Sapper.