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

need help

Former Member
0 Likes
778

HI THIS IS THE LOGIC........need to create prog in ALV .

Need help.

Pre-requisite

Document Number should exist in the database.

Program Logic/Pseudo Code:

Logic would be as under:

1. A new screen is to be prepared. Input would be the followings:

a. Company code

b. Posting Date (From – To)

2. Select all BELNR (Accounting Document Numbers) from table BSAK where BLART is either KR or RE.

3. For all selected BELNR get only those BELNR which are available in the table BSIS where HKONT is 27611002.

4. For these BELNR get all the line items from the table BSIS where BSCHL is equal to 40. Get the report in the following format.

5. All the above mentioned searches to be made for company code 1000.

Report Layout (For Reports):-----

BSIS-BLDAT, BSIS-BUDAT, BSIS-BELNR, BSIS-HKONT, BSIS-WRBTR, BSAK-AUGDT, BSAK-LIFNR, BSAK-AUGBL

THANKS.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
654

Hi Sam,

Use the following program as a templet and write u r own select statements.

REPORT ZHEXRUK_EXPENSE_ENTERTAIN NO STANDARD PAGE HEADING

LINE-SIZE 220 LINE-COUNT 65

MESSAGE-ID zukh.

  • Definition of Cluster TE

INCLUDE rpc1te00.

************************************************************************

  • Table Declarations

************************************************************************

tables : bkpf,

ska1.

************************************************************************

  • Type Declarations

************************************************************************

type-pools : slis.

************************************************************************

  • Structure Declarations

************************************************************************

  • To Hold GL Account Details

data: begin of x_bsis_bsas,

bukrs like bsis-bukrs,

hkont like bsis-hkont,

zuonr like bsis-zuonr,

gjahr like bsis-gjahr,

belnr like bsis-belnr,

buzei like bsis-buzei,

budat like bsis-budat,

blart like bsis-blart,

waers like bsis-waers,

dmbtr like bsis-dmbtr,

wrbtr like bsis-wrbtr,

sgtxt like bsis-sgtxt,

prctr like bsis-prctr,

shkzg like bsis-shkzg,

end of x_bsis_bsas.

  • To Hold Header details of Accounting Docs

data : begin of x_bkpf,

bukrs like bkpf-bukrs,

belnr like bkpf-belnr,

gjahr like bkpf-gjahr,

blart like bkpf-blart,

budat like bkpf-budat,

bktxt like bkpf-bktxt,

end of x_bkpf.

  • To hold Item details of the Accounting Docs

data : begin of x_bseg,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

buzei like bseg-buzei,

dmbtr like bseg-dmbtr,

zuonr like bseg-zuonr,

xref1 like bseg-xref1,

xref2 like bseg-xref2,

xref3 like bseg-xref3,

shkzg like bseg-shkzg,

bschl like bseg-bschl,

end of x_bseg.

  • To hold Trip numbers

data : begin of x_trip,

reinr like ptrv_srec-reinr,

end of x_trip.

  • To hold details of Standard Accounts Table

data : begin of x_t030,

ktopl like t030-ktopl, "Chart of accounts

komok like t030-komok, "Account Modification

konts like T030-konts, "GL Account No

kont1 like t706k-kont1, "Symbolic account assignment for trip

end of x_t030.

  • To hold details of Initial Account Assignment

data : begin of x_t706k,

morei like t706k-morei, "Trip provision variant

lgart like t706k-lgart, "Wage type

kont1 like t706k-kont1, "Symbolic account assignment for trip

"costs

end of x_t706k.

  • To hold Trip Expense Types: Assignment of Wage Types

data : begin of x_t706b4,

morei like t706b4-morei, "Trip provision variant

spkzl like t706b4-spkzl, "Travel expense type

lgarl like t706b4-lgarl, "First wage type

end of x_t706b4.

  • To hold Trip Expense Types

data : begin of x_t706b1,

morei like t706b4-morei, "Trip provision variant

spkzl like t706b1-spkzl, "Wage type

end of x_t706b1.

  • To hold Trip Statistics - Receipts

data : begin of x_ptrv_srec,

pernr like ptrv_srec-pernr, "Personal Number

reinr like ptrv_srec-reinr, "Trip Number

perio like ptrv_srec-perio, "Period

end of x_ptrv_srec.

  • To hold Creditor Determination via Personnel Number Entry

data : begin of x_ptrv_kredp,

pernr like ptrv_kredp-pernr, "Personal Number

lifnr like ptrv_kredp-lifnr, "Account number of vendor

end of x_ptrv_kredp.

  • To hold Final Output

data : begin of x_finaltab,

hkont like bsis-hkont, "GL Account No

sgtxt like bsis-sgtxt, "Line item Description

belnr like bsis-belnr, "Account No

blart like bsis-blart, "Account Type

budat like bsis-budat, "Posting Date

prctr like bsis-prctr, "Profit Center

wrbtr like bsis-wrbtr, "Amount

waers like bsis-waers, "Currency

xref2 type i, "UK Partners

xref1 type i, "UK Staff

xref3 type i, "Others

reinr like ptrv_srec-reinr, "Trip Number

bktxt like bkpf-bktxt, "Filling No

pernr like ptrv_srec-pernr, "Personal Number

lifnr like ptrv_kredp-lifnr,"Vendor Account Number

end of x_finaltab.

  • ------------------------------------------------------------------ *

  • INTERNAL TABLES.

  • ------------------------------------------------------------------ *

  • Table to collect GL Account Details(Open Items)

data : begin of it_bsis occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis.

data : begin of it_bsis_sa occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_sa.

  • Table to collect GL Account Details(Closed Items)

data : begin of it_bsas occurs 0.

include structure x_bsis_bsas.

data : end of it_bsas.

data : begin of it_bsas_sa occurs 0.

include structure x_bsis_bsas.

data : end of it_bsas_sa.

  • Table to collect GL Account Details(Open & Closed Items)

data : begin of it_bsis_bsas occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_bsas.

data : begin of it_bsis_bsas_sa occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_bsas_sa.

  • Table to collect Header details of Accounting Doc

data : begin of it_bkpf occurs 0.

include structure x_bkpf.

data : end of it_bkpf.

  • Table to hold Line item details of Accouting Doc

data : begin of it_bseg occurs 0.

include structure x_bseg.

data : end of it_bseg.

  • Table to hold Trip numbers

data : begin of it_trip occurs 0.

include structure x_trip.

data : end of it_trip.

  • Table to collect details of Standard Accounts Table

data : begin of it_t030 occurs 0.

include structure x_t030.

data : end of it_t030.

  • Table to collect details of Initial Account Assignment

data : begin of it_t706k occurs 0.

include structure x_t706k.

data : end of it_t706k.

  • Table to collect Trip Expense Types: Assignment of Wage Types

data : begin of it_t706b4 occurs 0.

include structure x_t706b4.

data : end of it_t706b4.

  • Table to collect Trip Expense Types

data : begin of it_t706b1 occurs 0.

include structure x_t706b1.

data : end of it_t706b1.

  • Table to collect Trip Statistics - Receipts

data : begin of it_ptrv_srec occurs 0.

include structure x_ptrv_srec.

data : end of it_ptrv_srec.

  • Table to collect Creditor Determination via Personnel Number Entry

data : begin of it_ptrv_kredp occurs 0.

include structure x_ptrv_kredp.

data : end of it_ptrv_kredp.

  • To hold Final Output

data : begin of it_finaltab occurs 0.

include structure x_finaltab.

data : end of it_finaltab.

  • Internal table to collect the key data for the cluster tbl

DATA: BEGIN OF it_keytab OCCURS 0.

INCLUDE STRUCTURE ptp00.

DATA: hdvrs LIKE ptrv_perio-hdvrs,

END OF it_keytab.

  • Table to collect Trip details

data : begin of it_trip_sum occurs 0.

include structure it_keytab.

data : n_stf(3) type c,

n_ptn(3) type c,

n_gst(3) type c,

end of it_trip_sum.

data : begin of it_ptrv_head occurs 0,

pernr like ptrv_head-pernr,

reinr like ptrv_head-reinr,

end of it_ptrv_head.

**Tables declaration for ALV Output*********************

  • Internal Table to trap the events

DATA: IT_EVENTcat TYPE SLIS_T_EVENT.

*Internal Table to hold the field Catalogue for ALV

DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

  • Interbal table to hold Header details of the Output

DATA: it_heading TYPE slis_t_listheader,

it_heading1 type slis_t_listheader.

  • it_print type slis_print_alv.

data: w_percentage(3) type n,

w_keytab_count(6) type n,

w_old_percent(3) type n,

w_progress_text(75),

w_track(1).

  • ------------------------------------------------------------------ *

  • CONSTANTS

  • ------------------------------------------------------------------ *

DATA : c_z001 like ska1-ktopl value 'Z001',

c_s4 like bsis-blart value 'S4',

c_morei like t706k-morei value '08',

c_pr04x like t706b1-pr04x value 'Z',

c_44(2) TYPE C value '44',

c_status TYPE slis_formname VALUE 'STATUS',

c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

