‎2008 Nov 07 9:34 AM
Hi all,
The foll. is the program code
&----
*& Report ZPU_PURCHASE_REG
*&
&----
*&
*&
&----
REPORT ZPU_PURCHASE_REG.
tables : bseg,bkpf,bset,ekko,ekpo,ekbe,lfa1,rseg.
type-pools : slis.
data : w_cat type slis_fieldcat_alv,
i_cat type slis_t_fieldcat_alv,
xlayout type slis_layout_alv,
gd_repid type sy-repid.
data : mbelnr like bseg-belnr.
data : begin of it_T077Y occurs 0,
ktokk like t077y-ktokk,
txt30 like T077Y-txt30,
end of it_T077Y.
data : begin of it_t007s occurs 0,
mwskz like t007s-mwskz,
TEXT1 like t007s-TEXT1,
end of it_t007s.
DATA: BEGIN OF IT_EKBE occurs 0,
EBELN like EKBE-EBELN,
EBELP like EKBE-EBELP,
GJAHR like EKBE-GJAHR,
BELNR like EKBE-BELNR,
BUZEI like EKBE-BUZEI,
BEWTP like EKBE-BEWTP,
BUDAT like EKBE-BUDAT,
bldat like ekbe-bldat,
xblnr like ekbe-xblnr,
dmbtr like ekbe-dmbtr,
mwskz like ekbe-mwskz,
SHKZG like EKBE-SHKZG,
werks like ekbe-werks,
menge like ekbe-menge,
BSART like EKKO-BSART,
LIFNR like EKKO-LIFNR,
ktokk like lfa1-ktokk,
END OF IT_EKBE.
data : begin of it_lfa1 occurs 0,
name1 like lfa1-name1,
ort01 like lfa1-ort01,
regio like lfa1-regio,
ktokk like lfa1-ktokk,
end of it_lfa1.
DATA: BEGIN OF IT_BKPF occurs 0,
BUKRS TYPE BKPF-BUKRS,
BELNR TYPE BKPF-BELNR,
GJAHR TYPE BKPF-GJAHR,
BLART TYPE BKPF-BLART,
budat TYPE BKPF-budat,
bldat like bkpf-bldat,
xblnr like bkpf-xblnr,
HWAER like bkpf-HWAER,
END OF IT_BKPF.
data : begin of it_skat occurs 0,
saknr like skat-saknr,
txt50 like skat-txt50,
end of it_skat.
DATA: BEGIN OF IT_BSET occurs 0,
BUKRS TYPE BSET-BUKRS,
BELNR TYPE BSET-BELNR,
GJAHR TYPE BSET-GJAHR,
BUZEI TYPE BSET-BUZEI,
MWSKZ TYPE BSET-MWSKZ,
HKONT TYPE BSET-HKONT,
HWBAS TYPE BSET-HWBAS, " LC Base amt
HWSTE TYPE BSET-HWSTE, " Tax Lc amt
FWSTE TYPE BSET-FWSTE, " Tax amt in doc curr
KSCHL TYPE BSET-KSCHL,
KBETR TYPE BSET-KBETR,
EBELN like EKBE-EBELN,
EBELP like EKBE-EBELP,
dmbtr like ekbe-dmbtr,
werks like ekbe-werks,
lifnr like bseg-lifnr,
name1 like lfa1-name1,
regio like lfa1-regio,
ort01 like lfa1-ort01,
ktokk like lfa1-ktokk,
txt30 like t077y-txt30,
budat like bkpf-budat,
blart like bkpf-blart,
bldat like bkpf-bldat,
xblnr like bkpf-xblnr,
rate like bset-kbetr,
text1 like t007s-text1,
txt50 like skat-txt50,
tax like bset-kbetr,
l_excise like bset-hwste,
l_vat like bset-hwste,
l_ecess like bset-hwste,
L_SERVICETAX like bset-hwste,
l_salestax like bset-hwste,
l_cess like bset-hwste,
END OF IT_BSET.
data : sss type p decimals 2.
data : begin of it_bseg occurs 0,
belnr like bseg-belnr,
hkont like bseg-hkont,
wrbtr like bseg-wrbtr,
lifnr like bseg-lifnr,
end of it_bseg.
selection-screen : begin of block abc with frame title txt.
SELECT-OPTIONS : comp FOR bkpf-bukrs NO INTERVALS OBLIGATORY .
SELECT-OPTIONS : acdoc FOR bkpf-belnr.
SELECT-OPTIONS : docno FOR ekbe-ebeln.
SELECT-OPTIONS : venno FOR ekko-lifnr .
SELECT-OPTIONS : ddate FOR bkpf-bldat .
SELECT-OPTIONS : pdate FOR bkpf-budat OBLIGATORY DEFAULT sy-datum.
*SELECT-OPTIONS : doctype FOR bkpf-blart.
SELECT-OPTIONS : tcode FOR bset-mwskz.
SELECT-OPTIONS : plant FOR ekbe-werks.
SELECT-OPTIONS : fisyr FOR bkpf-gjahr.
selection-screen : end of block abc.
perform data_fetch.
perform display.
&----
*& Form data_fetch
&----
text
----
form data_fetch.
select eebeln eebelp egjahr ebelnr ebudat ebldat exblnr edmbtr
ewerks emenge emwskz hbsart hlifnr lname1 lort01 lregio
l~ktokk
into corresponding fields of table it_ekbe
from ( ( ekbe as e
join ekko as h on eebeln = hebeln )
join lfa1 as l on hlifnr = llifnr )
*
*where e~ebeln in docno
*and e~bewtp in ('Q')
*and e~budat in pdate
*and e~bldat in ddate
*and e~werks in plant
*and h~lifnr in venno.
select belnr blart gjahr budat bldat xblnr HWAER from bkpf
into corresponding fields of table it_bkpf
where bukrs in comp
and belnr in acdoc
and gjahr in fisyr
and tcode = 'MIRO'
and bldat in ddate
and budat in pdate
and blart in ('AA','CM','ID','IR','KA','KG','KR','LC','PA',
'PS','RC','RD','RM','RP','SS','TR' ).
select belnr hkont wrbtr lifnr from bseg
into corresponding fields of table it_bseg
for all entries in it_bkpf
where bukrs in comp
and belnr = it_bkpf-belnr
and gjahr = it_bkpf-gjahr
and KOART = 'K'.
select name1 ort01 REGIO ktokk from lfa1
into corresponding fields of table it_lfa1
for all entries in it_bseg
where lifnr = it_bseg-lifnr.
select ktokk txt30 from T077Y into table it_T077Y
for all entries in it_lfa1
where ktokk = it_lfa1-ktokk
and spras = 'EN'.
select belnr mwskz hkont hwbas hwste fwste kschl kbetr from bset
into corresponding fields of table it_bset
for all entries in it_bkpf
where bukrs in comp
and belnr = it_bkpf-belnr
and gjahr = it_bkpf-gjahr
and ktosl <> 'VS1'
and mwskz in tcode .
select mwskz text1 from t007s into corresponding fields of table
it_t007s
for all entries in it_bset
where spras = 'EN'
and KALSM = 'TAXINJ'
and mwskz = it_bset-mwskz.
select saknr txt50 from skat into corresponding fields of table
it_skat
for all entries in it_bset
where spras = 'EN'
and saknr = it_bset-hkont.
loop at it_bset.
loop at it_bkpf where belnr = it_bset-belnr.
it_bset-xblnr = it_bkpf-xblnr.
it_bset-bldat = it_bkpf-bldat.
it_bset-budat = it_bkpf-budat.
it_bset-blart = it_bkpf-blart.
modify it_bset.
endloop.
endloop.
loop at it_bset.
loop at it_bseg where belnr = it_bset-belnr.
it_bset-lifnr = it_bseg-lifnr.
modify it_bset.
endloop.
endloop.
loop at it_bset.
loop at it_t007s where mwskz = it_bset-mwskz.
it_bset-text1 = it_t007s-text1.
modify it_bset.
endloop.
endloop.
loop at it_bset.
loop at it_skat where saknr = it_bset-hkont.
it_bset-txt50 = it_skat-txt50.
modify it_bset.
endloop.
endloop.
loop at it_bset.
it_bset-tax = it_bset-kbetr / 10.
modify it_bset.
endloop.
loop at it_bset.
loop at it_lfa1.
it_bset-name1 = it_lfa1-name1.
it_bset-ort01 = it_lfa1-ort01.
it_bset-regio = it_lfa1-regio.
it_bset-ktokk = it_lfa1-ktokk.
endloop.
modify it_bset.
clear it_lfa1.
endloop.
loop at it_bset.
loop at it_t077y.
it_bset-txt30 = it_t077y-txt30.
endloop.
modify it_bset.
clear it_t077y.
endloop.
******* To display Excise Freight Cess HigherCEss Service tax *******
loop at it_bset.
For VAT ***********
if it_bset-hkont = '185520' or
it_bset-hkont = '185528' or
it_bset-hkont = '185530' or
it_bset-hkont = '185550' or
it_bset-hkont = '185560' or
it_bset-hkont = '185561' or
it_bset-hkont = '185562' or
it_bset-hkont = '185585'.
it_bset-l_vat = it_bset-l_vat + it_bset-hwste.
endif.
For Excise ***********
if it_bset-hkont = '185300' or
it_bset-hkont = '185400' or
it_bset-hkont = '185521'.
it_bset-l_excise = it_bset-l_excise + it_bset-hwste.
endif.
For Education Cess *******
if it_bset-hkont = '185541' or
it_bset-hkont = '185543' or
it_bset-hkont = '185545' or
it_bset-hkont = '185547'.
it_bset-l_cess = it_bset-l_cess + it_bset-hwste.
endif.
For Higher Edu. Cess *******
if it_bset-hkont = '185552' or
it_bset-hkont = '185553' or
it_bset-hkont = '185554' or
it_bset-hkont = '185555'.
it_bset-l_ecess = it_bset-l_ecess + it_bset-hwste.
endif.
For Service Tax *********
if it_bset-hkont = '185542' or
it_bset-hkont = '185544' or
it_bset-hkont = '185546' or
it_bset-hkont = '311491'.
it_bset-L_SERVICETAX = it_bset-L_SERVICETAX + it_bset-hwste.
endif.
Sales Tax *********
if it_bset-hkont = '181000'.
it_bset-l_salestax = it_bset-l_salestax + it_bset-hwste.
endif.
modify it_bset.
clear it_bset.
endloop.
endform. "data_fetch
&----
*& Form display
&----
text
----
form display.
w_cat-fieldname = 'BELNR'.
w_cat-seltext_m = 'Document No'.
w_cat-just = 'R'.
w_cat-col_pos = 0.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'LIFNR'.
w_cat-seltext_m = 'Vendor Code'.
w_cat-just = 'R'.
w_cat-col_pos = 1.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'NAME1'.
w_cat-seltext_m = 'Vendor Name'.
w_cat-just = 'R'.
w_cat-col_pos = 2.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'ORT01'.
w_cat-seltext_m = 'City'.
w_cat-just = 'R'.
w_cat-col_pos = 3.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'REGIO'.
w_cat-seltext_m = 'Region'.
w_cat-just = 'R'.
w_cat-col_pos = 4.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'KTOKK'.
w_cat-seltext_m = 'Vendor Group'.
w_cat-just = 'R'.
w_cat-col_pos = 5.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'TXT30'.
w_cat-seltext_m = 'Group Description'.
w_cat-just = 'R'.
w_cat-col_pos = 6.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'BUDAT'.
w_cat-seltext_m = 'Posting Date'.
w_cat-just = 'R'.
w_cat-col_pos = 7.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'BLDAT'.
w_cat-seltext_m = 'Document Date'.
w_cat-just = 'R'.
w_cat-col_pos = 8.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'XBLNR'.
w_cat-seltext_m = 'Refrance Doc.No'.
w_cat-just = 'R'.
w_cat-col_pos = 9.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'MWSKZ'.
w_cat-seltext_m = 'Tax Code'.
w_cat-just = 'R'.
w_cat-col_pos = 10.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'TEXT1'.
w_cat-seltext_m = 'Tax Description'.
w_cat-just = 'R'.
w_cat-col_pos = 11.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'HKONT'.
w_cat-seltext_m = 'G/L Account'.
w_cat-just = 'R'.
w_cat-col_pos = 12.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'TXT50'.
w_cat-seltext_m = 'G/L Text'.
w_cat-just = 'R'.
w_cat-col_pos = 13.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'BLART'.
w_cat-seltext_m = 'Document Type'.
w_cat-just = 'R'.
w_cat-col_pos = 14.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'HWBAS'.
w_cat-seltext_m = 'Base Amount'.
w_cat-just = 'R'.
w_cat-col_pos = 15.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'L_EXCISE'.
w_cat-seltext_m = 'Excise'.
w_cat-just = 'R'.
w_cat-col_pos = 16.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'L_VAT'.
w_cat-seltext_m = 'Vat'.
w_cat-just = 'R'.
w_cat-col_pos = 17.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'L_CESS'.
w_cat-seltext_m = 'Cess'.
w_cat-just = 'R'.
w_cat-col_pos = 18.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'L_ECESS'.
w_cat-seltext_m = 'ECess'.
w_cat-just = 'R'.
w_cat-col_pos = 19.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'L_SERVICETAX'.
w_cat-seltext_m = 'Service Tax'.
w_cat-just = 'R'.
w_cat-col_pos = 20.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
w_cat-fieldname = 'TAX'.
w_cat-seltext_m = 'Tax Rate'.
w_cat-just = 'R'.
w_cat-col_pos = 21.
w_cat-outputlen = 15.
append w_cat to i_cat.
clear w_cat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = gd_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Purchase Register'
I_GRID_SETTINGS =
IS_LAYOUT = xlayout
IT_FIELDCAT = i_cat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = it_bset
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. "display
The proplem is i am not able to get the vales of variables l_excise, l_cess,l_ecess depending on the G/L Account.
The complier is not executing the statements in the if condition.
Plz guide so that i can solve the prob asap.
Thank You.
‎2008 Nov 07 10:56 AM
hi,
if it_bset-hkont = '185520' .
use conversion exit before this condition.
HKONT is a field with length 10 char,you are hard coding the value in the if condition.sometimes it will not work unless you use conversion exit.
‎2008 Nov 10 5:50 AM
Hi all,
I am still not able to find the solution for it.
Suggest some solution for this.
is any worng in the internal table that i have declared???
becoz the complier does not execute the if statements.
Thanks.
‎2008 Nov 10 8:24 AM
Hi,
One thing you need to do is declare constants for your accout numbers that you have hard coded while comparing in the if condition. Make sure you type the constants as bset-hkont
Secondly, I would suggest you use case endcase instead of if stament. code will become much more legible and simpler to understand and debug.
regards,
Advait
‎2008 Nov 17 7:05 AM
I solved the problem myself only.
Neways Thanks all 4 d reply.
Purva.