Skip to Content
0
Former Member
Oct 29, 2012 at 12:26 PM

Tds is not showing as per std tcode

113 Views

I have created a z report for tds deduction .For some document the TDS is deducted twice but in zreport is only showing the last value .The code i have written is below

*&---------------------------------------------------------------------*
*& Report ZFI_REP_TDS_REG
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*


REPORT ZRFI_TDS_REG
NO STANDARD PAGE HEADING LINE-SIZE 225.

TYPE-POOLS : SLIS .
TABLES : BSEG,BKPF,LFA1,KNA1,
VBRK,
VBRP,
VBPA,VBFA,J_1IEWTCHLN,J_1ICERTIF,
VBAK,
KONV ,
TVFK , TCURX,T059Z.

*&---------------------------------------------------------------------*
*& GLOBLE DATA
*&---------------------------------------------------------------------*
DATA : G_SAVE(1) TYPE C ,
G_EXIT(1) TYPE C ,
G_VARIANT LIKE DISVARIANT ,
GX_VARIANT LIKE DISVARIANT ,
F2CODE LIKE SY-UCOMM VALUE '&ETA' ,
LAYOUT TYPE SLIS_LAYOUT_ALV ,
PRG LIKE SY-REPID ,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER ,
GT_EVENTS TYPE SLIS_T_EVENT ,
FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE ,
END_PAGE TYPE SLIS_FORMNAME,
HEADING TYPE SLIS_T_LISTHEADER ,
FOOTER TYPE SLIS_T_LISTHEADER.


DATA : BEGIN OF WA_ITAB ,
BELNR LIKE BSEG-BELNR,
GJAHR LIKE BSEG-GJAHR,
LIFNR LIKE BSEG-LIFNR,
NAME1 LIKE LFA1-NAME1,
DMBTR LIKE BSEG-DMBTR,
TDS LIKE BSEG-DMBTR,
SC LIKE BSEG-DMBTR,
CESS LIKE BSEG-DMBTR,
SHCESS LIKE BSEG-DMBTR,
QBSHB LIKE BSEG-QBSHB,
QSREC LIKE LFBW-QSREC,
RTEXT(10),
QSATZ LIKE T059Z-QSATZ,
SECCO LIKE BSEG-SECCO,
PRCTR TYPE BSEG-PRCTR ,
BUDAT LIKE BKPF-BUDAT,
BLDAT LIKE BKPF-BLDAT,
XBLNR LIKE BKPF-XBLNR,
J_1IINTCHLN LIKE J_1IEWTCHLN-J_1IINTCHLN, "inter-num
J_1IINTCHDT LIKE J_1IEWTCHLN-J_1IINTCHDT, "date
J_1IEXTCHLN LIKE J_1IEWTCHLN-J_1IEXTCHLN, " exter-num
J_1IEXTCHDT LIKE J_1IEWTCHLN-J_1IEXTCHDT, "date
J_1ITDSDOC LIKE J_1ICERTIF-J_1ITDSDOC, "tds certif no
J_1ICERTDT LIKE J_1ICERTIF-J_1ICERTDT, "date
TEXT(5),
J_1IPANNO LIKE J_1IMOVEND-J_1IPANNO,
END OF WA_ITAB.


DATA : BEGIN OF WA_BSEG1 ,
BELNR LIKE BSEG-BELNR,
GJAHR LIKE BSEG-GJAHR,
BUKRS LIKE BSEG-BUKRS,
BUZEI LIKE BSEG-BUZEI,
LIFNR LIKE BSEG-LIFNR,
SECCO LIKE BSEG-SECCO,
DMBTR LIKE BSEG-DMBTR,
SHKZG LIKE BSEG-SHKZG,
QBSHB LIKE BSEG-QBSHB,
REBZG LIKE BSEG-REBZG,
REBZJ LIKE BSEG-REBZJ,
PRCTR TYPE BSEG-PRCTR ,
UMSKZ TYPE BSEG-UMSKZ ,
END OF WA_BSEG1.