c_gb02 like bkpf-bukrs value 'GB02'.

  • ------------------------------------------------------------------ *

  • GLOBAL VARIABLES

  • ------------------------------------------------------------------ *

data : g_gjahr like bkpf-gjahr,

g_dmbtr like bsis-dmbtr,

g_repid like sy-repid.

  • ------------------------------------------------------------------ *

  • RANGE TABLES.

  • ------------------------------------------------------------------ *

ranges : r_exp_type for t706b4-spkzl.

************************************************************************

  • Selection Screen Parameters

*

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_hkont FOR ska1-saknr,

s_budat for bkpf-budat.

SELECTION-SCREEN END OF BLOCK b1.

************************************************************************

  • AT SELECTION-SCREEN

************************************************************************

AT SELECTION-SCREEN.

  • To validate dates in selection screen

PERFORM sub_validate_gl_accounts.

  • Get Fiscal Year

perform sub_get_fiscal_year.

************************************************************************

  • START-OF-SELECTION

************************************************************************

START-OF-SELECTION.

  • To collect GL Account details for Open & Closed items

perform sub_select_gl_details.

  • To collect the expense types

perform sub_select_expense_type.

  • To get FI DOC details

perform sub_select_fi_details.

  • To get the trip details

perform sub_get_trip_details.

  • To build the final output table

perform sub_build_finaltab.

  • To display the output in ALV

perform sub_disp_finaltab.

&----


*& Form sub_validate_gl_accounts

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_validate_gl_accounts.

select single * from ska1 where ktopl = c_z001

and saknr in s_hkont.

if sy-subrc ne 0.

message e097(zukh).

endif.

endform. " sub_validate_gl_accounts

&----


*& Form sub_select_gl_details

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_select_gl_details.

data : begin of it_bsis_local occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_local.

data : begin of it_bsas_local occurs 0.

include structure x_bsis_bsas.

data : end of it_bsas_local.

data : l_augbl like bsis-augbl,

l_augdt like bsis-augdt.

w_percentage = 0.

w_progress_text = 'Selecting GL Open Items...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

refresh: it_bsis_local,

it_bsis,

it_bsas_local,

it_bsas,

it_bsis_bsas,

it_bsis_sa,

it_bsas_sa,

it_bsis_bsas_sa.

  • To get the GL Account details of all the open items with in the

  • selection screen

select bukrs

hkont

zuonr

gjahr

belnr

buzei

budat

blart

waers

dmbtr

wrbtr

sgtxt

prctr

shkzg

from bsis into corresponding fields of table it_bsis_local

where bukrs eq c_gb02

and hkont in s_hkont

and augdt = l_augdt

and augbl = l_augbl

and gjahr = g_gjahr.

if not it_bsis_local[] is initial.

sort it_bsis_local by budat blart.

loop at it_bsis_local where budat in s_budat

and blart ne c_s4.

if it_bsis_local-blart eq 'SA'.

move-corresponding it_bsis_local to it_bsis_sa.

append it_bsis_sa.

clear it_bsis_sa.

else.

move-corresponding it_bsis_local to it_bsis.

append it_bsis.

clear it_bsis.

endif.

endloop.

endif.

w_percentage = 0.

w_progress_text = 'Selecting GL Cleared Items...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

select bukrs

hkont

zuonr

gjahr

belnr

buzei

budat

blart

waers

dmbtr

wrbtr

sgtxt

prctr

shkzg

from bsas into corresponding fields of table it_bsas_local

where bukrs eq c_gb02

and hkont in s_hkont

and gjahr = g_gjahr.

if not it_bsas_local[] is initial.

sort it_bsas_local by budat blart.

loop at it_bsas_local where budat in s_budat

and blart ne 'S4'.

if it_bsas_local-blart eq 'SA'.

move-corresponding it_bsas_local to it_bsas_sa.

append it_bsas_sa.

clear it_bsas_sa.

else.

move-corresponding it_bsas_local to it_bsas.

append it_bsas.

clear it_bsas.

endif.

endloop.

endif.

if not it_bsis[] is initial or not it_bsas[] is initial

or not it_bsis_sa[] is initial or not it_bsas_sa[] is initial.

it_bsis_bsas[] = it_bsis[].

append lines of it_bsas to it_bsis_bsas.

it_bsis_bsas_sa[] = it_bsis_sa[].

append lines of it_bsas_sa to it_bsis_bsas_sa.

else.

message e053(zukh).

endif.

endform. " sub_select_gl_details

&----


*& Form sub_select_expense_type

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_select_expense_type.

w_percentage = 0.

w_progress_text = 'Selecting Expense Types...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

refresh: it_t030,

it_t706k,

it_t706b4,

it_t706b1.

  • To build account modification field for the following GL Accounts

select komok from t030 into corresponding fields of table it_t030

where ktopl = c_z001

and konts in s_hkont.

sort it_t030 by komok.

delete adjacent duplicates from it_t030 comparing komok.

  • To build Symbolic account assignment for trip

loop at it_t030.

concatenate '' it_t030-komok1(2) into it_t030-kont1.

modify it_t030.

endloop.

  • To get wage types

select lgart from t706k into corresponding fields of table it_t706k

for all entries in it_t030

where morei = c_morei

and kont1 = it_t030-kont1.

sort it_t706k by lgart.

delete adjacent duplicates from it_t706k comparing lgart.

  • To get the Expense type

select spkzl from t706b4 into corresponding fields of table it_t706b4

for all entries in it_t706k

where morei = c_morei

and lgarl = it_t706k-lgart.

sort it_t706b4 by spkzl.

delete adjacent duplicates from it_t706b4 comparing spkzl.

  • To get expense type with line of expense in weekly report

select spkzl from t706b1 into corresponding fields of table it_t706b1

for all entries in it_t706b4

where morei = c_morei

and spkzl = it_t706b4-spkzl

and pr04x = c_pr04x.

loop at it_t706b4.

read table it_t706b1 with key spkzl = it_t706b4-spkzl.

if sy-subrc = 0.

delete it_t706b4.

clear it_t706b4.

endif.

endloop.

endform. " sub_select_expense_type

&----


*& Form sub_select_fi_details

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_select_fi_details.

data : begin of it_bseg_local occurs 0.

include structure x_bseg.

data : end of it_bseg_local.

w_percentage = 0.

w_progress_text = 'Selecting FI Details - step 1...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

refresh: it_bseg_local,

it_bseg,

it_bkpf.

if not it_bsis_bsas_sa[] is initial.

sort it_bsis_bsas_sa by bukrs belnr gjahr.

  • Select SA type documents to determine if employee vendor related

select bukrs

belnr

gjahr

from bseg into corresponding fields of table it_bseg_local

for all entries in it_bsis_bsas_sa

where bukrs = it_bsis_bsas_sa-bukrs

and belnr = it_bsis_bsas_sa-belnr

and gjahr = it_bsis_bsas_sa-gjahr

and bschl in ('21', '31').

loop at it_bsis_bsas_sa.

read table it_bseg_local with key bukrs = it_bsis_bsas_sa-bukrs

belnr = it_bsis_bsas_sa-belnr

gjahr = it_bsis_bsas_sa-gjahr.

if sy-subrc ne 0.

delete it_bsis_bsas_sa.

continue.

endif.

endloop.

if not it_bsis_bsas_sa[] is initial.

append lines of it_bsis_bsas_sa to it_bsis_bsas.

endif.

endif.

refresh: it_bseg_local,

it_bsis_bsas_sa.

sort it_bsis_bsas by bukrs belnr gjahr.

  • To collect the item details

select bukrs

belnr

gjahr

buzei

dmbtr

zuonr

xref1

xref2

xref3

shkzg

bschl

from bseg into corresponding fields of table it_bseg

for all entries in it_bsis_bsas

where bukrs = it_bsis_bsas-bukrs

and belnr = it_bsis_bsas-belnr

and gjahr = it_bsis_bsas-gjahr

and buzei = it_bsis_bsas-buzei.

sort it_bseg by bukrs belnr gjahr.

  • To collect all the trip records

loop at it_bseg.

if it_bseg-shkzg = 'S'.

it_bseg-dmbtr = it_bseg-dmbtr * -1.

modify it_bseg transporting dmbtr.

endif.

if it_bseg-zuonr+0(2) = c_44.

it_trip-reinr = it_bseg-zuonr+0(10).

append it_trip.

endif.

endloop.

w_percentage = 0.

w_progress_text = 'Selecting FI Details - step 2...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

it_bseg_local[] = it_bseg[].

delete adjacent duplicates from it_bseg_local comparing belnr.

  • To get the header details

select bukrs

belnr

gjahr

blart

budat

bktxt

  • from zukex_bkpf into corresponding fields of table it_bkpf

from bkpf into corresponding fields of table it_bkpf

for all entries in it_bseg_local

where bukrs = it_bseg_local-bukrs

and belnr = it_bseg_local-belnr

and gjahr = it_bseg_local-gjahr.

endform. " sub_select_fi_details

&----


*& Form sub_get_trip_details

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_get_trip_details.

data : it_ptrv_srec_local like it_ptrv_srec occurs 0 with header line.

data : l_n_stf(10) type c, " Variable to hold UK staff

