cancel
Showing results for 
Search instead for 
Did you mean: 

smartform into pdf...

Former Member
0 Kudos

hi friends...

i am developing one GR Tag, this GR Tag will be generated while doing

MB1B .

The requirement is to show the vehicle chassis no. in Barcode, i am generating the smartform and converting it to pdf format and then i want it to send to PRINTER .

i could not able to send the converted pdf file to printer , is there any way to do this ... pls help if you have information.

thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

tables:
  zhfa.                                " HFA table

*"Selection screen elements............................................
selection-screen begin of block blk1 with frame title text-001.
select-options:
  s_vin6 for zhfa-zz_vin6 .
selection-screen end of block blk1.

selection-screen begin of block blk4 with frame title text-008.
parameters:
  p_lay1 radiobutton group rad,                             " Layout 1
  p_lay2 radiobutton group rad,                             " Layout 2
  p_lay3 radiobutton group rad,                             " Layout 3
  p_lay4 radiobutton group rad.                             " Layout 4
selection-screen end of block blk4.

selection-screen begin of block blk3 with frame title text-003.
parameters:
  p_mail  radiobutton group rad2,      " Mail
  p_fax   radiobutton group rad2,      " Fax
  p_print radiobutton group rad2,      " Print
  p_mailid type somlreci1-receiver modif id sc1,
                                       " email-id
  p_faxno type somlreci1-receiver modif id sc2.
" fax-number
selection-screen end of block blk3.

selection-screen begin of block blk2 with frame title text-006.
parameters:
  p_single radiobutton group rad1,     " Single spool
  p_indivi radiobutton group rad1.     " Individual spool
selection-screen end of block blk2.

*" Data declarations...................................................
*"--------------------------------------------------------------------*
* Work variables                                                      *
*"--------------------------------------------------------------------*
data:
  w_name     type rs38l_fnam,          " Name of the function module
  w_form     type tdsfname,            " Smart form name
  w_input    type ssfcompin,           " Input for spool
  w_flag     type i,                   " Temporary flag
  w_control  type ssfctrlop,           " Control parameters
  w_output   type ssfcompop,           " Output options
  w_return   type ssfcrescl,           " Job output info
  w_filesize type sood-objlen,         " Bin file size
  w_string   type string,              " To convert from 132 to 255
  w_msg      type i,                   " Message length
  w_docdata  type sodocchgi1,          " Document data
  w_objbin   type i,                   " Contents bin
  w_sender   type soextreci1-receiver. " Sender

*"--------------------------------------------------------------------*
* Field string for historical VIN data                                *
*"--------------------------------------------------------------------*
data:
  fs_zhfa type zhfa.

*"--------------------------------------------------------------------*
* Internal table to hold the historical VIN data                      *
*"--------------------------------------------------------------------*
data:
  t_zhfa type standard table
           of zhfa.

*"--------------------------------------------------------------------*
* Internal table to hold the OTF data                                 *
*"--------------------------------------------------------------------*
data:
  t_otf type itcoo occurs 0
        with header line.

*"--------------------------------------------------------------------*
* Internal table to hold the PDF data                                 *
*"--------------------------------------------------------------------*
data:
  t_line type table of tline
                  with header line.

*"--------------------------------------------------------------------*
* Internal table to hold the receivers data                           *
*"--------------------------------------------------------------------*
data:
  t_receivers type table of somlreci1
                       with header line.

*"--------------------------------------------------------------------*
* Internal table to hold the attachment data                          *
*"--------------------------------------------------------------------*
data:
  t_attach type solisti1 occurs 0
           with header line.

data:
  t_objbin type solisti1 occurs 0
           with header line.

*"--------------------------------------------------------------------*
* Internal table to hold the message data                             *
*"--------------------------------------------------------------------*
data:
    t_message type standard table
              of solisti1
            with header line.

*"--------------------------------------------------------------------*
* Internal table to hold the packing list data                        *
*"--------------------------------------------------------------------*
data:
  t_packing_list like sopcklsti1 occurs 0
                 with header line.

