Google Search - Blog...........

SAP ABAP - Sample Programs On Uploading & Downloading Files.


Sample programs On Uploading & Downloading Data:

- Upload Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.

- Download Data Without Files Using FM WS_DOWNLOAD.

- Calling Word Documents From ABAP Using OLE Automation.

- Download ABAP Data To An Excel Sheet Using OLE Automation.

- Download Data From Internal Table To Excel Sheet Using SAP_CONVERT_TO_XLS_FORMAT Function Module.

- Transfer Data Into A Word Document Using OLE Automation.

- Download Data From Internal Table To Excel Sheet (With Header).

- Download Code To System Using FM RS_TESTFRAME_CALL.

- Download Code To The Desktop With Screens.

- Report Program On Uploading And Downloading Using FM BX_FAVOS_READ_ALL_NODES And BX_FAVOS_WRITE_ALL_NODES.

- Sample Program On Downloading From Internal Table To File Using GUI_DOWNLOAD.

- Downlaod Internal Table Data To Excel or TXT File Using FM GUI_DOWNLOAD.

- Sample Program To Open A File On The System Using FM WS_EXECUTE.

- Download Code To System Using FM RS_TESTFRAME_CALL.

- Download Code To The Desktop With Screens.

- Uploading Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.

- Uploading Images From PC To An Internal Table Using FM BDS_BUSINESSDOCUMENT_CREATEF.

- Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.

- Sample Program For Creating XML File On Presentation Server.

- Uploading Multiple Files At One Time.

- Download Data Into More Than One Excel Sheet.



- Download A File With The Specified Delimit Character Dynamically.

- Download ABAP Source Code & TEXTPOOL To The Desktop.

- Downloading Programs Into A Folder In Presentation Server.

- Download SAP Data In XML Format.

- Download SAPScript Output To PDF File.

- Download Data From Application Server Files To Presentation Server Using FM C13Z_APPL_TO_FRONT_END.

- Creating A Directory On Presentation Server Using FM GUI_CREATE_DIRECTORY.

- Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.

- Removing A File From Presentation Server Using FM GUI_DELETE_FILE.

- ZIP Files In Application Server Using FM SCMS_XSTRING_TO_BINARY.

- Saving Files To Presentation Server Using Methods.

- Uploading CSV Files Into Internal Table Using FM GUI_UPLOAD.

- Downloading All Custom Reports From The Server Using FM GUI_DOWNLOAD.

- Downloading Code From The Type Groups Using FM TYPD_GET_OBJECT.

- Creating A File & Folder In Presentation Server.

.....Back To MAIN INDEX.

INDEX - SAP ABAP Sample Programs.


Here is a list of sample programs on ABAP:-



SAP ABAP - Sample Programs On BDC....



Sample Programs on BDC:-

.....Back To MAIN INDEX.

- BDC For Open Sales Order - SD (VA01).

- BDC Program To Upload Material Master Data (MM01).

- BDC Program For Vendor XK01.

- BDC Program To Send Mails And Trigger Jobs.

.....Back To MAIN INDEX.

- BDC Program To Load The Material Assignment Of Routing (CA02) - PP.




- Sample Code To Handle Multiple Records In BDC Table Control (IB01).

- HR ABAP - BDC For Uploading Absence Data Into PA30 Transaction.

- HR ABAP - BDC To Upload The OM Relations Through T-code PO13.

- HR ABAP - BDC Upload For The Org Unit Relationship Through T-Code PO10.

- HR ABAP - BDC For The Action Transfer Of Location.

.....Back To MAIN INDEX.

SAP ABAP - Sample Programs On Selection Screen.



Sample Programs On Selection Screen:


- TAB Strips In Selection Screen.

- F4 (Value On Request) For Date On Selection Screen.

- F4 (Value On Request) For Ztable On Selection Screen.

- F4 (Value On Request) For A Field Of Ztable On Selection Screen.

- F4 (Value On Request) For Month On Selection Screen.

- F4 (Value On Request) For Month On Selection Screen.

- ListBox From User Values In Selection Screen.

- F4 Help (Value On Request) For Month And Year.

- Printing The Selection Screen Data On The Report Program.

- Changing Selection Screen Design Through Tcode SE51.

- F4 (Value On Request) On Field BUKRS On Selection Screen.

- F4 (Value On Request) On Logical File On selection Screen.

- Display Icon On Selection Screen.

- Sample Program To Display Icon On Selection Screen.

.....Back To MAIN INDEX.

- Multiple Selection Screen Options.

- Pop Up Window With Check Box.

- F4 (Value On Request) For Parameter On Selection Screen.

- Updating Value Of Another Field On The Selection Screen.

- Complex Selection Screen (Using Macros).

- Printing Selection Screen Data On The Report Output.

- Creating The Listbox Using Macros.

- Restrict Values For The F4 (Value On Request) Help.

- Screen Field Validation Using Chain Endchain.

- Drop Down List Box In The Selection Screen.

- Creating Dynamic F4 (Value On Request) Help.

- Express Select-Options Values In SY-LANGU.

- F4 (Value On Request) For Files On Presentation Or Application Server.

- Sample Program On Use Of Selection Screen.

- Creating Tab-Strip Selection Screen tab-strip Without Using SE51.

- Change The Height Of The Screen Layout To Make It Full Screen.

- F4 (Value On Request) For Field Using FM RSISP_DDIC_F4_VALUES.

- F4 (Value On Request) For Organization Unit In HR Report Program.

- Check Box As A Radio Button In Selection Screen.

.....Back To MAIN INDEX.


SAP ABAP - Sample Report Programs On ALV List/ Grid Display



Here are a few links to Sample Report Programs on ALV Grid / List Display :

........Back To MAIN INDEX.

- Traffic Light In An ALV Report Program.

- Display ALV Report In Different Language.

- ALV Pop Up To Select The Options & Display Them.

- Example On Blocking ALV List/Grid Display.

- Change The Layout Of The ALV List/Grid Display.

- Add Color In ALV List/Grid Display.

- Use Of Double Click On ALV Grid/List Display.

- Hierarchical ALV Grid/List Display Report Program.

- Header In Bold - ALV Grid/List Display.

- Double Click On ALV Grid/List Report.

........Back To MAIN INDEX.

- ALV Interactive (Double Clicking).

- Simple Example On How To Display Table Data In ALV Grid/List Display.

- Change Of ALV Grid/ List Layout (VARIANT).

- Repeating Colors In ALV Grid/List Display.

- Display Data From MARA Table In ALV Grid Display.

- Convert ALV Rows Into Column.

- ALV Pop Up Screen To Select.

- ALV Heading At Center & At The End Of Page.

- ALV Blocked In HR ABAP.

- ALV With Some Columns In Bold Letters.

........Back To MAIN INDEX.

- ALV Data In Different Languages.

- ALV Hierarchical For Tables.

- Display ALV List/Grid Sub-Total & Total.

- Interactive ALV On T-Codes.

- Display EKPO Table Data In ALV Grid/List Display.

- ALV Report With Variant Option Save.

- Display Red, Yellow & Green Signal In ALV Display.

- Column's With Different Colors (Using Methods) In ALV Display.