l_n_ptn(10) type c, " Variable to hold UK partners

l_n_gst(10) type c. " Variable to hold others

  • To build range table for the expense types

loop at it_t706b4.

r_exp_type-sign = 'I'.

r_exp_type-option = 'EQ'.

r_exp_type-low = it_t706b4-spkzl.

append r_exp_type.

endloop.

  • To get the personal number for the trips

sort it_trip by reinr.

delete adjacent duplicates from it_trip comparing reinr.

select pernr

reinr

from ptrv_head into corresponding fields of table it_ptrv_head

for all entries in it_trip

where reinr = it_trip-reinr.

select pernr

reinr

from ptrv_srec into corresponding fields of table it_ptrv_srec

for all entries in it_ptrv_head

where pernr = it_ptrv_head-pernr

and reinr = it_ptrv_head-reinr

and EXP_TYPE in r_exp_type.

it_ptrv_srec_local[] = it_ptrv_srec[].

sort it_ptrv_srec_local by pernr.

delete adjacent duplicates from it_ptrv_srec_local comparing pernr.

w_percentage = 0.

w_progress_text = 'Selecting Expense Trip Details...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

  • To get vendor account number for the personal data

select pernr

lifnr

from ptrv_kredp into corresponding fields of table

it_ptrv_kredp for all entries in it_ptrv_srec_local

where pernr = it_ptrv_srec_local-pernr.

  • To build the key table for the cluster

select pernr

reinr

perio

pdvrs

from ptrv_perio into corresponding fields of table it_keytab

for all entries in it_ptrv_srec

where pernr = it_ptrv_srec-pernr

and reinr = it_ptrv_srec-reinr

and perio = it_ptrv_srec-perio.

CHECK NOT it_keytab[] IS INITIAL.

SORT it_keytab BY pernr "Personnel No

reinr "Trip No

perio "Number of trip period

pdvrs ASCENDING. "Seq no. of period

**---- Eliminate anything that is not the lowest version on the trip

*

  • DELETE ADJACENT DUPLICATES FROM it_keytab COMPARING pernr

  • reinr.

clear: w_percentage,

w_old_percent.

w_progress_text = 'Processing Expense Details...'.

describe table it_keytab lines w_keytab_count.

loop at it_keytab.

w_percentage = sy-tabix / w_keytab_count * 100.

if w_percentage ne w_old_percent.

PERFORM sapgui_progress using w_percentage w_progress_text.

w_old_percent = w_percentage.

endif.

ON CHANGE OF IT_KEYTAB-REINR.

*Populate the table TE-KEY for retrieving data from the cluster table

MOVE-CORRESPONDING it_keytab TO te-key.

IMPORT te-version TO ote-version

exbel "Additional receipt information

beleg "Indiv.recpts

FROM DATABASE pcl1(te)

ID te-key.

check sy-subrc = 0.

delete beleg where not spkzl in r_exp_type.

loop at exbel.

read table beleg with key belnr = exbel-belnr.

if sy-subrc = 0.

l_n_stf = l_n_stf + exbel-n_stf.

l_n_ptn = l_n_ptn + exbel-n_ptn.

l_n_gst = l_n_gst + exbel-n_gst.

endif.

endloop.

move-corresponding it_keytab to it_trip_sum.

condense: l_n_stf, l_n_ptn, l_n_gst.

it_trip_sum-n_stf = l_n_stf.

it_trip_sum-n_ptn = l_n_ptn.

it_trip_sum-n_gst = l_n_gst.

append it_trip_sum.

clear : it_trip_sum, l_n_stf, l_n_ptn, l_n_gst.

endon.

endloop.

endform. " sub_get_trip_details

&----


*& Form sub_build_finaltab

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_build_finaltab.

data : l_wrbtr like bsis-wrbtr,

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005 .

l_finaltab-xref1 type i ,

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

l_reinr like bseg-zuonr.

data: l_1st_belnr like bseg-belnr,

l_1st_buzei like bseg-buzei.

clear : g_dmbtr.

sort it_trip_sum by reinr.

sort it_ptrv_kredp by pernr.

sort it_bseg by bukrs belnr gjahr buzei.

sort it_bsis_bsas by bukrs belnr gjahr.

sort it_ptrv_head by reinr.

sort it_trip_sum by reinr.

sort it_bkpf by bukrs belnr gjahr.

clear: w_percentage,

w_old_percent.

w_progress_text = 'Building Output Table...'.

describe table it_bseg lines w_keytab_count.

refresh: it_finaltab.

delete adjacent duplicates from it_bseg

comparing bukrs belnr gjahr buzei.

clear: l_1st_belnr,

l_1st_buzei.

loop at it_bseg.

clear it_finaltab.

w_percentage = sy-tabix / w_keytab_count * 100.

if w_percentage ne w_old_percent.

PERFORM sapgui_progress using w_percentage w_progress_text.

w_old_percent = w_percentage.

endif.

read table it_bkpf with key bukrs = it_bseg-bukrs

belnr = it_bseg-belnr

gjahr = it_bseg-gjahr

BINARY SEARCH.

if sy-subrc = 0 .

it_finaltab-bktxt = it_bkpf-bktxt.

endif.

if it_bseg-belnr ne l_1st_belnr.

l_1st_belnr = it_bseg-belnr.

l_1st_buzei = it_bseg-buzei.

endif.

if it_bseg-buzei ne l_1st_buzei.

continue.

endif.

loop at it_bsis_bsas where bukrs = it_bseg-bukrs

and belnr = it_bseg-belnr

and gjahr = it_bseg-gjahr.

  • and buzei = it_bseg-buzei.

if it_bsis_bsas-shkzg = 'H'.

it_bsis_bsas-wrbtr = it_bsis_bsas-wrbtr * -1.

endif.

if it_bsis_bsas-blart ne 'S2'.

it_finaltab-hkont = it_bsis_bsas-hkont.

it_finaltab-sgtxt = it_bsis_bsas-sgtxt.

it_finaltab-belnr = it_bsis_bsas-belnr.

it_finaltab-blart = it_bsis_bsas-blart.

it_finaltab-budat = it_bsis_bsas-budat.

it_finaltab-prctr = it_bsis_bsas-prctr.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005.

  • it_finaltab-waers = it_bsis_bsas-waers.

it_finaltab-waers = 'GBP'.

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

if it_bseg-zuonr+0(2) ne c_44.

perform set_attendee_value using it_bseg-xref1

it_finaltab-xref1.

perform set_attendee_value using it_bseg-xref2

it_finaltab-xref2.

perform set_attendee_value using it_bseg-xref3

it_finaltab-xref3.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005.

if it_finaltab-blart = 'KR' .

clear : l_finaltab-xref1 .

l_finaltab-xref1 = it_finaltab-xref1 .

it_finaltab-xref1 = it_finaltab-xref2 .

it_finaltab-xref2 = l_finaltab-xref1 .

  • it_finaltab-waers = 'GBP'.

endif .

*

  • it_finaltab-wrbtr = it_bsis_bsas-wrbtr.

it_finaltab-wrbtr = it_bsis_bsas-dmbtr.

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

if not it_finaltab-wrbtr is initial.

append it_finaltab.

endif.

clear it_finaltab.

else.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005 .

  • l_wrbtr = l_wrbtr + it_bsis_bsas-wrbtr.

l_wrbtr = l_wrbtr + it_bsis_bsas-dmbtr.

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

it_finaltab-wrbtr = l_wrbtr.

read table it_ptrv_head with

key reinr = it_bseg-zuonr+0(10)

BINARY SEARCH.

it_finaltab-reinr = it_ptrv_head-reinr.

it_finaltab-pernr = it_ptrv_head-pernr.

read table it_ptrv_kredp with key pernr = it_ptrv_head-pernr.

if sy-subrc = 0.

it_finaltab-lifnr = it_ptrv_kredp-lifnr.

endif.

read table it_trip_sum with key reinr = it_bseg-zuonr+0(10)

BINARY SEARCH.

if sy-subrc = 0.

perform set_attendee_value using it_trip_sum-n_stf

it_finaltab-xref1.

perform set_attendee_value using it_trip_sum-n_ptn

it_finaltab-xref2.

perform set_attendee_value using it_trip_sum-n_gst

it_finaltab-xref3.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005.

if it_finaltab-blart = 'KR' .

clear : l_finaltab-xref1 .

l_finaltab-xref1 = it_finaltab-xref1 .

it_finaltab-xref1 = it_finaltab-xref2 .

it_finaltab-xref2 = l_finaltab-xref1 .

  • it_finaltab-waers = 'GBP'.

endif .

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

endif.

at end of zuonr.

if not it_finaltab-wrbtr is initial.

append it_finaltab.

endif.

clear it_finaltab.

clear l_wrbtr.

endat.

endif.

else.

g_dmbtr = g_dmbtr + it_bsis_bsas-dmbtr.

endif.

endloop.

endloop.

ENDFORM. " sub_build_finaltab

&----


*& Form sub_disp_finaltab

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_disp_finaltab.

g_repid = sy-repid.

  • Building of Fieldcatalog

PERFORM sub_initialize_fieldcat USING it_fieldcat[].

  • Building of Events

