Skip to Content
0
Former Member
Apr 07, 2014 at 01:39 PM

OTFDATA IS INITIAL

84 Views

Hi All;

I want to send mail with converting the smartforms to PDF,but when Iam sending the mail

the OTFDATA is coming initial so the PDF is not viewing.Can u help abaout this problem?

The codes like below;

REPORT ZMM21098.

TABLES : mseg,mkpf,ekko,ekpo.

**********************************************************************

TYPE-POOLS: slis.

DATA: lt_fldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

alv_layout TYPE slis_layout_alv,

gt_header TYPE slis_t_listheader WITH HEADER LINE,

ls_fldcat TYPE slis_fieldcat_alv,

gs_grid TYPE lvc_s_glay,

gv_repid LIKE sy-repid,

ok_code LIKE sy-ucomm,

v_bin_filesize TYPE i,

st_document_output_info TYPE ssfcrespd,

st_job_output_info TYPE ssfcrescl,

st_job_output_options TYPE ssfcresop,

it_docs TYPE STANDARD TABLE OF docs,

it_lines TYPE STANDARD TABLE OF tline,

v_name TYPE string,

v_path TYPE string,

v_fullpath TYPE string,

v_filter TYPE string,

v_uact TYPE i,

v_guiobj TYPE REF TO cl_gui_frontend_services,

v_filename TYPE string.

DATA: LS_SENDER TYPE SWOTOBJID.

DATA : LV_PDF,

LV_BASLIK(100).

DATA : w_return TYPE ssfcrescl,

w_bin_filesize TYPE i,

i_tline TYPE TABLE OF tline,

i_record TYPE TABLE OF solisti1 INITIAL SIZE 0,

i_objpack TYPE TABLE OF sopcklsti1 INITIAL SIZE 0,

"i_objtxt TYPE TABLE OF solisti1 INITIAL SIZE 0,

i_objbin TYPE TABLE OF solisti1 INITIAL SIZE 0,

i_reclist TYPE TABLE OF somlreci1 INITIAL SIZE 0,

t_otf TYPE TABLE OF itcoo INITIAL SIZE 0,

wa_buffer TYPE string,

wa_objhead TYPE soli_tab,

wa_doc_chng TYPE sodocchgi1,

s_tline TYPE tline,

s_record TYPE solisti1,

s_objpack TYPE sopcklsti1,

s_reclist TYPE somlreci1,

"s_objtxt TYPE solisti1,

v_lines_txt TYPE i,

v_lines_bin TYPE i,

lv_fname TYPE string,

i_objtxt TYPE TABLE OF solisti1 ,

s_objtxt TYPE solisti1.

DATA : GV_MBLNR TYPE MSEG-MBLNR.

DATA: MAIL_BASLIK(100) TYPE C.

DATA : gs_grid_settings TYPE lvc_s_glay.

DATA :BEGIN OF itab OCCURS 0,"""""""""""""

werks like mseg-werks,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

lifnr like mseg-lifnr,

name1 like lfa1-name1,

name2 like lfa1-name2,

MATNR LIKE MSEG-MATNR,

ERFMG LIKE MSEG-ERFMG,

ERFME LIKE MSEG-ERFME,

BLDAT LIKE MKPF-BLDAT,

BUDAT LIKE MKPF-BUDAT,

mblnr like mseg-mblnr,

xblnr_mkpf like MSEG-xblnr_mkpf,

unvan TYPE char40,

MAIL TYPE C LENGTH 1,

sec TYPE c LENGTH 1 ,

box TYPE c LENGTH 1,

END OF itab.

DATA : itab_frm TYPE TABLE OF ZKONTROL WITH HEADER LINE .

DATA : wa1 LIKE LINE OF ITAB.

********************************************************************

DATA: gt_fieldcat TYPE slis_fieldcat_alv OCCURS 1 WITH HEADER LINE.

********************************************************************

SELECTION-SCREEN: BEGIN OF BLOCK itab1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_werks FOR mseg-werks OBLIGATORY DEFAULT 251,

s_ebeln FOR mseg-ebeln,