DATA : BEGIN OF WA_BSEG2 ,
BELNR LIKE BSEG-BELNR,
GJAHR LIKE BSEG-GJAHR,
BUKRS LIKE BSEG-BUKRS,
BUZEI LIKE BSEG-BUZEI,
LIFNR LIKE BSEG-LIFNR,
SECCO LIKE BSEG-SECCO,
DMBTR LIKE BSEG-DMBTR,
SHKZG LIKE BSEG-SHKZG,
QBSHB LIKE BSEG-QBSHB,
REBZG LIKE BSEG-REBZG,
REBZJ LIKE BSEG-REBZJ,
PRCTR TYPE BSEG-PRCTR ,
END OF WA_BSEG2.

DATA : WITH_ITEM1 LIKE STANDARD TABLE OF WITH_ITEM WITH HEADER LINE.
DATA : ITAB LIKE STANDARD TABLE OF WA_ITAB WITH HEADER LINE.
DATA : BSEG1 LIKE STANDARD TABLE OF WA_BSEG1 WITH HEADER LINE.
DATA : BSEG2 LIKE STANDARD TABLE OF WA_BSEG2 WITH HEADER LINE.
DATA: BKPF1 TYPE STANDARD TABLE OF BKPF WITH HEADER LINE.

RANGES : R_VBTYP FOR VBRK-VBTYP.

DATA : CURR_DEC TYPE I ,
N TYPE I.
DATA : TDID TYPE THEAD-TDID,
TDNAME TYPE THEAD-TDNAME,
TDOBJECT TYPE THEAD-TDOBJECT.

DATA: BEGIN OF TLINE OCCURS 10.
INCLUDE STRUCTURE TLINE .
DATA: END OF TLINE .

DATA: AVG1 TYPE P DECIMALS 2,
AVG2 TYPE P DECIMALS 2,
V_QSATZ1 LIKE T059Z-QSATZ,
V_QSATZ2 LIKE T059Z-QSATZ,
V_QSATZ3 LIKE T059Z-QSATZ,
V_QSATZ4 LIKE T059Z-QSATZ,
V_TDS LIKE BSEG-DMBTR,
V_SC LIKE BSEG-DMBTR,
V_CESS LIKE BSEG-DMBTR,
V_SHCESS LIKE BSEG-DMBTR,
RESULT1 LIKE T059Z-QSATZ,
RESULT2 LIKE T059Z-QSATZ.
DATA : YEAR TYPE GJAHR,
YEAR1 TYPE GJAHR.

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS S_BUKRS FOR BKPF-BUKRS NO-EXTENSION NO INTERVALS OBLIGATORY DEFAULT '1100'.

SELECT-OPTIONS S_BUDAT FOR BKPF-BUDAT OBLIGATORY. "DOCUMENT DATE

SELECTION-SCREEN END OF BLOCK BLK1.

SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT. " ALV Variant
SELECTION-SCREEN END OF BLOCK BLK2.

*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION .


CALL FUNCTION 'FTI_FISCAL_YEAR_MONTH_GET'
EXPORTING
I_BUKRS = '1100'
I_BUDAT = SY-DATUM
IMPORTING
E_GJAHR = YEAR.
CONCATENATE YEAR '04' '01' INTO S_BUDAT-LOW.
S_BUDAT-HIGH = SY-DATUM.
APPEND S_BUDAT.

PRG = SY-REPID .

R_VBTYP-SIGN = 'I'.
R_VBTYP-OPTION = 'EQ'.
R_VBTYP-LOW = 'N'.
APPEND R_VBTYP.

R_VBTYP-SIGN = 'I'.
R_VBTYP-OPTION = 'EQ'.
R_VBTYP-LOW = 'O'.
APPEND R_VBTYP.

R_VBTYP-SIGN = 'I'.
R_VBTYP-OPTION = 'EQ'.
R_VBTYP-LOW = 'P'.
APPEND R_VBTYP.

R_VBTYP-SIGN = 'I'.
R_VBTYP-OPTION = 'EQ'.
R_VBTYP-LOW = 'S'.
APPEND R_VBTYP.

R_VBTYP-SIGN = 'I'.
R_VBTYP-OPTION = 'EQ'.
R_VBTYP-LOW = 'U'.
APPEND R_VBTYP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
PERFORM F4_FOR_VARIANT.

START-OF-SELECTION.

PERFORM GET_DATA .
IF ITAB[] IS NOT INITIAL .
PERFORM DISP_DATA .
ELSE .
MESSAGE I000(ZCVS) WITH 'No data Found ' .
ENDIF .


*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*

