Skip to Content
0
Jul 13, 2007 at 02:45 PM

problem after deleting the records........

30 Views

Hi Folks,

Kindly help me with this report.

At one point I am deleting the itfinal internal table w.r.t

to HKONT.Before deleting I am having all the values for

LIFNR and AWKey,but once deleting(as mentioned earlier) I

am not getting these two values.The same Awkey is getting repeated

again and again.

Where I am going wrong.

REPORT zf14 no standard page heading line-size 134. .

TABLES: bkpf,bseg,lfa1,t001.

type-pools:slis.

TYPES : BEGIN OF x_bkpf,

bukrs TYPE bkpf-bukrs, " Company Code

belnr TYPE bkpf-belnr, " Document Number

gjahr TYPE bkpf-gjahr, " Fiscal year

awkey TYPE bkpf-awkey, " Object Key

bldat TYPE bkpf-bldat,

budat TYPE bkpf-budat,

END OF x_bkpf.

TYPES : BEGIN OF x_bseg,

bukrs TYPE bseg-bukrs, " Company Code

belnr TYPE bseg-belnr, " Document Number

gjahr TYPE bseg-gjahr, " Fiscal Year

koart TYPE bseg-koart,

hkont TYPE bseg-hkont, " G/L Account

ebeln TYPE bseg-ebeln, " Purchasing Document

lifnr TYPE bseg-lifnr, " Vendor Code

name1 type lfa1-name1,

ort01 type lfa1-ort01,

END OF x_bseg.

TYPES : BEGIN OF x_bseg1,

bukrs TYPE bseg-bukrs, " Company Code

belnr TYPE bsak-belnr, " Document Number

gjahr TYPE bsak-gjahr, " Fiscal Year

hkont TYPE bseg-hkont, " G/L Account

ebeln TYPE bseg-ebeln, " Purchasing Document

lifnr TYPE bseg-lifnr, " Vendor Code

wrbtr TYPE bseg-wrbtr, " Amt.in Doc.Curr

END OF x_bseg1.

types:begin of x_ven,

name1 type lfa1-name1,

ort01 type lfa1-ort01,

end of x_ven.

TYPES : BEGIN OF x_final,

bukrs TYPE bkpf-bukrs, " Company Code

belnr TYPE bkpf-belnr, " Document Number

gjahr TYPE bkpf-gjahr, " Fiscal year

blart TYPE bkpf-blart, " Document Type

awkey TYPE bkpf-awkey, " Object Key

bldat TYPE bkpf-bldat,

budat TYPE bkpf-budat,

mwskz TYPE bseg-mwskz,

qsskz TYPE bseg-qsskz,

wrbtr TYPE bseg-wrbtr, " Amount in Doc Curr

werks TYPE bseg-werks, " Recv Facility Code

hkont TYPE bseg-hkont, " G/L Account

ebeln TYPE bseg-ebeln, " Purchasing Document

ebeln1 type bseg-ebeln,

lifnr TYPE bseg-lifnr, " Vendor Code

lifnr1 type bseg-lifnr,

dmbtr TYPE bseg-dmbtr,

wrtbr type bseg-wrbtr,

vbill type bseg-wrbtr,

tdsamt type c,

tdsrate(4),

shkzg TYPE bseg-shkzg,

name1 TYPE lfa1-name1, "vendor Name

ort01 TYPE lfa1-ort01, "City

j_1icstno TYPE j_1imovend-j_1icstno, "CST

j_1ilstno TYPE j_1imovend-j_1ilstno ,"LST

END OF x_final.

DATA : it_bkpf TYPE TABLE OF x_bkpf WITH HEADER LINE .

DATA : it_bseg TYPE TABLE OF x_bseg WITH HEADER LINE .

DATA : it_bseg1 TYPE TABLE OF x_bseg1 WITH HEADER LINE .

DATA : itfinal TYPE TABLE OF x_final WITH HEADER LINE.

DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.

DATA :i(2), "month

y TYPE int4, "year

c(4),

v_bill LIKE bseg-dmbtr. " bill value

DATA : pos TYPE sy-tabix,

month(99),

month1(99).

data:sl_no(3) value 0.

*Alv

DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA:itrepid TYPE sy-repid.

itrepid = sy-repid.

DATA:itevent TYPE slis_t_event.

DATA:itlistheader TYPE slis_t_listheader.

DATA:walistheader LIKE LINE OF itlistheader.

DATA:itlayout TYPE slis_layout_alv.

DATA:top TYPE slis_formname.

DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.

DATA:itprintparams TYPE slis_print_alv.

DATA:itvariant TYPE disvariant.

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

PARAMETERS : p_bukrs LIKE t001-bukrs OBLIGATORY. "Company code

SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr, "Vendor name

s_budat for sy-datum obligatory, "bkpf-budat OBLIGATORY, "Date

s_gjahr FOR bseg-gjahr NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN.

SELECT SINGLE bukrs

INTO t001-bukrs

FROM t001

WHERE bukrs = p_bukrs.

IF sy-subrc <> 0.

MESSAGE e000(z_ma) WITH 'Invalid Company Code'.

ENDIF.

IF NOT s_lifnr[] IS INITIAL.

SELECT SINGLE lifnr

INTO lfa1-lifnr

FROM lfa1

WHERE lifnr IN s_lifnr.

IF sy-subrc <> 0.

MESSAGE e000(z_ma) WITH 'Invalid Vendor'.

ENDIF.

ENDIF.

START-OF-SELECTION.

*13

if s_budat is not initial.

if s_budat-high is not initial.

while s_budat-low le s_budat-high.

i = s_budat+7(2).

if i > 3.

