SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Staff by Post code report



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Oct 13, 2007 1:00 pm    Post subject: Staff by Post code report Reply with quote

Uses Logical database 'PNP'(entered in program attributes) to retrieve personnel data based on postcode.
Data is then displayed as an ALV GRID report.

Code:
*.......................................................................
*: Report:  ZP_POSTCODE                                                :
*:                                                                     :
*: Author:  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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.