FORM GET_DATA.
TYPES : BEGIN OF TY_BSEG ,
BUKRS TYPE BSEG-BUKRS ,
GJAHR TYPE BSEG-GJAHR ,
BUZEI TYPE BSEG-BUZEI ,
BELNR TYPE BSEG-LIFNR ,
QSSKZ TYPE BSEG-QSSKZ ,
* PRCTR TYPE BSEG-PRCTR,
END OF TY_BSEG .
DATA : IT_BSEG TYPE TABLE OF TY_BSEG WITH HEADER LINE.

DATA : IT_BSEG_EXT TYPE FAGL_T_BSEG_EXT WITH HEADER LINE.

DATA : KNUMV LIKE VBRK-KNUMV .
DATA KONV1 TYPE KONV OCCURS 0 WITH HEADER LINE.

SELECT * FROM BKPF INTO TABLE BKPF1
WHERE BUKRS IN S_BUKRS
* AND gjahr = s_gjahr
AND BUDAT IN S_BUDAT
* AND blart = 'KR'
AND BSTAT IN (SPACE, 'A' , 'B' , 'D')
AND STBLG = ''
AND XREVERSAL EQ SPACE.

CHECK BKPF1[] IS NOT INITIAL.

SELECT * FROM BSEG INTO CORRESPONDING FIELDS OF TABLE BSEG1
FOR ALL ENTRIES IN BKPF1
WHERE BUKRS = BKPF1-BUKRS
AND BELNR = BKPF1-BELNR
AND GJAHR = BKPF1-GJAHR.
* AND KOART IN ('K')
* AND BSCHL in ('31',34)
* AND LIFNR NE SPACE
* AND SECCO NE SPACE.
* AND QBSHB NE 0.

CHECK BKPF1[] IS NOT INITIAL.

SELECT * FROM BSEG APPENDING CORRESPONDING FIELDS OF TABLE BSEG1
FOR ALL ENTRIES IN BKPF1
WHERE BUKRS = BKPF1-BUKRS
AND BELNR = BKPF1-BELNR
AND GJAHR = BKPF1-GJAHR
* AND KOART IN ('K')
* AND BSCHL in ('31',34)
* AND LIFNR NE SPACE
AND SECCO NE SPACE
AND QSZNR EQ '000001'.


sort bseg1 by belnr buzei.
* delete adjacent duplicates from bseg1 comparing belnr buzei.



BSEG2[] = BSEG1[].

LOOP AT BSEG2.
READ TABLE BKPF1 WITH KEY BELNR = BSEG2-BELNR GJAHR = BSEG2-GJAHR BUKRS = BSEG2-BUKRS.
IF BKPF1-TCODE = 'MIRO' OR BKPF1-TCODE = 'MR8M'.
READ TABLE BSEG1 WITH KEY BELNR = BSEG2-REBZG GJAHR = BSEG2-REBZJ.
IF SY-SUBRC = 0.
* DELETE BSEG1 WHERE BELNR = BSEG2-REBZG AND GJAHR = BSEG2-REBZJ.
* DELETE BSEG1 WHERE BELNR = BSEG2-BELNR AND GJAHR = BSEG2-GJAHR.
ENDIF.
ENDIF.
ENDLOOP.



SELECT * FROM WITH_ITEM INTO CORRESPONDING FIELDS OF TABLE WITH_ITEM1
FOR ALL ENTRIES IN BSEG1
WHERE BUKRS = BSEG1-BUKRS
AND BELNR = BSEG1-BELNR
AND GJAHR = BSEG1-GJAHR
* AND wt_qsshh NE 0
AND J_1IBUZEI NE SPACE.


IF NOT BSEG1[] IS INITIAL.
* REFRESH IT_BSEG.
SELECT BUKRS
GJAHR
BUZEI
BELNR
QSSKZ
INTO TABLE IT_BSEG
FROM BSEG
FOR ALL ENTRIES IN BSEG1
WHERE BUKRS IN S_BUKRS
AND BELNR EQ BSEG1-BELNR
AND GJAHR EQ BSEG1-GJAHR
AND QSSKZ NE SPACE
AND QSSKZ NE 'XX'.
IF SY-SUBRC EQ 0.
SORT IT_BSEG BY BUKRS BELNR buzei.
* DELETE ADJACENT DUPLICATES FROM IT_BSEG COMPARING BELNR buzei.
* DELETE ADJACENT DUPLICATES FROM IT_BSEG comparing buzei.
ENDIF.
ENDIF.