- ALV On The Selection Screen Of A Program.

- Header In ALV Grid/List Display.

........Back To MAIN INDEX.


- Calling A Transacton From ALV Grid/List Report.

- Simple ALV Grid/List With Save Layout.

- Checkbox In ALV Program.

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

- ALV Subtotals In Different Blocks.

- ALV With Page Numbers & Subtotals.

- Footer Functionality In ALV Reports.

- Calling One ALV From Other ALV Report Program.

- Capture Single & Multiple Row Selction In ALV Report Program.

........Back To MAIN INDEX.

- Coloring A Row & Column In ALV Display Using OOPS Concept.

- Create Unique Handle For ALV Layout (Variant).

- Customizing Toolbar In ALV Tree Using ABAP OO.

- Dropdown in ALV Grid Display.

- Dynamic ALV Grid/List Display.

- Handling Radio Buttons in SALV Tree Display.

- Implementing F4 Search Help In OO ALV Grid Display.

- List Of Transport Requests In ALV Format.

- ALV Report With User Defined Buttons In It's Toolbar.

........Back To MAIN INDEX.

- ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC.

- Displaying Percentage In ALV List / Grid Display.

- Handling An ALV Grid With Check Box Using A Method.

- Handling Radio Buttons In ALV Report.

- Display The PO Status In ALV Report - MM.

- SALV List With Check Box.

- SALV List With Symbol.

........Back To MAIN INDEX.


SAP ABAP - Sample Programs On HR ABAP.



Here is a list of sample program on HR ABAP:-

-.....Back To MAIN INDEX.

- HR TABLES.

- HR Tables & Infotypes.

- HR T-Codes.

- Sample HR Report Program On Macros.

- Get The Manager Of The Employee.

- Creating An HR Infotype Step By Step.

- Creating HR Report Category In PNP Logical Database.

- Fetching The Entry Or Joining Date For Employees.

-.....Back To MAIN INDEX.

- Fetching HR Data In Different Ways.

- Get Managers List For All The Organization Units.

- Get Employees List Working Under An Organization Unit.

- Retrieve Manager For An Employee.

- Generate Compensation Statement Report.

- Fetch HR Data Or Records From HR Database Tables.

- Using Macros In HR ABAP Report Program.

- Get The List Of Employees With Experience.

- BADI HRECM00_BDG0001 - Upload Initial Budgets From Excel Sheet.

- 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.

- Ordering (Descending ) Org. Unit For An Organization.

- Display Details about Organization unit, Position or Job In HR ABAP.

-.....Back To MAIN INDEX.


- First & Last Working Date Of An Employee.

- Get All The Existing Organization Units.

- Obtain All The Sub Org Units Under An Organization Unit.

- Display Texts For Personnel Subarea, Employee Group, Employee Subgroup, Cost Center & Organizational Unit.

- Minimum & Maximum Salaries For The Employees.

- Handling User Exits In HR ABAP.

- Termination Workbench Report In HR ABAP.

- Service Calculation Report In HR ABAP.

- Use Of BAPI HR_MAINTAIN_MASTERDATA For Updating HR DATA.

- Upload The Over Time Report In HR ABAP.

-.....Back To MAIN INDEX.

- Displaying Off-Cycle Report In HR ABAP.

- Loans Detail Report In HR ABAP.

- Gosi Calculation Report In HR ABAP.

- Employee Pay Details Report In HR ABAP.

- Employee Existence Check Report.

- Send Employee Payslip As An E-Mail Attachment.

- Time Quota For An Employee In HR ABAP.

-.....Back To MAIN INDEX.

- Employee Deduction Report In HR ABAP.

- Comparison Report For The Employee Salaries In HR ABAP.

- Cash Payment Report In HR ABAP.

- Bank Report For Employees In HR ABAP.

- BDC For Uploading Absence Data Into PA30 Transaction.

- HR Master Data Update Using T-Code CAT2 With BAPI.

- Upload Job & Position Relations Through PO03.

- BDC To Upload The OM Relations Through T-code PO13.

- Function Modules To Read Benefits Data In HR ABAP.

- Sample Code For Do Varying In HR ABAP.

- Get Family Data In HR ABAP.

- Net Salary Report In HR ABAP.

-.....Back To MAIN INDEX.

- Cumulative Amount Report in HR ABAP.

- Use Of Time Macro rp-read-all-time-ity in HR ABAP.

- Cumulative List Of Absences For Company Code, Personnel Area & Personnel Subarea.

- Employee Data Using Function Module In HR ABAP.

- BDC For The Action Transfer Of Location In HR ABAP.

-.....Back To MAIN INDEX.

BDC For The Action Transfer Of Location In HR ABAP



*---If u want to perform the transfer action you just need to change the personnel subarea, it is not possible for us to change the personnel subarea through BDC or using BAPI for the action info type 0000, as it is already grade out in that infotype even you are in change mode.

So you must enter through the tcode PA40 and tehre is another case we can do it. Fisrt change the personnel subarea in Org Management 0001 and then perform the action transfer in Actions infotype 0000.

refresh : bdcdata.

perform bdc_dynpro using 'SAPMP50A' '2000'.
perform bdc_field using 'BDC_CURSOR'
'RP50G-EINDA'.
perform bdc_field using 'BDC_OKCODE'
'=PICK'.
perform bdc_field using 'RP50G-PERNR'
it_pa0001-pernr.
perform bdc_field using 'RP50G-EINDA'
sy-datum.
perform bdc_field using 'RP50G-SELEC(03)'
'X'.
perform bdc_dynpro using 'MP000000' '2000'.
perform bdc_field using 'BDC_CURSOR'
'PSPAR-WERKS'.
perform bdc_field using 'BDC_OKCODE'
'UPD'.
perform bdc_field using 'P0000-BEGDA'
v_date.
perform bdc_field using 'P0000-MASSG'
'03'.
perform bdc_field using 'PSPAR-PLANS'
it_pa0001-plans.
perform bdc_field using 'PSPAR-WERKS'
v_werks.
perform bdc_field using 'PSPAR-PERSG'
it_pa0001-persg.
perform bdc_field using 'PSPAR-PERSK'
it_pa0001-persk.
perform bdc_dynpro using 'MP000100' '2000'.
perform bdc_field using 'BDC_OKCODE'
'/EBCK'.
perform bdc_field using 'BDC_CURSOR'
'P0001-BEGDA'.
perform bdc_dynpro using 'SAPLSPO1' '0200'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_dynpro using 'SAPMP50A' '2000'.
perform bdc_field using 'BDC_OKCODE'
'/EBCK'.
perform bdc_field using 'BDC_CURSOR'
'RP50G-PERNR'.

CALL TRANSACTION 'PA40' USING BDCDATA
MODE 'N'
UPDATE 'S'
MESSAGES INTO MESSTAB.


ALSO READ:

- HR TABLES.

- HR Tables & Infotypes.

- HR T-Codes.

- Sample HR Report Program On Macros.

- Get The Manager Of The Employee.

- HR ABAP - BDC For Uploading Absence Data Into PA30 Transaction.

- HR ABAP - BDC To Upload The OM Relations Through T-code PO13.