PERFORM sub_build_eventcat USING it_eventcat[].

  • Building of Header for the basic list.

PERFORM sub_build_comment USING it_heading[].

  • Build the details for end-of-page

  • perform sub_build_end_of_page using it_heading1[].

  • PERFORM sub_PRINT_BUILD USING it_PRINT.

  • it_print_alv-reserve_lines = 4.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_pf_status_set = c_status

it_fieldcat = it_fieldcat

it_events = it_eventcat[]

  • is_print = it_print

TABLES

t_outtab = it_finaltab

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

&----


*& Form sub_initialize_fieldcat

&----


  • text

----


  • -->P_IT_FIELDCAT[] text

----


FORM sub_initialize_fieldcat using it_fieldcat TYPE slis_t_fieldcat_alv.

DATA: l_fieldcat TYPE slis_fieldcat_alv.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '1'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'HKONT'.

l_fieldcat-seltext_l = 'GL ACCOUNT'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '12'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '2'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'SGTXT'.

l_fieldcat-seltext_l = 'Line Item Description'.

l_fieldcat-intlen = '35'.

l_fieldcat-outputlen = '35'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '3'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BELNR'.

l_fieldcat-seltext_l = 'Document Number'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '4'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BLART'.

l_fieldcat-seltext_l = 'Document Type'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '5'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BUDAT'.

l_fieldcat-seltext_l = 'Posting Date'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '6'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'PRCTR'.

l_fieldcat-seltext_l = 'Profit Center'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '7'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'WRBTR'.

l_fieldcat-seltext_l = 'Amount'.

l_fieldcat-do_sum = 'X'.

l_fieldcat-intlen = '16'.

l_fieldcat-outputlen = '16'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '8'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'WAERS'.

l_fieldcat-seltext_l = 'Currency'.

l_fieldcat-intlen = '05'.

l_fieldcat-outputlen = '15'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '9'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'XREF2'.

l_fieldcat-seltext_l = 'UK Partners'.

l_fieldcat-do_sum = 'X'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '10'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'XREF1'.

l_fieldcat-seltext_l = 'UK Staff'.

l_fieldcat-do_sum = 'X'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '11'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'XREF3'.

l_fieldcat-seltext_l = 'Others'.

l_fieldcat-do_sum = 'X'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '12'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'REINR'.

l_fieldcat-seltext_l = 'Trip No'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '13'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BKTXT'.

l_fieldcat-seltext_l = 'Filling No'.

l_fieldcat-intlen = '25'.

l_fieldcat-outputlen = '25'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '14'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'PERNR'.

l_fieldcat-seltext_l = 'Personal Number'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '15'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '15'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'LIFNR'.

l_fieldcat-seltext_l = 'Vendor'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '15'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

ENDFORM. " sub_initialize_fieldcat

&----


*& Form sub_build_eventcat

&----


  • text

----


  • -->P_IT_EVENTCAT[] text

----


FORM sub_build_eventcat USING p_events TYPE slis_t_event.

DATA : l_events TYPE slis_alv_event,

l_event_list TYPE slis_t_event.

CLEAR l_events.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = l_event_list

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc = 0.

  • CLEAR P_EVENTS.

READ TABLE l_event_list WITH KEY

name = slis_ev_top_of_page INTO l_events.

IF sy-subrc = 0.

MOVE c_formname_top_of_page TO l_events-form.

APPEND l_events TO p_events.

ENDIF.

  • READ TABLE l_event_list WITH KEY

  • name = slis_ev_end_of_page INTO l_events.

  • IF sy-subrc = 0.

  • MOVE c_formname_end_of_page TO l_events-form.

  • APPEND l_events TO p_events.

  • ENDIF.

ENDIF.

ENDFORM. " sub_build_eventcat

----


  • FORM STATUS *

----


  • This form is used to set the PF status that is built for basic list

----


  • --> EXTAB *

----


FORM status using g_extab TYPE slis_t_extab .

SET PF-STATUS 'DETAILS3'.

ENDFORM.

----


  • FORM TOP_OF_PAGE *

----


  • This form is executed when ever the top-of-page event is called.

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_heading[].

ENDFORM.

*----


    • FORM END_OF_PAGE *

*----


    • This form is executed when ever the top-of-page event is called.

*----


*FORM end_of_page.

*

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • it_list_commentary = it_heading1[].

*

*ENDFORM.

&----


*& Form sub_build_comment

&----


  • text

----


  • -->P_IT_HEADING[] text

----


FORM sub_build_comment USING p_heading TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader,

l_date_time(20) type c.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = 'Print Date / Time : '.

concatenate sy-datum6(2) ':' sy-datum4(2) ':' sy-datum+0(4) '/'

sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit+4(2) into

l_date_time.

ls_line-info = l_date_time.

append ls_line to p_heading.

CLEAR ls_line.

ls_line-typ = 'H'.

  • LS_LINE-KEY: not used for this type

ls_line-info+30(30) = text-002.

APPEND ls_line TO p_heading.

CLEAR ls_line.

CLEAR: ls_line.

ls_line-typ = 'S'.

ls_line-key = text-003.

if s_hkont-low ne space and s_hkont-high ne space.

concatenate s_hkont-low 'to' s_hkont-high into ls_line-info.

else.

ls_line-info = s_hkont-low.

endif.

append ls_line to p_heading.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-004.

concatenate s_budat-low6(2) '.' s_budat-low4(2) '.'

s_budat-low+0(4) into ls_line-info.

append ls_line to p_heading.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-005.

concatenate s_budat-high6(2) '.' s_budat-high4(2) '.'

s_budat-high+0(4) into ls_line-info.

append ls_line to p_heading.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-006.

ls_line-info = g_dmbtr.

append ls_line to p_heading.

clear ls_line.

ENDFORM. " sub_build_comment

&----


*& Form sub_build_End_of_page

&----


  • text

----


  • -->P_IT_HEADING1[] text

----


*FORM sub_build_end_of_page USING p_heading TYPE slis_t_listheader.

  • DATA: ls_line TYPE slis_listheader,

  • v_dmbtr(20) type c.

*

  • ls_line-typ = 'H'.

  • ls_line-key = text-006.

  • loop at it_bseg.

  • read table it_bsis_bsas with key bukrs = it_bseg-bukrs

  • belnr = it_bseg-belnr

  • gjahr = it_bseg-gjahr

  • buzei = it_bseg-buzei

  • blart = 'S2'.

  • if sy-subrc ne 0.

  • v_dmbtr = v_dmbtr + it_bsis_bsas-dmbtr.

  • endif.

  • endloop.

  • ls_line-info = v_dmbtr.

  • append ls_line to p_heading.

  • clear ls_line.

*ENDFORM. " sub_build_End_of_page

&----


*& Form sub_PRINT_BUILD

&----


  • text

----


  • -->P_IT_PRINT text

----


*FORM sub_PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.

  • LS_PRINT-PRINT = ' '. "P_PRINT. "PRINT IMMEDIATE

  • LS_PRINT-NO_PRINT_SELINFOS = ' '."P_NOSINF. "NO SELECTION INFO

  • LS_PRINT-NO_COVERPAGE = ' '."P_NOCOVE. "NO COVER PAGE

  • LS_PRINT-NO_NEW_PAGE = ' '."P_NONEWP.

  • LS_PRINT-NO_PRINT_LISTINFOS = ' '. "p_NOLINF. "NO PRINT LIST INFO

  • LS_PRINT-RESERVE_LINES = 6 ."P_RESERV

*ENDFORM. " sub_PRINT_BUILD

&----


*& Form sub_get_fiscal_year

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_get_fiscal_year.

CALL FUNCTION 'FTI_FISCAL_YEAR_MONTH_GET'

EXPORTING

I_BUKRS = c_gb02

I_BUDAT = s_budat-low

IMPORTING

E_GJAHR = g_gjahr.

ENDFORM. " sub_get_fiscal_year

&----


*& Form sapgui_progress

&----


  • text

----


  • -->P_W_PERCENTAGE text

  • -->P_W_PROGRESS_TEXT text

----


FORM sapgui_progress USING P_PERCENTAGE

P_PROGRESS_TEXT.

data: l_progress_text(80),

l_percentage(3).

clear l_progress_text.

if p_percentage eq 0.

l_progress_text = p_progress_text.

else.

write p_percentage to l_percentage no-zero.

concatenate l_percentage '% ' into

l_progress_text.

concatenate l_progress_text p_progress_text into

l_progress_text separated by space.

endif.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

PERCENTAGE = p_percentage

TEXT = l_progress_text.

ENDFORM. " sapgui_progress

&----


*& Form set_attendee_value

&----


  • text

----


  • -->P_IT_BSEG_XREF2 text

  • -->P_IT_FINALTAB_XREF2 text

----


FORM set_attendee_value USING p_xref_in

p_xref_out.

if p_xref_in co '0123456789 '.

if p_xref_in eq space.

clear p_xref_out.

else.

p_xref_out = p_xref_in.

endif.

else.

clear p_xref_out..

endif.

ENDFORM. " set_attendee_value

Regards,

Sunil

3 REPLIES 3
Read only

Former Member
0 Likes
655

