cancel
Showing results for 
Search instead for 
Did you mean: 

Generating PDF through triggering the output type

former_member195383
Active Contributor
0 Kudos

Hi All,

I have created one output type ZRUD, I have one print program and one Smartform. in Nace I have configured ZRUD with the Print Program .My print program has the facility to store the PDF in application server.

Now I want to generate the PDF and store the same in Application Server, by triggering the output type ZRUD through RSNAST00 . There I am facing the problem. In the selection screen of RSNAST00,

there is one input field called, Object key. What should be filled in that.

Am I missing , something in the above process . Here my basic purpose is to generate the PDF through , triggereing the output type .Hence please suggest the needful .

Thanks a lot in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

You have to give the document number in the object key field...

For example, If you are trying to print po form, then you have to give PO number..

Also, check the standard variants...available...for the program...you will get a better idea.

Regards,

Vishwa.

former_member195383
Active Contributor
0 Kudos

Hi ,

Yes, its certain that we have to give the document number. But what I have done is..I have created a printprogram and smartform and have linked that to a new output type . So I have not used any document number here.

My requirement is simply to get the PDF by triggering the output type .Please suggest if I am missing any step.

Former Member
0 Kudos

Hi

I can understand that. But to trigger using an executable and not from a transaction code...it is important to give the document number...only then system will pick the output type and generate the PDF..provided your program is working fine...

Could you just execute and then get back with the result?

Regards,

Vishwa.

former_member195383
Active Contributor
0 Kudos

Hi Vishwa,

Thnx for ur reply...

I have executed the program. Its working fine. Its able to store the PDF in application server.

If I have to give a document number..where can I put the same. in my program. because I am not using the documnet number any where.

If its not clear kindly get back...I am pasting the code of my print program..for reference. Kindly suggest the needful..

REPORT zdemo_print_program .

INCLUDE rvadtabl.

* Local Data Declarations
DATA: wf_filename TYPE rlgrap-filename,
      wf_directory LIKE /dceur/zvof_pdir-directory,
      wf_vkorg      LIKE vbrk-vkorg,
      wf_numbytes      TYPE i,
      wf_ftype(2)   TYPE c,
      wf_soldto     LIKE vbpa-kunnr,
      tb_lines           TYPE tline OCCURS 0 WITH header line,
      tb_doctab_archive  TYPE docs  OCCURS 0.

DATA :wa_output_opt           LIKE ssfcompop,
      wa_control_parameters   TYPE ssfctrlop,
      wa_document_output_info TYPE  ssfcrespd,
      wa_job_output_info      TYPE ssfcrescl,
      wa_job_output_options   TYPE ssfcresop,
      wa_arc_idx              LIKE toa_dara,
      wf_funcmodulename  TYPE rs38l_fnam,
      wf_purord     LIKE vbak-bstnk.


CONSTANTS : co_formname     TYPE tdsfname VALUE 'ZDEMO_SMARTFORM',
            co_printer(7)   TYPE c VALUE 'PRINTER',
            co_uscor        TYPE c VALUE '_',
            co_1            TYPE c        VALUE '1',
            co_pdf_extn(4)  TYPE c VALUE '.PDF'.


PERFORM processing.

*---------------------------------------------------------------------*
*       FORM processing                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM processing.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
       EXPORTING
            formname           = co_formname
       IMPORTING
            fm_name            = wf_funcmodulename
       EXCEPTIONS
            no_form            = 1
            no_function_module = 2
            OTHERS             = 3.



  wa_control_parameters-no_dialog = 'X'.
  wa_control_parameters-getotf    = 'X'.

*PDF language
  wa_control_parameters-langu = sy-langu.

  CALL FUNCTION wf_funcmodulename
       EXPORTING
            control_parameters =
               wa_control_parameters "control Params
            output_options       = wa_output_opt  "Control Params
            user_settings        = ''
       IMPORTING
            document_output_info = wa_document_output_info
            job_output_info      = wa_job_output_info
            job_output_options   = wa_job_output_options
       EXCEPTIONS
            formatting_error     = 1
            internal_error       = 2
            send_error           = 3
            user_canceled        = 4
            OTHERS               = 5.

  IF sy-subrc <> 0.
  ENDIF.

