SAP ABAP

Archive for May 25th, 2007

Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.

As with customer exits two different views are available:

In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object.

In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available.

In contrast to customer exits, Business Add-Ins no longer assume a two-level infrastructure (SAP and customer solutions), but instead allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.

SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. You do not have to register Business Add-Ins in SSCR.

The Business Add-In enhancement technique differentiates between enhancements that can only be implemented once and enhancements that can be used actively by any number of customers at the same time. In addition, Business Add-Ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example).

All ABAP sources, screens, GUIs, and table interfaces created using this enhancement technique are defined in a manner that allows customers to include their own enhancements in the standard. A single Business Add-In contains all of the interfaces necessary to implement a specific task.

The actual program code is enhanced using ABAP Objects. In order to better understand the programming techniques behind the Business Add-In enhancement concept, SAP recommends reading the section on ABAP Objects.

1) Difference between BADI and USER-EXIT.

i) BADI’s can be used any number of times, where as USER-EXITS can be used only one time. Ex:- if your assigning a USER-EXIT to a project in (CMOD), then you can not assign the same to other project. ii) BADI’s are oops based.

Using Query Exit to restrict users output

Please note this article has been written from an ABAPers point of view and some knowledge of creating BW queries will be required. When using an authorisation object to restrict a query report it determines if the user can see everything in a range. If they cant see them all then an authorisation error will be displayed. You may have a requirement to still allow the user to see the report but to remove values they are not authorised to see.This would be done by having 2 variables on the report selection screen, one for the user to enter theirselection and a hidden one which will do the actual report restriction. The code for this will look somethinglike this, where ‘ZGMGTNOI’ is the hidden field and ‘0S_GRANT’ is the visible user input field.

**** ZGMGTNOI variable derives input from variable OS_GRANT
WHEN ‘ZGMGTNOI’. if i_step = 2.
* gets selection values entered by user (0S_GRANT)
loop at I_T_VAR_RANGE into wa_range
where VNAMeq ‘0S_GRANT’
and IOBJNM eq ‘0GRANT_NBR’.
wa_grant-low = wa_range-low.
wa_grant-high = wa_range-high.
wa_grant-option = wa_range-opt.
wa_grant-sign = wa_range-sign.
append wa_grant to r_grant.
endloop.
* selects all grants user is authorised to see within entered
* selection values

select grant_nbr
from ZGMUSERGRANTS into corresponding fields of table it_ZGMUSERGRANTS where UNAME eq sy-uname
and grant_nbr in r_grant.

* If no values are found! Populates hidden restriction variable with
* user input
if sy-subrc ne 0. l
oop at r_grant into wa_grant.
move-corresponding wa_grant to wa_ETRANGE.
wa_ETRANGE-opt = wa_grant-option.
append wa_ETRANGE to E_T_RANGE.
endloop.
* If values are found! Populates hidden restriction variable with
* all values user is authorised to see
else.
clear: wa_range.
loop at it_ZGMUSERGRANTS into wa_ZGMUSERGRANTS.
wa_ETRANGE-sign = ‘I’.
wa_ETRANGE-opt = ‘EQ’.
wa_ETRANGE-low = wa_ZGMUSERGRANTS-grant_nbr.
append wa_ETRANGE to E_T_RANGE.
endloop.
endif.
endif.

BW Query User exit RSR00001:

Enhancement RSR00001 (user exit)

The enhancement RSR00001 (BW: Enhancements for Global Variables in Reporting) is called up several times
during execution of a report. Here, the parameter I_STEP specifies when the enhancement is called.
The following values are valid for I_STEP:
· I_STEP = 1
Call takes place directly before variable entry. Can be used to pre populate selection variables
· I_STEP = 2
Call takes place directly after variable entry. This step is only started up when the same variable
is not input ready and could not be filled at I_STEP=1.
· I_STEP = 3
In this call, you can check the values of the variables. Triggering an exception (RAISE) causes the
variable screen to appear once more. Afterwards, I_STEP=2 is also called again.
· I_STEP = 0
The enhancement is not called from the variable screen. The call can come from the authorization
check or from the Monitor. This is where you want to put the mod for populating the authorization
object. code for this is as follows:

Populate authorisation object dynamically :

Please note the article has been written from an ABAPers point of view and some knowledge of creating BW queries will be required. First you need to create an authorisation object which references a $Variable. In this example I am using$ZGMGRANT, which has been linked to the users authorisation profile via transaction PFCG.Now Within the BW query you have created via Bex Analyser you need to create and authorisation field with the processing type of ‘customer exit’.

The next step is to active the customer exit ‘EXIT_SAPLRRS0_001’. To do this create a project in the CMOD transaction, select the SAP enhancement RSR00001 and assign it to the enhancement project. Activate the project.

The enhancement RSR00001 (BW: Enhancements for Global Variables in Reporting) is called up several times during execution of the report. Here, the parameter I_STEP specifies when the enhancement is called.The following values are valid for I_STEP:

· I_STEP = 1Call takes place directly before variable entry. Can be used to pre populate selection variables·

I_STEP = 2Call takes place directly after variable entry. This step is only started up when the same variable is not input ready and could not be filled at I_STEP=1.·

I_STEP = 3In this call, you can check the values of the variables. Triggering an exception (RAISE) causes the variable screen to appear once more. Afterwards, I_STEP=2 is also called again.·

I_STEP = 0The enhancement is not called from the variable screen. The call can come from the authorization check or from the Monitor. This is where you want to put the mod for populating the authorizationobject. code for this is as follows:

case i_vnam.

WHEN ‘ZGMGRANT’. “Query field name

if i_step = 0.

BREAK-POINT.

clear wa_ETRANGE.

* Gets all grants a user is able to see from ZTable,

* which is populated elsewhere

select grant_nbr

from ZGMUSERGRANTS

into corresponding fields of table it_ZGMUSERGRANTS

where UNAME eq sy-uname.

* Populate Authorisation Object.In i_step 0

* E_T_RANGE is used to populate the authorisation object

loop at it_ZGMUSERGRANTS into wa_ZGMUSERGRANTS.

wa_ETRANGE-sign = ‘I’.

wa_ETRANGE-opt = ‘EQ’.

CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’

EXPORTING INPUT = wa_ZGMUSERGRANTS-grant_nbr IMPORTING OUTPUT = wa_ZGMUSERGRANTS-grant_nbr.

wa_ETRANGE-low = wa_ZGMUSERGRANTS-grant_nbr.

append wa_ETRANGE to E_T_RANGE.

endloop.

endif.

ENDCASE.

