Application Development and Automation 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: 
Read only

SMART FORMS

Former Member
0 Likes
457

The file is downloading to pc as pdf but the data is retriving but where i need to declare the internal table so that i can get display as output for the data here is my code.

&----


*& Include Z_PDF_CONVERSIONF *

&----


&----


*& Form f_validate_input

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f_validate_input .

DATA: l_temp_ebeln(10) TYPE c .

*Checking if field is empty.

IF s_ebeln IS INITIAL.

MESSAGE i000(zcommon).

ENDIF.

*Checking whether purchase docuemnt no contains any character.

l_temp_ebeln = s_ebeln-low.

IF l_temp_ebeln+0(1) CA sy-abcde.

MESSAGE i001(zcommon).

ENDIF.

ENDFORM. " f_validate_input

&----


*& Form f_data_selection

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f_data_selection .

CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

EXPORTING

i_language = v_language

i_application = 'SAPDEFAULT'

IMPORTING

e_devtype = v_devtype

  • EXCEPTIONS

  • NO_LANGUAGE = 1

  • LANGUAGE_NOT_INSTALLED = 2

  • NO_DEVTYPE_FOUND = 3

  • SYSTEM_ERROR = 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.

*It gets the name of local printer.

v_output_options-tdprinter = v_devtype.

v_control_parameters-no_dialog = 'X'.

v_control_parameters-getotf = 'X'.

*Selecting data from the tables.

select ebeln from ekko into table i_ebeln where ebeln in s_ebeln.

.................GET SMARTFORM FUNCTION MODULE NAME.................

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = c_formname

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = v_fm_name

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.

...........................CALLING SMARTFORM............................

CALL FUNCTION V_FM_NAME

EXPORTING

control_parameters = v_control_parameters

output_options = v_output_options

IMPORTING

document_output_info = st_ssfcrespd

job_output_info = st_ssfcrescl

job_output_options = st_ssfcresop

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.

ELSE.

.........................CONVERT TO OTF TO PDF.......................

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_bin_filesize

TABLES

otf = st_ssfcrescl-otfdata

doctab_archive = i_docs

lines = i_line

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....................

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 = i_line

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.

ENDIF.

ENDFORM. " f_data_selection

3 REPLIES 3
Read only

Former Member
0 Likes
424

hi u r question sounds vague

can u frame it properly

Read only

Former Member
0 Likes
424

hi,

pc to pdf conversion

REPORT ZWARUN_TEST4.

tables:mara,bseg.

data:begin of itab occurs 2,

matnr like mara-matnr,

ernam like mara-ernam,

end of itab.

data:begin of it_bseg occurs 2,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

shkzg like bseg-shkzg,

dmbtr like bseg-dmbtr,

  • blart like bkpf-blart,

end of it_bseg.

data: lv_numbytes type i,

lv_spoolno type tsp01-rqident,

c_layout like pri_params-paart value 'X_65_132',

C_X type c value 'X',

numbers type i,

cancel.

data:it_pdf like tline occurs 10 with header line.

data:p_down like rlgrap-filename.

*at selection-screen.

selection-screen:begin of block blk with frame.

select-options:s_matnr for mara-matnr,

s_bukrs for bseg-bukrs.

parameter: download as checkbox default 'X',

p_file like rlgrap-filename default 'c:\warun.pdf'.

  • p_down LIKE RLGRAP-FILENAME DEFAULT 'c:\warun2.txt'.

selection-screen:end of block blk .

selection-screen pushbutton 12(20) push user-command cl1.

at selection-screen.

perform validate.

top-of-page.

write:/10 sy-repid inverse color 3.

write:/2 'Date:' , sy-datum,

40 'Time:' , sy-uzeit.

write:/2 sy-uline.

end-of-page.

write:/50 'Intelligroup Asia Pvt'.

write:/20 sy-pagno.

start-of-selection.

select matnr

ernam