* conversion of OTF to PDF and storing in appserver.

  CLEAR: wf_filename,
         wf_directory.


  wf_directory = '/usr/sap/'.


  CALL FUNCTION 'CONVERT_OTF_2_PDF'
       EXPORTING
            archive_index          = wa_arc_idx
       IMPORTING
            bin_filesize           = wf_numbytes
       TABLES
            otf                    = wa_job_output_info-otfdata[]
            doctab_archive         = tb_doctab_archive[]
            lines                  = tb_lines[]
       EXCEPTIONS
            err_conv_not_possible  = 1
            err_otf_mc_noendmarker = 2
            OTHERS                 = 3.
  IF sy-subrc EQ 0.


* Concatenating filpath with date and time to
* filename
    IF wf_purord IS INITIAL.
      wf_purord = 'XXXXXXXX'.
    ENDIF.
    CONCATENATE wf_directory
                wf_ftype
                wf_soldto
                co_uscor
                wf_purord
                co_uscor
                nast-objky
                co_uscor
                sy-datum
                sy-uzeit
                co_pdf_extn
           INTO wf_filename.

* Downloading PDF file to Application server

    OPEN DATASET wf_filename FOR OUTPUT IN BINARY MODE.

    IF sy-subrc NE 0.

      EXIT.
    ENDIF.
  
*Writing to application server
    LOOP AT tb_lines.
      TRANSFER tb_lines-tdformat TO wf_filename.
      TRANSFER tb_lines-tdline   TO wf_filename.
      CLEAR tb_lines.
    ENDLOOP.
    CLOSE DATASET wf_filename.
  ENDIF.

ENDFORM.

Edited by: Rudra Prasanna Mohapatra on Nov 4, 2008 5:57 AM

Edited by: Rudra Prasanna Mohapatra on Nov 4, 2008 5:58 AM

Former Member
0 Kudos

U r using nast-objky in the filename that itself has the document number.

If u want to trigger ur output type for pdf u can use this FM

'RV_MESSAGE_UPDATE_SINGLE'

and then 'WFMC_MESSAGES_PROCESS'

former_member195383
Active Contributor
0 Kudos

Hi...

I am using Nast-objky. But if I execute it standalone..its value is blank .

To make my issue clear..I am stating it below.

I have one print program, one smartform which is called from print program .

All I want is I want to execute the printprogram and generate the PDF by triggering

one output type. The output type is linked to the print program in NACE .

Here I am nowhere using document number....

So please suggest hw I can achieve the same.

Former Member
0 Kudos

Well the document number is passed to print program when its called through some business transaction but if u r executing it standalone then thr wud be no doc no so in that case give the objectkey as '0000000000'.

former_member195383
Active Contributor
0 Kudos

Hi Karthik,

Thnx for ur reply .I gave the document number as 0000000000 in object key while executing RSNAST00.

But it did not get executed.

Before triggering an output type through RSNAST00, we go to the documnet in change mode and then doing repeate output, we get it to unprocessed state .Then save it. and then from RSNAST00, we execute it, for generating the PDF.

My uqestion is...hw can we achive it in my case .as we dont have any documnet number, which we can change in VA22 and trigger the outoput type..

Former Member
0 Kudos

Rudra..

Did you check what is happening when you are triggering the output type from the particular transaction...itself??

Vishwa.

former_member195383
Active Contributor
0 Kudos

Hi Vishwa..

In VA22 if I will give a document number it will takeme to the change document screen. But in my case I dont have document number. That is the problem.

My exact requirement is to show in a sample program...hw an output type , when triggered...generates a PDF .Thats what I am trying to achive.

Kindly suggest what I am missing in my approach

Former Member
0 Kudos

To process the output type u shud have appropriate entries in the nast table so create it in nast like this.

DATA: it_nast type standard table of nast,