Hi Sam,

Use the following program as a templet and write u r own select statements.

REPORT ZHEXRUK_EXPENSE_ENTERTAIN NO STANDARD PAGE HEADING

LINE-SIZE 220 LINE-COUNT 65

MESSAGE-ID zukh.

  • Definition of Cluster TE

INCLUDE rpc1te00.

************************************************************************

  • Table Declarations

************************************************************************

tables : bkpf,

ska1.

************************************************************************

  • Type Declarations

************************************************************************

type-pools : slis.

************************************************************************

  • Structure Declarations

************************************************************************

  • To Hold GL Account Details

data: begin of x_bsis_bsas,

bukrs like bsis-bukrs,

hkont like bsis-hkont,

zuonr like bsis-zuonr,

gjahr like bsis-gjahr,

belnr like bsis-belnr,

buzei like bsis-buzei,

budat like bsis-budat,

blart like bsis-blart,

waers like bsis-waers,

dmbtr like bsis-dmbtr,

wrbtr like bsis-wrbtr,

sgtxt like bsis-sgtxt,

prctr like bsis-prctr,

shkzg like bsis-shkzg,

end of x_bsis_bsas.

  • To Hold Header details of Accounting Docs

data : begin of x_bkpf,

bukrs like bkpf-bukrs,

belnr like bkpf-belnr,

gjahr like bkpf-gjahr,

blart like bkpf-blart,

budat like bkpf-budat,

bktxt like bkpf-bktxt,

end of x_bkpf.

  • To hold Item details of the Accounting Docs

data : begin of x_bseg,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

buzei like bseg-buzei,

dmbtr like bseg-dmbtr,

zuonr like bseg-zuonr,

xref1 like bseg-xref1,

xref2 like bseg-xref2,

xref3 like bseg-xref3,

shkzg like bseg-shkzg,

bschl like bseg-bschl,

end of x_bseg.

  • To hold Trip numbers

data : begin of x_trip,

reinr like ptrv_srec-reinr,

end of x_trip.

  • To hold details of Standard Accounts Table

data : begin of x_t030,

ktopl like t030-ktopl, "Chart of accounts

komok like t030-komok, "Account Modification

konts like T030-konts, "GL Account No

kont1 like t706k-kont1, "Symbolic account assignment for trip

end of x_t030.

  • To hold details of Initial Account Assignment

data : begin of x_t706k,

morei like t706k-morei, "Trip provision variant

lgart like t706k-lgart, "Wage type

kont1 like t706k-kont1, "Symbolic account assignment for trip

"costs

end of x_t706k.

  • To hold Trip Expense Types: Assignment of Wage Types

data : begin of x_t706b4,

morei like t706b4-morei, "Trip provision variant

spkzl like t706b4-spkzl, "Travel expense type

lgarl like t706b4-lgarl, "First wage type

end of x_t706b4.

  • To hold Trip Expense Types

data : begin of x_t706b1,

morei like t706b4-morei, "Trip provision variant

spkzl like t706b1-spkzl, "Wage type

end of x_t706b1.

  • To hold Trip Statistics - Receipts

data : begin of x_ptrv_srec,

pernr like ptrv_srec-pernr, "Personal Number

reinr like ptrv_srec-reinr, "Trip Number

perio like ptrv_srec-perio, "Period

end of x_ptrv_srec.

  • To hold Creditor Determination via Personnel Number Entry

data : begin of x_ptrv_kredp,

pernr like ptrv_kredp-pernr, "Personal Number

lifnr like ptrv_kredp-lifnr, "Account number of vendor

end of x_ptrv_kredp.

  • To hold Final Output

data : begin of x_finaltab,

hkont like bsis-hkont, "GL Account No

sgtxt like bsis-sgtxt, "Line item Description

belnr like bsis-belnr, "Account No

blart like bsis-blart, "Account Type

budat like bsis-budat, "Posting Date

prctr like bsis-prctr, "Profit Center

wrbtr like bsis-wrbtr, "Amount

waers like bsis-waers, "Currency

xref2 type i, "UK Partners

xref1 type i, "UK Staff

xref3 type i, "Others

reinr like ptrv_srec-reinr, "Trip Number

bktxt like bkpf-bktxt, "Filling No

pernr like ptrv_srec-pernr, "Personal Number

lifnr like ptrv_kredp-lifnr,"Vendor Account Number

end of x_finaltab.

  • ------------------------------------------------------------------ *

  • INTERNAL TABLES.

  • ------------------------------------------------------------------ *

  • Table to collect GL Account Details(Open Items)

data : begin of it_bsis occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis.

data : begin of it_bsis_sa occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_sa.

  • Table to collect GL Account Details(Closed Items)

data : begin of it_bsas occurs 0.

include structure x_bsis_bsas.

data : end of it_bsas.

data : begin of it_bsas_sa occurs 0.

include structure x_bsis_bsas.

data : end of it_bsas_sa.

  • Table to collect GL Account Details(Open & Closed Items)

data : begin of it_bsis_bsas occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_bsas.

data : begin of it_bsis_bsas_sa occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_bsas_sa.

  • Table to collect Header details of Accounting Doc

data : begin of it_bkpf occurs 0.

include structure x_bkpf.

data : end of it_bkpf.

  • Table to hold Line item details of Accouting Doc

data : begin of it_bseg occurs 0.

include structure x_bseg.

data : end of it_bseg.

  • Table to hold Trip numbers

data : begin of it_trip occurs 0.

include structure x_trip.

data : end of it_trip.

  • Table to collect details of Standard Accounts Table

data : begin of it_t030 occurs 0.

include structure x_t030.

data : end of it_t030.

  • Table to collect details of Initial Account Assignment

data : begin of it_t706k occurs 0.

include structure x_t706k.

data : end of it_t706k.

  • Table to collect Trip Expense Types: Assignment of Wage Types

data : begin of it_t706b4 occurs 0.

include structure x_t706b4.

data : end of it_t706b4.

  • Table to collect Trip Expense Types

data : begin of it_t706b1 occurs 0.

include structure x_t706b1.

data : end of it_t706b1.

  • Table to collect Trip Statistics - Receipts

data : begin of it_ptrv_srec occurs 0.

include structure x_ptrv_srec.

data : end of it_ptrv_srec.

  • Table to collect Creditor Determination via Personnel Number Entry

data : begin of it_ptrv_kredp occurs 0.

include structure x_ptrv_kredp.

data : end of it_ptrv_kredp.

  • To hold Final Output

data : begin of it_finaltab occurs 0.

include structure x_finaltab.

data : end of it_finaltab.

  • Internal table to collect the key data for the cluster tbl

DATA: BEGIN OF it_keytab OCCURS 0.

INCLUDE STRUCTURE ptp00.

DATA: hdvrs LIKE ptrv_perio-hdvrs,

END OF it_keytab.

  • Table to collect Trip details

data : begin of it_trip_sum occurs 0.

include structure it_keytab.

data : n_stf(3) type c,

n_ptn(3) type c,

n_gst(3) type c,

end of it_trip_sum.

data : begin of it_ptrv_head occurs 0,

pernr like ptrv_head-pernr,

reinr like ptrv_head-reinr,

end of it_ptrv_head.

**Tables declaration for ALV Output*********************

  • Internal Table to trap the events

DATA: IT_EVENTcat TYPE SLIS_T_EVENT.

*Internal Table to hold the field Catalogue for ALV

DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

  • Interbal table to hold Header details of the Output

DATA: it_heading TYPE slis_t_listheader,

it_heading1 type slis_t_listheader.

  • it_print type slis_print_alv.

data: w_percentage(3) type n,

w_keytab_count(6) type n,

w_old_percent(3) type n,

w_progress_text(75),

w_track(1).

  • ------------------------------------------------------------------ *

  • CONSTANTS

  • ------------------------------------------------------------------ *

DATA : c_z001 like ska1-ktopl value 'Z001',

c_s4 like bsis-blart value 'S4',

c_morei like t706k-morei value '08',

c_pr04x like t706b1-pr04x value 'Z',

c_44(2) TYPE C value '44',

c_status TYPE slis_formname VALUE 'STATUS',

c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

c_gb02 like bkpf-bukrs value 'GB02'.

  • ------------------------------------------------------------------ *

  • GLOBAL VARIABLES

  • ------------------------------------------------------------------ *

data : g_gjahr like bkpf-gjahr,

g_dmbtr like bsis-dmbtr,

g_repid like sy-repid.

  • ------------------------------------------------------------------ *

  • RANGE TABLES.

  • ------------------------------------------------------------------ *

ranges : r_exp_type for t706b4-spkzl.

************************************************************************

  • Selection Screen Parameters

*

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_hkont FOR ska1-saknr,

s_budat for bkpf-budat.

SELECTION-SCREEN END OF BLOCK b1.

************************************************************************

  • AT SELECTION-SCREEN

************************************************************************

AT SELECTION-SCREEN.

  • To validate dates in selection screen

PERFORM sub_validate_gl_accounts.

  • Get Fiscal Year

perform sub_get_fiscal_year.

************************************************************************

  • START-OF-SELECTION

************************************************************************

START-OF-SELECTION.

  • To collect GL Account details for Open & Closed items