*……………………………………………………………..
*: Report: ZDOWNEMPDATA :
*: :
*: Author: abapcode:
*: :
*: Date : 2007 :
*: :
*: Description: Downloads employee data to TAB delimited flat files :
*: :
*:……………………………………………………………:
*……………………………………………………………..
*: Report: ZDOWNEMPDATA :
*: :
*: Author: http://www.SAPDev.co.uk :
*: :
*: Date : 2004 :
*: :
*: Description: Downloads employee data to TAB delimited flat files :
*: :
*:……………………………………………………………:
REPORT zdownempdata .
INFOTYPES: 0000, 0001, 0007, 0008, 0121, 0615.
NODES: pernr.
TABLES: t001p.
TYPES: BEGIN OF t_employee,
* INCLUDE STRUCTURE hrms_biw_io_occupancy.
begda TYPE begda,
endda TYPE endda,
pernr TYPE pernr_d,
rfpnr TYPE rfpnr,
bukrs TYPE bukrs,
werks TYPE persa,
btrtl TYPE btrtl,
persg TYPE persg,
persk TYPE persk,
orgeh TYPE orgeh,
stell TYPE stell,
plans TYPE plans,
kokrs TYPE mast_coar,
kostl TYPE mast_cctr,
abkrs TYPE abkrs,
molga TYPE molga,
trfar TYPE trfar,
trfgb TYPE trfgb,
trfkz TYPE trfkz,
trfgr TYPE trfgr,
trfst TYPE trfst,
bsgrd TYPE bsgrd,
ansal TYPE ansal_15,
ancur TYPE ancur,
empct TYPE empct,
stat2 TYPE stat2,
ncsdate TYPE hiredate,
sltyp TYPE p_sltyp,
slreg TYPE p_slreg,
slgrp TYPE p_slgrp,
sllev TYPE p_sllvl,
ansvh TYPE ansvh,
vdsk1 TYPE vdsk1,
sname TYPE smnam,
END OF t_employee.
DATA: it_employee TYPE STANDARD TABLE OF t_employee INITIAL SIZE 0,
wa_employee TYPE t_employee.
TYPES: BEGIN OF t_emptexts,
* INCLUDE STRUCTURE hrms_bw_txt_employee.
DATEFROM TYPE RSDATEFROM,
DATETO TYPE RSDATETO,
PERNR TYPE PERSNO,
TXTMD TYPE EMNAM,
END OF t_emptexts.
DATA: it_emptexts TYPE STANDARD TABLE OF t_emptexts INITIAL SIZE 0,
wa_emptexts TYPE t_emptexts.
TYPES: BEGIN OF t_contract,
* INCLUDE STRUCTURE pa0615.
pernr TYPE p0615-pernr,
begda TYPE p0615-begda,
endda TYPE p0615-endda,
aedtm TYPE p0615-aedtm,
ctype TYPE p0615-ctype,
cbeg TYPE p0615-cbeg,
cend TYPE p0615-cend,
END OF t_contract.
DATA: it_contract TYPE STANDARD TABLE OF t_contract INITIAL SIZE 0,
wa_contract TYPE t_contract.
DATA: it_tabemp TYPE filetable,
gd_subrcemp TYPE i,
it_tabempt TYPE filetable,
gd_subrcempt TYPE i,
it_tabcont TYPE filetable,
gd_subrccont TYPE i.
DATA: gd_downfile TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
PARAMETERS: p_emp LIKE rlgrap-filename,
p_empt LIKE rlgrap-filename,
p_cont LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK block1.
***********************************************************************
*at selection-screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_emp.
REFRESH: it_tabemp.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = ‘Select File’
default_filename = ‘*.xls’
initial_directory = ‘C:\’
multiselection = ‘ ‘ “No multiple selection
CHANGING
file_table = it_tabemp
rc = gd_subrcemp.
LOOP AT it_tabemp INTO p_emp.
ENDLOOP.
***********************************************************************
*at selection-screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_empt.
REFRESH: it_tabemp.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = ‘Select File’
default_filename = ‘*.xls’
initial_directory = ‘C:\’
multiselection = ‘ ‘ “No multiple selection
CHANGING
file_table = it_tabempt
rc = gd_subrcempt.
LOOP AT it_tabempt INTO p_empt.
ENDLOOP.
***********************************************************************
*at selection-screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cont.
REFRESH: it_tabcont.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = ‘Select File’
default_filename = ‘*.xls’
initial_directory = ‘C:\’
multiselection = ‘ ‘ “No multiple selection
CHANGING
file_table = it_tabcont
rc = gd_subrccont.
LOOP AT it_tabcont INTO p_cont.
ENDLOOP.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
GET pernr.
* Selecting the latest infotype record
rp_provide_from_last p0000 space pn-begda pn-endda.
rp_provide_from_last p0001 space pn-begda pn-endda.
rp_provide_from_last p0007 space pn-begda pn-endda.
rp_provide_from_last p0008 space pn-begda pn-endda.
rp_provide_from_last p0121 space pn-begda pn-endda.
rp_provide_from_last p0615 space pn-begda pn-endda.
MOVE-CORRESPONDING p0001 TO wa_employee.
wa_employee-rfpnr = p0121-rfp01. “?????
MOVE-CORRESPONDING p0007 TO wa_employee.
MOVE-CORRESPONDING p0008 TO wa_employee.
MOVE-CORRESPONDING p0000 TO wa_employee.
SELECT SINGLE molga
FROM t001p
INTO wa_employee-molga
WHERE werks EQ p0001-werks AND
btrtl EQ p0001-btrtl.
SELECT SINGLE trfkz
FROM t503
INTO wa_employee-trfkz
WHERE persg EQ p0001-persg AND
persk EQ p0001-persk.
CALL FUNCTION ‘HR_ENTRY_DATE’
EXPORTING
persnr = pernr-pernr
* RCLAS =
* BEGDA = ‘18000101’
* ENDDA = ‘99991231’
* VARKY =
IMPORTING
entrydate = wa_employee-ncsdate
* TABLES
* ENTRY_DATES =
EXCEPTIONS
ENTRY_DATE_NOT_FOUND = 1
PERNR_NOT_ASSIGNED = 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.
* append employee data
APPEND wa_employee TO it_employee.
CLEAR: wa_employee.
wa_emptexts-datefrom = p0001-begda.
wa_emptexts-dateto = p0001-endda.
wa_emptexts-pernr = p0001-pernr.
wa_emptexts-txtmd = p0001-ename.
* append employee texts data
APPEND wa_emptexts TO it_emptexts.
CLEAR: wa_emptexts.
MOVE-CORRESPONDING p0615 TO wa_contract.
* append employee contract data
APPEND wa_contract TO it_contract.
CLEAR: wa_contract.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
* download employee data
IF NOT p_emp IS INITIAL.
gd_downfile = p_emp.
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = gd_downfile
filetype = ‘ASC’
write_field_separator = ‘X’
TABLES
data_tab = it_employee.
IF sy-subrc EQ 0.
WRITE:/ ‘Employee file downloaded to’,
gd_downfile.
ELSE.
WRITE:/ ‘There was an error downloading Employee file to’,
gd_downfile.
ENDIF.
ENDIF.
* download employee texts data
IF NOT p_empt IS INITIAL.
gd_downfile = p_empt.
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = gd_downfile
filetype = ‘ASC’
write_field_separator = ‘X’
TABLES
data_tab = it_emptexts.
IF sy-subrc EQ 0.
WRITE:/ ‘Employee text file downloaded to’,
gd_downfile.
ELSE.
WRITE:/ ‘There was an error downloading Employee text file to’,
gd_downfile.
ENDIF.
ENDIF.
* download contract data
IF NOT p_cont IS INITIAL.
gd_downfile = p_cont.
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = gd_downfile
filetype = ‘ASC’
write_field_separator = ‘X’
TABLES
data_tab = it_contract.
IF sy-subrc EQ 0.
WRITE:/ ‘Employee contract file downloaded to’,
gd_downfile.
ELSE.
WRITE:/ ‘There was an error downloading Employee contract file to’,
gd_downfile.
ENDIF.
ENDIF.