- HR ABAP - BDC Upload For The Org Unit Relationship Through T-Code PO10.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.

Posting FBV0 Error Documents In Foreground

When we are posting documents in FBV0, if u process this in background you will get some error like missing input in some screens.

Go to FBV0

Click on Document List.

Give the document numbers, company code and fiscal year (give the documents numbers which are problematic)

Execute

Select the documents with your cursor.

List ==> Create batch input.

A batch input session will be created for these documents to be posted.

Go to SM35 and post them in foreground mode (not in background mode) - You need check foreground radio button.

When you are posting in foreground, the problematic document numbers will throw you error and you can input the right values.


ALSO READ:

- HR TABLES.

- HR Tables & Infotypes.

- HR T-Codes.

- Sample HR Report Program On Macros.

- BDC For The Action Transfer Of Location In HR ABAP.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.


Employee Data Using Function Module In HR ABAP

*--instead of reading many infotypes 0000,00001,0002,0006,0105
* we can use this function module to read the complete data of
* an employee

REPORT ztest.

parameters: p_pernr type pa0001-pernr.

start-of-selection.

data: l_pernr LIKE OBJEC-OBJID,
wa_data LIKE PERSON.

l_pernr = p_pernr.

CALL FUNCTION 'HR_GET_EMPLOYEE_DATA'
EXPORTING
person_id = l_pernr
SELECTION_BEGIN = SY-DATUM
SELECTION_END = SY-DATUM
IMPORTING
PERSONAL_DATA = wa_data
EXCEPTIONS
PERSON_NOT_FOUND = 1
NO_ACTIVE_INTEGRATION = 2
OTHERS = 3
.

end-of-selection.

write:/ 'Employee Name : ' , wa_data-pernr.
write:/ 'Start Date : ' , wa_data-begda.
write:/ 'End Date : ' , wa_data-endda.
write:/ 'Organization : ' , wa_data-Orgeh.
write:/ 'Cost Center : ' , wa_data-kostl.
write:/ 'Pisition : ' , wa_data-PLANS.
write:/ 'Job : ' , wa_data-stell.
write:/ 'First Name : ' , wa_data-vorna.
write:/ 'Last Name : ' , wa_data-nachn.


ALSO READ:

- HR TABLES.

- HR Tables & Infotypes.

- HR T-Codes.

- Sample HR Report Program On Macros.

- BDC For The Action Transfer Of Location In HR ABAP.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.


HR ABAP - Cumulative List Of Absences For Company Code, Personnel Area & Personnel Subarea

REPORT ZHR_CUM_ABS no standard page heading.

*&-------------------------------------------------------------------------*
* Create a list for the current year showing the cumulated days of absence
* - for each company code
* - for each personnel area
* - for each Personnel Subarea
*--------------------------------------------------------------------------*
tables: pernr,
t554t, "Absence texts
t001p. "Personnel subareas

infotypes: 0001, "Organizational Assignment
2001 mode n. "Absences

data: begin of it_abstab occurs 20,
bukrs like p0001-bukrs,
werks like p0001-werks,
btrtl like t001p-btrtl,
moabw like t001p-moabw, "Subarea grouping for absences
awart like p2001-awart,
abwtg like p2001-abwtg,
end of it_abstab.

get pernr.

rp-provide-from-last p0001 space pn-begda pn-endda.

rp-read-t001p p0001-werks p0001-btrtl space.

move-corresponding: p0001 to it_abstab,
t001p to it_abstab.

rp-read-all-time-ity pn-begda pn-endda.

loop at p2001.
if p2001-abwtg gt 0.
move-corresponding p2001 to it_abstab.
collect it_abstab.
endif.
endloop.

end-of-selection.

sort it_abstab.

loop at it_abstab.
format intensified off.
perform re554t using it_abstab-moabw it_abstab-awart.
perform print.

at end of btrtl. "Personnel subarea
format intensified on.
sum.
clear t554t-atext.
perform print.
endat.

at end of werks. "Personnel area
format intensified on.
sum.
clear t554t-atext.
perform print.
endat.

at end of bukrs. "Company code
format intensified on.
sum.
clear t554t-atext. perform print.
skip.
endat.

at last.
format intensified on.
sum.
clear t554t-atext. perform print.

skip.
endat.
endloop.


*-----------------------------------------------------------------*


* FORM PRINT


*-----------------------------------------------------------------*


* Print cumulated absence days


*-----------------------------------------------------------------*

form print.

write: / it_abstab-bukrs,8 it_abstab-werks,14 it_abstab-btrtl,20 it_abstab-awart,26 t554t-atext,
60 it_abstab-abwtg.

endform.


*-----------------------------------------------------------------
* FORM RE554T



*-----------------------------------------------------------------
* Read absence texts



*-----------------------------------------------------------------

form re554t using value(grouping) "Subarea grouping for absences
value(absence).

check t554t-sprsl ne sy-langu
or t554t-moabw ne grouping
or t554t-awart ne absence.

select single * from t554t
where sprsl = sy-langu
and moabw = grouping
and awart = absence.

if sy-subrc ne 0.
clear t554t.
endif.

endform.


ALSO READ:

- HR TABLES.

- HR Tables & Infotypes.

- HR T-Codes.

- Sample HR Report Program On Macros.

- Employee Data Using Function Module In HR ABAP.

- BDC For The Action Transfer Of Location In HR ABAP.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.


Use Of Time Macro rp-read-all-time-ity in HR ABAP

REPORT ZHR_TEIME2
no standard page heading.


tables: pernr.
infotypes: 2001 mode n,
2002 mode n.

get pernr.
rp-read-all-time-ity pn-begda pn-endda.

sort p2001 by begda.
write:/ 'Start Date',
14 'End Date',
27 'Absence Type',
42 'Absence hours',
57 'Absence days'.
loop at p2001.
write: / p2001-begda,
14 p2001-endda,
27 p2001-awart,
42 p2001-stdaz,
57 p2001-abwtg.
endloop.

write:/ 'Attendances'.
write:/ 'Start Date',
14 'End Date',
'Attendance type',
'Attendance hours',
'Attendance days'.
loop at p2002.
write:/ p2002-begda,
14 p2002-endda,
27 p2002-awart,
42 p2002-stdaz,
57 p2002-abwtg.
endloop.


ALSO READ:

- HR TABLES.

- HR Tables & Infotypes.

- HR T-Codes.

- Cumulative List Of Absences For Company Code, Personnel Area & Personnel Subarea.

- Employee Data Using Function Module In HR ABAP.

- BDC For The Action Transfer Of Location In HR ABAP.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.


Cumulative Amount Report in HR ABAP

REPORT ZHR_CUM_REPORT NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65
MESSAGE-ID ZZ.

************************************************************************
* T A B L E S D E C L A R A T I O N *
************************************************************************
TABLES: PERNR, " STUCTURE PERNR DECLARATION
PCL1, " CLUSTER DECLARATION
PCL2. " CLUSTER DECLARATION

************************************************************************
* I N F O T Y P E S D E C L A R A T I O N *
************************************************************************
INFOTYPES: 0001, "INFOTYPE 0001 DECLARATION
0002. "INFOTYPE 0002 DECLARATION

