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: 

smartforms

Former Member
0 Kudos

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = 'YJSMARTSHEET'
  IMPORTING
    fm_name            = call1
  EXCEPTIONS
    no_form            = 1
    no_function_module = 2
    OTHERS             = 3.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*data it1 type tline occurs 0 with header line .




LOOP AT itab1.
  CALL FUNCTION call1
    EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
   control_parameters         = st_control_parameters
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
   output_options             = st_output_options
*   USER_SETTINGS              = 'X'
      pernr                      = itab1-pernr
      paycd                      = paycd
      werks                      = itab1-werks
      empname                    = itab1-sname
      stat                       = itab1-stat
      cc                         = itab1-cc
      pe                         = itab1-begda
      contno                     = contno
 IMPORTING
   document_output_info       = st_document_output_info
   job_output_info            = tab_otf_data
   job_output_options         = st_job_output_options
 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.

  tab_otf_final[] = tab_otf_data-otfdata[].


 DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.

  READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
    my_tabix = sy-tabix + 1.

  INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.
  my_tabix = sy-tabix + 1.
  INSERT LINES OF tab_otf_final INTO tab_otf_data-otfdata INDEX my_tabix.

*
ENDLOOP.







CALL FUNCTION 'CONVERT_OTF_2_PDF'
  IMPORTING
    bin_filesize           = v_bin_filesize
  TABLES
    otf                    = tab_otf_final[]
    doctab_archive         = it_docs
    lines                  = it_lines
  EXCEPTIONS
    err_conv_not_possible  = 1
    err_otf_mc_noendmarker = 2
    OTHERS                 = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*CALL FUNCTION 'CONVERT_OTF'
* EXPORTING
*   FORMAT                      = 'PDF'
*   MAX_LINEWIDTH               = 132
**   ARCHIVE_INDEX               = ' '
**   COPYNUMBER                  = 0
**   ASCII_BIDI_VIS2LOG          = ' '
* IMPORTING
*   BIN_FILESIZE                = bin_filesize
*   BIN_FILE                    = bin_file
*  TABLES
*    otf                         = tab_otf_data-otfdata
*    lines                       = it_lines
** EXCEPTIONS
**   ERR_MAX_LINEWIDTH           = 1
**   ERR_FORMAT                  = 2
**   ERR_CONV_NOT_POSSIBLE       = 3
**   ERR_BAD_OTF                 = 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.
**



*........................GET THE FILE NAME TO STORE....................*

CONCATENATE 'smrt' '.pdf' INTO v_name.

CREATE OBJECT v_guiobj.
CALL METHOD v_guiobj->file_save_dialog
  EXPORTING
    default_extension = 'pdf'
    default_file_name = v_name
    file_filter       = v_filter
  CHANGING
    filename          = v_name
    path              = v_path
    fullpath          = v_fullpath
    user_action       = v_uact.

IF v_uact = v_guiobj->action_cancel.
  EXIT.
ENDIF.

*..................................DOWNLOAD AS FILE....................*
MOVE v_fullpath TO v_filename.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    bin_filesize            = v_bin_filesize
    filename                = v_filename
    filetype                = 'BIN'
  TABLES
    data_tab                = it_lines
  EXCEPTIONS
    file_write_error        = 1
    no_batch                = 2
    gui_refuse_filetransfer = 3
    invalid_type            = 4
    no_authority            = 5
    unknown_error           = 6
    header_not_allowed      = 7
    separator_not_allowed   = 8
    filesize_not_allowed    = 9
    header_too_long         = 10
    dp_error_create         = 11
    dp_error_send           = 12
    dp_error_write          = 13
    unknown_dp_error        = 14
    access_denied           = 15
    dp_out_of_memory        = 16
    disk_full               = 17
    dp_timeout              = 18
    file_not_found          = 19
    dataprovider_exception  = 20
    control_flush_error     = 21
    OTHERS                  = 22.
IF sy-subrc <> 0.
*     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

this is the code but still its downloading only last pernr smartform into pdf and that too twice may i know the reason and how do i download the smartforms of the given pernr into a same pdf

thank you,

Regards,

Jagrut Bharatkumar Shukla

1 ACCEPTED SOLUTION

former_member189629
Active Contributor
0 Kudos

