Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

REPORT zhr_master_data.

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

* Type pools

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

TYPE-POOLS: slis.

TABLES: pa0000,

ptrv_head.

TYPES : BEGIN OF ty_ptrv_head,

pernr TYPE ptrv_head-pernr,

reinr TYPE ptrv_head-reinr,

molga TYPE ptrv_head-molga,

morei TYPE ptrv_head-morei,

schem TYPE ptrv_head-schem,

kztkt TYPE ptrv_head-kztkt,

zort1 TYPE ptrv_head-zort1,

zland TYPE ptrv_head-zland,

datv1 TYPE ptrv_head-datv1,

uhrv1 TYPE ptrv_head-uhrv1,

datb1 TYPE ptrv_head-datb1,

uhrb1 TYPE ptrv_head-uhrb1,

request TYPE ptrv_head-request,

travel_plan TYPE ptrv_head-travel_plan,

expenses TYPE ptrv_head-expenses,

END OF ty_ptrv_head.

TYPES : BEGIN OF ty_ptrv_perio,

pernr TYPE ptrv_head-pernr,

reinr TYPE ptrv_head-reinr,

perio TYPE ptrv_perio-perio,

pdatv TYPE ptrv_perio-pdatv,

puhrv TYPE ptrv_perio-puhrv,

pdatb TYPE ptrv_perio-pdatb,

puhrb TYPE ptrv_perio-puhrb,

druck TYPE ptrv_perio-druck,

antrg TYPE ptrv_perio-antrg,

abrec TYPE ptrv_perio-abrec,

waers TYPE ptrv_perio-waers,

begp1 TYPE ptrv_perio-begp1,

endp1 TYPE ptrv_perio-endp1,

accdt TYPE ptrv_perio-accdt,

verpa TYPE ptrv_perio-verpa,

uebkz TYPE ptrv_perio-uebkz,

anuep TYPE ptrv_perio-anuep,

END OF ty_ptrv_perio.

TYPES : BEGIN OF ty_t005t,

land1 TYPE t005t-land1,

landx TYPE t005t-landx,

END OF ty_t005t.

TYPES : BEGIN OF ty_pa0002,

pernr TYPE pa0002-pernr,

vorna TYPE pa0002-vorna,

nachn TYPE pa0002-nachn,

gbdat TYPE pa0002-gbdat,

END OF ty_pa0002.

TYPES : BEGIN OF ty_t706t,

morei TYPE t706t-morei,

schem TYPE t706t-schem,

stext TYPE t706t-stext,

END OF ty_t706t.

TYPES : BEGIN OF ty_t706r,

morei TYPE t706r-morei,

kztkt TYPE t706r-kztkt,

tktxt TYPE t706r-tktxt,

END OF ty_t706r.

TYPES : BEGIN OF ty_final15,

pernr TYPE ptrv_head-pernr,

name TYPE char40,

reinr TYPE ptrv_head-reinr,

type TYPE char20,

molga TYPE ptrv_head-molga,

morei TYPE ptrv_head-morei,

schem TYPE ptrv_head-schem,

kztkt TYPE ptrv_head-kztkt,

zort1 TYPE ptrv_head-zort1,

zland TYPE ptrv_head-zland,

datv1 TYPE ptrv_head-datv1,

uhrv1 TYPE ptrv_head-uhrv1,

datb1 TYPE ptrv_head-datb1,

uhrb1 TYPE ptrv_head-uhrb1,

pdatv TYPE ptrv_perio-pdatv,

puhrv TYPE ptrv_perio-puhrv,

pdatb TYPE ptrv_perio-pdatb,

puhrb TYPE ptrv_perio-puhrb,

druck TYPE ptrv_perio-druck,

antrg TYPE ptrv_perio-antrg,

abrec TYPE ptrv_perio-abrec,

waers TYPE ptrv_perio-waers,

begp1 TYPE ptrv_perio-begp1,

endp1 TYPE ptrv_perio-endp1,

accdt TYPE ptrv_perio-accdt,

verpa TYPE ptrv_perio-verpa,

uebkz TYPE ptrv_perio-uebkz,

anuep TYPE ptrv_perio-anuep,

ramt TYPE ptrv_trips-sum_reimbu,

curr TYPE ptrv_trips-currency,

comp_code TYPE ptrv_scos-comp_code,

bus_area TYPE ptrv_scos-bus_area,

co_area TYPE ptrv_scos-co_area,

costcenter TYPE ptrv_scos-costcenter,