perform sub_select_gl_details.

  • To collect the expense types

perform sub_select_expense_type.

  • To get FI DOC details

perform sub_select_fi_details.

  • To get the trip details

perform sub_get_trip_details.

  • To build the final output table

perform sub_build_finaltab.

  • To display the output in ALV

perform sub_disp_finaltab.

&----


*& Form sub_validate_gl_accounts

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_validate_gl_accounts.

select single * from ska1 where ktopl = c_z001

and saknr in s_hkont.

if sy-subrc ne 0.

message e097(zukh).

endif.

endform. " sub_validate_gl_accounts

&----


*& Form sub_select_gl_details

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_select_gl_details.

data : begin of it_bsis_local occurs 0.

include structure x_bsis_bsas.

data : end of it_bsis_local.

data : begin of it_bsas_local occurs 0.

include structure x_bsis_bsas.

data : end of it_bsas_local.

data : l_augbl like bsis-augbl,

l_augdt like bsis-augdt.

w_percentage = 0.

w_progress_text = 'Selecting GL Open Items...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

refresh: it_bsis_local,

it_bsis,

it_bsas_local,

it_bsas,

it_bsis_bsas,

it_bsis_sa,

it_bsas_sa,

it_bsis_bsas_sa.

  • To get the GL Account details of all the open items with in the

  • selection screen

select bukrs

hkont

zuonr

gjahr

belnr

buzei

budat

blart

waers

dmbtr

wrbtr

sgtxt

prctr

shkzg

from bsis into corresponding fields of table it_bsis_local

where bukrs eq c_gb02

and hkont in s_hkont

and augdt = l_augdt

and augbl = l_augbl

and gjahr = g_gjahr.

if not it_bsis_local[] is initial.

sort it_bsis_local by budat blart.

loop at it_bsis_local where budat in s_budat

and blart ne c_s4.

if it_bsis_local-blart eq 'SA'.

move-corresponding it_bsis_local to it_bsis_sa.

append it_bsis_sa.

clear it_bsis_sa.

else.

move-corresponding it_bsis_local to it_bsis.

append it_bsis.

clear it_bsis.

endif.

endloop.

endif.

w_percentage = 0.

w_progress_text = 'Selecting GL Cleared Items...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

select bukrs

hkont

zuonr

gjahr

belnr

buzei

budat

blart

waers

dmbtr

wrbtr

sgtxt

prctr

shkzg

from bsas into corresponding fields of table it_bsas_local

where bukrs eq c_gb02

and hkont in s_hkont

and gjahr = g_gjahr.

if not it_bsas_local[] is initial.

sort it_bsas_local by budat blart.

loop at it_bsas_local where budat in s_budat

and blart ne 'S4'.

if it_bsas_local-blart eq 'SA'.

move-corresponding it_bsas_local to it_bsas_sa.

append it_bsas_sa.

clear it_bsas_sa.

else.

move-corresponding it_bsas_local to it_bsas.

append it_bsas.

clear it_bsas.

endif.

endloop.

endif.

if not it_bsis[] is initial or not it_bsas[] is initial

or not it_bsis_sa[] is initial or not it_bsas_sa[] is initial.

it_bsis_bsas[] = it_bsis[].

append lines of it_bsas to it_bsis_bsas.

it_bsis_bsas_sa[] = it_bsis_sa[].

append lines of it_bsas_sa to it_bsis_bsas_sa.

else.

message e053(zukh).

endif.

endform. " sub_select_gl_details

&----


*& Form sub_select_expense_type

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_select_expense_type.

w_percentage = 0.

w_progress_text = 'Selecting Expense Types...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

refresh: it_t030,

it_t706k,

it_t706b4,

it_t706b1.

  • To build account modification field for the following GL Accounts

select komok from t030 into corresponding fields of table it_t030

where ktopl = c_z001

and konts in s_hkont.

sort it_t030 by komok.

delete adjacent duplicates from it_t030 comparing komok.

  • To build Symbolic account assignment for trip

loop at it_t030.

concatenate '' it_t030-komok1(2) into it_t030-kont1.

modify it_t030.

endloop.

  • To get wage types

select lgart from t706k into corresponding fields of table it_t706k

for all entries in it_t030

where morei = c_morei

and kont1 = it_t030-kont1.

sort it_t706k by lgart.

delete adjacent duplicates from it_t706k comparing lgart.

  • To get the Expense type

select spkzl from t706b4 into corresponding fields of table it_t706b4

for all entries in it_t706k

where morei = c_morei

and lgarl = it_t706k-lgart.

sort it_t706b4 by spkzl.

delete adjacent duplicates from it_t706b4 comparing spkzl.

  • To get expense type with line of expense in weekly report

select spkzl from t706b1 into corresponding fields of table it_t706b1

for all entries in it_t706b4

where morei = c_morei

and spkzl = it_t706b4-spkzl

and pr04x = c_pr04x.

loop at it_t706b4.

read table it_t706b1 with key spkzl = it_t706b4-spkzl.

if sy-subrc = 0.

delete it_t706b4.

clear it_t706b4.

endif.

endloop.

endform. " sub_select_expense_type

&----


*& Form sub_select_fi_details

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_select_fi_details.

data : begin of it_bseg_local occurs 0.

include structure x_bseg.

data : end of it_bseg_local.

w_percentage = 0.

w_progress_text = 'Selecting FI Details - step 1...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

refresh: it_bseg_local,

it_bseg,

it_bkpf.

if not it_bsis_bsas_sa[] is initial.

sort it_bsis_bsas_sa by bukrs belnr gjahr.

  • Select SA type documents to determine if employee vendor related

select bukrs

belnr

gjahr

from bseg into corresponding fields of table it_bseg_local

for all entries in it_bsis_bsas_sa

where bukrs = it_bsis_bsas_sa-bukrs

and belnr = it_bsis_bsas_sa-belnr

and gjahr = it_bsis_bsas_sa-gjahr

and bschl in ('21', '31').

loop at it_bsis_bsas_sa.

read table it_bseg_local with key bukrs = it_bsis_bsas_sa-bukrs

belnr = it_bsis_bsas_sa-belnr

gjahr = it_bsis_bsas_sa-gjahr.

if sy-subrc ne 0.

delete it_bsis_bsas_sa.

continue.

endif.

endloop.

if not it_bsis_bsas_sa[] is initial.

append lines of it_bsis_bsas_sa to it_bsis_bsas.

endif.

endif.

refresh: it_bseg_local,

it_bsis_bsas_sa.

sort it_bsis_bsas by bukrs belnr gjahr.

  • To collect the item details

select bukrs

belnr

gjahr

buzei

dmbtr

zuonr

xref1

xref2

xref3

shkzg

bschl

from bseg into corresponding fields of table it_bseg

for all entries in it_bsis_bsas

where bukrs = it_bsis_bsas-bukrs

and belnr = it_bsis_bsas-belnr

and gjahr = it_bsis_bsas-gjahr

and buzei = it_bsis_bsas-buzei.

sort it_bseg by bukrs belnr gjahr.

  • To collect all the trip records

loop at it_bseg.

if it_bseg-shkzg = 'S'.

it_bseg-dmbtr = it_bseg-dmbtr * -1.

modify it_bseg transporting dmbtr.

endif.

if it_bseg-zuonr+0(2) = c_44.

it_trip-reinr = it_bseg-zuonr+0(10).

append it_trip.

endif.

endloop.

w_percentage = 0.

w_progress_text = 'Selecting FI Details - step 2...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

it_bseg_local[] = it_bseg[].

delete adjacent duplicates from it_bseg_local comparing belnr.

  • To get the header details

select bukrs

belnr

gjahr

blart

budat

bktxt

  • from zukex_bkpf into corresponding fields of table it_bkpf

from bkpf into corresponding fields of table it_bkpf

for all entries in it_bseg_local

where bukrs = it_bseg_local-bukrs

and belnr = it_bseg_local-belnr

and gjahr = it_bseg_local-gjahr.

endform. " sub_select_fi_details

&----


*& Form sub_get_trip_details

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sub_get_trip_details.

data : it_ptrv_srec_local like it_ptrv_srec occurs 0 with header line.

data : l_n_stf(10) type c, " Variable to hold UK staff

l_n_ptn(10) type c, " Variable to hold UK partners

l_n_gst(10) type c. " Variable to hold others

  • To build range table for the expense types

loop at it_t706b4.

r_exp_type-sign = 'I'.

r_exp_type-option = 'EQ'.

r_exp_type-low = it_t706b4-spkzl.

append r_exp_type.

endloop.

  • To get the personal number for the trips

sort it_trip by reinr.

delete adjacent duplicates from it_trip comparing reinr.

select pernr

reinr

from ptrv_head into corresponding fields of table it_ptrv_head

for all entries in it_trip

where reinr = it_trip-reinr.

select pernr

reinr

from ptrv_srec into corresponding fields of table it_ptrv_srec

for all entries in it_ptrv_head

where pernr = it_ptrv_head-pernr

and reinr = it_ptrv_head-reinr

and EXP_TYPE in r_exp_type.

it_ptrv_srec_local[] = it_ptrv_srec[].