s_mblnr FOR mseg-mblnr OBLIGATORY .

SELECTION-SCREEN:END OF BLOCK itab1 .

INITIALIZATION.

START-OF-SELECTION .

PERFORM getdata .

PERFORM goster .

END-OF-SELECTION .

*&---------------------------------------------------------------------*

*& Form GETDATA

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM getdata .

SELECT

mseg~mblnr

mseg~matnr

mseg~erfmg

mseg~erfme

mseg~ebeln

mseg~ebelp

mseg~werks

mseg~lifnr

mseg~xblnr_mkpf

mkpf~bldat

mkpf~budat

INTO CORRESPONDING FIELDS OF TABLE itab FROM mseg

INNER JOIN mkpf ON mseg~mblnr EQ mkpf~mblnr

WHERE

mseg~ebeln IN s_ebeln AND

mseg~mblnr IN s_mblnr AND

mseg~werks IN s_werks .

SORT itab BY mblnr ebeln .

LOOP AT itab .

SELECT SINGLE name1 name2 FROM lfa1 INTO (itab-name1,

itab-name2)

WHERE lifnr EQ itab-lifnr .

CONCATENATE itab-name1 itab-name2 INTO itab-unvan.

MODIFY ITAB.

ENDLOOP.

ENDFORM . "GETDATA

*&---------------------------------------------------------------------*

*& Form GOSTER

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM goster .

DATA: gv_col_pos TYPE i.

DEFINE add-fieldcat.

gt_fieldcat-fieldname = &1.

gt_fieldcat-ref_tabname = &2.

gt_fieldcat-ref_fieldname = &3.

gt_fieldcat-seltext_s = &4.

gt_fieldcat-seltext_m = &4.

gt_fieldcat-seltext_l = &4.

gt_fieldcat-reptext_ddic = &4.

gt_fieldcat-ddictxt = 'L'.

" GT_FIELDCAT-no_out = &5.

gt_fieldcat-col_pos = gv_col_pos.

if gt_fieldcat-fieldname ='SEC'.

gt_fieldcat-checkbox ='X'.

gt_fieldcat-edit ='X'.

ELSEIF gt_fieldcat-fieldname ='MAIL'.

gt_fieldcat-checkbox ='X'.

gt_fieldcat-edit ='X'.

endif.

add 1 to gv_col_pos.

append gt_fieldcat. clear gt_fieldcat.

END-OF-DEFINITION.

********************************************************************

add-fieldcat 'BOX' ' ' ' ' 'Yazd─▒r─▒ld─▒'.

add-fieldcat 'SEC' ' ' ' ' 'Seçim'.

add-fieldcat 'MAIL' ' ' ' ' 'Mail Gönder'.

add-fieldcat 'MBLNR' 'MSEG' 'MBLNR' 'Malzeme belgesi'.

add-fieldcat 'MATNR' 'MSEG' 'MATNR' 'Malzeme'.

add-fieldcat 'ERFMG' 'MSEG' 'ERFMG' 'Miktar(gr┼č.ÖB)'.

add-fieldcat 'ERFME' 'MSEG' 'ERFME' 'Giri┼č ÖB'.

add-fieldcat 'EBELN' 'MSEG' 'EBELN' 'SA spr┼č.'.

add-fieldcat 'EBELP' 'MSEG' 'EBELP' 'Kalem'.

add-fieldcat 'WERKS' 'MSEG' 'WERKS' 'Üretim yeri'.

add-fieldcat 'LIFNR' 'MSEG' 'LIFNR' 'Sat─▒c─▒'.

add-fieldcat 'XBLNR_MKPF' 'MSEG' 'XBLNR' 'Referans'.

********************************************************************

alv_layout-zebra = 'X'.

alv_layout-colwidth_optimize = 'X'.

alv_layout-detail_popup = 'X'.

alv_layout-expand_fieldname = 'CHK'.

gs_grid_settings-edt_cll_cb = 'X'.

********************************************************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = gt_fieldcat[]

is_layout = alv_layout

i_callback_top_of_page = 'TOP_OF_PAGE'

i_callback_pf_status_set = 'SET_PF_STATUS'