Other Useful Link:

ZP_POSTCODE Staff by Post code report
ZP_GET_SXP_ABSENCE_DATA Retrieve actual sickpay values (ABAP)
ZDOWNEMPDATA Download various employee data to excel/tab flat files
Download Human Resources (HR) tutorial1Human Resources (HR) tutorial2
Download HR Form Editor (PY-XX-TL) tutorial
Download HR Forms Workplace (PY-XX-FO) tutorial
Download HR Funds and Position Management (PA-PM) Tutorial
Download HR – Human Resource Management Tutorial
Download HR Tools (PY-XX-TL) Tutorial
Download HR Infotypes tutorial

************************************************************************
* Report: ZSXP_ABSENCE_DATA *
* *
* Author: abap code *
* *
* Date : 25.05.2007 *
* *
* Description: Retrieve maternaty/Sickness Absence data
* *
************************************************************************
REPORT ZSXP_ABSENCE_DATA
LINE-SIZE 100 NO STANDARD PAGE HEADING
MESSAGE-ID 5g.
TABLES: t554s, pernr, pcl1, pcl2.
INCLUDE rpclst00.
INCLUDE rpc2rx09. “Payroll results datadefns-Intl.
INCLUDE rpc2rxx0. “Payroll results datadefns-Intl.
INCLUDE rpc2rgg0. “Payroll results datadefns-GB
INCLUDE rpcfdcg0. “Payroll results datadefns-GB
INCLUDE rpcdatg0.
INCLUDE rpc2cd00. “Cluster Directory defns.
INCLUDE rpc2ps00. “Cluster: Generierte Schematas
INCLUDE rpc2pt00.
INCLUDE rpcfdc10.
INCLUDE rpcfdc00.
INCLUDE rpppxd00.
INCLUDE rpppxd10.
INCLUDE rpcfvp09.
INCLUDE rpcfvpg0.
INCLUDE rpppxm00.
INFOTYPES: 0001, “Organisational assignment
0002, “Personal Data
0003, “Payroll Status
0088, “SMP
2001, “Absences
0086. “SSP/SMP Exlclusions
DATA: ssp_weeks TYPE p DECIMALS 2 VALUE 0.
DATA: ssp_total TYPE p DECIMALS 2 VALUE 0,
total_val TYPE p DECIMALS 2 VALUE 0,
smp_weeks TYPE p DECIMALS 2 VALUE 0,
smp_value TYPE p DECIMALS 2 VALUE 0,
gross LIKE pc207-betrg,
dis_gross TYPE p DECIMALS 2 VALUE 0.
DATA: gd_begda(10) TYPE c,
gd_endda(10) TYPE c.
DATA: ld_orgtxt LIKE t527x-orgtx.
DATA: name(30).
DATA: BEGIN OF itab OCCURS 0,
pernr LIKE p0002-pernr,
perid LIKE p0002-perid,
name LIKE name,
END OF itab.
TYPES: BEGIN OF t_report,
pernr TYPE pernr-pernr, “8
name TYPE name, “30
awart TYPE p2001-awart, “4
begda TYPE p2001-begda, “10
endda TYPE p2001-endda, “10
wkspaid TYPE p DECIMALS 2, “10
amtpaid TYPE p DECIMALS 2, “10
END OF t_report.
DATA: it_report TYPE STANDARD TABLE OF t_report INITIAL SIZE 0,
wa_report TYPE t_report.
DATA: moabw LIKE t001p-moabw.
DATA: printheader TYPE i VALUE 1,
gd_success TYPE i.
* NCALE declarations
TYPES : BEGIN OF pfra0_pcale,
annee(4) TYPE c.
INCLUDE STRUCTURE pcint.
TYPES : END OF pfra0_pcale.
TYPES : pfra0_tab_pcale TYPE pfra0_pcale OCCURS 0.
DATA: it_ncale TYPE STANDARD TABLE OF pcnat INITIAL SIZE 0,
wa_ncale TYPE pcnat,
it_pcale TYPE pfra0_tab_pcale,
pcale TYPE pfra0_tab_pcale.
* SMP/SSP absence data
data begin of it_msa occurs 0.
include structure pc27j.
data end of it_msa.
parameters: p_memid type char30.
************************************************************************
*STAR-OF-SELECTION
START-OF-SELECTION.
gd_begda = pn-begda.
gd_endda = pn-endda.
gd_begda+6(2) = ’01’.
gd_endda+6(2) = ’01’.
refresh: it_msa.
clear: it_msa.
GET pernr.
** PERFORM IMPORT_PC USING GD_SUCCESs.
PERFORM get_rgdir.
while gd_begda le gd_endda.
PERFORM get_new_rg USING gd_begda.
CALL FUNCTION ‘CALCULATE_DATE’
EXPORTING
* DAYS = ‘0’
MONTHS = ‘1’
START_DATE = gd_begda
IMPORTING
RESULT_DATE = gd_begda.
endwhile.
msa[] = it_msa[].
EXPORT msa TO MEMORY ID p_memid.
*&———————————————————————*
*& Form GET_RGDIR
*&———————————————————————*
FORM get_rgdir.
rp-init-buffer.
CLEAR rgdir.
REFRESH rgdir.
MOVE pernr-pernr(8) TO cd-key-pernr.
rp-imp-c2-cd.
IF rp-imp-cd-subrc = 0. “rgdir success
SORT rgdir BY seqnr ASCENDING.
CLEAR rgdir.
ENDIF.
ENDFORM.
*———————————————————————*
* FORM get_new_rg *
*———————————————————————*
* …….. *
*———————————————————————*
* –> search_date *
*———————————————————————*
FORM get_new_rg USING search_date.
DATA: rg_day TYPE d,
rgbeg TYPE d,
rgend TYPE d.
MOVE: search_date TO rg_day.
CLEAR: msa.
LOOP AT rgdir WHERE void NE ‘V’.
MOVE: rgdir-fpbeg TO rgbeg,
rgdir-fpend TO rgend.
IF ( rgbeg = rg_day ) AND
rgdir-srtza = ‘A’. “Must be periods actual set of results
EXIT.
ENDIF.
ENDLOOP.
UNPACK rgdir-seqnr TO rx-key-seqno.
MOVE pernr-pernr(8) TO rx-key-pernr(8).
rp-imp-c2-rg.
append lines of msa to it_msa.
IF rp-imp-rg-subrc 0.
* rg fail
ELSE.
* rg success
ENDIF.
ENDFORM.
*Text elements
*———————————————————-
* 001 Sickness History for SSP 1
* 002 Employee Name.
* 003 National Insurance Number.
* 004 Payroll Number.
* 005 Sickness Start Date
* 006 Sickness End Date
* 007 Number of weeks paid
* 008 system-error:
* 009 No SSP / SMP record found
* 010 Absence type
* 011 No. weeks paid
* 012 Amount
* 013 Organisation Unit.
* T01 Sickness Absence types
*Selection texts
*———————————————————-
* SO_SAP SAP Att./absence types
* SO_SMP SMP Att./absence types
* SO_SPP SPP Att./absence types
* SO_SSP SSP Att./absence types

