‎2007 Feb 13 7:27 AM
what is the eaxact diff nbetween normal abap and hr abap.
could u all clarify me.
‎2007 Feb 13 7:28 AM
‎2007 Feb 13 8:08 AM
refer below links -
for HR ABAP programs u have to specify the logical databsae name in the attributes of the program for e.g u can use PNP logical database.
Here is one demo code for understnading the use of PNP logical database -
REPORT ZPXX_DUPLICATES_PNP message-id rp
line-size 250
line-count 65 .
tables: pernr.
infotypes: 0000,
0001,
0002,
0105.
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_bt(2) type c value 'BT',
xfield value 'X'.
parameters: p_file like rlgrap-filename default 'C:TempPERNRS_LIST.xls',
p_test as checkbox default c_x.
data: SEQNR like p0001-SEQNR.
Data : begin of itab occurs 0,
pernr like pernr-pernr,
endda like p0001-endda,
SEQNR like p0001-SEQNR,
end of itab.
Data : begin of pernr_list occurs 0,
pernr like pernr-pernr,
end of pernr_list.
*data: itab1 like standard table of itab with header line.
Initialization.
perform init_selction_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.
Start-of-selection.
get pernr.
clear itab.
* 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 emp belongs to Active Group
check p0001-persg in pnppersg.
seqnr = 0.
loop at p0001 where endda = '99991231'.
seqnr = seqnr + 1.
move: p0001-pernr to itab-pernr,
p0001-endda to itab-endda,
seqnr to itab-seqnr.
append itab.
endloop.
end-of-selection.
perform find_duplicates.
perform display_data.
* Downlaod the file
if not PERNR_LIST[] is initial.
if p_test eq space.
perform download_file.
endif.
else.
write: 'No records selected' color col_negative.
endif.
*if not itab[] is initial.
* if p_test eq space.
* perform download_file.
* endif.
* else.
* write: 'No records selected' color col_negative.
* endif.
Top-of-page.
* Print Header
perform print_header.
*&---------------------------------------------------------------------*
*& Form init_selction_screen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM init_selction_screen .
refresh: pnpwerks,
pnppersg,
pnpstat2.
clear: pnpwerks,
pnppersg,
pnpstat2.
* pnpwerks-sign = c_i.
* pnpwerks-option = c_BT.
** 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
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .
data: i type i,
w_count type i.
sort pernr_list.
* Print the report
loop at pernr_list.
i = sy-tabix mod 2.
if i eq 0.
format color col_normal intensified on.
else.
format color col_normal intensified off.
endif.
write:/2 pernr_list-pernr.
endloop.
uline.
Describe table pernr_list lines w_count.
Skip 2.
if p_test = space and not PERNR_LIST[] is initial.
Write:/ 'Total No of Records Downloaded: ' color col_total,
w_count.
endif.
ENDFORM. " display_data
*&---------------------------------------------------------------------*
*& Form download_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
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 = pernr_list[]
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
*&---------------------------------------------------------------------*
*& Form find_duplicates
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM find_duplicates .
FIELD-SYMBOLS: <itab> LIKE LINE OF itab,
<itab_old> LIKE LINE OF itab.
data: tabix like sy-tabix.
sort itab by pernr endda seqnr.
LOOP AT itab ASSIGNING <itab>.
IF <itab>-seqnr = 2.
tabix = sy-tabix - 1.
READ TABLE itab ASSIGNING <itab_old> INDEX tabix.
IF sy-subrc = 0.
pernr_list-pernr = <itab_old>-pernr.
append pernr_list.
CLEAR: <itab_old>-pernr,
<itab_old>-endda,
<itab_old>-seqnr.
ENDIF.
* msg = xfield.
ENDIF.
IF <itab>-seqnr > 1.
DELETE itab.
ENDIF.
ENDLOOP.
ENDFORM. " find_duplicates
*&---------------------------------------------------------------------*
*& Form print_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM print_header .
skip 1.
Uline.
format Intensified on color col_heading.
write:/1 'Personal Number'.
format intensified off color off.
uline.
ENDFORM. " print_header
and the same program can be written in ABAP as follows -
REPORT ZPXX_DUPLICATES_NO_PNP message-id rp
line-size 250
line-count 65 .
parameters: p_file like rlgrap-filename default 'C:TempPERNRS_LIST.xls',
p_test as checkbox default 'X',
p_es like p0000-STAT2 default '3',
p_eg like p0001-PERSG default '1'.
Data : begin of itab occurs 0,
pernr like pernr-pernr,
endda like p0001-endda,
end of itab.
Data : begin of pernr_list occurs 0,
pernr like pernr-pernr,
end of pernr_list.
data : itab1 type range of itab WITH HEADER LINE,
itab2 like standard table of itab with header line.
DATA: DUPCOUNT TYPE I,
ORICOUNT TYPE I,
NEWCOUNT TYPE I,
TOTALHIT TYPE I VALUE 0.
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.
Start-of-selection.
select pernr endda into corresponding fields of table itab
from pa0001
where endda = '99991231' and persg = p_eg and
pernr in ( select pernr from pa0000 where STAT2 = p_es
and endda = '99991231' ).
if sy-subrc = 0.
sort itab by pernr.
itab2[] = itab[].
DESCRIBE TABLE ITAB LINES ORICOUNT.
DELETE ADJACENT DUPLICATES FROM ITAB2.
DESCRIBE TABLE ITAB2 LINES NEWCOUNT.
DUPCOUNT = ORICOUNT - NEWCOUNT.
ITAB1-SIGN = 'I'.
ITAB1-OPTION = 'EQ'.
ITAB1-LOW = '00000000'.
APPEND ITAB1.
loop at itab.
IF NOT ITAB-PERNR IN ITAB1.
ITAB1-SIGN = 'I'.
ITAB1-OPTION = 'EQ'.
ITAB1-LOW = ITAB-PERNR.
APPEND ITAB1.
ELSE.
pernr_list-pernr = itab-pernr.
append pernr_list.
TOTALHIT = TOTALHIT + 1.
IF DUPCOUNT EQ TOTALHIT.
EXIT.
ENDIF.
ENDIF.
endloop.
else.
MESSAGE e016 WITH 'Database Read Failed'.
endif.
end-of-selection.
perform display_data.
* Downlaod the file
if not pernr_list[] is initial.
if p_test eq space.
perform download_file.
endif.
else.
write: 'No records selected' color col_negative.
endif.
Top-of-page.
* Print Header
perform print_header.
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .
data: i type i,
w_count type i.
sort pernr_list.
* Print the report
loop at pernr_list.
i = sy-tabix mod 2.
if i eq 0.
format color col_normal intensified on.
else.
format color col_normal intensified off.
endif.
write:/2 pernr_list-pernr.
endloop.
uline.
Describe table pernr_list lines w_count.
Skip 2.
if p_test = space and not PERNR_LIST[] is initial.
Write:/ 'Total No of Records Downloaded: ' color col_total,
w_count.
endif.
ENDFORM. " display_data
*&---------------------------------------------------------------------*
*& Form download_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
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'
codepage = '1160'
IMPORTING
FILELENGTH = z_akt_filesize
CHANGING
data_tab = pernr_list[]
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
*&---------------------------------------------------------------------*
*& Form print_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM print_header .
skip 1.
Uline.
format Intensified on color col_heading.
write:/1 'Personal Number'.
format intensified off color off.
uline.
ENDFORM. " print_header
amit