sort it_ptrv_srec_local by pernr.

delete adjacent duplicates from it_ptrv_srec_local comparing pernr.

w_percentage = 0.

w_progress_text = 'Selecting Expense Trip Details...'.

PERFORM sapgui_progress using w_percentage w_progress_text.

  • To get vendor account number for the personal data

select pernr

lifnr

from ptrv_kredp into corresponding fields of table

it_ptrv_kredp for all entries in it_ptrv_srec_local

where pernr = it_ptrv_srec_local-pernr.

  • To build the key table for the cluster

select pernr

reinr

perio

pdvrs

from ptrv_perio into corresponding fields of table it_keytab

for all entries in it_ptrv_srec

where pernr = it_ptrv_srec-pernr

and reinr = it_ptrv_srec-reinr

and perio = it_ptrv_srec-perio.

CHECK NOT it_keytab[] IS INITIAL.

SORT it_keytab BY pernr "Personnel No

reinr "Trip No

perio "Number of trip period

pdvrs ASCENDING. "Seq no. of period

**---- Eliminate anything that is not the lowest version on the trip

*

  • DELETE ADJACENT DUPLICATES FROM it_keytab COMPARING pernr

  • reinr.

clear: w_percentage,

w_old_percent.

w_progress_text = 'Processing Expense Details...'.

describe table it_keytab lines w_keytab_count.

loop at it_keytab.

w_percentage = sy-tabix / w_keytab_count * 100.

if w_percentage ne w_old_percent.

PERFORM sapgui_progress using w_percentage w_progress_text.

w_old_percent = w_percentage.

endif.

ON CHANGE OF IT_KEYTAB-REINR.

*Populate the table TE-KEY for retrieving data from the cluster table

MOVE-CORRESPONDING it_keytab TO te-key.

IMPORT te-version TO ote-version

exbel "Additional receipt information

beleg "Indiv.recpts

FROM DATABASE pcl1(te)

ID te-key.

check sy-subrc = 0.

delete beleg where not spkzl in r_exp_type.

loop at exbel.

read table beleg with key belnr = exbel-belnr.

if sy-subrc = 0.

l_n_stf = l_n_stf + exbel-n_stf.

l_n_ptn = l_n_ptn + exbel-n_ptn.

l_n_gst = l_n_gst + exbel-n_gst.

endif.

endloop.

move-corresponding it_keytab to it_trip_sum.

condense: l_n_stf, l_n_ptn, l_n_gst.

it_trip_sum-n_stf = l_n_stf.

it_trip_sum-n_ptn = l_n_ptn.

it_trip_sum-n_gst = l_n_gst.

append it_trip_sum.

clear : it_trip_sum, l_n_stf, l_n_ptn, l_n_gst.

endon.

endloop.

endform. " sub_get_trip_details

&----


*& Form sub_build_finaltab

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_build_finaltab.

data : l_wrbtr like bsis-wrbtr,

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005 .

l_finaltab-xref1 type i ,

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

l_reinr like bseg-zuonr.

data: l_1st_belnr like bseg-belnr,

l_1st_buzei like bseg-buzei.

clear : g_dmbtr.

sort it_trip_sum by reinr.

sort it_ptrv_kredp by pernr.

sort it_bseg by bukrs belnr gjahr buzei.

sort it_bsis_bsas by bukrs belnr gjahr.

sort it_ptrv_head by reinr.

sort it_trip_sum by reinr.

sort it_bkpf by bukrs belnr gjahr.

clear: w_percentage,

w_old_percent.

w_progress_text = 'Building Output Table...'.

describe table it_bseg lines w_keytab_count.

refresh: it_finaltab.

delete adjacent duplicates from it_bseg

comparing bukrs belnr gjahr buzei.

clear: l_1st_belnr,

l_1st_buzei.

loop at it_bseg.

clear it_finaltab.

w_percentage = sy-tabix / w_keytab_count * 100.

if w_percentage ne w_old_percent.

PERFORM sapgui_progress using w_percentage w_progress_text.

w_old_percent = w_percentage.

endif.

read table it_bkpf with key bukrs = it_bseg-bukrs

belnr = it_bseg-belnr

gjahr = it_bseg-gjahr

BINARY SEARCH.

if sy-subrc = 0 .

it_finaltab-bktxt = it_bkpf-bktxt.

endif.

if it_bseg-belnr ne l_1st_belnr.

l_1st_belnr = it_bseg-belnr.

l_1st_buzei = it_bseg-buzei.

endif.

if it_bseg-buzei ne l_1st_buzei.

continue.

endif.

loop at it_bsis_bsas where bukrs = it_bseg-bukrs

and belnr = it_bseg-belnr

and gjahr = it_bseg-gjahr.

  • and buzei = it_bseg-buzei.

if it_bsis_bsas-shkzg = 'H'.

it_bsis_bsas-wrbtr = it_bsis_bsas-wrbtr * -1.

endif.

if it_bsis_bsas-blart ne 'S2'.

it_finaltab-hkont = it_bsis_bsas-hkont.

it_finaltab-sgtxt = it_bsis_bsas-sgtxt.

it_finaltab-belnr = it_bsis_bsas-belnr.

it_finaltab-blart = it_bsis_bsas-blart.

it_finaltab-budat = it_bsis_bsas-budat.

it_finaltab-prctr = it_bsis_bsas-prctr.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005.

  • it_finaltab-waers = it_bsis_bsas-waers.

it_finaltab-waers = 'GBP'.

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

if it_bseg-zuonr+0(2) ne c_44.

perform set_attendee_value using it_bseg-xref1

it_finaltab-xref1.

perform set_attendee_value using it_bseg-xref2

it_finaltab-xref2.

perform set_attendee_value using it_bseg-xref3

it_finaltab-xref3.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005.

if it_finaltab-blart = 'KR' .

clear : l_finaltab-xref1 .

l_finaltab-xref1 = it_finaltab-xref1 .

it_finaltab-xref1 = it_finaltab-xref2 .

it_finaltab-xref2 = l_finaltab-xref1 .

  • it_finaltab-waers = 'GBP'.

endif .

*

  • it_finaltab-wrbtr = it_bsis_bsas-wrbtr.

it_finaltab-wrbtr = it_bsis_bsas-dmbtr.

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

if not it_finaltab-wrbtr is initial.

append it_finaltab.

endif.

clear it_finaltab.

else.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005 .

  • l_wrbtr = l_wrbtr + it_bsis_bsas-wrbtr.

l_wrbtr = l_wrbtr + it_bsis_bsas-dmbtr.

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

it_finaltab-wrbtr = l_wrbtr.

read table it_ptrv_head with

key reinr = it_bseg-zuonr+0(10)

BINARY SEARCH.

it_finaltab-reinr = it_ptrv_head-reinr.

it_finaltab-pernr = it_ptrv_head-pernr.

read table it_ptrv_kredp with key pernr = it_ptrv_head-pernr.

if sy-subrc = 0.

it_finaltab-lifnr = it_ptrv_kredp-lifnr.

endif.

read table it_trip_sum with key reinr = it_bseg-zuonr+0(10)

BINARY SEARCH.

if sy-subrc = 0.

perform set_attendee_value using it_trip_sum-n_stf

it_finaltab-xref1.

perform set_attendee_value using it_trip_sum-n_ptn

it_finaltab-xref2.

perform set_attendee_value using it_trip_sum-n_gst

it_finaltab-xref3.

  • Begin of changes for R001 by Dolon Acharjee on 10.02.2005.

if it_finaltab-blart = 'KR' .

clear : l_finaltab-xref1 .

l_finaltab-xref1 = it_finaltab-xref1 .

it_finaltab-xref1 = it_finaltab-xref2 .

it_finaltab-xref2 = l_finaltab-xref1 .

  • it_finaltab-waers = 'GBP'.

endif .

  • End of changes for R001 by Dolon Acharjee on 10.02.2005 .

endif.

at end of zuonr.

if not it_finaltab-wrbtr is initial.

append it_finaltab.

endif.

clear it_finaltab.

clear l_wrbtr.

endat.

endif.

else.

g_dmbtr = g_dmbtr + it_bsis_bsas-dmbtr.

endif.

endloop.

endloop.

ENDFORM. " sub_build_finaltab

&----


*& Form sub_disp_finaltab

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_disp_finaltab.

g_repid = sy-repid.

  • Building of Fieldcatalog

PERFORM sub_initialize_fieldcat USING it_fieldcat[].

  • Building of Events

PERFORM sub_build_eventcat USING it_eventcat[].

  • Building of Header for the basic list.

PERFORM sub_build_comment USING it_heading[].

  • Build the details for end-of-page

  • perform sub_build_end_of_page using it_heading1[].

  • PERFORM sub_PRINT_BUILD USING it_PRINT.

  • it_print_alv-reserve_lines = 4.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_pf_status_set = c_status

it_fieldcat = it_fieldcat

it_events = it_eventcat[]

  • is_print = it_print

TABLES

t_outtab = it_finaltab

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

&----


*& Form sub_initialize_fieldcat

&----


  • text

----


  • -->P_IT_FIELDCAT[] text

----


