Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

help please

Former Member
0 Likes
1,052

Hi all,

Can anybody answer my questions please which regarding HR report programing?

Suppose I want to display employee master data:

1. Do I declare PERNR as atable or as a node?

2. Do I need to declare the selection screen block?

3.Do I need some includes?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

p291102
Active Contributor
0 Likes
1,011

Hi,

I am sending the code for HR model report. Kindly go through it.

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

Thanks,

Shankar

10 REPLIES 10
Read only

Former Member
0 Likes
1,011

Refer this

http://www.sapdevelopment.co.uk/hr/hrhome.htm

Reward if this helps.

Read only

Former Member
0 Likes
1,011

Hi ,

You will logical database as PNP so no selection screen and includes required because you will get from standard and you table pernr as Tables.

Please reward if useful.

Read only

p291102
Active Contributor
0 Likes
1,012

Hi,

I am sending the code for HR model report. Kindly go through it.

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

Thanks,

Shankar

Read only

Former Member
0 Likes
1,011

Hi

If you are using Logical database(se36),then you have to declare infotype number and you dont need to design selection-screen.

But fif you are getting data from tables without using LDB,then you have to design selection screen and table name.

Pernr(personel number) is the field name ,not table name and it is in pa001,pa008 etc .

Every infotype will be associated with one table

if infotype is 0001,then table is pa001.

Thanks

Read only

0 Likes
1,011

Thanks.... suppose I have more than one table pa0000 , pa0001,... and I want to declare pernr which table do I use to refer to pernr, do I do the following:

TYPES: BEGIN OF report,

<b>PERNR TYPE p0000-PERNR,</b> ENAME TYPE p0001-EMNAM,

BEGDA TYPE p0000-BEGDA,

ENDDA TYPE p0000-ENDDA,

END OF report.

Thanks

Read only

0 Likes
1,011

for declaration you can refer to any table, it won't create any prob.

Read only

0 Likes
1,011

the declaration u made is perfect.

u can declare pernr as p0000-pernr.

Read only

0 Likes
1,011

refer this demo code -



*&---------------------------------------------------------------------*
*& Report  ZPPL_PREVEMPLOYERS                                          *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZPPL_PREVEMPLOYERS   message-id rp
                             line-size 250
                             line-count 65.

*Program logic :- This Report is used to Download all the Previous
* Employer (IT0023) records of the employees
* **********************************************************************

*eject
*&---------------------------------------------------------------------*
*& Tables and Infotypes                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
tables: pernr.

infotypes: 0000,
           0001,
           0002,
           0023.

*eject
*&---------------------------------------------------------------------*
*& Constants                                                           *
*&                                                                     *
*&---------------------------------------------------------------------*
constants: c_1(1)       type c               value '1'   ,
           c_3(1)       type c               value '3'   ,
           c_i(1)       type c               value 'I'   ,
           c_x(1)       type c               value 'X'   ,
           c_eq(2)      type c               value 'EQ'  ,
           c_pl03       like p0001-werks     value 'PL03'.


*eject
*&---------------------------------------------------------------------*
*& Selection-Screen                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
parameters: p_file  like rlgrap-filename default 'C:TempABC.xls',
            p_test  as checkbox default c_x               .

*eject
*&---------------------------------------------------------------------*
*& Internal tables                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
* Internal Table for Output
data: begin of t_output occurs 0    ,
       pernr like pernr-pernr       ,
       nachn like p0002-nachn       ,
       vorna like p0002-vorna       ,
       orgeh_stext like p1000-stext ,
       plans_stext like p1000-stext ,
       begda like p0023-begda       ,
       endda like p0023-endda       ,
       land1 like p0023-land1       ,
       arbgb like p0023-arbgb       ,
       ort01 like p0023-ort01   .
data: end of t_output           .

*eject
*&---------------------------------------------------------------------*
*& Variables                                                           *
*&                                                                     *
*&---------------------------------------------------------------------*

data: o_stext like p1000-stext,
      p_stext like p1000-stext.

*eject
*&---------------------------------------------------------------------*
*& Initialization                                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
Initialization.
* Initialize Selection-Screen values
  perform init_selction_screen.

*eject
*&---------------------------------------------------------------------*
*& AT Selection-screen                                                 *
*&                                                                     *
*&---------------------------------------------------------------------*
at selection-screen .
* Check if Test run selected, download file name should be entered
  if p_test is initial.  "
    if p_file is initial.
      message e016 with 'Please enter file name'
                        'specifying complete path'.
    endif.
  endif.

*eject
*&---------------------------------------------------------------------*
*& Start-of Selection                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
Start-of-selection.

get pernr.

  clear t_output.

* Read Infotype 0
  rp-provide-from-last p0000 space pn-begda pn-endda.
  check pnp-sw-found eq c_1.
* Check if employee is active
  check p0000-stat2 in pnpstat2.      "pernr Active

* Read Infotype 1
  rp-provide-from-last p0001 space pn-begda pn-endda.
  check pnp-sw-found eq c_1.

* check if employee belongs to PL03
  check p0001-werks in pnpwerks.  "belongs to PL03
* Check if emp belongs to Active Group
  check p0001-persg in pnppersg.

* Read Infotype 2
  rp-provide-from-last p0002 space pn-begda pn-endda.
  check pnp-sw-found eq c_1.

* Read Org Unit Text.
CALL FUNCTION 'HR_READ_FOREIGN_OBJECT_TEXT'
     EXPORTING
          OTYPE                   = 'O'
          objid                   = p0001-orgeh
          begda                   = p0001-begda
          endda                   = p0001-endda
          reference_date          = p0001-begda
     IMPORTING
          object_text             = o_stext
      EXCEPTIONS
          nothing_found           = 1
          wrong_objecttype        = 2
          missing_costcenter_data = 3
          missing_object_id       = 4
          OTHERS                  = 5.