s_gjahr = s_budat+3(4).

append s_gjahr.

else.

c = s_budat+3(4).

S_GJAHR = C - 1.

append s_gjahr.

endif.

s_budat-low = s_budat-low + 1.

endwhile.

else.

i = s_budat+7(2).

if i > 3.

s_gjahr = s_budat+3(4).

append s_gjahr.

else.

c = s_budat+3(4).

S_GJAHR = C - 1.

append s_gjahr.

endif.

endif.

endif.

*13

SELECT bukrs belnr gjahr awkey bldat budat

INTO TABLE it_bkpf

FROM bkpf

WHERE bukrs = p_bukrs

AND budat IN s_budat

and gjahr = s_gjahr. "13

IF NOT it_bkpf[] IS INITIAL.

SELECT bukrs belnr dmbtr wrbtr hkont ebeln lifnr

FROM bseg

INTO CORRESPONDING FIELDS OF TABLE it_bseg

FOR ALL ENTRIES IN it_bkpf

WHERE bukrs = it_bkpf-bukrs

and belnr = it_bkpf-belnr

AND gjahr = s_gjahr "13-it_bkpf-gjahr

AND koart = 'K'.

ENDIF.

IF NOT it_bseg[] IS INITIAL.

SELECT belnr gjahr dmbtr wrbtr hkont ebeln lifnr

FROM bseg

INTO CORRESPONDING FIELDS OF TABLE it_bseg1

FOR ALL ENTRIES IN it_bkpf

WHERE bukrs = it_bkpf-bukrs "13it_bkpf-bukrs

AND belnr = it_bkpf-belnr "13it_bkpf-belnr

AND gjahr = s_gjahr. "13-it_bkpf-gjahr.

ENDIF.

LOOP AT it_bkpf.

MOVE-CORRESPONDING it_bkpf TO itfinal.

APPEND itfinal.

ENDLOOP.

LOOP AT it_bseg.

MOVE-CORRESPONDING it_bseg TO itfinal.

append itfinal.

select single name1 ort01 from lfa1 into (itfinal-name1 , itfinal-ort01) where lifnr = it_bseg-lifnr.

select single j_1icstno j_1ilstno into (itfinal-j_1icstno , itfinal-j_1ilstno) from j_1imovend

where lifnr = it_bseg-lifnr.

ENDLOOP.

LOOP AT it_bseg1.

MOVE-CORRESPONDING it_bseg1 TO itfinal.

APPEND itfinal.

ENDLOOP.

loop at it_bseg1.

itfinal-ebeln1 = it_bseg1-ebeln.

append itfinal.

endloop.

*Deleting the records from ITFINAL w.r.t HKONT.

<b>LOOP AT itfinal.

IF itfinal-hkont NE '0020106230' AND

itfinal-hkont NE '0020106330'.

DELETE itfinal.

endif.

clear itfinal.

ENDLOOP.</b>

*Caluculating Bill Value

loop at itfinal.

if itfinal-hkont = '0020106230'.

itfinal-tdsrate = '2%'.

itfinal-vbill = itfinal-wrbtr * 100 / 2.

modify itfinal.

elseif itfinal-hkont = '0020106330'.

itfinal-tdsrate = '4%'.

itfinal-vbill = itfinal-wrbtr * 100 / 4.

modify itfinal.

endif.

endloop.

sort itfinal by belnr.

delete adjacent duplicates from itfinal comparing belnr.

format reset.

format color col_normal.

LOOP AT itfinal.

sl_no = sl_no + 1.

write:/ sy-vline,

2 sl_no,

7 sy-vline,

10 itfinal-ebeln1,

21 sy-vline,

23 itfinal-awkey,

44 sy-vline,

45 itfinal-bldat,

57 sy-vline,

60 itfinal-vbill,

75 sy-vline,

76 itfinal-tdsrate,

85 sy-vline,

89 itfinal-wrbtr,

106 sy-vline,

109 itfinal-belnr,

121 sy-vline,

124 itfinal-budat,

134 sy-vline.

ENDLOOP.

write:/ sy-uline.

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

top-of-page.

data : name1(60).

data : month_text(127),

string(99).

call function 'MONTH_NAMES_GET'

exporting

language = sy-langu

  • IMPORTING

  • RETURN_CODE =

tables

month_names = month_names[]

exceptions

month_names_not_found = 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.

format reset.

format color col_positive.

if not s_budat-low is initial .

read table month_names with key mnr = s_budat-low+4(2).

if sy-subrc = 0.

month = month_names-ltx.

string = 'Details of TDS (2% / 4%) On Works Contract Deducted'.

concatenate string 'for the Month of' month into month_text

separated by space.

write :/ month_text.

skip 1.

endif.

endif.

concatenate itfinal-name1 ',' itfinal-ort01

into name1 separated by space.

write :/ 'Vendor Code :', itfinal-lifnr.

write :/ 'Vendor Name and City :', name1.

skip 1.

write :/ 'TNGST Registration No :', itfinal-j_1ilstno,

/ 'CST Registration No :', itfinal-j_1icstno.

skip 1.

  • Display the coloumn headings

format reset.

format color col_heading.

write :/ sy-uline.

write:/ sy-vline,

2 'Sl_no',

7 sy-vline,

10 'P.O. No',

21 sy-vline,

22 'Invoice No',

44 sy-vline,

45 'Inv Date',

57 sy-vline,

60 'Bill value',

75 sy-vline,

76 'TDS Rate',

85 sy-vline,

89 'TDS Amount' ,

106 sy-vline,

108 'Doc.No.',

121 sy-vline,

125 'Pos Date',

134 sy-vline,

sy-uline.

K.Kiran.