***********************************************************************
* I N C L U D E S T R U C T U R E S *
***********************************************************************
INCLUDE RPC2CD09. "Cluster CD Data-Definition
INCLUDE RPC2CA00. "Cluster CA Data-Definition "XUJP30K079863
INCLUDE RPC2RUU0. "Cluster RU Data-Definition
INCLUDE RPC2RX09. "Cluster RU Data-Definition internat. part
INCLUDE RPPPXD00. "Data Definition buffer PCL1/PCL2
INCLUDE RPPPXD10. "Common part buffer PCL1/PCL2
INCLUDE RPPPXM00. "Buffer handling routine


************************************************************************
* I N T E R N A L T A B L E S D E C L A R A T I O N *
************************************************************************
*....internal table to store final data
DATA: BEGIN OF IT_FINAL OCCURS 0,
PERNR LIKE PA0001-PERNR, "PERSONNEL NUMBER
GBDAT LIKE PA0002-GBDAT, "DATE OF BIRTH
VORNA LIKE PA0002-VORNA, "FIRST NAME
NACHN LIKE PA0002-NACHN, "LAST NAME
BETRG LIKE RT-BETRG, "BASIC PAY
BETRG1 LIKE TCRT-BETRG, "TOTAL GROSS CUMMULATIVE TAX
END OF IT_FINAL.
*....internal table used to get sequence number
DATA: IT_RGDIR LIKE PC261 OCCURS 0 WITH HEADER LINE.

************************************************************************
* D A T A D E C L A R A T I O N *
************************************************************************
DATA: V_PERMO LIKE T549A-PERMO, "VARIABLE TO GET PERIOD PARAMETERS
V_PABRJ LIKE T569V-PABRJ, "VARIABLE TO GET YEAR
V_PABRP LIKE T569V-PABRP, "VARIABLE TO GET PERIOD
V_ENDDA LIKE T549Q-ENDDA, "VARIABLE TO GET END DATE
V_BEGDA LIKE T549Q-BEGDA, "VARIABLE TO GET BEGIN DATE
V_SEQNR LIKE RGDIR-SEQNR, "VARIABLE TO GET SEQUENCE NUMBER
V_ABKRS LIKE PA0001-ABKRS, "PAY ROLL AREA
V_ATEXT LIKE T549T-ATEXT, "PAY ROLL AREA TEXT
V_NAME(35). "VARAIABLE TO STORE EMPLOYEE NAME


************************************************************************
* S T A R T O F S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
*....form to get payroll area text
PERFORM GET_PAYROLLAREATEXT.
*....form to get Period parameter into v_permo from table t549a
PERFORM GETPERMO.
*....from to get begda and endda
PERFORM GETDATES.


***********************************************************************
* G E T P E R N R E V E N T *
***********************************************************************
GET PERNR.
*.....form for getting latest org. info and personal info.
PERFORM GET-DATA.

************************************************************************
* E N D O F S E L E C T I O N *
************************************************************************
END-OF-SELECTION.
*.....form to display data as report
PERFORM DISPLAY-PARA.

************************************************************************
* Form GET_PAYROLLAREATEXT *
************************************************************************
FORM GET_PAYROLLAREATEXT.
V_ABKRS = PNPXABKR.
SELECT SINGLE
ATEXT
INTO V_ATEXT
FROM T549T WHERE ABKRS = V_ABKRS
AND SPRSL = SY-LANGU.
ENDFORM. " GET_PAYROLLAREATEXT

************************************************************************
* Form GETPERMO *
************************************************************************
FORM GETPERMO.
*.....get Period parameter into v_permo from table t549a
SELECT SINGLE PERMO
FROM T549A
INTO V_PERMO
WHERE ABKRS = V_ABKRS.
ENDFORM. " GETPERMO


************************************************************************
* Form GETDATES *
************************************************************************
FORM GETDATES.
*.....Time period indicator: Current period is initial
IF PNPTIMR9 = 'X'.
PERFORM GETDATES1.
*.....Time period indicator: Other period is initial
ELSEIF PNPTIMRA = 'X'.
PERFORM GETDATES2.
ENDIF.
ENDFORM. " GETDATES


************************************************************************
* Form GETDATES1 *
************************************************************************
FORM GETDATES1.
*.....get Payroll year and period from table t569v
SELECT SINGLE PABRJ
PABRP
FROM T569V
INTO (V_PABRJ , V_PABRP)
WHERE ABKRS = V_ABKRS.
*.....get Start Date and End Date from table t549q
SELECT SINGLE ENDDA
BEGDA
FROM T549Q
INTO (V_ENDDA , V_BEGDA)
WHERE PABRJ = V_PABRJ
AND PABRP = V_PABRP
AND PERMO = V_PERMO.
ENDFORM. " GETDATES1

************************************************************************
* Form GETDATES2 *
************************************************************************
FORM GETDATES2.
*.....get Start Date and End Date from table t549q
SELECT SINGLE ENDDA
BEGDA
FROM T549Q
INTO (V_ENDDA , V_BEGDA)
WHERE PABRJ = PNPPABRJ
AND PABRP = PNPPABRP
AND PERMO = V_PERMO.
ENDFORM. " GETDATES2


************************************************************************
* Form GET-DATA *
************************************************************************
FORM GET-DATA.

*.....HR macro to get Latest Personnel Org. Info by Start and End dates
RP-PROVIDE-FROM-LAST P0001 SPACE V_BEGDA
V_ENDDA.
*.....if infotype p0001 succussfully read
IF PNP-SW-FOUND = '1'.
IT_FINAL-PERNR = P0001-PERNR.
*.....HR macro to get Latest personal Info by Start and End dates
RP-PROVIDE-FROM-LAST P0002 SPACE V_BEGDA
V_ENDDA.
*.....if infotype p0002 succussfully read
IF PNP-SW-FOUND = '1'.
IT_FINAL-VORNA = P0002-VORNA.
IT_FINAL-NACHN = P0002-NACHN.
IT_FINAL-GBDAT = P0002-GBDAT.
*.....get data into Resultant table using function module CU_READ_RGDIR
PERFORM READ-RGDIR.
ENDIF.
ENDIF.
ENDFORM. " GET-DATA

************************************************************************
* Form READ-RGDIR *
************************************************************************
FORM READ-RGDIR.
*.....fill it_rgdir Personnel Number
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
PERSNR = P0001-PERNR
* BUFFER =
* NO_AUTHORITY_CHECK = ' '
* IMPORTING
* MOLGA =
TABLES
IN_RGDIR = IT_RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 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.

*.....check whether "Pay date for payroll result" with in Start Date and
* End date, and "Reason for Off-Cycle Payroll" is initial

LOOP AT IT_RGDIR WHERE PAYDT >= V_BEGDA
AND PAYDT <= V_ENDDA and VOID IS INITIAL AND OCRSN IS INITIAL AND SRTZA = 'A'. V_SEQNR = IT_RGDIR-SEQNR.

*.....Move pernr and seqnr to cluster

RX UNPACK P0001-PERNR TO RX-KEY-PERNR.
UNPACK V_SEQNR TO RX-KEY-SEQNO.