Other Useful Link:

ZP_POSTCODE Staff by Post code report
ZP_GET_SXP_ABSENCE_DATA Retrieve actual sickpay values (ABAP)
ZDOWNEMPDATA Download various employee data to excel/tab flat files
Download Human Resources (HR) tutorial1Human Resources (HR) tutorial2
Download HR Form Editor (PY-XX-TL) tutorial
Download HR Forms Workplace (PY-XX-FO) tutorial
Download HR Funds and Position Management (PA-PM) Tutorial
Download HR – Human Resource Management Tutorial
Download HR Tools (PY-XX-TL) Tutorial
Download HR Infotypes tutorial

*……………………………………………………………..
*: Report: ZP_POSTCODE :
*: :
*: Author: http://www.SAPDev.co.uk :
*: :
*: Date : 2004 :
*: :
*: Description: Displays report of employees by postcode area, :
*: includes current travelling allowances (i.e. parking :
*: permit or transport card etc..) :
*: :
*: Use: Help encourage the use of car sharing and public :
*: transport where appropriate. :
*:……………………………………………………………:
REPORT zp_postcode.
type-pools: slis. “ALV Declarations
NODES: pernr.
INFOTYPES: 0000, 0001, 0002, 0006, 0008, 0014, 0105, 0121.
SELECTION-SCREEN BEGIN OF BLOCK pcode WITH FRAME TITLE text-s01.
SELECT-OPTIONS: so_pcode FOR p0006-pstlz.
SELECTION-SCREEN END OF BLOCK pcode.
TYPES: BEGIN OF t_output,
pernr TYPE p0001-pernr, “personnel name
anredtxt TYPE t522t-atext, “title (based on p0002-anred)
fname TYPE p0002-vorna, “first name
lname TYPE p0002-nachn, “last name
orgtx TYPE t527x-orgtx, “dept
fte TYPE p0008-bsgrd, “fte
parking(20) TYPE c,
payslip TYPE t526-sachn, “payslip address
telno TYPE p0105-usrid_long, “tel number(p0105-usrty = 0020)
email TYPE p0105-usrid_long, “email (p0105-usrty = MAIL)
postcode type p0006-pstlz,
END OF t_output.
DATA: it_output TYPE STANDARD TABLE OF t_output INITIAL SIZE 0,
wa_output TYPE t_output.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv,
gd_count(6) type n,
gd_outtext(70) type c,
gd_lines type i.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
clear: gd_count.
GET pernr.
* Infotype 0121 is used to store multiple contracts for personnel.
* Field p0121-hpern contains the personnel number for the main contract.
PROVIDE * from p0121 between pn-begda and pn-endda.
* Check if main contract
if p0121-pernr ne p0121-hpern.
reject.
endif.
ENDPROVIDE.
add 1 to gd_count.
concatenate ‘Processing personnel data'(m10) gd_count into gd_outtext
separated by ‘ ‘.
* Display indicator for employee count
perform progress_indicator using gd_outtext.
* Retrieve datd from infotypes
rp_provide_from_last p0000 space pn-begda pn-endda.
rp_provide_from_last p0001 space pn-begda pn-endda.
rp_provide_from_last p0002 space pn-begda pn-endda.
rp_provide_from_last p0006 space pn-begda pn-endda.
rp_provide_from_last p0008 space pn-begda pn-endda.
rp_provide_from_last p0014 space pn-begda pn-endda.
* Check post code
CHECK p0006-pstlz IN so_pcode. “cp
* Post code
wa_output-postcode = p0006-pstlz.
* Personnel number
wa_output-pernr = pernr-pernr.
* Personnel title
SELECT SINGLE atext
FROM t522t
INTO wa_output-anredtxt
WHERE sprsl EQ sy-langu AND
anred EQ p0002-anred.
* First name
wa_output-fname = p0002-vorna.
* Last name
wa_output-lname = p0002-nachn.
* Organizational Unit text (dept)
SELECT SINGLE orgtx
FROM t527x
INTO wa_output-orgtx
WHERE sprsl EQ sy-langu AND
orgeh EQ p0001-orgeh AND
endda GE sy-datum.
* FTE
wa_output-fte = p0008-bsgrd.
* Parking / travel deducted?
CASE p0014-lgart.
WHEN ‘7180’ OR ‘7181’ OR ‘7182’.
wa_output-parking = text-002.
WHEN ‘7183’.
wa_output-parking = text-001.
WHEN ‘7171’ OR ‘7172’ or ‘7173’ or ‘7174’ or
‘7175’ or ‘7176’ or ‘7177’ or ‘7178’.
wa_output-parking = text-003.
ENDCASE.
* Payslip Address
SELECT SINGLE sachn
FROM t526
INTO wa_output-payslip
WHERE werks EQ p0001-werks AND
sachx EQ p0001-sacha.
PROVIDE * from p0105 between pn-begda and pn-endda.
* Telephone numbers
if p0105-usrty = ‘0020’.
wa_output-telno = p0105-usrid_long.
endif.
* Email address
if p0105-usrty = ‘MAIL’.
wa_output-email = p0105-usrid_long.
endif.
ENDPROVIDE.
append wa_output to it_output.
clear: wa_output.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
describe table it_output lines gd_lines.
if gd_lines gt 0.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
else.
message i003(zp) with ‘No records found’.
endif.
*&———————————————————————*
*& Form PROGRESS_INDICATOR
*&———————————————————————*
* Displays progress indicator on SAP screen
*———————————————————————-*
form progress_indicator using p_text.
call function ‘SAPGUI_PROGRESS_INDICATOR’
exporting
* PERCENTAGE = 0
text = p_text.
endform. ” PROGRESS_INDICATOR
*&———————————————————————*
*& Form BUILD_FIELDCATALOG
*&———————————————————————*
* Build Fieldcatalog for ALV Report
*———————————————————————-*
form build_fieldcatalog.
fieldcatalog-fieldname = ‘PERNR’.
fieldcatalog-seltext_m = ‘Personnel No.’.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
* fieldcatalog-emphasize = ‘X’.
* fieldcatalog-key = ‘X’.
* fieldcatalog-do_sum = ‘X’.
* fieldcatalog-no_zero = ‘X’.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘ANREDTXT’.
fieldcatalog-seltext_m = ‘Title’.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘FNAME’.
fieldcatalog-seltext_m = ‘First Name’.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘LNAME’.
fieldcatalog-seltext_m = ‘Last Name’.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘ORGTX’.
fieldcatalog-seltext_m = ‘Department’.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘FTE’.
fieldcatalog-seltext_m = ‘FTE’.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘PARKING’.
fieldcatalog-seltext_m = ‘Parking/Metrocard’.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘PAYSLIP’.
fieldcatalog-seltext_m = ‘Payslip Add.’.
fieldcatalog-col_pos = 7.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘TELNO’.
fieldcatalog-seltext_m = ‘Telephone’.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘EMAIL’.
fieldcatalog-seltext_m = ‘E-mail’.
fieldcatalog-col_pos = 9.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = ‘POSTCODE’.
fieldcatalog-seltext_m = ‘Post code’.
fieldcatalog-col_pos = 10.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. ” BUILD_FIELDCATALOG
*&———————————————————————*
*& Form BUILD_LAYOUT
*&———————————————————————*
* Build layout for ALV grid report
*———————————————————————-*
form build_layout.
gd_layout-no_input = ‘X’.
gd_layout-colwidth_optimize = ‘X’.
gd_layout-totals_text = ‘Totals'(201).
gd_layout-zebra = ‘X’.
endform. ” BUILD_LAYOUT
*&———————————————————————*
*& Form DISPLAY_ALV_REPORT
*&———————————————————————*
* Display report using ALV grid
*———————————————————————-*
form display_alv_report.
gd_repid = sy-repid.
call function ‘REUSE_ALV_GRID_DISPLAY’
exporting
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = ‘X’
tables
t_outtab = it_output
exceptions
program_error = 1
others = 2.
if sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. ” DISPLAY_ALV_REPORT

