대부분 EXCEL 이나 HTML 을 만든 후에 이곳에 업로드 해서 그대로 불러와서 쓴다고들 한다.
뭐.. EXCEL 필드들이야 동적으로 생성해도 되지만..
내가 한건 HTML을 전송한다나 뭐라나.. 해서 썼는데..
우선 SMW0에 HTML 템플릿을 올리고. (난 윗쪽 선택했다;;)
아이콘중에 흰색 용지 선택해서 올리면 된다.
흰색 용지 누르면 아래와 같은 팝업이 뜨는데..
OBJ.NAME 에는 니가 나중에 부를수 있는 ID 같은걸 만들어 주는거다..
대부분 사람들이 프로그램명을 아이디로 사용하더라...
설명이야 대충 써주면..
업로드 화면 나와서 업로드 하면 된다. 그럼 끝..
문제는 부르는거다...
*&---------------------------------------------------------------------* *& Form TRANSFER_DATA *&---------------------------------------------------------------------* FORM transfer_data . DATA : lv_subrc TYPE sy-subrc, lv_content TYPE string, " HTML String lv_apprno type zeapprno, lv_type TYPE bapi_mtype, lv_message TYPE bapi_msg.
DATA : ls_header LIKE zcmcs012, lt_content LIKE TABLE OF zcmcs016, " HTML Internal Table lt_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'Z_CMC_GET_HTML' "이걸로 가져온거긴 한데.. 아래 붙여넣어주마. EXPORTING i_obj_name = sy-repid IMPORTING o_content = lv_content TABLES t_content = lt_content.
function z_cmc_get_html. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(I_OBJ_NAME) TYPE PROGNAME *" REFERENCE(I_CODEPAGE) OPTIONAL *" EXPORTING *" REFERENCE(O_CONTENT) TYPE STRING *" TABLES *" T_CONTENT STRUCTURE ZCMCS016 *"---------------------------------------------------------------------- * Global data declarations data: lt_content like zcmcs016 occurs 0 with header line. data: lv_obj_name type wwwdataid-objid. lv_obj_name = i_obj_name. call function 'WWW_GET_SCRIPT_AND_HTML' exporting obj_name = lv_obj_name tables html = lt_content.
if i_codepage = space. data: l_file type string value 'c:\temp.tmp'. call function 'GUI_DOWNLOAD' exporting filename = l_file filetype = 'ASC' trunc_trailing_blanks = 'X' write_lf = 'X' tables data_tab = lt_content. call function 'GUI_UPLOAD' exporting filename = l_file filetype = 'ASC' codepage = '8500' tables data_tab = lt_content exceptions file_open_error = 1 file_read_error = 2. endif. t_content[] = lt_content[]. concatenate lines of t_content into o_content.
endfunction.
받는부분 IMPORT
I_OBJ_NAME TYPE PROGNAME ABAP 프로그램이름 I_CODEPAGE X 이거 PASS BY VALUE
보내는 부분 EXPORT
O_CONTENT TYPE STRING
이거 테이블
T_CONTENT LIKE ZCMCS016 [공통] HTML Contents
ZCMCS016은 스트럭쳐로 완전 아무것도 없이..
LINE Types TEXT255 CHAR 255 0 텍스트, 255개의 문자
이러 띨렁 잇다.. 참고해라.
ZCMCS
IF lv_content IS INITIAL. * gv_res = c_error. MESSAGE s000(swww) WITH sy-repid DISPLAY LIKE 'I'. EXIT. ENDIF.
* HTML에 데이터 바인딩 PERFORM set_approval_html TABLES lt_content <-- 더보기에 붙여넣어줌. CHANGING lv_content. <-- 그냥 웹폼에 있던 글자를 대체시켜줌.
*&---------------------------------------------------------------------* *& Form SET_APPROVAL_HTML *&---------------------------------------------------------------------* FORM set_approval_html TABLES pt_content STRUCTURE zcmcs016 CHANGING p_content TYPE string.
DATA : lv_contexts TYPE string, " 내역 lv_data TYPE string, " 일반 String 변환 변수 lv_lines TYPE i, " HTML Line Count lv_index TYPE i, " Index lv_count TYPE i, " COUNT lv_lpcnt TYPE i, " LOOP COUNT lv_date(10) TYPE c, " 일자 lv_gtext LIKE tgsbt-gtext, lv_amount(40). " 금액변환 변수
DATA : ls_result TYPE match_result, lt_result LIKE TABLE OF ls_result, ls_content LIKE zcmcs016, ls_content2 LIKE zcmcs016.
DATA : lt_content LIKE TABLE OF zcmcs016. " HTML Table
* 견적번호 REPLACE ALL OCCURRENCES OF '$H_ZESTNM$' IN TABLE pt_content WITH gs_expdat-zestnm.
* 프로젝트명 REPLACE ALL OCCURRENCES OF '$H_ZPRZNM$' IN TABLE pt_content WITH gs_expdat-zprjnm.
* 국가 REPLACE ALL OCCURRENCES OF '$H_ZEUSRCNTR$' IN TABLE pt_content WITH gs_expdat-zeusrcntr.
* 발주처 REPLACE ALL OCCURRENCES OF '$H_ZCUST$' IN TABLE pt_content WITH gs_expdat-zcust.
* 최종수정가 REPLACE ALL OCCURRENCES OF '$H_ZEUSR$' IN TABLE pt_content WITH gs_expdat-zeusr.
* 견적기종 REPLACE ALL OCCURRENCES OF '$H_ZPRODH$' IN TABLE pt_content WITH gs_expdat-zprodh.
* 요청부서 REPLACE ALL OCCURRENCES OF '$H_Z_TEAM_S$' IN TABLE pt_content WITH gs_expdat-z_team_s.
* 영업담당자 REPLACE ALL OCCURRENCES OF '$H_Z_PRS_S$' IN TABLE pt_content WITH gs_expdat-z_prs_s.
* 견적용도 REPLACE ALL OCCURRENCES OF '$H_PRPS$' IN TABLE pt_content WITH gs_expdat-zprps.
* 완료요청일 REPLACE ALL OCCURRENCES OF '$H_Z_DATE_F$' IN TABLE pt_content WITH gs_expdat-z_date_f.
* 완료예정일 REPLACE ALL OCCURRENCES OF '$H_Z_DATE_END$' IN TABLE pt_content WITH gs_expdat-z_date_end.
* 견적담당자 REPLACE ALL OCCURRENCES OF '$H_Z_PRS_Q' IN TABLE pt_content WITH gs_expdat-z_prs_q.
* 특기사항 REPLACE ALL OCCURRENCES OF '$H_Z_TEXT' IN TABLE pt_content WITH gs_expdat-z_text.
* 재료비 WRITE gs_expdat-vv200 TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_VV200$' IN TABLE pt_content WITH lv_amount.
* 노무비 CLEAR : lv_amount. WRITE gs_expdat-vv500 TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_VV500$' IN TABLE pt_content WITH lv_amount.
* 도급경비 CLEAR : lv_amount. WRITE gs_expdat-vv600 TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_VV600$' IN TABLE pt_content WITH lv_amount.
* 외주가공경비 CLEAR : lv_amount. WRITE gs_expdat-vv3400 TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_VV650$' IN TABLE pt_content WITH lv_amount.
* 외주 용역비 CLEAR : lv_amount. WRITE gs_expdat-zoutscost TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_ZWBTR$' IN TABLE pt_content WITH lv_amount.
* 기타경비 CLEAR : lv_amount. WRITE gs_expdat-zothcost TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_ZWBTR1$' IN TABLE pt_content WITH lv_amount.
* 경비계 CLEAR : lv_amount. WRITE gs_expdat-ztotcost TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_ZWBTRT$' IN TABLE pt_content WITH lv_amount.
* 단가 CLEAR : lv_amount. WRITE gs_expdat-vv800 TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_VV800$' IN TABLE pt_content WITH lv_amount.
* 수량 WRITE gs_expdat-zquan TO lv_amount. REPLACE ALL OCCURRENCES OF '$H_ZQUAN$' IN TABLE pt_content WITH lv_amount.
* 총원가 CLEAR : lv_amount. WRITE gs_expdat-ztcopri TO lv_amount CURRENCY 'KRW'. REPLACE ALL OCCURRENCES OF '$H_TOTAL$' IN TABLE pt_content WITH lv_amount.
* Table 구조의 HTML을 String 변수에 바인딩 CONCATENATE LINES OF pt_content INTO p_content. ENDFORM. " SET_APPROVAL_HTML
ls_header-modid = 'CO'. " 모듈명 ls_header-progid = sy-cprog. " 프로그램 ID ls_header-title = sy-title. " 프로그램명 ls_header-formid = 'REQ_C003_01'. " 임시 FORM ID * ls_header-aft_progid = 'ZFIQR019'. * ls_header-drafter = GS_EXPDAT-Z_PRS_S. "SAP 사용자 id
CALL FUNCTION 'Z_CMC_APPR_SEND' EXPORTING i_header = ls_header i_contents = lv_content <-- 결국 여기에서 보내는 거임.. IMPORTING e_apprno = lv_apprno e_type = lv_type e_message = lv_message TABLES t_contents = lt_content.
function z_cmc_appr_send . *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(I_HEADER) TYPE ZCMCS012 *" REFERENCE(I_CONTENTS) *" EXPORTING *" REFERENCE(E_APPRNO) TYPE ZEAPPRNO *" REFERENCE(E_TYPE) TYPE BAPI_MTYPE *" REFERENCE(E_MESSAGE) TYPE BAPI_MSG *" TABLES *" T_CONTENTS STRUCTURE ZCMCS016 OPTIONAL *"---------------------------------------------------------------------- if i_contents is initial . message s900 display like c_error. else. if i_header-drafter is initial. gv_drafter = sy-uname. else. gv_drafter = i_header-drafter. endif. select single * from zcmct001 where usrid = gv_drafter. if sy-subrc = 0. perform get_def_lines. <- 이거 아래 붙여줌 gv_contents = i_contents. gt_contents[] = t_contents[]. *zcmcs012 = i_header. *zcmcs011-drfsabun = zcmct001-sabun. *zcmcs011-subject = i_header-subject. *zcmcs011-urgflg = c_false. *zcmcs011-seqflg = c_false. *zcmcs011-opnflg = c_false. *zcmcs011-rsterm = '3'. *zcmcs011-deadline = '0'. call screen '0100'. if gv_apprno is not initial. e_apprno = gv_apprno. e_type = gv_rettype. e_message = gv_retmsg. else. if e_message is not initial. e_type = gv_rettype. e_message = gv_retmsg. else. message : s905 into e_message. endif. endif. else . e_type = c_error. message: s904 into e_message. endif. endif. endfunction.
IF lv_apprno = space. * gv_res = c_error. IF lv_message IS INITIAL. MESSAGE i001 WITH text-m18. ELSE. MESSAGE i001 WITH lv_message. ENDIF. EXIT. ENDIF. clear gs_expdat-z_text.
ENDFORM. " TRANSFER_DATA
PERFORM GET_DEF_LINES .이거 붙여줌
*&---------------------------------------------------------------------* *& Form GET_DEF_LINES *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form get_def_lines .
data : lv_cnt type i ,lv_jikgub like zcmct001-jikgubcd ,lv_deptcd like zcmct001-deptcd .
clear : lv_cnt, gt_lines, gt_lines[]. do 10 times. add 1 to lv_cnt. if lv_cnt = 1. * ps_uname = sy-uname. select single sabun usrid usrnm deptcd jikgubcd jikwicd into (*zcmcs011-drfsabun, *zcmcs011-drafter , *zcmcs011-drftnm , *zcmcs011-deptcd , lv_jikgub , *zcmcs011-jikwicd) from zcmct001 where usrid = gv_drafter. if sy-subrc eq 0. gt_lines-apprtyp = 'DR'. perform read_domain_text using 'ZDAPPR_TYPE' gt_lines-apprtyp changing gt_lines-typenm. if *zcmcs011-jikwicd is not initial. perform read_domain_text using 'ZDJIKWICD' *zcmcs011-jikwicd changing *zcmcs011-jikwinm. endif. if *zcmcs011-deptcd is not initial. select single deptnm into *zcmcs011-deptnm from zcmct002 where deptcd = *zcmcs011-deptcd.
gt_lines-apprsb = *zcmcs011-drfsabun. gt_lines-apprid = *zcmcs011-drafter. gt_lines-apprnm = *zcmcs011-drftnm. gt_lines-jikgubcd = lv_jikgub. perform read_domain_text using 'ZDJIKGUBCD' gt_lines-jikgubcd changing gt_lines-jikgubnm. gt_lines-deptcd = *zcmcs011-deptcd. gt_lines-deptnm = *zcmcs011-deptnm. gt_lines-seqno = lv_cnt. append gt_lines. clear gt_lines. add 1 to lv_cnt. concatenate 'hs' *zcmcs011-deptcd into lv_deptcd. select single sabun usrid usrnm jikgubcd deptcd into (gt_lines-apprsb, gt_lines-apprid , gt_lines-apprnm , gt_lines-jikgubcd , gt_lines-deptcd) from zcmct001 where bukrs = 'H100' and ( ( gradecd = c_team_ld and deptup = *zcmcs011-deptcd ) or ( con_grade1 = c_team_ld and con_dept1 = *zcmcs011-deptcd ) or ( con_grade2 = c_team_ld and con_dept2 = *zcmcs011-deptcd ) or ( con_grade3 = c_team_ld and con_dept3 = *zcmcs011-deptcd ) or ( con_grade4 = c_team_ld and con_dept4 = lv_deptcd ) ). if sy-subrc = 0. gt_lines-apprtyp = 'AP'. perform read_domain_text using 'ZDAPPR_TYPE' gt_lines-apprtyp changing gt_lines-typenm. perform read_domain_text using 'ZDJIKGUBCD' gt_lines-jikgubcd changing gt_lines-jikgubnm. select single deptnm into gt_lines-deptnm from zcmct002 where deptcd = gt_lines-deptcd. endif. endif. endif. endif. move : lv_cnt to gt_lines-seqno * ,'H100' TO gt_lines-bukrs . append gt_lines. clear gt_lines. enddo. endform. " GET_DEF_LINES
READ DOMAIN TEXT. 붙여줌
*&---------------------------------------------------------------------* *& Form READ_DOMAIN_TEXT *&---------------------------------------------------------------------* * 해당 Domain text를 읽어오는 Function *----------------------------------------------------------------------* * -->P_DFIELD : Domain명 * -->P_VALUE : Domain Value * <--P_DDTEXT : Domain text *----------------------------------------------------------------------* form read_domain_text using p_dfield type any p_value type any changing p_ddtext type any. clear st_domv. st_domv-domname = p_dfield. "도메인 NAME st_domv-ddlanguage = sy-langu. "Language st_domv-domvalue_l = p_value. "입력 값
call function 'C_DIC_DOMAIN_VALUE_TEXT_READ' exporting name = st_domv-domname spras = st_domv-ddlanguage value = st_domv-domvalue_l importing text = st_domv-ddtext exceptions not_found = 1 others = 4.