into table itab

from mara

where matnr in s_matnr.

if sy-subrc = 0.

sort itab by matnr.

endif.

perform besg_data.

set pf-status 'PUSH'.

at user-command.

if sy-ucomm = 'DOWNLOAD'.

  • if download = space.

perform get_file.

endif.

end-of-selection.

if download = 'X'.

  • perform PDFfile.

ENDIF.

&----


*& Form validate

&----


FORM validate .

data: v_temp(40).

select single

matnr

into v_temp

from mara

where matnr in s_matnr.

if sy-subrc <> 0.

message e000(zz) with 'no data found'.

endif.

ENDFORM. " validate

at line-selection.

set parameter ID 'MAT' FIELD ITAB-MATNR.

CALL TRANSACTION 'MM03' .

WRITE:/ 'Material data displayed' .

write:/2 itab-matnr.

&----


*& Form PDFfile

&----


FORM PDFfile .

data:lk_params type pri_params,

lv_valid.

  • All the parameters passed are constants, so exceptions

  • doesn't get raised

call function 'GET_PRINT_PARAMETERS'

EXPORTING

immediately = ' '

layout = c_layout "'X_65_132'

no_dialog = c_x

IMPORTING

out_parameters = lk_params

valid = lv_valid.

if lv_valid <> space .

new-page print on parameters lk_params no dialog.

*--To display the final report

perform print_report.

new-page print off.

*---To convert the download to PDF

perform conv_to_pdf_download.

perform download.

endif.

  • endif.

*--To display the final report

perform print_report.

ENDFORM. " PDFfile

&----


*& Form print_report

&----


FORM print_report .

loop at itab.

write:/2 sy-vline,

4 itab-matnr color 4 HOTSPOT,

40 sy-vline ,

41 itab-ernam color 5,

55 sy-vline.

HIDE: ITAB-MATNR.

endloop.

ENDFORM. " print_report

&----


*& Form conv_to_pdf_download

&----


FORM conv_to_pdf_download .

wait up to 2 seconds.

lv_spoolno = sy-spono.

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

exporting

src_spoolid = lv_spoolno

no_dialog = ''

  • DST_DEVICE =

  • PDF_DESTINATION =

importing

pdf_bytecount = lv_numbytes

  • PDF_SPOOLID = pdfspoolid

  • LIST_PAGECOUNT =

  • BTC_JOBNAME = jobname

  • BTC_JOBCOUNT = jobcount

tables

pdf = it_pdf.

ENDFORM. " conv_to_pdf_download

&----


*& Form download

&----


FORM download .

check download = 'X'.

call function 'DOWNLOAD'

EXPORTING

bin_filesize = lv_numbytes

filename = p_file

filetype = 'BIN'

IMPORTING

act_filename = p_file

filesize = lv_numbytes

cancel = cancel

TABLES

data_tab = it_pdf.

if cancel = space.

write: / lv_numbytes, p_file.

endif.

ENDFORM. " download

&----


*& Form get_file

&----


FORM get_file .

Data: s_filename like rlgrap-filename,

s_filepath like rlgrap-filename,

tm_filepath like rlgrap-filename.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = s_filename

DEF_PATH = s_filepath

  • MASK = ' '

  • MODE = ' '

  • TITLE = ' '

IMPORTING

FILENAME = tm_filepath

.

IF SY-SUBRC = 0.

p_down = tm_filepath.

perform download2.

endif.

ENDFORM. " get_file

&----


*& Form download2

&----


FORM download2 .

DATA: LV_STRING TYPE STRING.

LV_STRING = P_DOWN.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = LV_STRING

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = itab

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.

ENDFORM. " download2

&----


*& Form besg_data

&----


FORM besg_data .

if itab is initial.

select bukrs

belnr

gjahr

shkzg

dmbtr

into corresponding fields of table it_bseg

from bseg

where bukrs in s_bukrs.

endif.