receiptno TYPE ptrv_srec-receiptno,

seqno TYPE ptrv_srec-seqno ,

ded_flag TYPE ptrv_srec-ded_flag,

paid_com TYPE ptrv_srec-paid_com,

exp_type TYPE ptrv_srec-exp_type,

rec_amount TYPE ptrv_srec-rec_amount,

rec_curr TYPE ptrv_srec-rec_curr,

rec_rate TYPE ptrv_srec-rec_rate,

loc_amount TYPE ptrv_srec-loc_amount,

loc_curr TYPE ptrv_srec-loc_curr,

tax_code TYPE ptrv_srec-tax_code,

rec_date TYPE ptrv_srec-rec_date,

shorttxt TYPE ptrv_srec-shorttxt,

above_limit TYPE ptrv_srec-above_limit,

paper_receipt TYPE ptrv_srec-paper_receipt,

receipt_ok TYPE ptrv_srec-receipt_ok,

addit_amnt TYPE ptrv_shdr-addit_amnt,

sum_reimbu TYPE ptrv_shdr-sum_reimbu,

sum_advanc TYPE ptrv_shdr-sum_advanc,

sum_payout TYPE ptrv_shdr-sum_payout,

sum_paidco TYPE ptrv_shdr-sum_paidco,

trip_total TYPE ptrv_shdr-trip_total,

pd_food TYPE ptrv_shdr-pd_food,

pd_housing TYPE ptrv_shdr-pd_housing,

pd_mileage TYPE ptrv_shdr-pd_mileage,

currency TYPE ptrv_shdr-currency,

m_total TYPE ptrv_shdr-m_total,

tripdur TYPE ptrv_shdr-tripdur,

txf_food TYPE ptrv_shdr-txf_food,

landx TYPE t005t-landx,

text1 TYPE char40,

text2 TYPE char40,

text3 TYPE char40,

text4 TYPE char40,

text5 TYPE char40,

stext TYPE char40,

END OF ty_final15.

DATA : it_final15 TYPE TABLE OF ty_final15 WITH HEADER LINE,

it_triphead TYPE TABLE OF ty_ptrv_head WITH HEADER LINE,

it_tripitem TYPE TABLE OF ty_ptrv_perio WITH HEADER LINE,

it_t706t TYPE TABLE OF ty_t706t WITH HEADER LINE,

it_t706r TYPE TABLE OF ty_t706r WITH HEADER LINE,

it_pa0002 TYPE TABLE OF ty_pa0002 WITH HEADER LINE,

it_ptrv_scos TYPE TABLE OF ptrv_scos WITH HEADER LINE,

it_ptrv_shdr TYPE TABLE OF ptrv_shdr WITH HEADER LINE,

it_ptrv_srec TYPE TABLE OF ptrv_srec WITH HEADER LINE,

it_val1 TYPE TABLE OF dd07v WITH HEADER LINE,

it_val2 TYPE TABLE OF dd07v WITH HEADER LINE,

it_val3 TYPE TABLE OF dd07v WITH HEADER LINE,

it_val4 TYPE TABLE OF dd07v WITH HEADER LINE,

it_fieldcat15 TYPE slis_t_fieldcat_alv,

wa_fieldcat LIKE LINE OF it_fieldcat15,

wa_layout TYPE slis_layout_alv.

SELECT-OPTIONS: s_pernr FOR pa0000-pernr,

s_reinr FOR ptrv_head-reinr,

s_schem FOR ptrv_head-schem,

s_zland FOR ptrv_head-zland,

s_datv1 FOR ptrv_head-datv1,

s_uhrv1 FOR ptrv_head-uhrv1,

s_datb1 FOR ptrv_head-datb1,

s_uhrb1 FOR ptrv_head-uhrb1.

PARAMETERS: p_begda TYPE pa0001-begda DEFAULT '18000101' ,

p_endda TYPE pa0001-endda DEFAULT '99991231' .

START-OF-SELECTION..

SELECT pernr

reinr

molga

morei

schem

kztkt

zort1

zland

datv1

uhrv1

datb1

uhrb1

request

travel_plan

expenses

FROM ptrv_head

INTO TABLE it_triphead

WHERE pernr IN s_pernr.

IF sy-subrc = 0.

SELECT pernr

reinr

perio

pdatv

puhrv

pdatb

puhrb

druck

antrg

abrec

waers

begp1

endp1

accdt

verpa

uebkz

anuep

FROM ptrv_perio