*.....Macro for getting US pernrs Info. in cluster

PCL2 RP-IMP-C2-RU.

*.....populate internal table RT where Wage Type is '1000'

LOOP AT RT WHERE LGART = '1000'.
IT_FINAL-BETRG = RT-BETRG.

*.......populate internal table TCRT where Wage Type is '/100'

LOOP AT TCRT WHERE LGART = '/101' AND CTYPE = 'Y'.
IT_FINAL-BETRG1 = TCRT-BETRG.
APPEND IT_FINAL.
ENDLOOP.

ENDLOOP.
CLEAR IT_FINAL.
ENDLOOP.
REFRESH IT_RGDIR.

ENDFORM. " READ-RGDIR

************************************************************************ *
Form DISPLAY-PARA * ************************************************************************
FORM DISPLAY-PARA.

IF IT_FINAL[] IS INITIAL.
MESSAGE I013 WITH 'No data matched selection criteria'.

ELSE.
WRITE:/ SY-ULINE(125).
WRITE:/5 'PAYROLL AREA ' , 30 'PAYROLL TEXT'.
WRITE:/ SY-ULINE(125).
WRITE:/10 V_ABKRS, 35 V_ATEXT.
WRITE:/ SY-ULINE(125).
WRITE:/2 'EMP ID', 10 'FULL NAME', 46 'DATE OF BIRTH', 70 'BASIC PAY', 90'TOTAL GROSS CUMULATED TAX AMOUNT'.

WRITE:/ SY-ULINE(125).

LOOP AT IT_FINAL.
CONCATENATE IT_FINAL-VORNA IT_FINAL-NACHN INTO V_NAME SEPARATED BY ' '.

WRITE: / IT_FINAL-PERNR, V_NAME, IT_FINAL-GBDAT, IT_FINAL-BETRG, IT_FINAL-BETRG1.
CLEAR V_NAME.
CLEAR IT_FINAL.

ENDLOOP.
WRITE:/ SY-ULINE(125).
ENDIF.
ENDFORM. " DISPLAY-PARA


ALSO READ:

Net Salary Report In HR ABAP

* This program displays a grade-wise summary of salaries paid.
REPORT z_hr_py_net_salary NO STANDARD PAGE HEADING
LINE-SIZE 155
LINE-COUNT 65.


TABLES : pernr, " Standard Selections for HR Master Data Reporting
pcl1, " HR Cluster 1
pcl2. " HR Cluster 2

INFOTYPES : 0001, " Infotype 0001 (Org. Assignment)
0009. " Infotype 0009 (Bank Details)

INCLUDE : rpc2cd09, " Cluster Directory data definition
rpc2ca00, " Cluster CA Data-Definition
rpc2rx09, " Constants definition Payroll results
" country independent
rpppxd00, " Data definition buffer PCL1/PCL2
rpppxd10, " Common part buffer PCL1/PCL2
rpppxm00. " Buffer handling routine

* For Export and Import of Payroll Results
DATA: it_rgdir LIKE pc261 OCCURS 0 WITH HEADER LINE, " Cluster DIr.
gs_result TYPE pay99_result, " Str for payroll result:Intl.
gs_rt LIKE LINE OF gs_result-inter-rt. " RT Table

* Internal table to hold data
DATA : BEGIN OF it_data OCCURS 0,
werks TYPE p0001-werks, " Personnel Area
persk TYPE p0001-persk, " EE subgroup
emp(5) TYPE i, " Total no. of employees
gross LIKE pc207-betrg, " Amount from '/101'
pf LIKE pc207-betrg, " Amount from '/3F1'
vpf LIKE pc207-betrg, " Amount from '/3F2'
pfar LIKE pc207-betrg, " Amount from '/ZF5',
prtx LIKE pc207-betrg, " Amount from '/3P1'
esic LIKE pc207-betrg, " Amount from '/3E1'
inctx LIKE pc207-betrg, " Amount from '/460'
netsal LIKE pc207-betrg, " Amount from '/559'
END OF it_data.

* Internal table to hold final data
DATA : BEGIN OF it_final OCCURS 0,
row_num(5) TYPE n, " Row Number
werks(20), " Personnel Area Text
persk(20), " EE subgroup Text
emp(5) TYPE i, " Total no. of employees
gross LIKE pc207-betrg, " Amount from '/101'
pf LIKE pc207-betrg, " Amount from '/3F1'
vpf LIKE pc207-betrg, " Amount from '/3F2'
pfar LIKE pc207-betrg, " Amount from '/ZF5',
prtx LIKE pc207-betrg, " Amount from '/3P1'
esic LIKE pc207-betrg, " Amount from '/3E1'
inctx LIKE pc207-betrg, " Amount from '/460'
netsal LIKE pc207-betrg, " Amount from '/559'
END OF it_final.

* Internal table for Employee Subgroup text
DATA: it_t503t LIKE t503t OCCURS 0 WITH HEADER LINE.

* Internal table for Personnel Area text
DATA: BEGIN OF it_t500p OCCURS 0,
persa TYPE t500p-persa, " Personnel Area
name1 TYPE t500p-name1, " PA text
END OF it_t500p.

*--- TYPE POOLS( FOR ALV REPORTING )
TYPE-POOLS: slis.

DATA : it_fieldcat TYPE slis_t_fieldcat_alv, " Fieldcat
it_events TYPE slis_t_event, " Events
it_sort TYPE slis_t_sortinfo_alv, " Sorting
it_list_top_of_page TYPE slis_t_listheader, " Top Of Page
gs_variant LIKE disvariant, " To store Variant
v_repid LIKE sy-repid, " Program name
it_sp_group TYPE slis_t_sp_group_alv, " Grouping
gs_event TYPE slis_alv_event, " Events
gs_layout TYPE slis_layout_alv, " Layout
it_extab TYPE slis_t_extab, " FC Exclusion
it_list_top_of_list TYPE slis_t_listheader, " Top-of-list
v_count(5) TYPE n.