LOOP AT BSEG1.
READ TABLE WITH_ITEM1 WITH KEY BELNR = BSEG1-BELNR
GJAHR = BSEG1-GJAHR
BUKRS = BSEG1-BUKRS
BUZEI = BSEG1-BUZEI.
IF SY-SUBRC NE 0.
CONTINUE.
ENDIF.
ITAB-LIFNR = BSEG1-LIFNR.

SELECT SINGLE NAME1 FROM LFA1 INTO ITAB-NAME1 WHERE LIFNR = BSEG1-LIFNR.

SELECT SINGLE QSREC FROM LFBW INTO ITAB-QSREC WHERE LIFNR = BSEG1-LIFNR
AND BUKRS = BSEG1-BUKRS.
IF SY-SUBRC = 0.
IF ITAB-QSREC = 'CO'.
ITAB-RTEXT = '1'.
ELSEIF ITAB-QSREC = 'OT'.
ITAB-RTEXT = '2'.
ENDIF.
ENDIF.
ITAB-SECCO = BSEG1-SECCO.

READ TABLE BKPF1 WITH KEY BELNR = BSEG1-BELNR GJAHR = BSEG1-GJAHR BUKRS = BSEG1-BUKRS.
IF SY-SUBRC = 0.
ITAB-BELNR = BKPF1-BELNR.
ITAB-BUDAT = BKPF1-BUDAT.
ITAB-BLDAT = BKPF1-BLDAT.
ITAB-XBLNR = BKPF1-XBLNR.
ENDIF.

SELECT SINGLE J_1IPANNO FROM J_1IMOVEND INTO ITAB-J_1IPANNO WHERE LIFNR = ITAB-LIFNR.

* CLEAR : V_QSATZ1,V_QSATZ2 , V_QSATZ3 ,V_QSATZ4.
***************

LOOP AT WITH_ITEM1 WHERE BELNR = BSEG1-BELNR
AND GJAHR = BSEG1-GJAHR
AND BUKRS = BSEG1-BUKRS
AND BUZEI = BSEG1-BUZEI.

READ TABLE BKPF1 WITH KEY BELNR = WITH_ITEM1-BELNR GJAHR = WITH_ITEM1-GJAHR BUKRS = WITH_ITEM1-BUKRS.

IF WITH_ITEM1-WITHT = '1C' OR WITH_ITEM1-WITHT = 'C1' OR WITH_ITEM1-WITHT = 'A1' OR WITH_ITEM1-WITHT = '1A' OR WITH_ITEM1-WITHT = 'A5' OR WITH_ITEM1-WITHT = '5A'
OR WITH_ITEM1-WITHT = 'C5' OR WITH_ITEM1-WITHT = '5C'OR WITH_ITEM1-WITHT = 'H1' OR WITH_ITEM1-WITHT = '1H' OR WITH_ITEM1-WITHT = 'I1' OR WITH_ITEM1-WITHT = 'I5'
OR WITH_ITEM1-WITHT = 'P1' OR WITH_ITEM1-WITHT = '1I' OR WITH_ITEM1-WITHT = '5I' OR WITH_ITEM1-WITHT = '1P' OR WITH_ITEM1-WITHT = 'J1' OR WITH_ITEM1-WITHT = '1J'
OR WITH_ITEM1-WITHT = '1U' OR WITH_ITEM1-WITHT = 'U1'.

* itab-qsatz = itab-qsatz + with_item1-qsatz.
V_QSATZ1 = WITH_ITEM1-QSATZ.


IF WITH_ITEM1-WT_QBSHH LE 0.
ITAB-TDS = WITH_ITEM1-WT_QBSHH .
ELSE.
ITAB-TDS = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.


* IF WITH_ITEM1-WT_QBSHH < 0.
IF BKPF1-TCODE = 'FBA7' OR BKPF1-TCODE = 'FBZ2'.
ITAB-TDS = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.
ENDIF.

