DATA: BEGIN OF fs_budgets ,
objid(8) TYPE n , " Object Id
flag TYPE c , " Monetary/Non Monetary
newam TYPE CHAR22 , " Budgeted Amount,
newcu TYPE CHAR05 , " Currency Key,
END OF fs_budgets ,
t_budgets LIKE TABLE OF fs_budgets.
objid(8) TYPE n , " Object Id
flag TYPE c , " Monetary/Non Monetary
newam TYPE CHAR22 , " Budgeted Amount,
newcu TYPE CHAR05 , " Currency Key,
END OF fs_budgets ,
t_budgets LIKE TABLE OF fs_budgets.
DATA: w_sobid TYPE hrp1001-sobid , " Org. Unit
w_file TYPE rlgrap-filename . " File Name
w_file TYPE rlgrap-filename . " File Name
DATA: t_orgunit TYPE hap_t_hrsobid , " Id of Org. unit
t_suborgunits TYPE hap_t_hrsobid , " Ids of Sub Org Units
fs_orgunit LIKE LINE OF t_orgunit. " Work Area of orgunit
t_suborgunits TYPE hap_t_hrsobid , " Ids of Sub Org Units
fs_orgunit LIKE LINE OF t_orgunit. " Work Area of orgunit
REFRESH: t_orgunit,
t_suborgunits.
CLEAR : fs_orgunit..
t_suborgunits.
CLEAR : fs_orgunit..
***********************************************************************
* The Budget values are stored in the file 'BUDGETS' on the App Server*
* This data will be read from the App Server *
***********************************************************************
w_file = 'BUDGETS'.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
* The Budget values are stored in the file 'BUDGETS' on the App Server*
* This data will be read from the App Server *
***********************************************************************
w_file = 'BUDGETS'.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
***********************************************************************
* Fetching the corresponding Org Unit for the Budget Id *
***********************************************************************
* Fetching the corresponding Org Unit for the Budget Id *
***********************************************************************
SELECT sobid " Org. Unit
FROM hrp1001
INTO w_sobid
WHERE plvar EQ '01'
AND otype EQ 'BU'
AND objid EQ budid
AND rsign EQ 'B'
AND relat EQ '300'
AND istat EQ '1'
AND begda LE endda
AND endda GE begda.
ENDSELECT. " SELECT sobid
IF sy-subrc EQ 0.
fs_orgunit-plvar = '01'.
fs_orgunit-otype = 'O'.
fs_orgunit-sobid = w_sobid.
APPEND fs_orgunit TO t_orgunit.
CLEAR fs_orgunit.
fs_orgunit-plvar = '01'.
fs_orgunit-otype = 'O'.
fs_orgunit-sobid = w_sobid.
APPEND fs_orgunit TO t_orgunit.
CLEAR fs_orgunit.
***********************************************************************
* Fetching the Sub Org units for a given Org unit *
***********************************************************************
* Fetching the Sub Org units for a given Org unit *
***********************************************************************
CALL FUNCTION 'HRHAP_SEL_OBJECTS_OF_EVAL_PATH'
EXPORTING
T_OBJECTS_BASE = t_orgunit
EVALUATION_PATH = 'ORGEH'
FROM_DATE = begda
TO_DATE = endda
IMPORTING
T_OBJECTS = t_suborgunits.
EXPORTING
T_OBJECTS_BASE = t_orgunit
EVALUATION_PATH = 'ORGEH'
FROM_DATE = begda
TO_DATE = endda
IMPORTING
T_OBJECTS = t_suborgunits.
ENDIF. " IF sy-subrc EQ 0.
CLEAR newam.
CLEAR newam.
***********************************************************************
* Accumulating the budget values of all the Sub org units for a given *
* Org unit and populating the fields 'newam' and 'newcu'. *
* Accumulating the budget values of all the Sub org units for a given *
* Org unit and populating the fields 'newam' and 'newcu'. *
***********************************************************************
LOOP AT t_suborgunits INTO fs_orgunit.
CLOSE DATASET w_file.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET w_file INTO fs_budgets.
IF sy-subrc EQ 0.
IF fs_budgets-objid EQ fs_orgunit-sobid.
ADD fs_budgets-newam TO newam.
newcu = fs_budgets-newcu.
EXIT.
ENDIF.
ELSE.
EXIT.
ENDIF. " IF sy-subrc EQ 0.
ENDDO. " DO
ENDLOOP. " LOOP AT t_suborgunits
***********************************************************************
* Giving default values for the Budget Amount and Currency if they are*
* containing Initial values *
***********************************************************************
IF newam IS INITIAL.
newam = 0.
ENDIF. " IF newam IS INITIAL.
IF newcu IS INITIAL.
newcu = 'USD'.
ENDIF. " IF newcu IS INITIAL.
CLOSE DATASET w_file.
endmethod.
ALSO READ:
- Get Employee Picture In Selection Screen.
- Unified Access to All HR Infotypes.
- F4(Value On Request) For Organization Unit In HR Report Program.
- Employee Pay Scale Report Program.
- Finding Job Code For Position.
.....Back To Sub-Index On HR ABAP.
.....Back To MAIN INDEX.
hi Venkat,
ReplyDeleteIs it possible to upload budget amount for multiple budget unit since this BAdI has one export budget amount only ?
Rgds,
Dominic