INTO TABLE it_tripitem

FOR ALL ENTRIES IN it_triphead

WHERE pernr = it_triphead-pernr

AND reinr = it_triphead-reinr.

SELECT * FROM ptrv_scos

INTO TABLE it_ptrv_scos

FOR ALL ENTRIES IN it_tripitem

WHERE pernr = it_tripitem-pernr

AND reinr = it_tripitem-reinr

AND perio = it_tripitem-perio.

SELECT * FROM ptrv_shdr

INTO TABLE it_ptrv_shdr

FOR ALL ENTRIES IN it_tripitem

WHERE pernr = it_tripitem-pernr

AND reinr = it_tripitem-reinr

AND perio = it_tripitem-perio.

SELECT * FROM ptrv_srec

INTO TABLE it_ptrv_srec

FOR ALL ENTRIES IN it_tripitem

WHERE pernr = it_tripitem-pernr

AND reinr = it_tripitem-reinr

AND perio = it_tripitem-perio.

SELECT morei

kztkt

tktxt

FROM t706r

INTO TABLE it_t706r

FOR ALL ENTRIES IN it_triphead

WHERE morei = '98'

AND kztkt = it_triphead-kztkt

AND spras = sy-langu.

SELECT morei

schem

stext

FROM t706t

INTO TABLE it_t706t

FOR ALL ENTRIES IN it_triphead

WHERE morei = '98'

AND schem = it_triphead-schem

AND spras = sy-langu.

select pernr

vorna

nachn

gbdat

from pa0002

into table it_pa0002

for all entries in it_triphead

where pernr = it_triphead-pernr

and begda le p_endda

and endda ge p_begda.

if sy-subrc = 0.

sort it_pa0002 by pernr.

endif.

ENDIF.

END-OF-SELECTION.

CALL FUNCTION 'GET_DOMAIN_VALUES'

EXPORTING

domname = 'P_PRINT'

text = 'X'

TABLES

values_tab = it_val1.

CALL FUNCTION 'GET_DOMAIN_VALUES'

EXPORTING

domname = 'ANTRG'

text = 'X'

TABLES

values_tab = it_val2.

CALL FUNCTION 'GET_DOMAIN_VALUES'

EXPORTING

domname = 'ABREC'

text = 'X'

TABLES

values_tab = it_val3.

LOOP AT it_triphead.

MOVE-CORRESPONDING it_triphead TO it_final15.

READ TABLE it_tripitem WITH KEY pernr = it_triphead-pernr

reinr = it_triphead-reinr.

IF sy-subrc = 0.

MOVE-CORRESPONDING it_tripitem TO it_final15.

CALL FUNCTION 'PTRV_GET_REIMBURSEMENT_AMOUNT'

EXPORTING

employeenumber = it_tripitem-pernr

tripnumber = it_tripitem-reinr

period = it_tripitem-perio

IMPORTING

reimbursement_amount = it_final15-ramt

currency = it_final15-curr

EXCEPTIONS

no_entry_in_ptrv_shdr = 1

error_in_currency_conversion = 2

trip_prior_to_userprefs = 3

OTHERS = 4.

READ TABLE it_ptrv_srec WITH KEY pernr = it_tripitem-pernr

reinr = it_tripitem-reinr

perio = it_tripitem-perio.

IF sy-subrc = 0.

MOVE-CORRESPONDING it_ptrv_srec TO it_final15.

ENDIF.

READ TABLE it_ptrv_shdr WITH KEY pernr = it_tripitem-pernr

reinr = it_tripitem-reinr

perio = it_tripitem-perio.

IF sy-subrc = 0.

MOVE-CORRESPONDING it_ptrv_shdr TO it_final15.

ENDIF.

READ TABLE it_ptrv_scos WITH KEY pernr = it_tripitem-pernr

reinr = it_tripitem-reinr

perio = it_tripitem-perio.

IF sy-subrc = 0.

MOVE-CORRESPONDING it_ptrv_scos TO it_final15.

ENDIF.

ENDIF.

SELECT SINGLE landx

FROM t005t

INTO it_final15-landx

WHERE land1 = it_triphead-zland

AND spras = sy-langu.

READ TABLE it_val1 WITH KEY domvalue_l = it_final15-druck.

IF sy-subrc = 0.

it_final15-text1 = it_val1-ddtext.

ENDIF.

READ TABLE it_val2 WITH KEY domvalue_l = it_final15-antrg.

IF sy-subrc = 0.