IF WITH_ITEM1-WITHT = '2C' or WITH_ITEM1-WITHT = 'C2' or WITH_ITEM1-WITHT = 'A2' or WITH_ITEM1-WITHT = 'A6' or WITH_ITEM1-WITHT = '2A' or WITH_ITEM1-WITHT = '6A'
or WITH_ITEM1-WITHT = 'C6' or WITH_ITEM1-WITHT = '6C' or WITH_ITEM1-WITHT = 'H2' or WITH_ITEM1-WITHT = '2H' or WITH_ITEM1-WITHT = 'I2' or WITH_ITEM1-WITHT = 'I6'
or WITH_ITEM1-WITHT = 'P2' or WITH_ITEM1-WITHT = '2I' or WITH_ITEM1-WITHT = '6I' or WITH_ITEM1-WITHT = '2P' or WITH_ITEM1-WITHT = 'J2' or WITH_ITEM1-WITHT = '2J'.

V_QSATZ2 = WITH_ITEM1-QSATZ.


IF WITH_ITEM1-WT_QBSHH LE 0.
ITAB-SC = WITH_ITEM1-WT_QBSHH .
ELSE.
ITAB-SC = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.



IF BKPF1-TCODE = 'FBA7' OR BKPF1-TCODE = 'FBZ2'.
ITAB-SC = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.
ENDIF.

IF WITH_ITEM1-WITHT = '3C' OR WITH_ITEM1-WITHT = 'C3' or WITH_ITEM1-WITHT = 'A3' or WITH_ITEM1-WITHT = 'A7' or WITH_ITEM1-WITHT = '3A' or WITH_ITEM1-WITHT = '7A'
or WITH_ITEM1-WITHT = 'C7'or WITH_ITEM1-WITHT = '7C' or WITH_ITEM1-WITHT = 'H3' or WITH_ITEM1-WITHT = '3H' or WITH_ITEM1-WITHT = 'I3' or WITH_ITEM1-WITHT = 'I7'
or WITH_ITEM1-WITHT = 'P3' or WITH_ITEM1-WITHT = 'C2' or WITH_ITEM1-WITHT = '3I' or WITH_ITEM1-WITHT = '7I' or WITH_ITEM1-WITHT = '3P' or WITH_ITEM1-WITHT = 'J3'
or WITH_ITEM1-WITHT = '3J'.
*
V_QSATZ3 = WITH_ITEM1-QSATZ.


IF WITH_ITEM1-WT_QBSHH LE 0.
ITAB-CESS = WITH_ITEM1-WT_QBSHH .
ELSE.
ITAB-CESS = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.



IF BKPF1-TCODE = 'FBA7' OR BKPF1-TCODE = 'FBZ2'.
ITAB-CESS = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.
ENDIF.

IF WITH_ITEM1-WITHT = '4C' OR WITH_ITEM1-WITHT = 'C4' or WITH_ITEM1-WITHT = 'A4' or WITH_ITEM1-WITHT = 'A8' or WITH_ITEM1-WITHT = '4A' or WITH_ITEM1-WITHT = '8A'
or WITH_ITEM1-WITHT = 'C4' or WITH_ITEM1-WITHT = 'C8' or WITH_ITEM1-WITHT = '4C' or WITH_ITEM1-WITHT = '8C' or WITH_ITEM1-WITHT = 'H4' or WITH_ITEM1-WITHT = '4H'
or WITH_ITEM1-WITHT = 'I4' or WITH_ITEM1-WITHT = 'I8' or WITH_ITEM1-WITHT = 'P4' or WITH_ITEM1-WITHT = '4I' or WITH_ITEM1-WITHT = '8I' or WITH_ITEM1-WITHT = '4P'
or WITH_ITEM1-WITHT = '4J' or WITH_ITEM1-WITHT = 'J4'.
*
V_QSATZ4 = WITH_ITEM1-QSATZ.


IF WITH_ITEM1-WT_QBSHH LE 0.
ITAB-SHCESS = WITH_ITEM1-WT_QBSHH .
ELSE.
ITAB-SHCESS = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.


IF BKPF1-TCODE = 'FBA7' OR BKPF1-TCODE = 'FBZ2'.
ITAB-SHCESS = WITH_ITEM1-WT_QBSHH * -1.
ENDIF.
ENDIF.


ITAB-J_1IINTCHLN = WITH_ITEM1-J_1IINTCHLN. "inter-num
ITAB-J_1IINTCHDT = WITH_ITEM1-J_1IINTCHDT. "date