wa_nast type nast.

In ur case u can assign 0's to values not used by U.

wa_nast-mandt = sy-mandt.

wa_nast-kappl = <appropriate value>."Application area

wa_nast-objky = <appropriate value>."object key. Po, shipment etc

wa_nast-kschl = <output type>."output type to be processed

wa_nast-spras = <appropriate value>."language

wa_nast-parnr = <appropriate value>."message partner

wa_nast-parvw = <appropriate value>."partner function

wa_nast-erdat = sy-datum."current date

wa_nast-eruhr = sy-uzeit."current time

wa_nast-nacha = <appropriate value>."message transmission medium

wa_nast-anzal = '01'."number of messages

wa_nast-vsztp = <appropriate value>."Dispatch time

wa_nast-vstat = '0'."processing status

Now Update the NAST table with the fm 'RV_MESSAGE_UPDATE_SINGLE'

call function 'RV_MESSAGE_UPDATE_SINGLE'

exporting

msg_nast = wa_nast.

then u can trigger it using

data: lt_msg_nast type table of msg0,

ls_msg0 like msg0,

t_disp type table of naliv2.

move-corresponding wa_nast to ls_msg0.

append ls_msg0 to lt_msg_nast.

call function 'WFMC_MESSAGES_PROCESS'

exporting

pi_display_id = 'NALIV2'

pi_no_dialog = 'X'

tables

tx_messages = lt_msg_nast

tx_display = t_disp.

I think no need to use rsnast00 in this case

Former Member
0 Kudos

Rudra..

Check this sample program..here in the selection screen..we are giving the document number and the form name also.....So, here it will show the output here itself..An example of stand alone execution:

DATA : LF_FORMNAME TYPE TDSFNAME,
       LF_FM_NAME  TYPE RS38L_FNAM.

DATA : EKKO TYPE EKKO,
       EKPO TYPE EKPO,
       ESSR TYPE ESSR,
       LFA1 TYPE LFA1,
       RM11P TYPE RM11P.

DATA : LT_ML_ESLL TYPE STANDARD TABLE OF ML_ESLL WITH HEADER LINE.

PARAMETERS : P_PONUM LIKE EKKO-EBELN, "picking up doc.no
             P_FNAM TYPE TDSFNAME.


SELECT SINGLE * FROM EKKO INTO EKKO WHERE EBELN = P_PONUM. "and retreiving values based on the doc num.

SELECT SINGLE * FROM EKPO INTO EKPO WHERE EBELN = EKKO-EBELN.

SELECT SINGLE * FROM ESSR INTO ESSR
                WHERE EBELN = EKKO-EBELN AND EBELN = EKPO-EBELN.

SELECT SINGLE * FROM LFA1 INTO LFA1 WHERE LIFNR = EKKO-LIFNR.

SELECT * FROM ML_ESLL INTO TABLE LT_ML_ESLL
                      WHERE EBELN = EKKO-EBELN AND EBELN = EKPO-EBELN.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    FORMNAME                 = P_FNAM
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
  IMPORTING
    FM_NAME                  = LF_FM_NAME.

CALL FUNCTION LF_FM_NAME
  EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
    ESSR                       = ESSR
    EKKO                       = EKKO
    EKPO                       = EKPO
    LFA1                       = LFA1
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
  TABLES
    ML_ESLL                    = LT_ML_ESLL
* EXCEPTIONS
*   FORMATTING_ERROR           = 1
*   INTERNAL_ERROR             = 2
*   SEND_ERROR                 = 3
*   USER_CANCELED              = 4
*   OTHERS                     = 5
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Regards,

Vishwa.

Former Member
0 Kudos

Hi rudra, did u chk the approach i explained above.

Plz NOTE: to set the status as unprocessed since u cud not goto va22.

then set nast-vstat as 0.

Edited by: kartik tarla on Nov 4, 2008 11:39 AM

former_member195383
Active Contributor
0 Kudos

Hi Karthik,

thanks for the reply...

I will try the same...and will get back to you..