*"--------------------------------------------------------------------*
*                  AT SELECTION-SCREEN OUTPUT EVENT                   *
*"--------------------------------------------------------------------*
at selection-screen output.

  if p_mail eq 'X'.
*" Disable the fax number..............................................
    loop at screen.
      if screen-group1 = 'SC2'.
        screen-input = '0'.
        modify screen.
      endif.                           " IF SCREEN-GROUP1 = 'SC2'
    endloop.                           " LOOP AT SCREEN

  elseif p_fax eq 'X'.
*" Disable the email id ...............................................
    loop at screen.
      if screen-group1 = 'SC1'.
        screen-input = '0'.
        modify screen.
      endif.                           " IF SCREEN-GROUP1 = 'SC1'
    endloop.                           " LOOP AT SCREEN

  elseif p_print eq 'X'.
*" Disable email id and fax number.....................................
    loop at screen.
      if screen-group1 = 'SC1' or screen-group1 = 'SC2'.
        screen-input = '0'.
        modify screen.
      endif.                           " IF SCREEN-GROUP1 = 'SC1' OR...
    endloop.                           " LOOP AT SCREEN

  endif.                               " IF P_MAIL EQ 'X'


*"--------------------------------------------------------------------*
*                      START-OF-SELECTION EVENT                       *
*"--------------------------------------------------------------------*
start-of-selection.

*" Read the HFA records into internal table............................
  select *
    from zhfa
    into table t_zhfa
   where zz_vin6 in s_vin6.
  if sy-subrc ne 0.
    message text-002 type 'W'.
  else.
    if p_lay1 eq 'X'.

*" VIN Tag print is selected...........................................
      w_form = 'Y_LAYOUT1'.

    elseif p_lay2 eq 'X'.

*" Container Tag print is selected.....................................
      w_form = 'Y_LAYOUT2'.

    elseif p_lay3 eq 'X'.

*" Remanufactured Tag print is selected................................
      w_form = 'Y_LAYOUT3'.

    elseif p_lay4 eq 'X'.

*" Reefer Tag print is selected........................................
      w_form = 'Y_LAYOUT4'.
'.
    endif.                             " IF P_LAY1 EQ 'X'

  endif.                               " IF SY-SUBRC NE 0

*---------------------------------------------------------------------*
*  FUNCTION MODULE SSF_FUNCTION_MODULE_NAME                           *
*---------------------------------------------------------------------*
*  This function module generates the function module for the         *
*  selected smartform.                                                *
*---------------------------------------------------------------------*
  call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
      formname           = w_form
    importing
      fm_name            = w_name
    exceptions
      no_form            = 1
      no_function_module = 2.

  if p_print eq 'X'.
*" Set input parameters of spool.......................................
    w_input-dialog = 'X'.

*---------------------------------------------------------------------*
*  FUNCTION MODULE SSFCOMP_OPEN                                       *
*---------------------------------------------------------------------*
*  This function module opens the spool request.                      *
*---------------------------------------------------------------------*
    call function 'SSFCOMP_OPEN'
      exporting
        input = w_input
      exceptions
        error = 1.

    loop at t_zhfa into fs_zhfa.

*" Set control parameters for individual spool.........................
      w_control-no_open   = ' '.
      w_control-no_close  = ' '.

      if p_single eq 'X'.

*" Set control parameters for single spool.............................
        w_control-no_open   = 'X'.
        w_control-no_close  = 'X'.

      else.
        if w_flag ne 1.
          w_flag = 1.

*" Set control parameters for first print of individual spool..........
          w_control-no_open   = 'X'.
          w_control-no_close  = ' '.

