共计 15768 个字符,预计需要花费 40 分钟才能阅读完成。
*&---------------------------------------------------------------------*
*& Report ZJOBY_EMAIL_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZJOBY_EMAIL_TEST.
TYPE-POOLS: IXML.
*------------------------------------------------------------------------*
* Data Declarations *
*------------------------------------------------------------------------*
* Structure for Final Internal Table
TYPES: BEGIN OF TY_FINAL,
SRNO(3) TYPE N,
USER_ID TYPE USR02-BNAME,
FULL_NAME TYPE BAPIADDR3-FULLNAME,
DEPT TYPE BAPIADDR3-DEPARTMENT,
LOGIN(3) TYPE C,
END OF TY_FINAL.
* Structure for USR02
TYPES: BEGIN OF TY_USR02,
BNAME TYPE USR02-BNAME,
TRDAT TYPE USR02-TRDAT,
END OF TY_USR02.
* Internal Table & Work Area for Final Internal Table
DATA: IT_FINAL TYPE TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL.
* Internal Table & Work Area for USR02 Internal Table
DATA: IT_USR02 TYPE TABLE OF TY_USR02,
WA_USR02 TYPE TY_USR02.
* Work Area for ADD3_DATA Structre
DATA: WA_ADDR TYPE BAPIADDR3.
DATA: IT_RETURN TYPE TABLE OF BAPIRET2.
DATA: LV_DATE TYPE D.
DATA: LV_FILENAME TYPE STRING.
TYPES: BEGIN OF XML_LINE,
DATA(255) TYPE X,
END OF XML_LINE.
DATA: L_IXML TYPE REF TO IF_IXML,
L_STREAMFACTORY TYPE REF TO IF_IXML_STREAM_FACTORY,
L_OSTREAM TYPE REF TO IF_IXML_OSTREAM,
L_RENDERER TYPE REF TO IF_IXML_RENDERER,
L_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
DATA: L_ELEMENT_ROOT TYPE REF TO IF_IXML_ELEMENT,
NS_ATTRIBUTE TYPE REF TO IF_IXML_ATTRIBUTE,
R_ELEMENT_PROPERTIES TYPE REF TO IF_IXML_ELEMENT,
R_ELEMENT TYPE REF TO IF_IXML_ELEMENT,
R_WORKSHEET TYPE REF TO IF_IXML_ELEMENT,
R_TABLE TYPE REF TO IF_IXML_ELEMENT,
R_COLUMN TYPE REF TO IF_IXML_ELEMENT,
R_ROW TYPE REF TO IF_IXML_ELEMENT,
R_CELL TYPE REF TO IF_IXML_ELEMENT,
R_DATA TYPE REF TO IF_IXML_ELEMENT,
L_VALUE TYPE STRING,
L_TYPE TYPE STRING,
L_TEXT(100) TYPE C,
R_STYLES TYPE REF TO IF_IXML_ELEMENT,
R_STYLE TYPE REF TO IF_IXML_ELEMENT,
R_STYLE1 TYPE REF TO IF_IXML_ELEMENT,
R_FORMAT TYPE REF TO IF_IXML_ELEMENT,
R_BORDER TYPE REF TO IF_IXML_ELEMENT,
NUM_ROWS TYPE I.
DATA: L_XML_TABLE TYPE TABLE OF XML_LINE,
WA_XML TYPE XML_LINE,
L_XML_SIZE TYPE I,
L_RC TYPE I.
*------------------------------------------------------------------------*
* Initialization *
*------------------------------------------------------------------------*
INITIALIZATION.
LV_DATE = SY-DATUM - 1.
*------------------------------------------------------------------------*
* Start of Selection *
*------------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM GET_USER_DATA.
PERFORM PROCESS_XML_DATA.
PERFORM SEND_MAIL.
*&---------------------------------------------------------------------*
*& Form get_user_data
*&---------------------------------------------------------------------*
* Fetch User details from USR02
*----------------------------------------------------------------------*
FORM GET_USER_DATA.
REFRESH IT_FINAL.
SELECT DISTINCT BNAME TRDAT FROM USR02 INTO TABLE IT_USR02.
SORT IT_USR02 BY BNAME.
IF NOT IT_USR02[] IS INITIAL.
LOOP AT IT_USR02 INTO WA_USR02.
CLEAR WA_FINAL.
WA_FINAL-SRNO = SY-TABIX. " Serial No.
WA_FINAL-USER_ID = WA_USR02-BNAME. " User ID
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = WA_USR02-BNAME
IMPORTING
ADDRESS = WA_ADDR
TABLES
RETURN = IT_RETURN.
IF SY-SUBRC EQ 0.
WA_FINAL-FULL_NAME = WA_ADDR-FULLNAME. " Full Name
WA_FINAL-DEPT = WA_ADDR-DEPARTMENT. " Department
ENDIF.
IF WA_USR02-TRDAT EQ LV_DATE.
WA_FINAL-LOGIN = 'YES'. " Login on Previous Day
ELSE.
WA_FINAL-LOGIN = 'NO'.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.
ENDIF.
ENDFORM. " get_user_data
*&---------------------------------------------------------------------*
*& Form SEND_MAIL
*&---------------------------------------------------------------------*
* Send Email
*----------------------------------------------------------------------*
FORM SEND_MAIL.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLIX OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: L_NUM(3).
DATA: SUBJ_DATE(10) TYPE C.
* Mail Subject
CONCATENATE LV_DATE+6(2) '-' LV_DATE+4(2) '-' LV_DATE+0(4) INTO SUBJ_DATE.
CONCATENATE 'SAP Application Usage Report' SUBJ_DATE INTO DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.
* Mail Contents
OBJTXT = 'Dear User,'.
APPEND OBJTXT.
CLEAR OBJTXT.
APPEND OBJTXT.
CONCATENATE 'Please find the attached SAP Application Usage Report for' SUBJ_DATE INTO OBJTXT SEPARATED BY SPACE. " Mail Contents
APPEND OBJTXT.
CLEAR OBJTXT.
APPEND OBJTXT.
OBJTXT = 'Thanks & Regards,'.
APPEND OBJTXT.
OBJTXT = 'Himanshu Kanekar'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = (TAB_LINES - 1) * 255 + STRLEN(OBJTXT).
* Packing List For the E-mail Body
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
* Creation of the Document Attachment
LOOP AT L_XML_TABLE INTO WA_XML.
CLEAR OBJBIN.
OBJBIN-LINE = WA_XML-DATA.
APPEND OBJBIN.
ENDLOOP.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'SAP Login Details'.
APPEND OBJHEAD.
* Packing List For the E-mail Attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
CONCATENATE 'SAP_Login_Details' SUBJ_DATE INTO OBJPACK-OBJ_DESCR SEPARATED BY SPACE.
OBJPACK-DOC_TYPE = 'XLS'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
* Target Recipent
CLEAR RECLIST.
RECLIST-RECEIVER = '家里蹲 @qq.com'.
RECLIST-REC_TYPE = 'U'.
RECLIST-NOTIF_READ = 'X'.
RECLIST-COM_TYPE = 'INT'.
RECLIST-NOTIF_DEL = 'X'.
RECLIST-NOTIF_NDEL = 'X'.
APPEND RECLIST.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_TXT = OBJTXT
CONTENTS_HEX = OBJBIN
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
IF SY-SUBRC = 0.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
ENDFORM. " SEND_MAIL
*&---------------------------------------------------------------------*
*& Form process_xml_data
*&---------------------------------------------------------------------*
* Process XML Data
*----------------------------------------------------------------------*
FORM PROCESS_XML_DATA .
* Creating a ixml Factory
L_IXML = CL_IXML=>CREATE( ).
* Creating the DOM Object Model
L_DOCUMENT = L_IXML->CREATE_DOCUMENT( ).
* Create Root Node 'Workbook'
L_ELEMENT_ROOT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Workbook' PARENT = L_DOCUMENT).
L_ELEMENT_ROOT->SET_ATTRIBUTE(NAME = 'xmlns' VALUE = 'urn:schemas-microsoft-com:office:spreadsheet').
NS_ATTRIBUTE = L_DOCUMENT->CREATE_NAMESPACE_DECL(NAME = 'ss' PREFIX = 'xmlns' URI = 'urn:schemas-microsoft-com:office:spreadsheet').
L_ELEMENT_ROOT->SET_ATTRIBUTE_NODE(NS_ATTRIBUTE).
NS_ATTRIBUTE = L_DOCUMENT->CREATE_NAMESPACE_DECL(NAME = 'x' PREFIX = 'xmlns' URI = 'urn:schemas-microsoft-com:office:excel').
L_ELEMENT_ROOT->SET_ATTRIBUTE_NODE(NS_ATTRIBUTE).
* Create node for document properties.
R_ELEMENT_PROPERTIES = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'TEST_REPORT' PARENT = L_ELEMENT_ROOT).
L_VALUE = SY-UNAME.
L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Author' VALUE = L_VALUE PARENT = R_ELEMENT_PROPERTIES).
* Styles
R_STYLES = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Styles' PARENT = L_ELEMENT_ROOT).
* Style for Header
R_STYLE = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Style' PARENT = R_STYLES).
R_STYLE->SET_ATTRIBUTE_NS(NAME = 'ID' PREFIX = 'ss' VALUE = 'Header').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Font' PARENT = R_STYLE).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Bold' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Interior' PARENT = R_STYLE).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Color' PREFIX = 'ss' VALUE = '#92D050').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Pattern' PREFIX = 'ss' VALUE = 'Solid').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Alignment' PARENT = R_STYLE).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Vertical' PREFIX = 'ss' VALUE = 'Center').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'WrapText' PREFIX = 'ss' VALUE = '1').
R_BORDER = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Borders' PARENT = R_STYLE).
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Bottom').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Left').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Top').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Right').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
* Style for Data
R_STYLE1 = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Style' PARENT = R_STYLES).
R_STYLE1->SET_ATTRIBUTE_NS(NAME = 'ID' PREFIX = 'ss' VALUE = 'Data').
R_BORDER = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Borders' PARENT = R_STYLE1).
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Bottom').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Left').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Top').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
R_FORMAT = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Border' PARENT = R_BORDER).
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Position' PREFIX = 'ss' VALUE = 'Right').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'LineStyle' PREFIX = 'ss' VALUE = 'Continuous').
R_FORMAT->SET_ATTRIBUTE_NS(NAME = 'Weight' PREFIX = 'ss' VALUE = '1').
* Worksheet
R_WORKSHEET = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Worksheet' PARENT = L_ELEMENT_ROOT).
R_WORKSHEET->SET_ATTRIBUTE_NS(NAME = 'Name' PREFIX = 'ss' VALUE = 'Sheet1').
* Table
R_TABLE = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Table' PARENT = R_WORKSHEET).
R_TABLE->SET_ATTRIBUTE_NS(NAME = 'FullColumns' PREFIX = 'x' VALUE = '1').
R_TABLE->SET_ATTRIBUTE_NS(NAME = 'FullRows' PREFIX = 'x' VALUE = '1').
* Column Formatting
R_COLUMN = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Column' PARENT = R_TABLE).
R_COLUMN->SET_ATTRIBUTE_NS(NAME = 'Width' PREFIX = 'ss' VALUE = '40').
R_COLUMN = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Column' PARENT = R_TABLE).
R_COLUMN->SET_ATTRIBUTE_NS(NAME = 'Width' PREFIX = 'ss' VALUE = '90').
R_COLUMN = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Column' PARENT = R_TABLE).
R_COLUMN->SET_ATTRIBUTE_NS(NAME = 'Width' PREFIX = 'ss' VALUE = '140').
R_COLUMN = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Column' PARENT = R_TABLE).
R_COLUMN->SET_ATTRIBUTE_NS(NAME = 'Width' PREFIX = 'ss' VALUE = '150').
R_COLUMN = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Column' PARENT = R_TABLE).
R_COLUMN->SET_ATTRIBUTE_NS(NAME = 'Width' PREFIX = 'ss' VALUE = '90').
* Blank Row
* R_ROW = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Row' PARENT = R_TABLE).
* Column Headers Row
R_ROW = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Row' PARENT = R_TABLE).
R_ROW->SET_ATTRIBUTE_NS(NAME = 'AutoFitHeight' PREFIX = 'ss' VALUE = '1').
* Sr. No.
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Header').
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = 'Sr. No.' PARENT = R_CELL).
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String').
* User Name
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Header').
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = 'User Name' PARENT = R_CELL).
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String').
* Full Name
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Header').
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = 'Full Name' PARENT = R_CELL).
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String').
* Department
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Header').
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = 'Department' PARENT = R_CELL).
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String').
* Login
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Header').
CONCATENATE 'Login -' LV_DATE+6(2) '/' LV_DATE+4(2) '/' LV_DATE+0(4) INTO L_VALUE.
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = L_VALUE PARENT = R_CELL).
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String').
* Blank Row after Column Headers
* R_ROW = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Row' PARENT = R_TABLE).
* R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
* R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
*
* R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
* R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
*
* R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
* R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
*
* R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
* R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
*
* R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
* R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
* Data Table
LOOP AT IT_FINAL INTO WA_FINAL.
R_ROW = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Row' PARENT = R_TABLE).
* Sr. No.
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
L_VALUE = SY-TABIX.
CONDENSE L_VALUE NO-GAPS.
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = L_VALUE PARENT = R_CELL). " Data
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'Number'). " Cell format
* User Name
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
L_VALUE = WA_FINAL-USER_ID.
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = L_VALUE PARENT = R_CELL). " Data
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String'). " Cell format
* Full Name
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
L_VALUE = WA_FINAL-FULL_NAME.
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = L_VALUE PARENT = R_CELL). " Data
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String'). " Cell format
* Department
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
L_VALUE = WA_FINAL-DEPT.
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = L_VALUE PARENT = R_CELL). " Data
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String'). " Cell format
* Login
R_CELL = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Cell' PARENT = R_ROW).
R_CELL->SET_ATTRIBUTE_NS(NAME = 'StyleID' PREFIX = 'ss' VALUE = 'Data').
L_VALUE = WA_FINAL-LOGIN.
R_DATA = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(NAME = 'Data' VALUE = L_VALUE PARENT = R_CELL). " Data
R_DATA->SET_ATTRIBUTE_NS(NAME = 'Type' PREFIX = 'ss' VALUE = 'String'). " Cell format
ENDLOOP.
* Creating a Stream Factory
L_STREAMFACTORY = L_IXML->CREATE_STREAM_FACTORY( ).
* Connect Internal XML Table to Stream Factory
L_OSTREAM = L_STREAMFACTORY->CREATE_OSTREAM_ITABLE(TABLE = L_XML_TABLE).
* Rendering the Document
L_RENDERER = L_IXML->CREATE_RENDERER(OSTREAM = L_OSTREAM DOCUMENT = L_DOCUMENT).
L_RC = L_RENDERER->RENDER( ).
* Saving the XML Document
L_XML_SIZE = L_OSTREAM->GET_NUM_WRITTEN_RAW( ).
ENDFORM. " process_xml_data
正文完