在FB01创建的会计凭证,可以在FB02中,增加附件,比如,打印的凭证PDF附件,我们的需求是把票据信息生成的PDF放到对应的会计凭证 ,或者是把银企直连接支付后银行的电子回单的PDF文件放到对应的会计凭证 上,
之前一开始做的是附件保存到SAP的服务器上,后来修改为传到OPENTEXT上,
以下记录一些样的功能点,文章来源:https://www.toymoban.com/news/detail-694088.html
- 使用函数SSF_FUNCTION_MODULE_NAME得到SMARTFORM,并打印,得到打印的内容LS_CONTROL_PARAMETERS
- 函数CONVERT_OTF把SMARTFORM生成PDF文件,
- SCMS_XSTRING_TO_BINARY转换为二进制值,用于传输 上传。
- 调用函数BINARY_RELATION_CREATE_COMMIT“创建附件”,把文件传到SAP服务器,并使用成为会计凭证附件
- 调用BINARY_RELATION_CREATE,“创建外部凭证(URL)”,把URL地址作为作为会计凭证附件。
-
背面信息 DATA(LT_NEW) = LT_BMXX2. DELETE LT_NEW WHERE DRAFTNO <> <FS_PMXX>-DRAFTNO. IF LT_NEW IS NOT INITIAL. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING FORMNAME = 'ZTR2_0580_BMXX' VARIANT = ' ' DIRECT_CALL = ' ' IMPORTING FM_NAME = LV_FM_NAME EXCEPTIONS NO_FORM = 1 NO_FUNCTION_MODULE = 2 OTHERS = 3. IF SY-SUBRC <> 0. RETURN. ENDIF. CALL FUNCTION LV_FM_NAME EXPORTING CONTROL_PARAMETERS = LS_CONTROL_PARAMETERS OUTPUT_OPTIONS = LS_OUTPUT_OPTIONS USER_SETTINGS = 'X' IV_ZTR2T0350 = <FS_PMXX> IMPORTING JOB_OUTPUT_INFO = LS_JOB_OUTPUT_INFO TABLES IT_ZTR2T0370 = LT_NEW 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. REFRESH LT_NEW. ENDIF. CALL FUNCTION 'SSF_CLOSE' IMPORTING JOB_OUTPUT_INFO = LS_JOB_OUTPUT_INFO EXCEPTIONS FORMATTING_ERROR = 1 INTERNAL_ERROR = 2 SEND_ERROR = 3 OTHERS = 4. 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 PDF content CALL FUNCTION 'CONVERT_OTF' EXPORTING FORMAT = 'PDF' MAX_LINEWIDTH = 132 IMPORTING BIN_FILESIZE = LV_BIN_FILESIZE BIN_FILE = LV_BIN_FILE TABLES OTF = LS_JOB_OUTPUT_INFO-OTFDATA[] LINES = LT_PDF_LINE EXCEPTIONS ERR_MAX_LINEWIDTH = 1 ERR_FORMAT = 2 ERR_CONV_NOT_POSSIBLE = 3 ERR_BAD_OTF = 4 OTHERS = 5. IF SY-SUBRC <> 0. ENDIF. DATA: GT_BIN TYPE SOLIX OCCURS 0, G_ATTSIZE TYPE INT4. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING BUFFER = LV_BIN_FILE * APPEND_TO_TABLE = ' ' IMPORTING OUTPUT_LENGTH = G_ATTSIZE TABLES BINARY_TAB = GT_BIN. INCLUDE <CNTN01>. TYPE-POOLS: SLIS, ABAP, TRUXS. DATA:L_OBJ TYPE SWC_OBJECT, G_FILENAME TYPE STRING, GS_OBJB TYPE BORIDENT, GS_OBJA TYPE BORIDENT, GS_BINREL TYPE GBINREL, GT_BINATT TYPE STANDARD TABLE OF BRELATTR. IF <FS_PMXX>-PJZT = '100006' OR <FS_PMXX>-PJZT = '030006'. G_FILENAME = '票面信息-已签收-' && <FS_PMXX>-DRAFTNO. ELSE. G_FILENAME = '票面信息-待签收-' && <FS_PMXX>-DRAFTNO. ENDIF. DATA: L_SEQ TYPE I. SWC_CONTAINER L_CONT. SWC_CREATE_OBJECT L_OBJ 'MESSAGE' ''. SWC_SET_ELEMENT L_CONT 'NO_DIALOG' 'X'. SWC_SET_ELEMENT L_CONT 'DOCUMENTTITLE' G_FILENAME. SWC_SET_TABLE L_CONT 'Content_Hex' GT_BIN. SWC_SET_ELEMENT L_CONT 'DOCUMENTTYPE' 'PDF'. SWC_SET_ELEMENT L_CONT 'DOCUMENTSIZE' G_ATTSIZE. SWC_REFRESH_OBJECT L_OBJ. SWC_CALL_METHOD L_OBJ 'CREATE' L_CONT. SWC_GET_OBJECT_KEY L_OBJ GS_OBJB-OBJKEY. GS_OBJB-OBJTYPE = 'MESSAGE'. "type of attach document GS_OBJA-OBJTYPE = 'BKPF'. "BO of SAP Document. CONCATENATE GS_UPLOAD-BUKRS "company code GS_UPLOAD-BELNR "FI Document GS_UPLOAD-GJAHR "fiscal year INTO GS_OBJA-OBJKEY. CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT' EXPORTING OBJ_ROLEA = GS_OBJA OBJ_ROLEB = GS_OBJB RELATIONTYPE = 'ATTA' IMPORTING BINREL = GS_BINREL TABLES BINREL_ATTRIB = GT_BINATT EXCEPTIONS NO_MODEL = 1 INTERNAL_ERROR = 2 UNKNOWN = 3 OTHERS = 4.
使用OPENTEXT保存附件,把URL地址作为会计凭证附件地址。文章来源地址https://www.toymoban.com/news/detail-694088.html
-
FORM PF_UPLOAD_FILE USING PS_JOB_OUTPUT_INFO TYPE SSFCRESCL PS_PMXX TYPE ZTR2T0350 PS_UPLOAD TYPE TY_DATA CHANGING P_FALG TYPE CHAR1. DATA: LS_CONTROL_PARAMETERS TYPE SSFCTRLOP, LS_OUTPUT_OPTIONS TYPE SSFCOMPOP, LS_JOB_OUTPUT_INFO TYPE SSFCRESCL. DATA: LT_PDF_LINE TYPE STANDARD TABLE OF TLINE, LV_BIN_FILESIZE TYPE I, LV_BIN_FILE TYPE XSTRING, LV_FILELENGTH TYPE NUM12. DATA: LV_FILENAME TYPE STRING. DATA: L_ZOAREF_NO TYPE ZOAREF_NO. DATA: LV_FLAG TYPE CHAR1, "返回状态 LV_MESSAGE TYPE STRING, " 返回消息 LV_ATT_NO TYPE ZDEATT_NO, " 文件编号 LV_ARC_DOC_ID TYPE SAEARDOID. " SAP 归档链接:文档 ID DATA: LT_0100 TYPE TABLE OF ZTRT0100. LS_JOB_OUTPUT_INFO = PS_JOB_OUTPUT_INFO. *Get PDF content CALL FUNCTION 'CONVERT_OTF' EXPORTING FORMAT = 'PDF' MAX_LINEWIDTH = 132 IMPORTING BIN_FILESIZE = LV_BIN_FILESIZE BIN_FILE = LV_BIN_FILE TABLES OTF = LS_JOB_OUTPUT_INFO-OTFDATA[] LINES = LT_PDF_LINE EXCEPTIONS ERR_MAX_LINEWIDTH = 1 ERR_FORMAT = 2 ERR_CONV_NOT_POSSIBLE = 3 ERR_BAD_OTF = 4 OTHERS = 5. IF SY-SUBRC <> 0. ENDIF. DATA: GT_BIN TYPE TBL1024 OCCURS 0, G_ATTSIZE TYPE INT4. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING BUFFER = LV_BIN_FILE * APPEND_TO_TABLE = ' ' IMPORTING OUTPUT_LENGTH = G_ATTSIZE TABLES BINARY_TAB = GT_BIN. LV_FILELENGTH = G_ATTSIZE. INCLUDE <CNTN01>. TYPE-POOLS: SLIS, ABAP, TRUXS. IF PS_PMXX-PJZT = '100006' OR PS_PMXX-PJZT = '030006'. LV_FILENAME = '票面信息-已签收-' && PS_PMXX-DRAFTNO. ELSE. LV_FILENAME = '票面信息-待签收-' && PS_PMXX-DRAFTNO. ENDIF. CONCATENATE PS_UPLOAD-BUKRS "company code PS_UPLOAD-BELNR "FI Document PS_UPLOAD-GJAHR "fiscal year INTO L_ZOAREF_NO. "外围系统附件上传OpenText CALL FUNCTION 'ZRFC_ARCHIV_CREATE_FILE' EXPORTING IV_BUSTYPE = 'TR_0130' "文件类型 IV_BUKRS = PS_UPLOAD-BUKRS IV_REF_NO = L_ZOAREF_NO "会计凭证号 IV_ITEM = 0 "收款单行项目 IV_SCJS = '' "上传角色 IV_DOC_TYPE = 'PDF' " IV_FILENAME = LV_FILENAME IV_FILELENGTH = LV_FILELENGTH IV_TEXT = '' IMPORTING EV_FLAG = LV_FLAG EV_MESSAGE = LV_MESSAGE EV_ATT_NO = LV_ATT_NO TABLES IT_BIN = GT_BIN. IF LV_FLAG NE 'T'."失败 RETURN . * wd_comp_controller->pup_message( is_message = lv_message is_type = 2 ). ENDIF. LT_0100 = VALUE #( BASE LT_0100 ( GUID = CL_SWF_UTL_GUID_CREATE=>GET_GUID_16( ) REF_NO = L_ZOAREF_NO BUSTYPE = 'TR_0130' ATT_NO = LV_ATT_NO ) ). MODIFY ZTRT0100 FROM TABLE LT_0100[]. COMMIT WORK. *--------------------------------------------------------------------* *取得URL DATA LOBJ TYPE REF TO ZCL_TR_POST_CHECK. DATA L_URL TYPE SAPB-URI. CREATE OBJECT LOBJ. L_URL = LOBJ->DOWNLOAD_FILE_AS_URL( I_ATT_NO = LV_ATT_NO MODE = 'U' ). *--------------------------------------------------------------------* *设置FB03可见 DATA MSG TYPE STRING . DATA ANSWER . DATA LINES TYPE STRING . DATA FOLDER_ID TYPE SOFDK . DATA LT_OBJHEAD TYPE STANDARD TABLE OF SOLI . DATA LT_OBJCONT TYPE STANDARD TABLE OF SOLI WITH HEADER LINE . DATA L_OBJ_ID TYPE SOODK . DATA L_OBJ_DATA TYPE SOOD1 . DATA DOCUMENT_ID TYPE SOFMK . DATA REL_DOC TYPE BORIDENT . DATA IS_OBJECT TYPE BORIDENT . DATA L_INDEX TYPE SY-INDEX . CLEAR :MSG ,ANSWER , LINES ,FOLDER_ID ,LT_OBJHEAD ,LT_OBJCONT ,LT_OBJCONT[] ,L_OBJ_ID ,L_OBJ_DATA ,DOCUMENT_ID ,IS_OBJECT ,REL_DOC ,L_INDEX . DATA LS_OBJCONT TYPE SOLI. DATA LT_URLTAB TYPE STANDARD TABLE OF SOOD-OBJDES. DATA L_TAB_SIZE TYPE I. DATA L_URL_ID TYPE SO_URL. CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET' EXPORTING REGION = 'B' IMPORTING FOLDER_ID = FOLDER_ID EXCEPTIONS OTHERS = 1. L_URL_ID = L_URL. L_OBJ_DATA-OBJDES = LV_FILENAME. WHILE NOT L_URL_ID IS INITIAL. CONCATENATE '&KEY&' L_URL_ID(250) INTO LS_OBJCONT. L_OBJ_DATA-OBJDES = LV_FILENAME. APPEND LS_OBJCONT TO LT_OBJCONT. SHIFT L_URL_ID LEFT BY 250 PLACES. ENDWHILE. L_OBJ_DATA-OBJSNS = 'O'. L_OBJ_DATA-OBJLA = SY-LANGU. CALL FUNCTION 'SO_OBJECT_INSERT' EXPORTING FOLDER_ID = FOLDER_ID OBJECT_TYPE = 'URL' OBJECT_HD_CHANGE = L_OBJ_DATA IMPORTING OBJECT_ID = L_OBJ_ID TABLES OBJHEAD = LT_OBJHEAD OBJCONT = LT_OBJCONT EXCEPTIONS ACTIVE_USER_NOT_EXIST = 35 FOLDER_NOT_EXIST = 6 OBJECT_TYPE_NOT_EXIST = 17 OWNER_NOT_EXIST = 22 PARAMETER_ERROR = 23 OTHERS = 1000. IF SY-SUBRC = 0. DOCUMENT_ID-FOLTP = FOLDER_ID-FOLTP. DOCUMENT_ID-FOLYR = FOLDER_ID-FOLYR. DOCUMENT_ID-FOLNO = FOLDER_ID-FOLNO. DOCUMENT_ID-DOCTP = L_OBJ_ID-OBJTP. DOCUMENT_ID-DOCYR = L_OBJ_ID-OBJYR. DOCUMENT_ID-DOCNO = L_OBJ_ID-OBJNO. CLEAR REL_DOC . REL_DOC-OBJKEY = DOCUMENT_ID . REL_DOC-OBJTYPE = 'MESSAGE' . * CONCATENATE GS_OUT-BUKRS GS_OUT-BELNR GS_OUT-GJAHR INTO IS_OBJECT-OBJKEY . IS_OBJECT-OBJKEY = L_ZOAREF_NO. IS_OBJECT-OBJTYPE = 'BKPF' . CALL FUNCTION 'BINARY_RELATION_CREATE' EXPORTING OBJ_ROLEA = IS_OBJECT OBJ_ROLEB = REL_DOC RELATIONTYPE = 'URL' "'NOTE' EXCEPTIONS OTHERS = 1. IF SY-SUBRC = 0 . P_FALG = 'X'. ELSE . P_FALG = ''. ENDIF . ELSE. P_FALG = ''. ENDIF. ENDFORM.
到了这里,关于SAP FICO创建会计凭证添加附件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!