*---------------------------------------------------------------------*
*  FUNCTION MODULE w_name                                             *
*---------------------------------------------------------------------*
*  This function module executes the smartform that is selected.      *
*---------------------------------------------------------------------*
          call function w_name
            exporting
              control_parameters = w_control
              fs_zhfa            = fs_zhfa
            exceptions
              formatting_error   = 1
              internal_error     = 2
              send_error         = 3
              user_canceled      = 4.

        endif.                         " IF W_FLAG NE 1

      endif.                           " IF P_SINGLE EQ 'X'

*---------------------------------------------------------------------*
*  FUNCTION MODULE w_name                                             *
*---------------------------------------------------------------------*
*  This function module executes the smartform that is selected.      *
*---------------------------------------------------------------------*
      call function w_name
        exporting
          control_parameters = w_control
          fs_zhfa            = fs_zhfa
        exceptions
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4.

    endloop.                           " LOOP AT T_ZHFA INTO FS_ZHFA

*---------------------------------------------------------------------*
*  FUNCTION MODULE SSFCOMP_CLOSE                                      *
*---------------------------------------------------------------------*
*  This function module closes the spool request.                     *
*---------------------------------------------------------------------*
    call function 'SSFCOMP_CLOSE'
      exceptions
        error = 1.

  elseif p_print ne 'X'.
*" Set OTF parameters..................................................
    w_control-getotf = 'X'.
    w_control-no_dialog = 'X'.
    w_output-tdnoprev = 'X'.

    loop at t_zhfa into fs_zhfa.

*---------------------------------------------------------------------*
*  FUNCTION MODULE w_name                                             *
*---------------------------------------------------------------------*
*  This function module executes the smartform that is selected.      *
*---------------------------------------------------------------------*
      call function w_name
        exporting
          control_parameters = w_control
          output_options     = w_output
          user_settings      = 'X'
          fs_zhfa            = fs_zhfa
        importing
          job_output_info    = w_return
        exceptions
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4.

*" w_return-otfdata holds the smartform OTF data.......................
      append lines of w_return-otfdata to t_otf.

    endloop.                           " LOOP AT T_ZHFA INTO FS_ZHFA

*" t_otf is the OTF data...............................................
*" t_line is the PDF data..............................................

*---------------------------------------------------------------------*
*  FUNCTION MODULE CONVERT_OTF                                        *
*---------------------------------------------------------------------*
*  This function module converts the OTF data into PDF format.        *
*---------------------------------------------------------------------*
    call function 'CONVERT_OTF'
      exporting
        format                = 'PDF'
        max_linewidth         = 132
      importing
        bin_filesize          = w_filesize
      tables
        otf                   = t_otf
        lines                 = t_line
      exceptions
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        err_bad_otf           = 4.

    loop at t_line.
      concatenate w_string t_line into w_string.
    endloop.                           " LOOP AT T_LINE
*" convert the 132 line character to 255 character ....................
    do.
      t_attach = w_string.
      append t_attach.
      shift w_string left by 255 places.
      if w_string is initial.
        exit.
      endif.                           " IF W_STRING IS INITIAL
    enddo.                             " DO

    t_objbin[] = t_attach[].

*" Body of the mail..................................................
    clear t_message. refresh t_message.
    t_message = 'This is a mail from SAP ECC6'.
    append t_message.
    t_message = 'Thanks and Regards'.
    append t_message.
    t_message = 'sravanthi'.
    append t_message.
    describe table t_message lines w_msg.

*" Document data.......................................................
    w_docdata-obj_name = 'SAPRPT'.
    w_docdata-expiry_dat = sy-datum + 10.
    w_docdata-obj_descr = 'Smartform mail from sravanthi'.
    w_docdata-sensitivty = 'F'.
    w_docdata-doc_size = w_msg * 255.
    w_docdata-obj_langu = sy-langu .

*" Fill the packing list...............................................
    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.
    t_packing_list-body_num = w_msg.
    t_packing_list-doc_type = 'RAW'.
    append t_packing_list.

    t_packing_list-transf_bin = 'X'.
    describe table t_objbin lines w_objbin.