*Read Position Text.
CALL FUNCTION 'HR_READ_FOREIGN_OBJECT_TEXT'
     EXPORTING
          OTYPE                   = 'S'
          objid                   = p0001-plans
          begda                   = p0001-begda
          endda                   = p0001-endda
          reference_date          = p0001-begda
     IMPORTING
          object_text             = p_stext
     EXCEPTIONS
          nothing_found           = 1
          wrong_objecttype        = 2
          missing_costcenter_data = 3
          missing_object_id       = 4
          OTHERS                  = 5.

* Gather all the required information related to the emp
  move: pernr-pernr to t_output-pernr,
        o_stext to t_output-orgeh_stext,
        p_stext to t_output-plans_stext,
        p0002-nachn to t_output-nachn,
        p0002-vorna to t_output-vorna.

* Gather previous Employee details
  loop at p0023.
    move-corresponding p0023 to t_output.
    append t_output.
  endloop.

*eject
*&---------------------------------------------------------------------*
*& End-of Selection                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
end-of-selection.

  perform print_report.

* Downlaod the file
  if not t_output[] is initial.
    if p_test eq space.
      perform download_file.
    endif.
  else.
    write: 'No records selected' color col_negative.
  endif.

*eject
*&---------------------------------------------------------------------*
*& Top-of-page                                                         *
*&                                                                     *
*&---------------------------------------------------------------------*
Top-of-page.

* Print Header
  perform print_header.

*eject
*&---------------------------------------------------------------------*
*&      Form  download_file
*&---------------------------------------------------------------------*
* Description :
*----------------------------------------------------------------------*
FORM download_file .

  DATA: full_file_name    TYPE string,
        z_akt_filesize    TYPE i     .

  full_file_name = p_file.

*  download table into file on presentation server
  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename                = full_file_name
      filetype                = 'DAT'
      NO_AUTH_CHECK           = c_x
      codepage                = '1160'
    IMPORTING
      FILELENGTH              = z_akt_filesize
    CHANGING
      data_tab                = t_output[]
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      not_supported_by_gui    = 22
      error_no_gui            = 23
      OTHERS                  = 24.

*
  IF  sy-subrc               NE        0.
    MESSAGE e016 WITH 'Download-Error; RC:' sy-subrc.
  ENDIF.


ENDFORM.                    " download_file

*eject
*&---------------------------------------------------------------------*
*&      Form  print_report
*&---------------------------------------------------------------------*
*Description:
*----------------------------------------------------------------------*
FORM print_report .
  data: i       type i,
        w_count type i.
  sort t_output.

* Print the report
  loop at t_output.
    i = sy-tabix mod 2.
    if i eq 0.
      format color col_normal intensified on.
    else.
      format color col_normal intensified off.
    endif.

    write:/1     t_output-pernr          ,
           10     t_output-vorna(25)     ,
           35    t_output-nachn(25)      ,
           61   t_output-orgeh_stext     ,
           102  t_output-plans_stext     ,
           143  t_output-begda           ,
           154   t_output-endda          ,
           168   t_output-land1          ,
           178   t_output-arbgb(40)      ,
           219   t_output-ort01          ,
           249   space              .

  endloop.

  uline.

  Describe table t_output lines w_count.
  Skip 2.

  Write:/ 'Total No of Records Downloaded: ' color col_total,
          w_count.

ENDFORM.                    " print_report

*eject
*&---------------------------------------------------------------------*
*&      Form  print_header
*&---------------------------------------------------------------------*
*Description:
*----------------------------------------------------------------------*
FORM print_header .

  skip 1.
  Uline.

  format Intensified on color col_heading.


  write:/1   'Pers. #'        ,
         10   'Last Name'     ,
         35   'First Name'    ,
         61   'Org Unit'      ,
         102  'Position'      ,
         143  'Beg Date'      ,
        154   'End Date'      ,
        168   'Cntry Key'     ,
        178   'Prev Employer' ,
        219  'City'           ,
        249   space          .


  format intensified off color off.

  uline.


ENDFORM.                    " print_header

*eject
*&---------------------------------------------------------------------*
*&      Form  init_selction_screen
*&---------------------------------------------------------------------*
*Description:
*----------------------------------------------------------------------*
FORM init_selction_screen .

  refresh: pnpwerks,
           pnppersg,
           pnpstat2.
  clear:   pnpwerks,
           pnppersg,
           pnpstat2.

  pnpwerks-sign   = c_i.
  pnpwerks-option = c_EQ.
  pnpwerks-low    = c_pl03.
  append pnpwerks.

  pnppersg-sign   = c_i.
  pnppersg-option = c_EQ.
  pnppersg-low    = c_1.
  append pnppersg.

  pnpstat2-sign   = c_i.
  pnpstat2-option = c_EQ.
  pnpstat2-low    = c_3.
  append pnpstat2.


ENDFORM.                    " init_selction_screen

Read only

0 Likes
1,011

Thank you....... I'm being asked to select all the employees such that stat2 = any number lets say 6...... so do I specify it when I declaring as the following:

TYPES: BEGIN OF report,

PERNR TYPE p0000-PERNR,

STAT2 TYPE p0000-STAT2 = '6',

ENAME TYPE p0001-EMNAM,

BEGDA TYPE p0000-BEGDA,

ENDDA TYPE p0000-ENDDA,

END OF report.

Thanks.

Read only

0 Likes
1,011

u shud refer the perform init_selction_screen in my code which i gave above.

there i have appended values for stat2 = 3.

and then in get pernr i m checking this.

and u shud reward answers which r solving ur problem.

if u can go thru and understand my code then u need not to ask further questions like this.

amit