FORM sub_initialize_fieldcat using it_fieldcat TYPE slis_t_fieldcat_alv.

DATA: l_fieldcat TYPE slis_fieldcat_alv.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '1'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'HKONT'.

l_fieldcat-seltext_l = 'GL ACCOUNT'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '12'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '2'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'SGTXT'.

l_fieldcat-seltext_l = 'Line Item Description'.

l_fieldcat-intlen = '35'.

l_fieldcat-outputlen = '35'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '3'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BELNR'.

l_fieldcat-seltext_l = 'Document Number'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '4'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BLART'.

l_fieldcat-seltext_l = 'Document Type'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '5'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BUDAT'.

l_fieldcat-seltext_l = 'Posting Date'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '6'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'PRCTR'.

l_fieldcat-seltext_l = 'Profit Center'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '7'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'WRBTR'.

l_fieldcat-seltext_l = 'Amount'.

l_fieldcat-do_sum = 'X'.

l_fieldcat-intlen = '16'.

l_fieldcat-outputlen = '16'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '8'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'WAERS'.

l_fieldcat-seltext_l = 'Currency'.

l_fieldcat-intlen = '05'.

l_fieldcat-outputlen = '15'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '9'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'XREF2'.

l_fieldcat-seltext_l = 'UK Partners'.

l_fieldcat-do_sum = 'X'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '10'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'XREF1'.

l_fieldcat-seltext_l = 'UK Staff'.

l_fieldcat-do_sum = 'X'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '11'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'XREF3'.

l_fieldcat-seltext_l = 'Others'.

l_fieldcat-do_sum = 'X'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '12'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'REINR'.

l_fieldcat-seltext_l = 'Trip No'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '10'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '13'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'BKTXT'.

l_fieldcat-seltext_l = 'Filling No'.

l_fieldcat-intlen = '25'.

l_fieldcat-outputlen = '25'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '14'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'PERNR'.

l_fieldcat-seltext_l = 'Personal Number'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '15'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '15'.

l_fieldcat-tabname = 'IT_FINALTAB'.

l_fieldcat-fieldname = 'LIFNR'.

l_fieldcat-seltext_l = 'Vendor'.

l_fieldcat-intlen = '10'.

l_fieldcat-outputlen = '15'.

APPEND l_fieldcat TO it_fieldcat.

CLEAR l_fieldcat.

ENDFORM. " sub_initialize_fieldcat

&----


*& Form sub_build_eventcat

&----


  • text

----


  • -->P_IT_EVENTCAT[] text

----


FORM sub_build_eventcat USING p_events TYPE slis_t_event.

DATA : l_events TYPE slis_alv_event,

l_event_list TYPE slis_t_event.

CLEAR l_events.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = l_event_list

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc = 0.

  • CLEAR P_EVENTS.

READ TABLE l_event_list WITH KEY

name = slis_ev_top_of_page INTO l_events.

IF sy-subrc = 0.

MOVE c_formname_top_of_page TO l_events-form.

APPEND l_events TO p_events.

ENDIF.

  • READ TABLE l_event_list WITH KEY

  • name = slis_ev_end_of_page INTO l_events.

  • IF sy-subrc = 0.

  • MOVE c_formname_end_of_page TO l_events-form.

  • APPEND l_events TO p_events.

  • ENDIF.

ENDIF.

ENDFORM. " sub_build_eventcat

----


  • FORM STATUS *

----


  • This form is used to set the PF status that is built for basic list

----


  • --> EXTAB *

----


FORM status using g_extab TYPE slis_t_extab .

SET PF-STATUS 'DETAILS3'.

ENDFORM.

----


  • FORM TOP_OF_PAGE *

----


  • This form is executed when ever the top-of-page event is called.

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_heading[].

ENDFORM.

*----


    • FORM END_OF_PAGE *

*----


    • This form is executed when ever the top-of-page event is called.

*----


*FORM end_of_page.

*

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • it_list_commentary = it_heading1[].

*

*ENDFORM.

&----


*& Form sub_build_comment

&----


  • text

----


  • -->P_IT_HEADING[] text

----


FORM sub_build_comment USING p_heading TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader,

l_date_time(20) type c.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = 'Print Date / Time : '.

concatenate sy-datum6(2) ':' sy-datum4(2) ':' sy-datum+0(4) '/'

sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit+4(2) into

l_date_time.

ls_line-info = l_date_time.

append ls_line to p_heading.

CLEAR ls_line.

ls_line-typ = 'H'.

  • LS_LINE-KEY: not used for this type

ls_line-info+30(30) = text-002.

APPEND ls_line TO p_heading.

CLEAR ls_line.

CLEAR: ls_line.

ls_line-typ = 'S'.

ls_line-key = text-003.

if s_hkont-low ne space and s_hkont-high ne space.

concatenate s_hkont-low 'to' s_hkont-high into ls_line-info.

else.

ls_line-info = s_hkont-low.

endif.

append ls_line to p_heading.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-004.

concatenate s_budat-low6(2) '.' s_budat-low4(2) '.'

s_budat-low+0(4) into ls_line-info.

append ls_line to p_heading.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-005.

concatenate s_budat-high6(2) '.' s_budat-high4(2) '.'

s_budat-high+0(4) into ls_line-info.

append ls_line to p_heading.

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-006.

ls_line-info = g_dmbtr.

append ls_line to p_heading.

clear ls_line.

ENDFORM. " sub_build_comment

&----


*& Form sub_build_End_of_page

&----


  • text

----


  • -->P_IT_HEADING1[] text

----


*FORM sub_build_end_of_page USING p_heading TYPE slis_t_listheader.

  • DATA: ls_line TYPE slis_listheader,

  • v_dmbtr(20) type c.

*

  • ls_line-typ = 'H'.

  • ls_line-key = text-006.

  • loop at it_bseg.

  • read table it_bsis_bsas with key bukrs = it_bseg-bukrs

  • belnr = it_bseg-belnr

  • gjahr = it_bseg-gjahr

  • buzei = it_bseg-buzei

  • blart = 'S2'.

  • if sy-subrc ne 0.

  • v_dmbtr = v_dmbtr + it_bsis_bsas-dmbtr.

  • endif.

  • endloop.

  • ls_line-info = v_dmbtr.

  • append ls_line to p_heading.

  • clear ls_line.

*ENDFORM. " sub_build_End_of_page

&----


*& Form sub_PRINT_BUILD

&----


  • text

----


  • -->P_IT_PRINT text

----


*FORM sub_PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.

  • LS_PRINT-PRINT = ' '. "P_PRINT. "PRINT IMMEDIATE

  • LS_PRINT-NO_PRINT_SELINFOS = ' '."P_NOSINF. "NO SELECTION INFO

  • LS_PRINT-NO_COVERPAGE = ' '."P_NOCOVE. "NO COVER PAGE

  • LS_PRINT-NO_NEW_PAGE = ' '."P_NONEWP.

  • LS_PRINT-NO_PRINT_LISTINFOS = ' '. "p_NOLINF. "NO PRINT LIST INFO

  • LS_PRINT-RESERVE_LINES = 6 ."P_RESERV

*ENDFORM. " sub_PRINT_BUILD

&----


*& Form sub_get_fiscal_year

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_get_fiscal_year.

CALL FUNCTION 'FTI_FISCAL_YEAR_MONTH_GET'

EXPORTING

I_BUKRS = c_gb02

I_BUDAT = s_budat-low

IMPORTING

E_GJAHR = g_gjahr.

ENDFORM. " sub_get_fiscal_year

&----


*& Form sapgui_progress

&----


  • text

----


  • -->P_W_PERCENTAGE text

  • -->P_W_PROGRESS_TEXT text

----


FORM sapgui_progress USING P_PERCENTAGE

P_PROGRESS_TEXT.

data: l_progress_text(80),

l_percentage(3).

clear l_progress_text.

if p_percentage eq 0.

l_progress_text = p_progress_text.

else.

write p_percentage to l_percentage no-zero.

concatenate l_percentage '% ' into

l_progress_text.

concatenate l_progress_text p_progress_text into

l_progress_text separated by space.

endif.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

PERCENTAGE = p_percentage

TEXT = l_progress_text.

ENDFORM. " sapgui_progress

&----


*& Form set_attendee_value

&----


  • text

----


  • -->P_IT_BSEG_XREF2 text

  • -->P_IT_FINALTAB_XREF2 text

----


FORM set_attendee_value USING p_xref_in

p_xref_out.

if p_xref_in co '0123456789 '.

if p_xref_in eq space.

clear p_xref_out.

else.

p_xref_out = p_xref_in.

endif.

else.

clear p_xref_out..

endif.

ENDFORM. " set_attendee_value

Regards,

Sunil

Read only

0 Likes
654

thanks sunil,

but i am totally puzzled seeing this prog......

Read only

Former Member
0 Likes
654

Hi Sam ,

What is the help you want , if you can be specific it would help us answer the question better.

Looking at your requirement , it does not seem to tough , i have just one query regaridng the specification given , your program takes as input company code , but at step 5 it is given 'All the above mentioned searches to be made for company code 1000' .

So what is the use of having the company code as input.

Please revert back , with your queries.

Regards

Arun