*" doc_size = (lines in pdf table) * 255...............................
    t_packing_list-doc_size = w_objbin * 255.
    t_packing_list-body_num = w_objbin.
    t_packing_list-doc_type = 'PDF'.
    t_packing_list-obj_name = 'smart'.
    t_packing_list-obj_descr = 'test'.
    append t_packing_list.

*" Fill the receiver parameters........................................
    if p_mail eq 'X'.
      clear t_receivers.
      t_receivers-receiver = p_mailid.
      t_receivers-rec_type = 'U'.
      append t_receivers.
    elseif p_fax eq 'X'.
      clear t_receivers.
      t_receivers-receiver = p_faxno.
      t_receivers-rec_type = 'F'.
      t_receivers-com_type = 'FAX'.
      append t_receivers.
    endif.                             " IF P_MAIL EQ 'X'

    w_sender = 'SAPDEV02'.
*---------------------------------------------------------------------*
*  FUNCTION MODULE SO_DOCUMENT_SEND_API1                              *
*---------------------------------------------------------------------*
*  This function module enables you send a new document including any *
*  existing attachments. The document and the attachments are         *
*  transferred in the same table. They are created when sent and can  *
*  also be placed in the sender's outbox.                             *
*---------------------------------------------------------------------*
    call function 'SO_DOCUMENT_SEND_API1'
      exporting
        document_data              = w_docdata
        put_in_outbox              = 'X'
        sender_address             = w_sender
        commit_work                = 'X'
      tables
        packing_list               = t_packing_list
        contents_bin               = t_objbin
        contents_txt               = t_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.
    if sy-subrc ne 0.
      write:/ 'Error When Sending the File', sy-subrc.
    else.
      write:/ 'Mail sent'.
    endif.
*** These two statemnets are used to force the mail to send it to the
*receipeint otherwise we need to go to SOST tcode where we need to press
* F8 to send the mail to the other user. To avoid this we need to use
*these two statemnets. Here the mail is not in queue.

    submit rsconn01 using selection-set 'INT' and return.
    call function 'SO_DEQUEUE_UPDATE_LOCKS'.

  elseif p_fax eq 'X'.

  endif.

Regards,

Sravanthi

Former Member
0 Kudos

Hi Sekhar


*    IF SY-UNAME = 'ITNR'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME           = 'ZPP014_REP_LINESITUATION_SLD_2'  "ZPP014_REP_DAILYLINESITUTN_SLD' "
      IMPORTING
        FM_NAME            = LV_FNAME
      EXCEPTIONS
        NO_FORM            = 1
        NO_FUNCTION_MODULE = 2
        OTHERS             = 3.
*    ELSE.
*      MESSAGE 'Sorry This layout under construction, Try again later' TYPE 'E'.
*    ENDIF.
  ENDIF.
*
  EXPORT IT_SCHDB TO MEMORY ID 'SCHDB'.
** call the function module to print the layout
  IF NOT LV_FNAME IS INITIAL.
    CALL FUNCTION LV_FNAME.

*    BREAK ITNR.

*    IF SY-UCOMM = 'SPRI'.

    CALL FUNCTION 'POPUP_CONTINUE_YES_NO'
      EXPORTING
        TEXTLINE1    = 'Do you want to save in PDF format?'
        TEXTLINE2    = ''
        TITEL        = 'Production Planning & Detail Scheduling'
        START_COLUMN = 10
        START_ROW    = 10
      IMPORTING
        ANSWER       = LV_ANS.
    IF LV_ANS = 'J'.
      PERFORM PRINT_PDF USING LV_FNAME.
    ENDIF.
  ENDIF.

ELSE.
  MESSAGE I005(ZLOAD).
ENDIF.


FORM PRINT_PDF USING P_LV_FNAME.
*
  DATA  :  T_OTF          TYPE ITCOO OCCURS 0 WITH HEADER LINE.
  DATA  :  WA_CTRLOP      TYPE SSFCTRLOP.
  DATA  :  WA_OUTOPT      TYPE SSFCOMPOP.
  DATA  :  T_OTFDATA      TYPE SSFCRESCL.
  DATA  :  T_PDF_TAB      LIKE TLINE OCCURS 0 WITH HEADER LINE.