Other Useful Link:

ZP_POSTCODE Staff by Post code report
ZP_GET_SXP_ABSENCE_DATA Retrieve actual sickpay values (ABAP)
ZDOWNEMPDATA Download various employee data to excel/tab flat files
Download Human Resources (HR) tutorial1Human Resources (HR) tutorial2
Download HR Form Editor (PY-XX-TL) tutorial
Download HR Forms Workplace (PY-XX-FO) tutorial
Download HR Funds and Position Management (PA-PM) Tutorial
Download HR – Human Resource Management Tutorial
Download HR Tools (PY-XX-TL) Tutorial
Download HR Infotypes tutorial

ZP_POSTCODE Staff by Post code report

ZP_GET_SXP_ABSENCE_DATA Retrieve actual sickpay values (ABAP)

ZDOWNEMPDATA Download various employee data to excel/tab flat files

Other Useful Link:

ZP_POSTCODE Staff by Post code report
ZP_GET_SXP_ABSENCE_DATA Retrieve actual sickpay values (ABAP)
ZDOWNEMPDATA Download various employee data to excel/tab flat files
Download Human Resources (HR) tutorial1Human Resources (HR) tutorial2
Download HR Form Editor (PY-XX-TL) tutorial
Download HR Forms Workplace (PY-XX-FO) tutorial
Download HR Funds and Position Management (PA-PM) Tutorial
Download HR – Human Resource Management Tutorial
Download HR Tools (PY-XX-TL) Tutorial
Download HR Infotypes tutorial

The use of object orientated code within SAP has lead to new method of enhancing standard SAP code called Business Add-Ins or BADI’s for short. Although the implementation concept is based on classes, methods and inheritance you do not really have to understand this fully to implement a BADI. Simply think of methods as a function module with the same import and export parameters and follow the simple instructions below
Steps:1. Execute Business Add-In(BADI) transaction SE18

2. Enter BADI name i.e. HRPBSGB_HESA_NISR and press the display button

3. Select menu option Implementation->Create

4. Give implementation a name such as Z_HRPBSGB_HESA_NISR

5. You can now make any changes you require to the BADI within this implementation, for example choose the Interface tab.

6. Double click on the method you want to change, you can now enter any code you require.

7. Please note to find out what import and export parameters a method has got return the original BADI definition (i.e. HRPBSGB_HESA_NISR) and double click on the method name for example within HRPBSGB_HESA_NISR contract is a method

8. When changes have been made activate the implementation.


Read Whole Site there

http://abapcode.info

Topic Wise Content

blog content

May 2007
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Blog Stats

  • 550,558 hits