* Constants
CONSTANTS: c_relid LIKE pcl2-relid VALUE 'IN', " Area identification
* wage types
c_101(4) TYPE c VALUE '/101', " Gross salary
c_3f1(4) TYPE c VALUE '/3F1', " Provident Fund
c_3f2(4) TYPE c VALUE '/3F2', " Voluntary PF
c_3p1(4) TYPE c VALUE '/3P1', " Professional tax
c_zf5(4) TYPE c VALUE '/ZF5', " PF & VPF arrears
c_3e1(4) TYPE c VALUE '/3E1', " ESIC
c_460(4) TYPE c VALUE '/460', " Income Tax
c_559(4) TYPE c VALUE '/559', " Bank Transfer
c_560(4) TYPE c VALUE '/560', " Net Salary
* payment method
c_pm(1) TYPE c VALUE 'T'.
CONSTANTS: c_x(1) TYPE c VALUE 'X',
c_molga(2) TYPE c VALUE '40', " Country key
c_mastek(4) TYPE c VALUE 'MLTD', " Company
c_0(1) TYPE n VALUE '0',
c_1(1) TYPE c VALUE '1', " Emp Group
c_2(1) TYPE c VALUE '2',
c_lt01(4) TYPE c VALUE 'LT01', " Location
c_lt02(4) TYPE c VALUE 'LT02',
c_co(2) TYPE c VALUE 'CO',
c_h(1) TYPE c VALUE 'H',
* Payroll period - Months
c_01(2) TYPE c VALUE '01',
c_02(2) TYPE c VALUE '02',
c_03(2) TYPE c VALUE '03',
c_04(2) TYPE c VALUE '04',
c_05(2) TYPE c VALUE '05',
c_06(2) TYPE c VALUE '06',
c_07(2) TYPE c VALUE '07',
c_08(2) TYPE c VALUE '08',
c_09(2) TYPE c VALUE '09',
c_10(2) TYPE c VALUE '10',
c_11(2) TYPE c VALUE '11',
c_12(2) TYPE c VALUE '12',
c_up(4) TYPE c VALUE '&OUP',
c_dwn(4) TYPE c VALUE '&ODN',
c_flt(4) TYPE c VALUE '&ILT'.
*----------------------------------------------------------------------*
* Selection-screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-028.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
SELECTION-SCREEN COMMENT 1(13) text-029
FOR FIELD chk_off.
PARAMETER : chk_off AS CHECKBOX. " Off cycle only
SELECTION-SCREEN POSITION 25.
SELECTION-SCREEN COMMENT 20(12) text-030
FOR FIELD p_pytdt.
PARAMETER: p_pytdt TYPE sy-datum. " Payment date
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

*----------------------------------------------------------------------*
* Initialization
*----------------------------------------------------------------------*
INITIALIZATION.
* default values
pnpxabkr = c_01. "Payroll area 01:Monthly
pnpabkrs-low = c_01. "Payroll area 01:Monthly
APPEND pnpabkrs.
pnpbukrs-low = c_mastek. "Company Code MLTD
APPEND pnpbukrs.
* Assign report id to list display
v_repid = sy-repid.
*----------------------------------------------------------------------*
* At selection screen
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
* Validate selections
PERFORM validate_fields.

*----------------------------------------------------------------------*
* Start of Selection
*----------------------------------------------------------------------*
START-OF-SELECTION.
* Get text
PERFORM get_text.

GET pernr.
* Fetch Org Assignment details
PERFORM get_emp_details.
* get payment method
PERFORM payment_method.
* get amounts from RT ( Results table )
PERFORM get_data_rt.

***********************************************************************
* END-OF-SELECTION
***********************************************************************
END-OF-SELECTION.
* Sort final internal table
PERFORM sort_itab.
* Populating the field catalog
PERFORM fieldcat_init USING it_fieldcat[].
*-Calling the Function Module
PERFORM sort_build USING it_sort[].
* Populating the Header data
PERFORM list_head_buid USING it_list_top_of_list[].
*.Populating Events data
PERFORM get_events.
* List display
PERFORM alv_display TABLES it_final.
*&---------------------------------------------------------------------*
*& Form get_emp_details
*&---------------------------------------------------------------------*
* Fetch Personnel Area, EE group & EE subgroup
*----------------------------------------------------------------------*
FORM get_emp_details .
CLEAR it_data.
rp-provide-from-last p0001 space pn-begda pn-endda.
* process only for Employee Group 1 & 2
IF p0001-persg = c_1 OR "1:Active Employee
p0001-persg = c_2. "2:Consultant
ELSE.
REJECT.
ENDIF.
* process only for Employee Subgroup 'CO' in Employee Group 2
IF p0001-persg = c_2.
IF p0001-persk = c_co. "CO:Consultant
ELSE.
REJECT.
ENDIF.
ENDIF.
* assign count, personal area & employee subgroup
it_data-emp = v_count + 1.
it_data-werks = p0001-werks.
it_data-persk = p0001-persk.

ENDFORM. " get_emp_details
*&---------------------------------------------------------------------*
*& Form get_data_rt
*&---------------------------------------------------------------------*
* Populate waget type amounts to internal table
*----------------------------------------------------------------------*
FORM get_data_rt .

cd-key-pernr = pernr-pernr.
rp-init-buffer. " initialize buffer
rp-imp-c2-cd. " import cluster Directory

IF chk_off IS INITIAL.
* regular payroll runs
PERFORM fetch_regular_data.
ELSE.
PERFORM fetch_offcycle_data.
ENDIF.

IF NOT rgdir-seqnr IS INITIAL.
* read payroll result
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
clusterid = c_relid
employeenumber = pernr-pernr
sequencenumber = rgdir-seqnr
read_only_international = c_x
CHANGING
payroll_result = gs_result.

* Read RT
LOOP AT gs_result-inter-rt INTO gs_rt.
CASE gs_rt-lgart.
* Gross salary
WHEN c_101. "/101
it_data-gross = gs_rt-betrg.
* Provident Fund
WHEN c_3f1. "/3F1
it_data-pf = it_data-pf + gs_rt-betrg.
* Voluntary Provident Fund
WHEN c_3f2. "/3F2
it_data-vpf = it_data-vpf + gs_rt-betrg.
* PF & VPF arrears
WHEN c_zf5. "/ZF5
it_data-pfar = gs_rt-betrg.
* Professional tax
WHEN c_3p1. "/3P1
it_data-prtx = it_data-prtx + gs_rt-betrg.
* ESIC
WHEN c_3e1. "/3E1
it_data-esic = it_data-esic + gs_rt-betrg.
* Income tax
WHEN c_460. "/460
it_data-inctx = gs_rt-betrg.
ENDCASE.
* Net salary
IF p0009-zlsch = c_pm. "T
IF gs_rt-lgart = c_559. "/559:Bank Transfer Wage Type
it_data-netsal = gs_rt-betrg.
ENDIF.
ELSE.
IF gs_rt-lgart = c_560. "/560:Net Salary Wage Type
it_data-netsal = gs_rt-betrg.
ENDIF.
ENDIF.
ENDLOOP.
COLLECT it_data.
CLEAR it_data.
ENDIF.
ENDFORM. " get_data_rt
*&---------------------------------------------------------------------*
*& Form Payment_method
*&---------------------------------------------------------------------*
* get payment method from IT0009
*----------------------------------------------------------------------*
FORM payment_method.
rp-provide-from-last p0009 space pn-begda pn-endda.
ENDFORM. " Payment_method
*&---------------------------------------------------------------------*
*& Form sort_itab
*&---------------------------------------------------------------------*
* Sort data internal table
*----------------------------------------------------------------------*
FORM sort_itab.
DATA: l_count(5) TYPE i.

SORT it_data BY werks persk.
LOOP AT it_data.
CLEAR: it_t500p,it_t503t.
l_count = l_count + 1.
AT NEW werks.
CLEAR it_t500p.
READ TABLE it_t500p WITH KEY persa = it_data-werks BINARY SEARCH.
IF sy-subrc = 0.
it_final-row_num = l_count.
it_final-werks = it_data-werks.
it_final-persk = 'Mastek Ltd'(001).
it_final-emp = space.
it_final-gross = space.
it_final-pf = space.
it_final-vpf = space.
it_final-pfar = space.
it_final-prtx = space.
it_final-esic = space.
it_final-inctx = space.
it_final-netsal = space.
APPEND it_final.
CLEAR it_final.
l_count = l_count + 1.
it_final-row_num = l_count.
it_final-werks = it_data-werks.
it_final-persk = it_t500p-name1.
it_final-emp = space.
it_final-gross = space.
it_final-pf = space.
it_final-vpf = space.
it_final-pfar = space.
it_final-prtx = space.
it_final-esic = space.
it_final-inctx = space.
it_final-netsal = space.
APPEND it_final.
CLEAR it_final.
ENDIF.
ENDAT.