*
  DATA  :  V_FILESIZE     TYPE I.
  DATA  :  W_BIN_SIZE     TYPE I.
*
  WA_CTRLOP-GETOTF = 'X'.
  WA_CTRLOP-NO_DIALOG = 'X'.
  WA_OUTOPT-TDNOPREV = 'X'.
*
*
  CALL FUNCTION P_LV_FNAME
    EXPORTING
      OUTPUT_OPTIONS     = WA_OUTOPT
      USER_SETTINGS      = 'X'
      CONTROL_PARAMETERS = WA_CTRLOP
    IMPORTING
      JOB_OUTPUT_INFO    = T_OTFDATA
    EXCEPTIONS
      FORMATTING_ERROR   = 1
      INTERNAL_ERROR     = 2
      SEND_ERROR         = 3
      USER_CANCELED      = 4
      OTHERS             = 5.
*
  T_OTF[] = T_OTFDATA-OTFDATA[].
*
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      FORMAT                = 'PDF'
      MAX_LINEWIDTH         = 132
    IMPORTING
      BIN_FILESIZE          = W_BIN_SIZE
    TABLES
      OTF                   = T_OTF
      LINES                 = T_PDF_TAB
    EXCEPTIONS
      ERR_MAX_LINEWIDTH     = 1
      ERR_FORMAT            = 2
      ERR_CONV_NOT_POSSIBLE = 3
      OTHERS                = 4.
*
*
  DATA  :  LV_DOWN_FILE TYPE RLGRAP-FILENAME.
  DATA  :  LV_TEXT      TYPE STRING.
  CASE SSCRFIELDS-UCOMM.
*
    WHEN 'REPRUNMOLD'.
      CONCATENATE '(' SO_SCHDT-LOW '-' SO_PLANT-LOW ')' INTO LV_TEXT.
      CONCATENATE '\\lkdb01\FTP-Loadstar\0.PP_Planning\ZPP014\Run_Moulds\' SY-DATUM '-' SY-TIMLO '-' 'Running Mould' '-' LV_TEXT '.pdf' INTO LV_DOWN_FILE SEPARATED BY SPACE.
    WHEN  'REPLINESIT'.
      CONCATENATE '(' SO_SCHDT-LOW '-' SO_PLANT-LOW '-' SO_LINE2-LOW ')' INTO LV_TEXT.
      CONCATENATE '\\lkdb01\FTP-Loadstar\0.PP_Planning\ZPP014\Line_Situation\' SY-DATUM '-' SY-TIMLO '-' 'Line Situation' '-' LV_TEXT '.pdf' INTO LV_DOWN_FILE SEPARATED BY SPACE.
    WHEN  'REPPPCLOVW'.
      CONCATENATE '(' SO_SCDT3-LOW '-' SO_PLANT-LOW ')' INTO LV_TEXT.
      CONCATENATE '\\lkdb01\FTP-Loadstar\0.PP_Planning\ZPP014\PPCL_Report\' SY-DATUM '-' SY-TIMLO '-' 'PPCL & Prodn  Performance' '-' LV_TEXT '.pdf' INTO LV_DOWN_FILE SEPARATED BY SPACE.

*
  ENDCASE.
*
*
  CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE            = W_BIN_SIZE
      FILENAME                = LV_DOWN_FILE
      FILETYPE                = 'BIN'
    IMPORTING
      FILELENGTH              = V_FILESIZE
    TABLES
      DATA_TAB                = T_PDF_TAB
    EXCEPTIONS
      FILE_OPEN_ERROR         = 1
      FILE_WRITE_ERROR        = 2
      INVALID_FILESIZE        = 3
      INVALID_TYPE            = 4
      NO_BATCH                = 5
      UNKNOWN_ERROR           = 6
      INVALID_TABLE_WIDTH     = 7
      GUI_REFUSE_FILETRANSFER = 8
      CUSTOMER_ERROR          = 9
      OTHERS                  = 10.
  IF SY-SUBRC <> 0.
    MESSAGE  'File not downloaded succesfully' TYPE 'I'.
    EXIT.
  ELSE.
    MESSAGE 'PDF File downloaded succesfully' TYPE 'I'.
  ENDIF.