i_grid_settings = gs_grid_settings

i_default = 'X'

i_save = 'X'

i_callback_user_command = 'USER_COMMAND'

TABLES

t_outtab = ITAB[].

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

ENDFORM. "CALLSMARTFORM

*&---------------------------------------------------------------------*

*& Form set_pf_status

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->RT_EXTAB text

*----------------------------------------------------------------------*

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'Z100' .

SET TITLEBAR 'T100' .

ENDFORM. "set_pf_status

*&---------------------------------------------------------------------*

*& Form top_of_page

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM top_of_page.

PERFORM build_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING " i_logo = 'Z_ECH_LOGO'

" i_background_id = 'Z_ECH_LOGO'

it_list_commentary = gt_header[].

ENDFORM. "TOP_OF_PAGE

*&---------------------------------------------------------------------*

*& Form build_header

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM build_header .

CLEAR: gt_header[].

gt_header-typ = 'H'.

gt_header-info = 'Depo Girdi Kontrol Raporu'.

APPEND gt_header.

ENDFORM. "BUILD_HEADER

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""yazd─▒r

*&---------------------------------------------------------------------*

*& Form user_command

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->R_UCOMM text

* -->RS_SELFIELD text

*----------------------------------------------------------------------*

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&PRT'.

LOOP AT ITAB where sec ='X'.

MOVE :

ITAB-SEC TO itab_frm-SEC,

ITAB-MBLNR TO ITAB_FRM-MBLNR,

ITAB-MATNR TO itab_frm-matnr,

itab-erfMG TO itab_frm-ERFMG,

itab-ERFME TO itab_frm-ERFME,

itab-ebeln TO itab_frm-EBELN,

ITAB-EBELP TO itab_frm-ebelp,

ITAB-WERKS TO itab_frm-WERKS,

ITAB-LIFNR TO itab_frm-lifnr,

ITAB-xblnr_mkpf TO itab_frm-xblnr_mkpf,

ITAB-bldat TO itab_frm-BLDAT,

ITAB-buDAT TO itab_frm-BUDAT,

ITAB-unvan TO itab_frm-UNVAN.

APPEND itab_frm.

ENDLOOP.

PERFORM callsmartform TABLES itab_frm.

PERFORM MAIL .

**********************************************tablo güncelleme confg

LOOP AT itab_frm .

itab_frm-box = 'X'.

MODIFY itab_frm.

LOOP AT ITAB INTO wa1 WHERE MBLNR = itab_frm-MBLNR.

wa1-box = 'X'.

MODIFY ITAB FROM wa1.

ENDLOOP.

ENDLOOP.

* MODIFY zmm14055 FROM TABLE itab_frm.

* COMMIT WORK AND WAIT .

IF sy-subrc EQ 0.

CLEAR itab_frm[].

ENDIF.

**********************************************tablo güncelleme confg

rs_selfield-refresh = 'X'.

WHEN '&ALL1'.

LOOP AT itab.

itab-sec = 'X'.

MODIFY itab.

ENDLOOP.

rs_selfield-refresh = 'X'.

WHEN '&MAIL1'.

LOOP AT itab.

itab-MAIL = 'X'.

MODIFY itab.

ENDLOOP.

rs_selfield-refresh = 'X'.

WHEN '&SAL1'.

LOOP AT itab.

itab-sec = ' '.

MODIFY itab.

ENDLOOP.

rs_selfield-refresh = 'X'.

ENDCASE. "

*&-------------------------------------------------------------------*

ENDFORM. "

*&---------------------------------------------------------------------*

*& Form callsmartform

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->ITAB_FRM text

*----------------------------------------------------------------------*

FORM callsmartform TABLES t_itab.

DATA: lv_formname TYPE tdsfname.

DATA: ls_control_param TYPE ssfctrlop,

cs_composer_param TYPE ssfcompop.

lv_formname = 'ZMM2255'.

************************************do─črudan yazd─▒r

ls_control_param-no_dialog = ' '. "Yazd─▒rma diyalog penceresi

ls_control_param-preview = 'X'. "Önizleme Sayfas─▒