SELECT SINGLE * FROM J_1IEWTCHLN WHERE BUKRS = BSEG1-BUKRS
AND GJAHR = BSEG1-GJAHR
AND J_1IINTCHLN = ITAB-J_1IINTCHLN
AND J_1IINTCHDT = ITAB-J_1IINTCHDT.
IF SY-SUBRC = 0.
ITAB-J_1IEXTCHLN = J_1IEWTCHLN-J_1IEXTCHLN. " exter-num
ITAB-J_1IEXTCHDT = J_1IEWTCHLN-J_1IEXTCHDT. "date
ENDIF.

IF SY-SUBRC = 0.
ITAB-J_1ITDSDOC = WITH_ITEM1-CTNUMBER. "tds certif no
ITAB-J_1ICERTDT = WITH_ITEM1-J_1ICERTDT. "date
ENDIF.

SELECT SINGLE QSCOD FROM T059Z INTO ITAB-SECCO WHERE LAND1 = 'IN'
AND WITHT = WITH_ITEM1-WITHT
AND WT_WITHCD = WITH_ITEM1-WT_WITHCD .



ENDLOOP.


RESULT1 = ( V_QSATZ1 * V_QSATZ2 ) / 100.
RESULT1 = RESULT1 + V_QSATZ1.
RESULT2 = ( RESULT1 * 3 ) / 100.
ITAB-QSATZ = RESULT1 + RESULT2 .


IF BSEG1-SHKZG = 'H'.
BSEG1-DMBTR = BSEG1-DMBTR * -1.
ENDIF.

ITAB-QBSHB = ITAB-TDS + ITAB-SC + ITAB-CESS + ITAB-SHCESS.

* To get advance payment value instead of actual amount paid
* CLEAR WITH_ITEM1.
READ TABLE WITH_ITEM1 WITH KEY BELNR = BSEG1-BELNR
GJAHR = BSEG1-GJAHR
BUKRS = BSEG1-BUKRS
BUZEI = BSEG1-BUZEI
WITHT = 'I1'
WT_BASMAN = 'X'.
IF SY-SUBRC EQ 0.
ITAB-DMBTR = WITH_ITEM1-WT_QSSHH.
ELSE.
IF BSEG1-UMSKZ NE 'A'.
ITAB-DMBTR = BSEG1-DMBTR + ITAB-QBSHB.
ELSE.
ITAB-DMBTR = BSEG1-DMBTR.
ENDIF.
ENDIF.

* CLEAR IT_BSEG.
READ TABLE IT_BSEG WITH KEY BUKRS = BSEG1-BUKRS
BELNR = BSEG1-BELNR
buzei = BSEG1-Buzei.
IF SY-SUBRC EQ 0.
CALL FUNCTION 'FAGL_GET_GL_DOCUMENT'
EXPORTING
I_RLDNR = '0L'
I_BUKRS = IT_BSEG-BUKRS
I_BELNR = IT_BSEG-BELNR
I_GJAHR = IT_BSEG-GJAHR
I_BUZEI = IT_BSEG-BUZEI
* IT_FIELDLIST = IT_FIELDLIST
* IT_WHERE_CLAUSE = IT_WHERE_CLAUSE
* I_AUTHORITY_CHECK = ' '
IMPORTING
ET_BSEG_EXT = IT_BSEG_EXT[]
EXCEPTIONS
NOT_FOUND = 1.

IF SY-SUBRC EQ 0.
* CLEAR IT_BSEG_EXT.
READ TABLE IT_BSEG_EXT INDEX 1.
IF SY-SUBRC EQ 0.
MOVE IT_BSEG_EXT-PRCTR TO ITAB-PRCTR.
REFRESH IT_BSEG_EXT.
CLEAR IT_BSEG_EXT.
ENDIF.
ENDIF.
ENDIF.


APPEND ITAB.
* CLEAR ITAB.

* endloop.
ENDLOOP.
ENDFORM. " GET_DATA

*&---------------------------------------------------------------------*
*& Form DISP_DATA
*&---------------------------------------------------------------------*
FORM DISP_DATA .
PERFORM MERGE_FIELDCATALOG .
PERFORM SET_FIELDCAT .
PERFORM EVENTTAB_BUILD USING GT_EVENTS .
PERFORM BUILD_LAYOUT USING LAYOUT .
IF G_SAVE EQ SPACE .
PERFORM INITIALIZE_VARIANT .
ENDIF .
PERFORM DISP_ALV .

