*** We've got a standart FM to check a BG Jobs state SUBST_GET_JOBSTATE
*** Below you can see my code
*** I've the job name MY_JOB_NAME and i am searching
*** if there is any active job still running for 2 days. if you have
*** program name then just use progname field instead of jobname.
TABLES : tbtco.
data : lt_tbtcp type table of tbtcp with header line.
data : lv_datum type sy-datum.
data : lv_message type string.
data: lv_running.
** Check For A reasonable period
lv_datum = sy-datum - 3.
CLEAR : lv_running.
select *
into corresponding fields of table lt_tbtcp
from tbtcp
where jobname eq 'MY_JOB_NAME'
and sdldate gt lv_datum.
loop at lt_tbtcp.
select single * from tbtco
where jobname = lt_tbtcp-jobname
and jobcount = lt_tbtcp-jobcount.
check sy-subrc eq 0.
if tbtco-status eq 'R'.
"JOB is running
message 'JOB is running' type 'I'.
lv_running = 'X'.
exit.
endif.
endloop.
if lv_running = 'X'.
" We have a running job with the specified parameters
endif.
Thursday, January 21, 2010
Sunday, January 10, 2010
USER EXISTENCE CHECK
*** Check if user exists :
*** BAPI_USER_EXISTENCE_CHECK
call function 'BAPI_USER_EXISTENCE_CHECK'
exporting
username = p_user
importing
return = ls_return.
if ls_return-number = '124'.
" DOES NOT EXISTS
elseif ls_return-number = '088'.
" EXISTS
endif.
*** SUSR_USER_CHECK_EXISTENCE
call function 'SUSR_USER_CHECK_EXISTENCE'
exporting
user_name = user_name
exceptions
user_name_not_exists = 1
others = 2.
if sy-subrc EQ 0.
" EXISTS
endif.
*** BAPI_USER_EXISTENCE_CHECK
call function 'BAPI_USER_EXISTENCE_CHECK'
exporting
username = p_user
importing
return = ls_return.
if ls_return-number = '124'.
" DOES NOT EXISTS
elseif ls_return-number = '088'.
" EXISTS
endif.
*** SUSR_USER_CHECK_EXISTENCE
call function 'SUSR_USER_CHECK_EXISTENCE'
exporting
user_name = user_name
exceptions
user_name_not_exists = 1
others = 2.
if sy-subrc EQ 0.
" EXISTS
endif.
Thursday, January 7, 2010
Get ALV instance From ALV Function
While using ALV function to display ALV grid , there are some restrictions according to oo alv. FM below gives us the chance to use alv instance without restrictions.
****
data: lr_grid type ref to cl_gui_alv_grid.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = lr_grid.
***
****
data: lr_grid type ref to cl_gui_alv_grid.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = lr_grid.
***
Merge Fieldcat From Dictionary Structure
*** FOR OO ALV
data : gt_fcat type lvc_t_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'YOUR_DICT_STRUCTURE'
i_bypassing_buffer = 'X'
changing
ct_fieldcat = gt_fcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*** FOR ALV FUNCTION
data : gt_fieldcat type slis_t_fieldcat_alv.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'YOUR_DICT_STRUCTURE'
i_bypassing_buffer = 'X'
changing
ct_fieldcat = gt_fieldcat.
--
data : gt_fcat type lvc_t_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'YOUR_DICT_STRUCTURE'
i_bypassing_buffer = 'X'
changing
ct_fieldcat = gt_fcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*** FOR ALV FUNCTION
data : gt_fieldcat type slis_t_fieldcat_alv.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'YOUR_DICT_STRUCTURE'
i_bypassing_buffer = 'X'
changing
ct_fieldcat = gt_fieldcat.
--
Tuesday, January 5, 2010
HR : FM to Find Active Plan Variant
DATA : gv_plvar TYPE plvar.
call function 'RH_GET_ACTIVE_WF_PLVAR'
importing
act_plvar = gv_plvar
exceptions
no_active_plvar = 1
others = 2.
call function 'RH_GET_ACTIVE_WF_PLVAR'
importing
act_plvar = gv_plvar
exceptions
no_active_plvar = 1
others = 2.
ABAP Date Calculations
Class CL_HRPAD_DATE_COMPUTATIONS has static methods for most of the date operations you need.
ADD_WEEKS_TO_DATE Adfd No. of Weeks to Date
ADD_MONTHS_TO_DATE Adds No. of Months to Date
ADD_YEARS_TO_DATE Adds No. of Years to Date
SUBTRACT_WEEKS_FROM_DATE Subtracts No. of Weeks from Date
SUBTRACT_MONTHS_FROM_DATE Subtracts No. of Months from Date
SUBTRACT_YEARS_FROM_DATE Subtracts No. of Years from Date
GET_WEEKDAY_NUMBER Determines Number of Weekday
GET_WEEKDAY_NUMBER_SHIFTED Determines Number of Weekday (Shifted)
GET_FIRST_DAY_CALENDAR_WEEK Determines First Day of Calendar Week for Particular Year
GET_LAST_WEEKDAY_NUMBER Determines Number of Last Weekday
GET_FIRST_DAY_IN_WEEK Determines First Day of a Week
GET_FIRST_DAY_IN_SHIFTED_WEEK Determines First Day of Week (Shifted)
GET_FIRST_DAY_PREVIOUS_MONTH Determines First Day in Previous Month
GET_WEEK Determines Week in Which Date Lies (Shifted)
GET_SHIFTED_WEEK Determines Week in Which Date Lies (Shifted)
GET_LAST_DAY_IN_MONTH Calculates Last Day of Current Month
GET_LAST_DAY_PREVIOUS_MONTH Determines Last Day of Previous Month
GET_DAYS_PER_YEAR Determines No. of Days per Year
*** Example
call method cl_hrpad_date_computations=>get_last_day_in_month
exporting
date_in = lv_begda
receiving
date_out = lv_endda.
ADD_WEEKS_TO_DATE Adfd No. of Weeks to Date
ADD_MONTHS_TO_DATE Adds No. of Months to Date
ADD_YEARS_TO_DATE Adds No. of Years to Date
SUBTRACT_WEEKS_FROM_DATE Subtracts No. of Weeks from Date
SUBTRACT_MONTHS_FROM_DATE Subtracts No. of Months from Date
SUBTRACT_YEARS_FROM_DATE Subtracts No. of Years from Date
GET_WEEKDAY_NUMBER Determines Number of Weekday
GET_WEEKDAY_NUMBER_SHIFTED Determines Number of Weekday (Shifted)
GET_FIRST_DAY_CALENDAR_WEEK Determines First Day of Calendar Week for Particular Year
GET_LAST_WEEKDAY_NUMBER Determines Number of Last Weekday
GET_FIRST_DAY_IN_WEEK Determines First Day of a Week
GET_FIRST_DAY_IN_SHIFTED_WEEK Determines First Day of Week (Shifted)
GET_FIRST_DAY_PREVIOUS_MONTH Determines First Day in Previous Month
GET_WEEK Determines Week in Which Date Lies (Shifted)
GET_SHIFTED_WEEK Determines Week in Which Date Lies (Shifted)
GET_LAST_DAY_IN_MONTH Calculates Last Day of Current Month
GET_LAST_DAY_PREVIOUS_MONTH Determines Last Day of Previous Month
GET_DAYS_PER_YEAR Determines No. of Days per Year
*** Example
call method cl_hrpad_date_computations=>get_last_day_in_month
exporting
date_in = lv_begda
receiving
date_out = lv_endda.
Subscribe to:
Posts (Atom)