선언부는 일반 스마트폼 뿌리듯이 만들고.. 포인트는 전송쪽이 아닐까..
전송쪽만 붙이겠다...
선언부쪽만 붙여넣음.. 이런 형식이라는 것을 보여주기 위해.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_BUKRS) TYPE BUKRS DEFAULT '1000'
*" VALUE(I_LIFNR) TYPE LIFNR
*" VALUE(I_COLIF) TYPE ZOE0VDCO
*" EXPORTING
*" VALUE(E_CONTENTS) TYPE XSTRING
*" VALUE(ES_RETURN) LIKE ZO1SCOF STRUCTURE ZO1SCOF
*" TABLES
*" ET_HEADER STRUCTURE ZO1SSF0010
*" ET_ITEM STRUCTURE ZO1SSF0011
*"----------------------------------------------------------------------
DATA : ls_t001w LIKE t001w,
lt_t001w LIKE TABLE OF ls_t001w,
ls_branch LIKE j_1bbranch,
address LIKE addr1_val.
DATA : ls_zo1tvpg LIKE zo1tvpg,
ls_zo1tvph LIKE zo1tvph,
lt_zo1tvph LIKE TABLE OF zo1tvph.
DATA : ls_header LIKE zo1ssf0010,
ls_item LIKE zo1ssf0011,
lt_item LIKE TABLE OF ls_item.
DATA : BEGIN OF ls_etel,
tel_number LIKE adrc-tel_number,
fax_number LIKE adrc-fax_number,
END OF ls_etel.
DATA : lv_cnt TYPE int4.
*----------------------------------------------------------------------*
*-- Call smartforms
*... Local Variable Declaration
DATA:
lt_document_output_info TYPE ssfcrespd,
lt_job_output_info TYPE ssfcrescl,
lt_job_output_options TYPE ssfcresop,
ls_control_parameters TYPE ssfctrlop,
ls_output_options TYPE ssfcompop,
func_module_name TYPE rs38l_fnam.
CONSTANTS:
*... Determine the name of the generated function module
c_formname TYPE ssfscreen-fname VALUE 'ZXXXX_ORI01'. <- 내가 만든 스마트폼 이름
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname <- 스마트폼 이름 넣으면
IMPORTING
fm_name = func_module_name <- 펑션모듈 이름이 튀어나온다.
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CASE sy-subrc. "그냥 체크문만든것임..
WHEN 1.
es_return-type = 'E'.
es_return-message = 'No form'.
RETURN.
WHEN 2.
es_return-type = 'E'.
es_return-message = 'No function module'.
RETURN.
WHEN 3.
es_return-type = 'E'.
es_return-message = 'Smartform error'.
RETURN.
ENDCASE.
ls_control_parameters-no_dialog = 'X'. "다이얼로그 박스 안띄우는 명령어-프린트 프리뷰같은게 안나옴.
ls_control_parameters-getotf = 'X'. "이거 꼭 체크해줘야 함.. OTF 얻겠다는 것임..
*... Call the generated function module of the form
CALL FUNCTION func_module_name <-위에서 받아온 펑션모듈네임으로 콜펑션!
EXPORTING
control_parameters = ls_control_parameters <- 위에 다이얼로그박스랑 OTF에 대한거 들어감.
output_options = ls_output_options <- 위에선 안넣었다.
user_settings = space
is_header = ls_header <-내가 만든 헤더분.. 선언부 맨 위에 붙여주겠다.
IMPORTING
document_output_info = lt_document_output_info "정보 받아오기..
job_output_info = lt_job_output_info
job_output_options = lt_job_output_options
TABLES
it_item = lt_item <-이거 ls_item 형식의 테이블, 헤더부 아이템부 따로만든거라..
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
my_exception = 5
OTHERS = 6.
*----------------------------------------------------------------------*
*-- convert OTF to xstring "OTF를 xstring 으로 변환함..
DATA:
l_bin_filesize TYPE i, "파일 사이즈 받아오기 위해서
lt_dummy TYPE STANDARD TABLE OF docs, "이건 sap에서 들어가보길..
lt_lines TYPE STANDARD TABLE OF tline.
FIELD-SYMBOLS:
<lines> TYPE tline,
<x> TYPE x.
CALL FUNCTION 'CONVERT_OTF_2_PDF' "OTF를 PDF로 변환하는 펑션
IMPORTING
bin_filesize = l_bin_filesize
TABLES
otf = lt_job_output_info-otfdata "이거 위에서 콜펑션 할때 나왔던 info의 otfdata 임.
doctab_archive = lt_dummy
lines = lt_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
LOOP AT lt_lines "이거 라인별로 끊어서 날릴려고 나눠준것임..
ASSIGNING <lines>.
ASSIGN <lines> TO <x> CASTING TYPE x.
CONCATENATE e_contents <x> INTO e_contents IN BYTE MODE. "e_contents는 출력용
ENDLOOP.
**----------------------------------------------------------------------*
**-- convert OTF to PDF binary "바이너리로 날리려다가 막음.. 위에가 끝임..
* DATA:
* lt_content_txt TYPE soli_tab,
* lt_content_bin TYPE solix_tab,
* lt_objhead TYPE soli_tab,
* l_transfer_bin TYPE sx_boolean,
* l_len TYPE so_obj_len.
*
* FIELD-SYMBOLS:
* <otf> TYPE itcoo.
*
* CLEAR:
* e_contents.
*
* LOOP AT lt_job_output_info-otfdata
* ASSIGNING <otf>.
* APPEND <otf> TO lt_content_txt.
* ENDLOOP.
*
* CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
* EXPORTING
* format_src = 'OTF'
* format_dst = 'PDF'
* CHANGING
* transfer_bin = l_transfer_bin
* content_txt = lt_content_txt
* content_bin = lt_content_bin
* objhead = lt_objhead
* len = l_len
* EXCEPTIONS
* err_conv_failed = 1
* OTHERS = 2.
*
* CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
** EXPORTING
** input_length = 255
* IMPORTING
* buffer = e_contents
* TABLES
* binary_tab = lt_content_bin
* EXCEPTIONS
* failed = 1
* OTHERS = 2.
*----------------------------------------------------------------------*
IF e_contents IS NOT INITIAL.
es_return-type = 'S'.
es_return-message = 'PDF Export Success'.
ELSE.
es_return-type = 'E'.
es_return-message = 'PDF Export Error'.
ENDIF.
----------------------------------------------------------
그냥 이렇게 된다는거... 연습은 알아서.. ^^
'ERP-SAP > SAMRTFORMS' 카테고리의 다른 글
<ABAP> Smartforms 에서 알아둘 SAP SCRIPT (0) | 2012.02.08 |
---|---|
<ABAP> Smartforms 여러건의 문서에 여러 아이템들 인쇄하기 (다수 페이지) (0) | 2011.06.29 |
<ABAP> Smartforms 에서 1페이지에서 2페이지로 넘어가며 출력하기 (0) | 2011.06.03 |