*
ENDFORM.                    " Print_PDF

former_member598013
Active Contributor
0 Kudos

REPORT zsmartform_driver.

----


  • T A B L E S D E C L A R A T I O N

----


*---Tables Used.

TABLES: afpo,

mara,

marc,

aufk,

afko,

itcoo,

nast, "Messages

*nast, "Messages

tnapr, "Programs & Forms

addr_key,

arc_params, "Archive parameters

toa_dara. "Archive parameters

----


  • I N T E R N A L T A B L E S D E C L A R A T I O N

----


*--Internal Tables Used.

----


  • D A T A D E C L A R A T I O N

----


*--Global Variables Used.

DATA: ws_matnr LIKE afpo-matnr,

ws_werks LIKE aufk-werks,

ws_mtart LIKE mara-mtart,

ws_wrkst LIKE mara-wrkst,

ws_fname TYPE rs38l_fnam,

ws_ctrlp TYPE ssfctrlop,

ws_optns TYPE ssfcompop,

w_padest LIKE tsp03l-padest. "BMC01+

DATA: da_message_printed(1) TYPE c,

da_preview_processed(1) TYPE c,

repeat(1) TYPE c,

da_subrc LIKE sy-subrc.

DATA: w_otfdata TYPE ssfcrescl.

DATA: BEGIN OF it_itcoo OCCURS 0.

INCLUDE STRUCTURE itcoo.

DATA: END OF it_itcoo.

DATA: w_otf TYPE itcoo.

*--Data Declaration for Printing Layout

DATA: ls_itcpo TYPE itcpo.

DATA: lf_repid TYPE sy-repid.

DATA: lf_device TYPE tddevice.

DATA: cf_retcode TYPE sy-subrc.

DATA: ls_recipient TYPE swotobjid.

DATA: ls_sender TYPE swotobjid.

DATA: ls_control_param TYPE ssfctrlop.

DATA: ls_composer_param TYPE ssfcompop.

DATA: ls_addr_key LIKE addr_key.

DATA: w_screen(1) TYPE c.

DATA: xscreen(1) TYPE c.

DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.

----


  • C O N S T A N T S

----


CONSTANTS: c_fas1(8) TYPE c VALUE 'PRINTFAS',

c_fas2(15) TYPE c VALUE 'PRINTFASDRAWING',

c_wip1(8) TYPE c VALUE 'PRINTWIP',

c_wip2(15) TYPE c VALUE 'PRINTWIPDRAWING'.

----


  • S E L E C T I O N - S C R E E N.

----


SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.

  • Production order

PARAMETERS: p_aufnr LIKE afpo-aufnr OBLIGATORY.

SELECTION-SCREEN END OF BLOCK bl1.

----


START-OF-SELECTION.

----


*--Get Partially processed orders

MOVE: sy-mandt TO nast-mandt,

'V1' TO nast-kappl,

p_aufnr TO nast-objky,

p_aufnr TO nast-parnr,

sy-langu TO nast-spras,

sy-datum TO nast-erdat,

'1' TO nast-nacha,

'3' TO nast-vsztp,

'X' TO nast-manue,

sy-uname TO nast-usnam,

'DFLT' TO nast-ldest,

sy-langu TO nast-tdspras,

'Shop Floor Papers' TO nast-tdcovtitle,

'1' TO nast-tdarmod,

'BUS2032' TO nast-objtype.

*--Printer settings

CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'

EXPORTING

pi_nast = nast

pi_repid = sy-repid

IMPORTING

pe_returncode = cf_retcode

pe_itcpo = ls_itcpo