ENDFORM. " DISP_DATA
*&---------------------------------------------------------------------*
*& Form MERGE_FIELDCATALOG
*&---------------------------------------------------------------------*
FORM MERGE_FIELDCATALOG .
*

ENDFORM. " MERGE_FIELDCATALOG

*&---------------------------------------------------------------------*
*& Form SET_FIELDCAT
*&---------------------------------------------------------------------*
FORM SET_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'BELNR'.
FIELDCAT-SELTEXT_M = 'Document No'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'RTEXT'.
FIELDCAT-SELTEXT_M = 'Recepient Type'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'LIFNR'.
FIELDCAT-SELTEXT_M = 'Vendor'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'NAME1'.
FIELDCAT-SELTEXT_M = 'NAME'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'PRCTR'.
FIELDCAT-NO_ZERO = 'X'.
FIELDCAT-SELTEXT_M = 'Profit Center'.
APPEND FIELDCAT.


CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1IPANNO'.
FIELDCAT-SELTEXT_M = 'PAN.No.'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'SECCO'.
FIELDCAT-SELTEXT_M = 'Section'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'BUDAT'.
FIELDCAT-SELTEXT_M = 'Posting Date'.
APPEND FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'BLDAT'.
FIELDCAT-SELTEXT_M = 'Document Date'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'XBLNR'.
FIELDCAT-SELTEXT_M = 'Vendor bill no.'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'DMBTR'.
FIELDCAT-SELTEXT_M = 'Bill Amount'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'QSATZ'.
FIELDCAT-SELTEXT_M = 'TDS %'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'TDS'.
FIELDCAT-SELTEXT_M = 'TDS'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'SC'.
FIELDCAT-SELTEXT_M = 'Surcharge'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'CESS'.
FIELDCAT-SELTEXT_M = 'ECESS'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'SHCESS'.
FIELDCAT-SELTEXT_M = 'SHECESS'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'QBSHB'.
FIELDCAT-SELTEXT_M = 'Total Amt'.
* fieldcat-hotspot = 'X' .
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1IINTCHLN'.
FIELDCAT-SELTEXT_M = 'Internal Challan'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1IINTCHDT'.
FIELDCAT-SELTEXT_M = 'Internal challan Date'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1IEXTCHLN'.
FIELDCAT-SELTEXT_M = 'External Challan'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1IEXTCHDT'.
FIELDCAT-SELTEXT_M = 'External Challan Date'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1ITDSDOC'.
FIELDCAT-SELTEXT_M = 'Certificate'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'J_1ICERTDT'.
FIELDCAT-SELTEXT_M = 'Cert.Date.'.
APPEND FIELDCAT.

CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-FIELDNAME = 'TEXT'.
FIELDCAT-SELTEXT_M = 'Sign'.
APPEND FIELDCAT.




ENDFORM. " SET_FIELDCAT

*&---------------------------------------------------------------------*
*& Form EVENTTAB_BUILD
*&---------------------------------------------------------------------*
FORM EVENTTAB_BUILD USING LT_EVENTS TYPE SLIS_T_EVENT.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
GC_FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
DATA: LS_EVENT1 TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.

READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.

DATA TODAY(10).
DATA TODAY1(10).
DATA TODAY2(10).
DATA TIMEDAY1(10).

DATA : HLINE TYPE SLIS_LISTHEADER .
DATA : TEXT(50).

HLINE-TYP = 'H'.
TEXT = 'SHIV-VANI TDS Register'.
HLINE-INFO = TEXT.
APPEND HLINE TO HEADING.
CLEAR TEXT.

CLEAR TODAY .
CONCATENATE SY-DATUM+6(2) SY-DATUM+4(2)
SY-DATUM+0(4) INTO TODAY SEPARATED BY '.'.


CONCATENATE SY-UZEIT+0(2) SY-UZEIT+2(2)
SY-UZEIT+4(2) INTO TIMEDAY1 SEPARATED BY '.'.