ls_control_param-device = 'PRINTER'."Yaz─▒c─▒ modu

ls_control_param-langu = 'T'. "Dil Deste─či

* cs_composer_param-tdnoprev = 'X'. "Önizleme kapat

* cs_composer_param-tdnoprint = 'X'. "Yaz─▒m Kapat

cs_composer_param-tdprinter = 'ZI9SWIN'."Yaz─▒c─▒ Ayg─▒t Tipi

cs_composer_param-tddest = 'ZLOCAL'. "Yaz─▒c─▒ K─▒sa Ad─▒

cs_composer_param-rqposname = 'ZLOCAL'. "Yaz─▒c─▒

cs_composer_param-tdnewid = 'X'.

cs_composer_param-tdimmed = 'X'. "Hemen yazdir TDRECE

************************************do─črudan yazd─▒r

DATA: T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE.

DATA: W_FILESIZE TYPE I.

DATA: W_BIN_FILESIZE TYPE I.

DATA: WA_CTRLOP TYPE SSFCTRLOP,

WA_OUTOPT TYPE SSFCOMPOP.

DATA: T_OTFDATA TYPE SSFCRESCL,

T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA fm_name TYPE rs38l_fnam.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = lv_formname

IMPORTING

fm_name = fm_name.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = ls_control_param

OUTPUT_OPTIONS = cs_composer_param

GV_MBLNR = GV_MBLNR

MAIL_SENDER = LS_SENDER

TABLES

it_itab1 = t_itab

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

ENDFORM.

*&---------------------------------------------------------------------*

*& Form MAIL

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM MAIL .

DATA : LV_FORMNAME TYPE RS38L_FNAM.

DATA FM_NAME TYPE RS38L_FNAM.

LV_FORMNAME = 'ZMM2255'.

******************************************

*PDF conversion

DATA: T_OTFDATA TYPE SSFCRESCL,

T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA: T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE.

DATA: W_FILESIZE TYPE I.

DATA: W_BIN_FILESIZE TYPE I.

DATA: WA_CTRLOP TYPE SSFCTRLOP,

WA_OUTOPT TYPE SSFCOMPOP.

DATA: ls_control_param TYPE ssfctrlop,

cs_composer_param TYPE ssfcompop.

************************************do─črudan yazd─▒r

ls_control_param-no_dialog = ' '. "Yazd─▒rma diyalog penceresi

ls_control_param-preview = 'X'. "Önizleme Sayfas─▒

ls_control_param-device = 'PRINTER'."Yaz─▒c─▒ modu

ls_control_param-langu = 'T'. "Dil Deste─či

* cs_composer_param-tdnoprev = 'X'. "Önizleme kapat

* cs_composer_param-tdnoprint = 'X'. "Yaz─▒m Kapat

cs_composer_param-tdprinter = 'ZI9SWIN'."Yaz─▒c─▒ Ayg─▒t Tipi

cs_composer_param-tddest = 'ZLOCAL'. "Yaz─▒c─▒ K─▒sa Ad─▒

cs_composer_param-rqposname = 'ZLOCAL'. "Yaz─▒c─▒

cs_composer_param-tdnewid = 'X'.

cs_composer_param-tdimmed = 'X'. "Hemen yazdir TDRECE

************************************do─črudan yazd─▒r

"DATA fm_name TYPE rs38l_fnam.

WA_CTRLOP-GETOTF = 'X'.

WA_CTRLOP-NO_DIALOG = 'X'.

WA_OUTOPT-TDNOPREV = 'X'.

WA_OUTOPT-TDDEST = 'HP_N'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = lv_formname

IMPORTING

fm_name = fm_name.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = ls_control_param

OUTPUT_OPTIONS = cs_composer_param

* GV_MBLNR = GV_MBLNR

MAIL_SENDER = LS_SENDER

IMPORTING

JOB_OUTPUT_INFO = T_OTFDATA

TABLES

it_itab1 = ITAB_FRM

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF T_OTFDATA-OTFDATA[] IS INITIAL.

MESSAGE 'Belge maile eklenmedi. Yazd─▒r─▒n─▒z!' TYPE 'S'.