TRY THIS

LOOP AT itab1.

CALL FUNCTION call1

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = st_control_parameters

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = st_output_options

  • USER_SETTINGS = 'X'

pernr = itab1-pernr

paycd = paycd

werks = itab1-werks

empname = itab1-sname

stat = itab1-stat

cc = itab1-cc

pe = itab1-begda

contno = contno

IMPORTING

document_output_info = st_document_output_info

job_output_info = tab_otf_data

job_output_options = st_job_output_options

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.

tab_otf_final[] = tab_otf_data-otfdata[].

DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.

READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.

my_tabix = sy-tabix + 1.

INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.

my_tabix = sy-tabix + 1.

INSERT LINES OF tab_otf_final INTO tab_otf_data-otfdata INDEX my_tabix.

*

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_bin_filesize

TABLES

otf = tab_otf_final[]

doctab_archive = it_docs

lines = it_lines

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.

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

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

ENDIF.

........................GET THE FILE NAME TO STORE....................

<b>CLEAR v_name.</b>

CONCATENATE <b>itab1-pernr</b> 'smrt' '.pdf' INTO v_name.

CREATE OBJECT v_guiobj.

CALL METHOD v_guiobj->file_save_dialog

EXPORTING

default_extension = 'pdf'

default_file_name = v_name

file_filter = v_filter

CHANGING

filename = v_name

path = v_path

fullpath = v_fullpath

user_action = v_uact.

IF v_uact = v_guiobj->action_cancel.

EXIT.

ENDIF.

..................................DOWNLOAD AS FILE....................

MOVE v_fullpath TO v_filename.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = v_bin_filesize

filename = v_filename

filetype = 'BIN'

TABLES

data_tab = it_lines

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDLOOP.

5 REPLIES 5

former_member189629
Active Contributor
0 Kudos

TRY THIS

LOOP AT itab1.

CALL FUNCTION call1

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = st_control_parameters

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = st_output_options

  • USER_SETTINGS = 'X'

pernr = itab1-pernr

paycd = paycd

werks = itab1-werks

empname = itab1-sname

stat = itab1-stat

cc = itab1-cc

pe = itab1-begda

contno = contno

IMPORTING

document_output_info = st_document_output_info

job_output_info = tab_otf_data

job_output_options = st_job_output_options

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.

tab_otf_final[] = tab_otf_data-otfdata[].

DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.

READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.

my_tabix = sy-tabix + 1.

INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.

my_tabix = sy-tabix + 1.

INSERT LINES OF tab_otf_final INTO tab_otf_data-otfdata INDEX my_tabix.

*

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_bin_filesize

TABLES

otf = tab_otf_final[]

doctab_archive = it_docs

lines = it_lines

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.

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

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

ENDIF.

........................GET THE FILE NAME TO STORE....................

<b>CLEAR v_name.</b>

CONCATENATE <b>itab1-pernr</b> 'smrt' '.pdf' INTO v_name.

CREATE OBJECT v_guiobj.

CALL METHOD v_guiobj->file_save_dialog

EXPORTING

default_extension = 'pdf'

default_file_name = v_name

file_filter = v_filter

CHANGING

filename = v_name

path = v_path

fullpath = v_fullpath

user_action = v_uact.

IF v_uact = v_guiobj->action_cancel.

EXIT.

ENDIF.

..................................DOWNLOAD AS FILE....................

MOVE v_fullpath TO v_filename.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = v_bin_filesize

filename = v_filename

filetype = 'BIN'

TABLES

data_tab = it_lines

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDLOOP.

0 Kudos

hi karthik,

thank you for your valuable info,

but i need all the pernr into one pdf

is there any way

thank you,

Regards,

Jagrut bharatkumar shukla

0 Kudos

Is ur smartform coming with all PERNRs? I mean in print preview, can u see all in diff pages?

0 Kudos

yes all pernrs are in different smartforms or pages but i want all those pages into one pdf

thank you,

Regards,

Jagrut Bharatkumar Shukla

0 Kudos

Hi,

I think you are trying to print no of copies..

If that is your requirment..

Pass a parameter for no of copies in function module like

ws_c_copies type i

do ws_c_copies.

*Call your function module

enddo.

Regards,

Sreeja

Please rewards if useful.