pe_device = lf_device

pe_recipient = ls_recipient

pe_sender = ls_sender.

MOVE-CORRESPONDING ls_itcpo TO ls_composer_param.

ls_control_param-device = 'PRINTER'.

ls_control_param-no_dialog = 'X'.

ls_control_param-preview = 'X'.

ls_control_param-getotf = ls_itcpo-tdgetotf.

ls_control_param-langu = sy-langu.

CLEAR: ws_werks.

SELECT SINGLE werks

INTO ws_werks

FROM aufk

WHERE aufnr = p_aufnr.

CLEAR: ws_matnr.

SELECT SINGLE plnbez

INTO ws_matnr

FROM afko

WHERE aufnr = p_aufnr.

CLEAR: marc.

SELECT SINGLE matgr

INTO marc-matgr

FROM marc

WHERE matnr = ws_matnr

AND werks = ws_werks.

  • CHECK NOT ws_matnr IS INITIAL.

IF NOT ws_matnr IS INITIAL.

SELECT SINGLE matgr

INTO marc-matgr

FROM marc

WHERE matnr = ws_matnr

AND werks = ws_werks.

ELSE.

marc-matgr = c_wip1.

ENDIF.

----


END-OF-SELECTION.

----


PERFORM call_smartform.

----


  • F O R M R O U T I N E S

----


&----


*& Form call_smartform

&----


  • text

----


FORM call_smartform.

CLEAR: ws_ctrlp, ws_optns, ws_fname.

TRANSLATE marc-matgr TO UPPER CASE.

IF marc-matgr = c_fas1 OR

marc-matgr = c_fas2.

PERFORM call_paper_a.

ELSEIF marc-matgr = c_wip1 OR

marc-matgr = c_wip2.

PERFORM call_paper_b.

ENDIF.

ENDFORM. "call_smartform

&----


*& Form call_paper_a

&----


  • text

----


FORM call_paper_a.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZSMARTFORM' " -


>This is your smartform

IMPORTING

fm_name = ws_fname

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

CHECK NOT ws_fname IS INITIAL.

CLEAR w_otfdata.

ls_control_param-getotf = 'X'.

CALL FUNCTION ws_fname

EXPORTING

archive_index = toa_dara

archive_parameters = arc_params

control_parameters = ls_control_param

mail_recipient = ls_recipient

mail_sender = ls_sender

output_options = ls_composer_param

user_settings = ' '

is_nast = nast

aufnr = p_aufnr

flag_orig = 'X'

IMPORTING

job_output_info = w_otfdata

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

LOOP AT w_otfdata-otfdata INTO w_otf.

APPEND w_otf TO it_itcoo.

ENDLOOP.

CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'

TABLES

otf_table = it_itcoo.

ENDFORM. "call_paper_a

&----


*& Form call_paper_b

&----


  • text

----


FORM call_paper_b.

DATA: ws_doknr TYPE draw-doknr,

ws_dokvr TYPE draw-dokvr.

CLEAR: ws_doknr, ws_dokvr.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZSMARTFORM' "----


> Pass your smartform name.

IMPORTING

fm_name = ws_fname

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

CHECK NOT ws_fname IS INITIAL.

CLEAR w_otfdata.

ls_control_param-getotf = 'X'.

CALL FUNCTION ws_fname

EXPORTING

archive_index = toa_dara

archive_parameters = arc_params

control_parameters = ls_control_param

mail_recipient = ls_recipient

mail_sender = ls_sender

output_options = ls_composer_param

user_settings = ' '

is_nast = nast

aufnr = p_aufnr

doknr = ws_doknr

dokvr = ws_dokvr

flag_orig = 'X'

IMPORTING

job_output_info = w_otfdata

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

LOOP AT w_otfdata-otfdata INTO w_otf.

APPEND w_otf TO it_itcoo.

ENDLOOP.

CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'

TABLES

otf_table = it_itcoo.

ENDFORM. "call_paper_b