HLINE-TYP = 'A'.
CONCATENATE 'DATE -' TODAY 'TIME -' TIMEDAY1 INTO HLINE-INFO SEPARATED BY ' '.
APPEND HLINE TO HEADING.
HLINE-TYP = 'A'.
CONCATENATE 'User Name -' SY-UNAME INTO HLINE-INFO SEPARATED BY SPACE .
APPEND HLINE TO HEADING.
CONCATENATE S_BUDAT-LOW+6(2) S_BUDAT-LOW+4(2)
S_BUDAT-LOW+0(4) INTO TODAY1 SEPARATED BY '.'.
CONCATENATE S_BUDAT-HIGH+6(2) S_BUDAT-HIGH+4(2)
S_BUDAT-HIGH+0(4) INTO TODAY2 SEPARATED BY '.'.
HLINE-TYP = 'A'.
CONCATENATE 'From - ' TODAY1 ' to-' TODAY2 INTO HLINE-INFO .
APPEND HLINE TO HEADING.
HLINE-TYP = 'H'.
TEXT = 'Calculated Average Rates:'.
HLINE-INFO = TEXT.
APPEND HLINE TO FOOTER.
CLEAR TEXT.

DATA: TEXT1(15).
TEXT1 = AVG1.

HLINE-TYP = 'S'.
CONCATENATE TEXT1 'Per KG (AWB)' INTO TEXT SEPARATED BY SPACE.
HLINE-INFO = TEXT.
APPEND HLINE TO FOOTER.
CLEAR :TEXT,TEXT1.

TEXT1 = AVG2.

HLINE-TYP = 'S'.
CONCATENATE TEXT1 'Per KG (Bill)' INTO TEXT SEPARATED BY SPACE.
HLINE-INFO = TEXT.
APPEND HLINE TO FOOTER.
CLEAR :TEXT,TEXT1.


ENDFORM. "eventtab_build
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
* P_LAYOUT-F2CODE = F2CODE.
P_LAYOUT-ZEBRA = 'X'.
P_LAYOUT-DETAIL_POPUP = 'X'.

ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form INITIALIZE_VARIANT
*&---------------------------------------------------------------------*
FORM INITIALIZE_VARIANT .
G_SAVE = 'A'.
CLEAR G_VARIANT.
G_VARIANT-REPORT = PRG.
GX_VARIANT = G_VARIANT .
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.

ENDFORM. " INITIALIZE_VARIANT
*&---------------------------------------------------------------------*
*& Form DISP_ALV
*&---------------------------------------------------------------------*
FORM DISP_ALV .
*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = PRG
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_BACKGROUND_ID = 'ALV_BACKGROUND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT[]
I_SAVE = G_SAVE
I_DEFAULT = 'X'
IS_VARIANT = G_VARIANT
IT_EVENTS = GT_EVENTS[]
* I_CALLBACK_HTML_END_OF_LIST = ' '
** I_SCREEN_END_LINE = '4'

TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.

ENDFORM. " DISP_ALV

*&--------------------------------------------------------------------*
*& Form top_of_page
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING[]
I_LOGO = 'ENJOY_SAP_LOGO'.
ENDFORM. "TOP_OF_PAGE


*&--------------------------------------------------------------------*
*& Form user_COMMAND
*&--------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
IF R_UCOMM EQ '&IC1' .
READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
CHECK SY-SUBRC EQ 0.

IF RS_SELFIELD-FIELDNAME EQ 'BELNR'.
SET PARAMETER ID 'BLN' FIELD ITAB-BELNR.
SET PARAMETER ID 'BUK' FIELD S_BUKRS-LOW.
SET PARAMETER ID 'GJR' FIELD YEAR.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
* ELSEIF rs_selfield-fieldname EQ 'VBELN'.
* SET PARAMETER ID 'VF' FIELD itab-vbeln.
* CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.

ENDFORM. " BUILD_FIELDCAT

**&--------------------------------------------------------------------*
**& Form standard
**&--------------------------------------------------------------------*
*FORM STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
* SET PF-STATUS 'STATUS' EXCLUDING RT_EXTAB.
*ENDFORM. "standard
*&---------------------------------------------------------------------*
*& Form F4_FOR_VARIANT
*&---------------------------------------------------------------------*
FORM F4_FOR_VARIANT .
G_SAVE = 'A'.
G_VARIANT-REPORT = PRG.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE = G_SAVE
IMPORTING
E_EXIT = G_EXIT
ES_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF G_EXIT = SPACE.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDIF.

ENDFORM. " F4_FOR_VARIANT