LEAVE TO SCREEN 0.

ENDIF.

W_RETURN = T_OTFDATA.

T_OTF[] = T_OTFDATA-OTFDATA[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

IMPORTING

BIN_FILESIZE = W_BIN_FILESIZE

TABLES

OTF = T_OTF

LINES = I_TLINE

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

OTHERS = 4.

LOOP AT I_TLINE INTO S_TLINE.

TRANSLATE S_TLINE USING '~'.

CONCATENATE WA_BUFFER S_TLINE INTO WA_BUFFER.

ENDLOOP.

TRANSLATE WA_BUFFER USING '~'.

DO.

S_RECORD = WA_BUFFER.

APPEND S_RECORD TO I_RECORD.

SHIFT WA_BUFFER LEFT BY 255 PLACES.

IF WA_BUFFER IS INITIAL.

EXIT.

ENDIF.

ENDDO.

* Attachment

REFRESH: I_RECLIST,

I_OBJTXT,

I_OBJBIN,

I_OBJPACK.

CLEAR WA_OBJHEAD.

I_OBJBIN[] = I_RECORD[].

* Mesaj gövdesi ve attachment olu┼čtur.

data : tex1 type char30.

data : tex2 type char30.

tex1 = 'Bu e-posta, taraf─▒ndan'.

tex2 = ' Lütfen Reply Etmeyiniz.....!'.

CONCATENATE " maildeki alt yaz─▒

'TEXXT1' 'TEXT2' into S_OBJTXT.

CONCATENATE " maildeki konu

'BASLIK' '-'

into MAIL_BASLIK.

APPEND S_OBJTXT TO I_OBJTXT.

DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.

READ TABLE I_OBJTXT INDEX V_LINES_TXT TRANSPORTING NO FIELDS.

WA_DOC_CHNG-OBJ_NAME = MAIL_BASLIK.

WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.

WA_DOC_CHNG-OBJ_DESCR = MAIL_BASLIK.

WA_DOC_CHNG-SENSITIVTY = 'F'.

WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.

* Main Text

CLEAR S_OBJPACK-TRANSF_BIN.

S_OBJPACK-HEAD_START = 1.

S_OBJPACK-HEAD_NUM = 0.

S_OBJPACK-BODY_START = 1.

S_OBJPACK-BODY_NUM = V_LINES_TXT.

S_OBJPACK-DOC_TYPE = 'RAW'.

APPEND S_OBJPACK TO I_OBJPACK.

* Attachment (pdf-Attachment)

S_OBJPACK-TRANSF_BIN = 'X'.

S_OBJPACK-HEAD_START = 1.

S_OBJPACK-HEAD_NUM = 0.

S_OBJPACK-BODY_START = 1.

DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.

READ TABLE I_OBJBIN INDEX V_LINES_BIN TRANSPORTING NO FIELDS.

S_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .

S_OBJPACK-BODY_NUM = V_LINES_BIN.

S_OBJPACK-DOC_TYPE = 'PDF'.

S_OBJPACK-OBJ_NAME = 'EK'.

CONCATENATE '_' 'BASLIK' INTO LV_BASLIK. "ahmedt

S_OBJPACK-OBJ_DESCR = LV_BASLIK.

APPEND S_OBJPACK TO I_OBJPACK.

DATA : MAIL_ADRES TYPE CHAR50.

S_RECLIST-RECEIVER = 'developer@yahoo.com' .

S_RECLIST-REC_TYPE = 'U'.

APPEND S_RECLIST TO I_RECLIST.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = WA_DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = I_OBJPACK

OBJECT_HEADER = WA_OBJHEAD

CONTENTS_BIN = I_OBJBIN

CONTENTS_TXT = I_OBJTXT

RECEIVERS = I_RECLIST

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

OTHERS = 8.

DATA : MESSAGE TYPE CHAR200.

CONCATENATE GV_mblnr 'NOLU BELGE ' 'GÖNDER─░LD─░.' INTO MESSAGE.

MESSAGE MESSAGE TYPE 'S'.

ENDFORM. " MAIL