it_final15-text2 = it_val2-ddtext.

ENDIF.

READ TABLE it_val3 WITH KEY domvalue_l = it_final15-abrec.

IF sy-subrc = 0.

it_final15-text3 = it_val3-ddtext.

ENDIF.

READ TABLE it_t706r WITH KEY kztkt = it_triphead-kztkt.

IF sy-subrc = 0.

it_final15-text4 = it_t706r-tktxt.

ENDIF.

IF it_triphead-request = 'X'.

it_final15-type = 'Travel Request'.

ELSEIF it_triphead-travel_plan = 'X'.

it_final15-type = 'Travel Plan'.

ELSEIF it_triphead-expenses = 'X'.

it_final15-type = 'Travel Expense'.

ENDIF.

READ TABLE it_pa0002 WITH KEY pernr = it_triphead-pernr.

IF sy-subrc = 0.

CONCATENATE it_pa0002-vorna it_pa0002-nachn

INTO it_final15-name SEPARATED BY space.

ENDIF.

READ TABLE it_t706t WITH KEY schem = it_triphead-schem.

IF sy-subrc = 0.

it_final15-stext = it_t706t-stext.

ENDIF.

APPEND it_final15.

CLEAR it_final15.

ENDLOOP.

perform build_fcat using 'PERNR' 'Emp Number' ''.

perform build_fcat using 'NAME' 'Employee Name' ''.

perform build_fcat using 'REINR' 'Trip Number' ''.

perform build_fcat using 'TYPE' 'Type' ''.

perform build_fcat using 'STEXT' 'Schema Text' ''.

perform build_fcat using 'TEXT4' 'Activity Text' ''.

perform build_fcat using 'ZORT1' 'Location' ''.

perform build_fcat using 'LANDX' 'Country Name' ''.

perform build_fcat using 'DATV1' 'Beginning Date' ''.

perform build_fcat using 'UHRV1' 'Beginning Time' ''.

perform build_fcat using 'DATB1' 'End Date' ''.

perform build_fcat using 'UHRB1' 'End Time ' ''.

perform build_fcat using 'TEXT1' 'Print Status' ''.

perform build_fcat using 'TEXT2' 'Approval Status' ''.

perform build_fcat using 'TEXT3' 'Settlement Status' ''.

perform build_fcat using 'BEGP1' 'Start of Settl Period' ''.

perform build_fcat using 'ENDP1' 'End of Settlt Period' ''.

perform build_fcat using 'ACCDT' 'Trip Settl Date' ''.

perform build_fcat using 'ANUEP' 'Overnight Stayed' ''.

perform build_fcat using 'COMP_CODE' 'Company Code' ''.

perform build_fcat using 'BUS_AREA' 'Business Area' ''.

perform build_fcat using 'CO_AREA' 'Controlling Area' ''.

perform build_fcat using 'COSTCENTER' 'Cost Center' ''.

perform build_fcat using 'CURR' 'Currency' ''.

perform build_fcat using 'ADDIT_AMNT' 'Additional Amount' ''.

perform build_fcat using 'SUM_REIMBU' 'Reimbursement Amount' ''.

perform build_fcat using 'SUM_ADVANC' 'Total Advances for a Trip' ''.

perform build_fcat using 'SUM_PAYOUT' 'Payment Amount' ''.

perform build_fcat using 'SUM_PAIDCO' 'Travel Expenses Paid by Company' ''.

perform build_fcat using 'PD_FOOD' 'Meals per Diems' ''.

perform build_fcat using 'PD_HOUSING' 'Accommodations per Diems' ''.

perform build_fcat using 'TRIPDUR' 'Trip Duration' ''.

perform build_fcat using 'TRIP_TOTAL' 'Total Cost of Trip' ''.

wa_layout-zebra = 'X'.

wa_layout-colwidth_optimize = 'X'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

i_callback_top_of_page = 'TOP_OF_PAGE'

is_layout = wa_layout

it_fieldcat = it_fieldcat15

tables

t_outtab = it_final15.

*&---------------------------------------------------------------------*

*& Form BUILD_FCAT

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

FORM build_fcat USING value(p_0107)

value(p_0108)

value(p_0109).

wa_fieldcat-fieldname = p_0107.

wa_fieldcat-reptext_ddic = p_0108.

wa_fieldcat-do_sum = p_0109.

APPEND wa_fieldcat TO it_fieldcat15.

CLEAR wa_fieldcat.

ENDFORM. "build_fcat

  • No labels