2017年2月3日 星期五
取得人員兼職職位
*&---------------------------------------------------------------------*
*& Form GET_POSITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_PERSON text
* -->P_LT_P1001 text
* -->P_LT_P0000_BEGDA text
* -->P_LT_P0000_ENDDA text
*----------------------------------------------------------------------*
FORM get_position TABLES lt_person TYPE hrobject_t
lt_p1001 TYPE p1001tab
USING p_begda
p_endda.
CLEAR: lt_p1001, lt_p1001[].
CALL FUNCTION 'HR_HCP_GET_POSITION_FOR_EMPL' "人員所屬職位
EXPORTING
im_objecttab = lt_person[]
im_begda = p_begda
im_endda = p_endda
IMPORTING
ex_1001_tab = lt_p1001[]
EXCEPTIONS
read_1001_error = 1
OTHERS = 2.
ENDFORM.
取得主管員編
TYPES: objec_t TYPE objec.
Data: lt_result TYPE STANDARD TABLE OF objec_t WITH HEADER LINE,
DATA: lv_leader TYPE objid.
PERFORM get_manager USING lt_result-objid lw_p0001-begda lw_p0001-endda
CHANGING lv_leader.
*&---------------------------------------------------------------------*
*& Form GET_MANAGER
*&---------------------------------------------------------------------*
FORM get_manager USING p_objid p_begda p_endda
CHANGING p_manager.
DATA: lt_manager LIKE TABLE OF objec,
ls_manager LIKE LINE OF lt_manager.
CALL FUNCTION 'HRCM_ORGUNIT_MANAGER_GET'
EXPORTING
plvar = '01'
otype = 'O'
objid = p_objid
begda = p_begda
endda = p_endda
* PATH_ID = ' '
TABLES
manager_info_table = lt_manager
EXCEPTIONS
path_error = 1
root_error = 2
nothing_found = 3
OTHERS = 4.
IF sy-subrc = 0.
READ TABLE lt_manager INTO ls_manager INDEX 1.
p_manager = ls_manager-objid.
ENDIF.
ENDFORM.
Data: lt_result TYPE STANDARD TABLE OF objec_t WITH HEADER LINE,
DATA: lv_leader TYPE objid.
PERFORM get_manager USING lt_result-objid lw_p0001-begda lw_p0001-endda
CHANGING lv_leader.
*&---------------------------------------------------------------------*
*& Form GET_MANAGER
*&---------------------------------------------------------------------*
FORM get_manager USING p_objid p_begda p_endda
CHANGING p_manager.
DATA: lt_manager LIKE TABLE OF objec,
ls_manager LIKE LINE OF lt_manager.
CALL FUNCTION 'HRCM_ORGUNIT_MANAGER_GET'
EXPORTING
plvar = '01'
otype = 'O'
objid = p_objid
begda = p_begda
endda = p_endda
* PATH_ID = ' '
TABLES
manager_info_table = lt_manager
EXCEPTIONS
path_error = 1
root_error = 2
nothing_found = 3
OTHERS = 4.
IF sy-subrc = 0.
READ TABLE lt_manager INTO ls_manager INDEX 1.
p_manager = ls_manager-objid.
ENDIF.
ENDFORM.
取得組織資料
TYPES: objec_t TYPE objec.
data: lv_wegid like T778A-wegid.
data: lt_result TYPE STANDARD TABLE OF objec_t WITH HEADER LINE.
data: l_root TYPE gdstr.
PERFORM get_structure TABLES lt_result
USING sy-datum sy-datum lw_p0001-orgeh lv_wegid l_root. "組織資料
*&---------------------------------------------------------------------*
*& Form GET_STRUCTURE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM get_structure TABLES lt_result
USING p_begda p_endda p_objid p_path l_root LIKE gdstr.
CLEAR: lt_result, lt_result[], l_root.
CALL FUNCTION 'HR_STRUCTURE_GET' "取得組織清單
EXPORTING
root_plvar = '01'
root_otype = 'O'
root_objid = p_objid
* ROOT_OBJECTS =
begda = p_begda
endda = p_endda
pathid = p_path
* PATHID_IS_INTERN =
* STRU_TECH_DEPTH = 0
* STRU_STATUS_VECTOR = '1'
* STRU_STATUS_OVERLAP = ' '
* PROVIDE_TEXT = 'X'
* PROVIDE_RELAT = 'X'
* PROVIDE_DFLAG = 'X'
* RECURSION_CHECK = 'X'
* AUTHORITY_CHECK = 'X'
* TEXT_BUFFER_FILL = 'X'
* READ_MODE = 'F'
* KEEP_ORDER =
IMPORTING
result_objects = lt_result[]
* RESULT_STRUCTURE =
root_copy = l_root
EXCEPTIONS
plvar_not_found = 1
root_not_found = 2
path_not_found = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
data: lv_wegid like T778A-wegid.
data: lt_result TYPE STANDARD TABLE OF objec_t WITH HEADER LINE.
data: l_root TYPE gdstr.
PERFORM get_structure TABLES lt_result
USING sy-datum sy-datum lw_p0001-orgeh lv_wegid l_root. "組織資料
*&---------------------------------------------------------------------*
*& Form GET_STRUCTURE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM get_structure TABLES lt_result
USING p_begda p_endda p_objid p_path l_root LIKE gdstr.
CLEAR: lt_result, lt_result[], l_root.
CALL FUNCTION 'HR_STRUCTURE_GET' "取得組織清單
EXPORTING
root_plvar = '01'
root_otype = 'O'
root_objid = p_objid
* ROOT_OBJECTS =
begda = p_begda
endda = p_endda
pathid = p_path
* PATHID_IS_INTERN =
* STRU_TECH_DEPTH = 0
* STRU_STATUS_VECTOR = '1'
* STRU_STATUS_OVERLAP = ' '
* PROVIDE_TEXT = 'X'
* PROVIDE_RELAT = 'X'
* PROVIDE_DFLAG = 'X'
* RECURSION_CHECK = 'X'
* AUTHORITY_CHECK = 'X'
* TEXT_BUFFER_FILL = 'X'
* READ_MODE = 'F'
* KEEP_ORDER =
IMPORTING
result_objects = lt_result[]
* RESULT_STRUCTURE =
root_copy = l_root
EXCEPTIONS
plvar_not_found = 1
root_not_found = 2
path_not_found = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
TP_R3_TO_SERVER生成文件放到FTP中.中文亂碼問題
原文:
http://www.itpub.net/thread-1368352-1-1.html
這樣就可以用後台的方式正常往ftp傳輸漢字了。
"把內表數據用此函數SCMS_TEXT_TO_BINARY轉換成2進制;
然後再FTP_R3_TO_SERVER用這個函數傳ftp 注意用BLOB = IN_DATA 和 BLOB_LENGTH = LEN
CALL FUNCTION 'SCMS_TEXT_TO_BINARY'
IMPORTING
OUTPUT_LENGTH = LEN
TABLES
TEXT_TAB = CONTENT
BINARY_TAB = IN_DATA
EXCEPTIONS
FAILED = 1
OTHERS = 2.
CLEAR CONTENT[].
REFRESH RESULT.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
COMMAND = 'ascii' "'binary' "
TABLES
DATA = RESULT
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
COMMAND = 'cr'
TABLES
DATA = RESULT
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = HDL
FNAME = FILENAME
BLOB_LENGTH = LEN
* CHARACTER_MODE = 'X'
TABLES
* TEXT = IN_DATA
BLOB = IN_DATA
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
IF SY-SUBRC <> 0.
MESSAGE = '往FTP服務器寫數據失敗。'.
EXIT.
ENDIF.
ENDIF.
http://www.itpub.net/thread-1368352-1-1.html
這樣就可以用後台的方式正常往ftp傳輸漢字了。
"把內表數據用此函數SCMS_TEXT_TO_BINARY轉換成2進制;
然後再FTP_R3_TO_SERVER用這個函數傳ftp 注意用BLOB = IN_DATA 和 BLOB_LENGTH = LEN
CALL FUNCTION 'SCMS_TEXT_TO_BINARY'
IMPORTING
OUTPUT_LENGTH = LEN
TABLES
TEXT_TAB = CONTENT
BINARY_TAB = IN_DATA
EXCEPTIONS
FAILED = 1
OTHERS = 2.
CLEAR CONTENT[].
REFRESH RESULT.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
COMMAND = 'ascii' "'binary' "
TABLES
DATA = RESULT
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
COMMAND = 'cr'
TABLES
DATA = RESULT
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = HDL
FNAME = FILENAME
BLOB_LENGTH = LEN
* CHARACTER_MODE = 'X'
TABLES
* TEXT = IN_DATA
BLOB = IN_DATA
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
IF SY-SUBRC <> 0.
MESSAGE = '往FTP服務器寫數據失敗。'.
EXIT.
ENDIF.
ENDIF.
訂閱:
文章 (Atom)