Beruflich Dokumente
Kultur Dokumente
message-id zh.
************************************************************************
* Report: ZHO00036
* Object: HRI0036
*****------------------------------------------------------------------*
* Program title: Org publisher extract
*****------------------------------------------------------------------*
* Author:
* Date:
*****------------------------------------------------------------------*
* Processing Details:
* This program will display org structure using relationaships org to
* org, position to org and chief to org
* Inputs : for Detailed Audit Report
* Output :
* Logical Path
* Physical File Name
* Download File Name
: Z_INT_OUTBOUND_PATH
: ZHO00036
: /<sid>/int/out/hr/ZHO00004_YYYYMMDD_HHMM.TXT
*
* Requirement
* Assumptions in Program :
* Procedures / Forms Used :
* Logical Database Used
: PCH
* Message Class
: ZH
************************************************************************
*
S E L E C T I O N
S C R E E N
*
************************************************************************
*----------------------------------------------------------------------*
*
SELECT-OPTIONS & PARAMETERS
**---------------------------------------------------------------------*
cust_fld3(15) type c,
cust_fld4(15) type c,
cust_fld5(15) type c,
cust_fld6(15) type c,
cust_fld7(15) type c,
cust_fld8(15) type c,
cust_fld9(15) type c,
cust_fld10(15) type c,
end of i_data.
data: i_fieldcat type slis_t_fieldcat_alv.
*----------------------------------------------------------------------*
*
WORKAREAS - variables that will hold temporary data values
*----------------------------------------------------------------------data: w_name
like p0001-ename,
w_position
like p1001-sobid,
w_tabname(10) type c,
w_fldname(10) type c,
w_itabfld(15) type c,
w_fieldcat_ln like line of i_fieldcat, " Work area for alv
w_pgm
like sy-repid,
w_actn(06)
type c,
" Used for Authorization Check Action
w_dataset(60) type c, " Used for FileName Get Storage
w_ofile(60)
type c, " Final Output File Name
w_dd03fldname
like dd03l-fieldname.
*----------------------------------------------------------------------*
*
ACCUMULATORS - accumulate for subtotals or counters
**---------------------------------------------------------------------data: a_cntr type i,
a_col_pos type i,
a_tablines type i,
a_person like sy-index,
a_position like sy-index,
a_orgunit like sy-index,
a_len type i.
*----------------------------------------------------------------------*
*
Constantns
*
*----------------------------------------------------------------------*
data: c_module(2)
type c
value 'hr',
c_write(6)
type c
value 'WRITE ',
c_sep(1)
type c
value '_',
c_ext(4)
type c
value '.txt',
c_coma
type c
value ','.
*----------------------------------------------------------------------*
*
SWITCHES - off/on or true/false values
**---------------------------------------------------------------------*
data: x_chief
type c,
"Flag for chief
x_appended
type c.
*----------------------------------------------------------------------*
*
Field-symbols
*----------------------------------------------------------------------*
field-symbols: <ftab> like p_tab1,
*----------------------------------------------------------------------*
*
S E L E C T I O N
S C R E E N
E V E N T S
**---------------------------------------------------------------------at selection-screen on value-request for p_lfile.
call function 'WS_FILENAME_GET'
exporting
def_filename
= p_ofile
def_path
= 'C:\ '
mask
= ',,*.*,*.*.'
mode
= 'O'
importing
filename
= p_lfile
exceptions
inv_winsys
= 1
no_batch
= 2
selection_cancel = 3
selection_error = 4
others
= 5.
at selection-screen.
if p_ofile is initial.
message e027. " File Name Missing !!
endif.
if p_opfil1 = 'X'. " Local PC
if p_lfile is initial.
message e021. " File Name Missing !!
else.
a_len = strlen( p_lfile ).
if a_len <= 3.
message e021. " File Name Missing !!
endif.
endif.
else.
select pathintern up to 1 rows into filenameci-pathintern
from filenameci where pathintern = p_lgfil.
endselect.
if sy-subrc <> 0.
message e019.
endif.
endif.
************************************************************************
*
F O R M S
** NOTE: Write 'Perform <name> and double-click to create forms
***********************************************************************
*&---------------------------------------------------------------------*
*&
Form z_get_data
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form z_get_data.
data: w_org1 like hrp1001-objid,
w_org2 like hrp1001-sobid,
w_sobid like hrp1001-sobid.
* x_appended = ' '.
* x_chief = ' '.
if objec-otype = 'O'. "and objec-endda = '12.31.9999'.
i_data-org_unit = objec-objid.
"Org id
i_data-org_name = objec-stext.
loop at p1001 where begda le pc-endda
and endda ge pc-begda
and rsign = 'A'
and sclas = 'O'
and relat = '002'.
i_data-sup_org = p1001-sobid.
endloop.
*---Start of Sailaja Change
w_org1 = objec-objid.
do.
select single sobid
into w_sobid
from hrp1001
where begda le pc-endda
and endda ge pc-begda
and rsign = 'A'
and sclas = 'K'
and relat = '011'
and objid = w_org1.
if sy-subrc = 0.
i_data-cust_fld2 = w_sobid+0(10).
exit.
else.
clear : w_org2.
select single sobid
into w_org2
from hrp1001
where begda le pc-endda
and endda ge pc-begda
and rsign = 'A'
and sclas = 'O'
and relat = '002'
and objid = w_org1.
if sy-subrc <> 0.
exit.
endif.
endif.
w_org1 = w_org2+0(8).
enddo.
*---End of Sailaja Change
a_orgunit = a_orgunit + 1.
endif.
if objec-otype = 'S'.
i_data-pos_no = objec-objid.
i_data-pos_text = objec-stext.
loop at p1001 where begda le pc-endda
and endda ge pc-begda
and rsign = 'A'
and relat = '012'
and sclas = 'O'.
*
i_data-emp_id = p1001-sobid.
x_chief = 'X'.
*
i_data-emp_type = 'M'.
*
provide vorna nachn from p0002
*
between pc-begda and pc-endda.
**
where pernr = p001-sobid.
*
i_data-f_name = p0002-vorna.
"Superior org.
*
*
*
*
*
*
*
i_data-l_name = p0002-nachn.
i_data-m_name = p0002-midnm.
endprovide.
perform z_custom_fields.
if x_appended = ' '.
append i_data.
endif.
endloop.
a_position = a_position + 1.
endif.
if objec-otype = 'P' .
i_data-emp_id = objec-objid.
*
i_data-f_name = objec-stext.
provide vorna nachn from p0002
between pc-begda and pc-endda.
i_data-f_name = p0002-vorna.
i_data-l_name = p0002-nachn.
i_data-m_name = p0002-midnm.
endprovide.
*
*
*
*
*
*
" z_get_data
*&---------------------------------------------------------------------*
*&
Form z_custom_fields
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
form z_custom_fields.
data: l_cntr(2) type c.
a_cntr = 0.
do 10 times.
a_cntr = a_cntr + 1.
if a_cntr = 2.
continue.
endif.
l_cntr = a_cntr.
concatenate 'P_TAB' l_cntr into w_tabname.
concatenate 'P_FLD' l_cntr into w_fldname.
<ftab> = w_tabname.
<ffld> = w_fldname.
<fitabfld> = w_itabfld.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'ORG_NAME'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Org Unit Name'(020).
w_fieldcat_ln-outputlen = '020'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'EMP_TYPE'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-just = 'R'.
w_fieldcat_ln-reptext_ddic = 'Employee Type'(013).
w_fieldcat_ln-outputlen = '013'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
w_fieldcat_ln-just = ' '.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'EMP_ID'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Employee ID'(011).
w_fieldcat_ln-outputlen = '011'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'L_NAME'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Last Name'(009).
w_fieldcat_ln-outputlen = '015'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'F_NAME'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'First Name'(025).
w_fieldcat_ln-outputlen = '015'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'M_NAME'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Middle Name'(011).
w_fieldcat_ln-outputlen = '015'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'POS_NO'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Position Number'(015).
w_fieldcat_ln-outputlen = '015'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'POS_TEXT'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Position Text'(030).
w_fieldcat_ln-outputlen = '030'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'BLANK1'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Blank'(005).
w_fieldcat_ln-outputlen = '005'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'BLANK2'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Blank'(005).
w_fieldcat_ln-outputlen = '005'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'BLANK3'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Blank'(005).
w_fieldcat_ln-outputlen = '005'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'BLANK4'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Blank'(005).
w_fieldcat_ln-outputlen = '005'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'BLANK5'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Blank'(005).
w_fieldcat_ln-outputlen = '005'.
w_fieldcat_ln-hotspot = ' '.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD3'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD4'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD5'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD6'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD7'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD8'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD9'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
a_col_pos = a_col_pos + 1.
w_fieldcat_ln-tabname = 'i_data'.
w_fieldcat_ln-fieldname = 'CUST_FLD10'.
w_fieldcat_ln-key = ' '.
w_fieldcat_ln-col_pos = a_col_pos.
w_fieldcat_ln-no_out = space.
w_fieldcat_ln-qfieldname = space.
w_fieldcat_ln-reptext_ddic = 'Custom Field'(012).
w_fieldcat_ln-outputlen = '012'.
w_fieldcat_ln-hotspot = ' '.
append w_fieldcat_ln to i_fieldcat.
endform.
" z_create_alv
*&---------------------------------------------------------------------*
*&
Form z_call_func
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form z_call_func.
w_pgm = sy-repid.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program
= w_pgm
*
i_callback_user_command = 'USER_COMMAND'
it_fieldcat
= i_fieldcat
i_default
= 'X'
i_save
= 'A'
*
it_events
= g_eventcat
*
it_sort
= g_sortcat
tables
t_outtab
= i_data.
endform.
" z_call_func
*&---------------------------------------------------------------------*
*&
Form z_file_name
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form z_file_name using p_logfil like filenameci-pathintern
p_datset like filenameci-fileextern
p_module like c_module.
* Get the platform-independent logical file name
call function 'FILE_GET_NAME_USING_PATH'
exporting
client
= sy-mandt
logical_path
= p_logfil
operating_system
= sy-opsys
parameter_2
= p_module
file_name
= p_datset
importing
file_name_with_path
= w_dataset
exceptions
path_not_found
= 1
missing_parameter
= 2
operating_system_not_found = 3
file_system_not_found
= 4
others
= 5.
* Error Messages
if sy-subrc <> 0.
message e003 with text-e01.
endif.
w_ofile = w_dataset.
perform z_dwnld_file_check. "To check for download file
clear: w_dataset.
endform.
" z_file_name
*&---------------------------------------------------------------------*
*&
Form Z_DWNLD_FILE_CHECK
*&---------------------------------------------------------------------*
*To check the download file existance
*----------------------------------------------------------------------*
form z_dwnld_file_check.
* Adding Date & Time Stamp into Output File Name
condense w_ofile no-gaps.
* CONDENSE p_ofile NO-GAPS.
concatenate w_ofile c_sep sy-datum c_sep sy-uzeit+0(4) c_ext
into w_ofile.
w_actn = c_write.
* Checking User Authorization
perform z_dataset_auth_check using w_ofile w_actn.
* Checking if file already exist
* open dataset w_ofile in text mode for input.
* if sy-subrc = 0.
*
close dataset w_ofile.
*
message e002 with w_ofile.
* endif.
endform.
" Z_DWNLD_FILE_CHECK
*&---------------------------------------------------------------------*
*&
Form Z_DATASET_AUTH_CHECK
*&---------------------------------------------------------------------*
*To check user authorization before writing dataset
*----------------------------------------------------------------------*
form z_dataset_auth_check using
p_fil like authb-filename
p_actn like c_write.
data: l_fil like authb-filename,
l_actn like c_write.
l_fil = p_fil.
l_actn = p_actn.
call function 'AUTHORITY_CHECK_DATASET'
exporting
activity
= l_actn
filename
= l_fil
exceptions
no_authority
= 1
activity_unknown = 2
others
= 3.
if sy-subrc <> 0.
message e003 with text-e07.
endif.
clear: l_fil, l_actn.
endform.
" Z_DATASET_AUTH_CHECK
*&---------------------------------------------------------------------*
*&
Form Z_Write_Download
*&---------------------------------------------------------------------*
* This Procedure will Check i_line for number of records. If there are
* records in i_line then it will download i_line to Application sever on
* file name stored in w_ofile.
*----------------------------------------------------------------------*
form z_write_download.
data : l_filename like rlgrap-filename.
* Check i_line Internal Table for Number of Records.
a_tablines = 0.
describe table i_data lines a_tablines.
* If I_line has any record.
if a_tablines > 0.
*&---------------------------------------------------------------------*
*&
Form Z_Control_report
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form z_control_report.
write :/2 text-c01, 25 sy-datum, 40 sy-uzeit.
skip 2.
write :/2 text-c04, 22 w_ofile color 1.
skip 2.
write :/2 text-c05, 22 a_orgunit.
write :/2 text-c06, 22 a_position.
write :/2 text-c07, 22 a_person.
skip 2.
write :/2 text-c12 color 1.
write :/2 text-c08, 22 pchplvar.
write :/2 text-c09, 22 pchotype.
write :/2 text-c10.
loop at pchobjid.
if pchobjid-sign = 'I'. write 22 text-c02. endif.
if pchobjid-sign = 'E'. write 22 text-c03. endif.
if not ( pchobjid-option is initial ).
write 32 pchobjid-option.
endif.
write: 42(10) pchobjid-low, 55(10) pchobjid-high.
skip 1.
endloop.
write :/2 text-c11, 22 pchwegid.
endform.
" Z_Control_report