AT NEW persk.
READ TABLE it_t503t WITH KEY persk = it_data-persk BINARY SEARCH.
IF sy-subrc = 0.
it_final-persk = it_t503t-ptext.
ENDIF.
ENDAT.
IF NOT it_t503t-ptext IS INITIAL.
l_count = l_count + 1.
it_final-row_num = l_count.
it_final-werks = it_data-werks.
it_final-emp = it_data-emp.
it_final-gross = it_data-gross.
it_final-pf = it_data-pf.
it_final-vpf = it_data-vpf.
it_final-pfar = it_data-pfar.
it_final-prtx = it_data-prtx.
it_final-esic = it_data-esic.
it_final-inctx = it_data-inctx.
it_final-netsal = it_data-netsal.
APPEND it_final.
CLEAR it_final.
ENDIF.
ENDLOOP.
ENDFORM. " sort_itab
*&---------------------------------------------------------------------*
*& Form get_text
*&---------------------------------------------------------------------*
* Get text for Personnel Areas & Employee Subgroups
*----------------------------------------------------------------------*
FORM get_text.
*Personnel area
SELECT persa
name1
FROM t500p
INTO TABLE it_t500p
WHERE molga = c_molga "40:India
AND bukrs = c_mastek. "MLTD

SORT it_t500p BY persa.
*Employee Subgroups
SELECT * FROM t503t
INTO TABLE it_t503t
WHERE sprsl = sy-langu.

SORT it_t503t BY persk.
ENDFORM. " get_text
*&---------------------------------------------------------------------*
*& Form fieldcat_init
*&---------------------------------------------------------------------*
* Fill field catalog
*----------------------------------------------------------------------*
FORM fieldcat_init USING gt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv,
v_pos TYPE i VALUE 1.

PERFORM list_header USING v_pos 'WERKS' 'WERKS' ' ' ' '.
PERFORM list_header USING v_pos 'PERSK' 'PERSK' ' ' ' '.
PERFORM list_header USING v_pos 'EMP' 'EMP' ' ' ' '.
PERFORM list_header USING v_pos 'GROSS' 'GROSS' ' ' ' '.
PERFORM list_header USING v_pos 'PF' 'PF' ' ' ' '.
PERFORM list_header USING v_pos 'VPF' 'VPF' ' ' ' '.
PERFORM list_header USING v_pos 'PFAR' 'PFAR' ' ' ' '.
PERFORM list_header USING v_pos 'PRTX' 'PRTX' ' ' ' '.
PERFORM list_header USING v_pos 'ESIC' 'ESIC' ' ' ' '.
PERFORM list_header USING v_pos 'INCTX' 'INCTX' ' ' ' '.
PERFORM list_header USING v_pos 'NETSAL' 'NETSAL' ' ' ' '.

ENDFORM. " fieldcat_init
*&---------------------------------------------------------------------*
*& Form list_header
*&---------------------------------------------------------------------*
* List Header for ALV
*----------------------------------------------------------------------*
FORM list_header USING v_pos TYPE i
fieldname TYPE slis_fieldcat_alv-fieldname
ref_fieldname TYPE slis_fieldcat_alv-ref_fieldname
tabname TYPE slis_fieldcat_alv-tabname
key TYPE slis_fieldcat_alv-key.

DATA : ls_fieldcat TYPE slis_fieldcat_alv.

CLEAR ls_fieldcat.
ls_fieldcat-col_pos = v_pos.
ls_fieldcat-fieldname = fieldname.
ls_fieldcat-ref_fieldname = ref_fieldname.
ls_fieldcat-ref_tabname = tabname.
ls_fieldcat-key = key.

IF fieldname = 'ROW_NUM'.
ls_fieldcat-no_out = c_x.
ENDIF.

IF fieldname = 'WERKS'.
ls_fieldcat-tech = c_x.
ENDIF.

IF fieldname = 'PERSK'.
ls_fieldcat-seltext_s = 'DETAIL'(017).
ls_fieldcat-seltext_m = 'DETAIL'(017).
ls_fieldcat-seltext_l = 'DETAIL'(017).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-fix_column = c_x.
ENDIF.

IF fieldname = 'EMP'.
ls_fieldcat-seltext_s = 'TOTAL EMP.'(018).
ls_fieldcat-seltext_m = 'TOTAL EMP.'(018).
ls_fieldcat-seltext_l = 'TOTAL EMP.'(018).
ls_fieldcat-ddic_outputlen = '10'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'GROSS'.
ls_fieldcat-seltext_s = 'GROSS SALARY'(019).
ls_fieldcat-seltext_m = 'GROSS SALARY'(019).
ls_fieldcat-seltext_l = 'GROSS SALARY'(019).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'PF'.
ls_fieldcat-seltext_s = 'P.F.'(020).
ls_fieldcat-seltext_m = 'P.F.'(020).
ls_fieldcat-seltext_l = 'P.F.'(020).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'VPF'.
ls_fieldcat-seltext_s = 'V.P.F.'(021).
ls_fieldcat-seltext_m = 'V.P.F.'(021).
ls_fieldcat-seltext_l = 'V.P.F.'(021).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'PFAR'.
ls_fieldcat-seltext_s = 'PF/VPF Arrears'(033).
ls_fieldcat-seltext_m = 'PF/VPF Arrears'(033).
ls_fieldcat-seltext_l = 'PF/VPF Arrears'(033).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'PRTX'.
ls_fieldcat-seltext_s = 'PROF. TAX'(022).
ls_fieldcat-seltext_m = 'PROF. TAX'(022).
ls_fieldcat-seltext_l = 'PROF. TAX'(022).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'ESIC'.
ls_fieldcat-seltext_s = 'E.S.I.C.'(023).
ls_fieldcat-seltext_m = 'E.S.I.C.'(023).
ls_fieldcat-seltext_l = 'E.S.I.C.'(023).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'INCTX'.
ls_fieldcat-seltext_s = 'INCOME TAX'(024).
ls_fieldcat-seltext_m = 'INCOME TAX'(024).
ls_fieldcat-seltext_l = 'INCOME TAX'(024).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

IF fieldname = 'NETSAL'.
ls_fieldcat-seltext_s = 'NET SALARY'(025).
ls_fieldcat-seltext_m = 'NET SALARY'(025).
ls_fieldcat-seltext_l = 'NET SALARY'(025).
ls_fieldcat-ddic_outputlen = '15'.
ls_fieldcat-do_sum = c_x.
ls_fieldcat-no_zero = c_x.
ENDIF.

APPEND ls_fieldcat TO it_fieldcat.
v_pos = v_pos + 1.

ENDFORM. " list_header
*&---------------------------------------------------------------------*
*& Form get_events
*&---------------------------------------------------------------------*
* Subroutine to get events list
* ------------------------------------------------------------------*
FORM get_events.

*---To get Events list
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events.

READ TABLE it_events WITH KEY name = slis_ev_top_of_list
INTO gs_event.
IF sy-subrc = 0.
MOVE 'TOP_OF_LIST' TO gs_event-form.
APPEND gs_event TO it_events.
ENDIF.

ENDFORM. " get_events
*&---------------------------------------------------------------------*
*& Form alv_display
*&---------------------------------------------------------------------*
* Display list
*----------------------------------------------------------------------*
FORM alv_display TABLES i_itab STRUCTURE it_final.
* Layout settings( to display text in totals row )
gs_layout-totals_text = 'Grand Total'(026).
gs_layout-subtotals_text = 'Total'(027).
gs_layout-numc_sum = c_x.
* to exclude sort buttons
APPEND c_up TO it_extab. " '&OUP'
APPEND c_dwn TO it_extab. " '&ODN'
APPEND c_flt TO it_extab. " '&ILT'
*---Output of a simple list (single-line)
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
i_callback_program = v_repid
is_layout = gs_layout
it_fieldcat = it_fieldcat[]
it_excluding = it_extab[]
it_special_groups = it_sp_group[]
it_sort = it_sort[]
is_variant = gs_variant
it_events = it_events[]
TABLES
t_outtab = i_itab
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. " alv_display
*---------------------------------------------------------------------*
* FORM TOP_OF_LIST *
*---------------------------------------------------------------------*
* Description: This form is to call the Function Module *
* 'REUSE_ALV_COMMENTARY_WRITE' *
*---------------------------------------------------------------------*
FORM top_of_list.
*---List body comment block output
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_list_top_of_list.

ENDFORM. "top_of_page
*&---------------------------------------------------------------------*
*& Form list_head_buid
*&---------------------------------------------------------------------*
* Populate list header
*----------------------------------------------------------------------*
FORM list_head_buid USING lt_top_of_list
TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader,
lv_month(12),
lv_year(4),
lv_period(25),
lv_offdt(10).
* Company
ls_line-typ = c_h. " H
ls_line-key = ' '.
ls_line-info = 'MASTEK LTD.'(002).
APPEND ls_line TO lt_top_of_list.
CLEAR ls_line.

* Title of list
ls_line-typ = c_h. " H
ls_line-key = ' '.
ls_line-info = 'NET SALARY REPORT'(003).
APPEND ls_line TO lt_top_of_list.
CLEAR ls_line.

* if current period is selected,assign current month & year to
* other month & year for display in output
IF pnptimr9 = c_x.
pnppabrp = pnpdispp. " Current month
pnppabrj = pnpdispj. " Current Year
ENDIF.

* to display period in words
IF chk_off IS INITIAL.
CASE pnppabrp.
WHEN c_01. " 01
lv_month = 'APRIL'(004).
WHEN c_02. " 02
lv_month = 'MAY'(005).
WHEN c_03. " 03
lv_month = 'JUNE'(006).
WHEN c_04. " 04
lv_month = 'JULY'(007).
WHEN c_05. " 05
lv_month = 'AUGUST'(008).
WHEN c_06. " 06
lv_month = 'SEPTEMBER'(009).
WHEN c_07. " 07
lv_month = 'OCTOBER'(010).
WHEN c_08. " 08
lv_month = 'NOVEMBER'(011).
WHEN c_09. " 09
lv_month = 'DECEMBER'(012).
WHEN c_10. " 10
lv_month = 'JANUARY'(013).
WHEN c_11. " 11
lv_month = 'FEBRUARY'(014).
WHEN c_12. "12
lv_month = 'MARCH'(015).
ENDCASE.

lv_year = pnppabrj.
CONCATENATE 'SALARY FOR'(016) lv_month '-' lv_year INTO lv_period
SEPARATED BY space.
ELSE.
WRITE p_pytdt TO lv_offdt.
CONCATENATE 'Off-Cycle on:'(032) lv_offdt INTO lv_period
SEPARATED BY space.
ENDIF.
ls_line-typ = c_h.
ls_line-key = ' '.
ls_line-info = lv_period.
APPEND ls_line TO lt_top_of_list.
CLEAR ls_line.

ENDFORM. " list_head_buid
*&---------------------------------------------------------------------*
*& Form sort_build
*&---------------------------------------------------------------------*
* sort for display
*----------------------------------------------------------------------*
FORM sort_build USING p_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort LIKE LINE OF it_sort.

ls_sort-fieldname = 'WERKS'.
ls_sort-spos = c_1.
ls_sort-up = c_x.
ls_sort-obligatory = c_x.
ls_sort-subtot = c_x.
APPEND ls_sort TO p_sort.

ENDFORM. " sort_build
*&---------------------------------------------------------------------*
*& Form validate_fields
*&---------------------------------------------------------------------*
* If off-cycle is checked then payment date is mandatory
*----------------------------------------------------------------------*
FORM validate_fields.

IF chk_off IS NOT INITIAL.
IF p_pytdt IS INITIAL.
MESSAGE e034(zb) WITH text-031.
ENDIF.
ENDIF.

ENDFORM. " validate_fields
*&---------------------------------------------------------------------*
*& Form fetch_regular_data
*&---------------------------------------------------------------------*
* If off-cycle is not checked, get data of regular payroll runs
* ( do not consider retro & off-cycle )
*----------------------------------------------------------------------*
FORM fetch_regular_data.
CLEAR rgdir.
LOOP AT rgdir WHERE ipend <= pn-endda AND ipend >= pn-begda
AND void IS INITIAL
AND reversal IS INITIAL
AND ocrsn IS INITIAL
AND inocr IS INITIAL.
* original results => forperiod = inperiod
IF rgdir-fpper = rgdir-inper.
* assign emp no. & seq no. to rx-key
rx-key-pernr = pernr-pernr.
rx-key-seqno = rgdir-seqnr.
ENDIF.
ENDLOOP.

ENDFORM. " fetch_regular_data
*&---------------------------------------------------------------------*
*& Form fetch_offcycle_data
*&---------------------------------------------------------------------*
* If off-cycle is checked, get data of off-cycle runs only
*----------------------------------------------------------------------*
FORM fetch_offcycle_data.
CLEAR rgdir.
LOOP AT rgdir WHERE ipend <= pn-endda AND ipend >= pn-begda
AND void IS INITIAL
AND reversal IS INITIAL
AND ocrsn IS NOT INITIAL
AND paydt = p_pytdt.
* assign emp no. & seq no. to rx-key
rx-key-pernr = pernr-pernr.
rx-key-seqno = rgdir-seqnr.
ENDLOOP.
ENDFORM. " fetch_offcycle_data


ALSO READ:

- Cumulative Amount Report in HR ABAP.

- Use Of Time Macro rp-read-all-time-ity in HR ABAP.

- Cumulative List Of Absences For Company Code, Personnel Area & Personnel Subarea.

- Employee Data Using Function Module In HR ABAP.

- BDC For The Action Transfer Of Location In HR ABAP.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.