Skip to Content
0
Former Member
Sep 24, 2012 at 09:49 AM

Wrong data displaying while making selection based on vendor

27 Views

I have created a report for purchase detail now my client want to display detail based on vendor no.I have added lifnr field on selection screen but the report is not displaying according to lifnr.The code is given below plz provide me some suitable solution:

*
*&---------------------------------------------------------------------*
REPORT ZMM_CST_PURCHASE.

TABLES: MKPF, MSEG, EKKO, EKPO, EKBE, T007A.

DATA: BEGIN OF ITAB OCCURS 0,
EBELN TYPE EKKO-EBELN,
AEDAT TYPE EKPO-AEDAT,"PO DATE
BUKRS TYPE EKPO-BUKRS,
EBELP TYPE EKBE-EBELP,
BEWTP TYPE EKBE-BEWTP,
BELNR TYPE EKBE-BELNR, "INV NO
WERKS TYPE EKBE-WERKS,
LIFNR TYPE LFA1-LIFNR,
MATNR TYPE EKBE-MATNR,
XBLNR TYPE EKBE-XBLNR, "VENDOR INV
MBLNR LIKE MSEG-MBLNR,
LFBNR LIKE ekbe-LFBNR,
LOEKZ TYPE EKPO-LOEKZ,
INV_DT TYPE VBRK-FKDAT,
REF TYPE EKBE-XBLNR,
INV_AMT TYPE EKBE-DMBTR,
GRN_NO TYPE EKBE-BELNR,
C_FORMNO LIKE J_1IFRDTPO-J_1IFRMNUM,
ISSUE_DATE LIKE J_1IFRDTPO-J_1IISSDAT,
VNAME LIKE ADRC-NAME1,
TIN LIKE LFA1-STCEG,
VREGION LIKE ADRC-REGION,
VSTATE LIKE T005U-BEZEI,
FT LIKE T005U-BEZEI,
TAX LIKE T007A-MWSKZ,
NETPR LIKE EKPO-NETPR,
MENGE LIKE EKPO-MENGE,
RTAX LIKE KOMV-KWERT,
TOT_VAL TYPE EKBE-DMBTR,
V_CST LIKE KOMV-KWERT,
INV_NO TYPE EKBE-BELNR,

END OF ITAB.


DATA:BEGIN OF ITAB1 OCCURS 0,
EBELN TYPE EKKO-EBELN,
LIFNR TYPE EKKO-LIFNR,
END OF ITAB1.

DATA: BEGIN OF I_CFORM OCCURS 0,
J_1IDOCNUM TYPE J_1IFRDTPO-J_1IDOCNUM,
J_1ISECREF TYPE J_1IFRDTPO-J_1ISECREF,
J_1IREFYER TYPE J_1IFRDTPO-J_1IREFYER,
J_1IFRMTYP TYPE J_1IFRDTPO-J_1IFRMTYP,
J_1IFRMNUM TYPE J_1IFRDTPO-J_1IFRMNUM,
J_1IISSDAT TYPE J_1IFRDTPO-J_1IISSDAT,
END OF I_CFORM.



DATA: BEGIN OF ITAB_DOC OCCURS 0,
EBELN LIKE EKKO-EBELN,
MBLNR LIKE MKPF-MBLNR,
END OF ITAB_DOC.


DATA: ITAB_Q LIKE ITAB OCCURS 0 WITH HEADER LINE,
ITAB_E LIKE ITAB OCCURS 0 WITH HEADER LINE,
ITAB_1 LIKE ITAB_DOC OCCURS 0 WITH HEADER LINE,
FINAL_ITAB LIKE ITAB OCCURS 0 WITH HEADER LINE.


DATA: INV_DT LIKE SY-DATUM.
DATA: REF TYPE RBKP-XBLNR.
DATA: INV_AMT TYPE EKBE-DMBTR.
DATA: VADRNR LIKE LFA1-ADRNR.
DATA: VNAME LIKE ADRC-NAME1.
DATA: LIFNR LIKE LFA1-LIFNR.
DATA: TIN LIKE LFA1-STCEG.
DATA: VREGION LIKE ADRC-REGION.
DATA: VSTATE LIKE T005U-BEZEI.
DATA: TAX LIKE T007A-MWSKZ.
DATA: NETPR LIKE EKPO-NETPR.
DATA: MENGE LIKE EKPO-MENGE.
DATA: RTAX LIKE KOMV-KWERT.
DATA: V_KBETR LIKE KONV-KBETR.
DATA: GRN_NO TYPE EKBE-BELNR.

DATA: CST_KNUMH LIKE A950-KNUMH,
V_KNUMH1 LIKE A950-KNUMH,
V_KNUMH2 LIKE A950-KNUMH,
V_KNUMH3 LIKE A950-KNUMH,
V_KNUMH4 LIKE A950-KNUMH,
V_KNUMH5 LIKE A950-KNUMH,
V_KNUMH6 LIKE A950-KNUMH,

V_EXC LIKE KOMV-KWERT,

V_EXC1 LIKE KOMV-KWERT,
V_EXC2 LIKE KOMV-KWERT,
V_EXC3 LIKE KOMV-KWERT,
V_EXC4 LIKE KOMV-KWERT,
V_EXC5 LIKE KOMV-KWERT,
V_EXC6 LIKE KOMV-KWERT,

V_AMT1 LIKE KOMV-KWERT,
V_AMT2 LIKE KOMV-KWERT,
V_AMT3 LIKE KOMV-KWERT,
V_AMT4 LIKE KOMV-KWERT,
V_CST LIKE KOMV-KWERT.

TYPE-POOLS : SLIS.

DATA: W_REPID LIKE SY-REPID,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
I_HEADING TYPE SLIS_T_LISTHEADER,
I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_EVENTS TYPE SLIS_T_EVENT.

DATA: GD_REPID LIKE SY-REPID,
GD_DYNNR LIKE SY-DYNNR.


DATA : COL_POS TYPE I.

GD_REPID = SY-REPID.
GD_DYNNR = SY-DYNNR.


*SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : s_gjahr like bkpf-GJAHR .

SELECT-OPTIONS : S_WERKS FOR EKBE-WERKS OBLIGATORY. "DATE
SELECT-OPTIONS : S_BUDAT FOR EKKO-AEDAT OBLIGATORY. "DATE
SELECT-OPTIONS : S_TAX FOR T007A-MWSKZ.
SELECT-OPTIONS : S_LIFNR FOR EKKO-LIFNR.

SELECTION-SCREEN END OF BLOCK A1.

*AT SELECTIN SCREEN----------------------------------------------------*
AT SELECTION-SCREEN.
TOP-OF-PAGE.
*PERFORM TOP_OF_PAGE.
END-OF-PAGE.
*START OF SELECTION----------------------------------------------------*
START-OF-SELECTION.
PERFORM : GET_DATA.

FORM:GET_DATA.

SELECT LIFNR INTO FINAL_ITAB FROM EKKO WHERE LIFNR IN S_LIFNR.
ENDSELECT.
SELECT P~EBELN "PO NO
P~AEDAT "PO DATE
P~BUKRS
Q~EBELP
Q~BEWTP
Q~BELNR
Q~WERKS
Q~MATNR
Q~XBLNR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM EKPO AS P INNER JOIN EKBE AS Q
ON P~EBELN = Q~EBELN
WHERE P~AEDAT IN S_BUDAT
AND Q~GJAHR = S_GJAHR
AND Q~werks IN s_werks.

DATA: LOEKZ TYPE EKPO-LOEKZ.

LOOP AT ITAB.
SELECT LOEKZ INTO LOEKZ FROM EKPO WHERE EBELN = ITAB-EBELN.
ENDSELECT.

ITAB-LOEKZ = LOEKZ .
MODIFY ITAB TRANSPORTING LOEKZ.
ENDLOOP.

DELETE ITAB WHERE LOEKZ = 'L'.





LOOP AT ITAB.
MOVE-CORRESPONDING ITAB TO ITAB_DOC .
APPEND ITAB_DOC .


IF ITAB-BEWTP = 'Q'.
MOVE-CORRESPONDING ITAB TO ITAB_Q .
APPEND ITAB_Q.

MOVE-CORRESPONDING ITAB TO ITAB_1.
APPEND ITAB_1.
ENDIF.
ENDLOOP.


LOOP AT ITAB_Q.
MOVE-CORRESPONDING ITAB_Q TO ITAB_E.
MOVE-CORRESPONDING ITAB_Q TO FINAL_ITAB.

APPEND ITAB_E.
APPEND FINAL_ITAB.

ITAB_1-EBELN = ITAB_Q-EBELN.
ITAB_1-MBLNR = ITAB_Q-LFBNR.
APPEND ITAB_1.
ENDLOOP.


SORT ITAB_DOC.
DELETE ADJACENT DUPLICATES FROM ITAB_DOC COMPARING MBLNR.

SORT ITAB_1.
DELETE ADJACENT DUPLICATES FROM ITAB_1 COMPARING MBLNR.

LOOP AT ITAB_1.
DELETE ITAB_DOC WHERE EBELN = ITAB_1-EBELN AND MBLNR = ITAB_1-MBLNR.
ENDLOOP.


LOOP AT ITAB_DOC.
LOOP AT ITAB WHERE EBELN = ITAB_DOC-EBELN AND MBLNR = ITAB_DOC-MBLNR .

final_itab-ebeln = ITAB-ebeln.
* final_itab-bedat = ITAB-bedat.
final_itab-LFBNR = ITAB-mblnr.
* final_itab-bldat = ITAB-bldat.
final_itab-lifnr = ITAB-lifnr.
final_itab-XBLNR = ITAB-XBLNR.
* final_itab-DMBTR = ITAB-DMBTR.
final_itab-matnr = ITAB-matnr.
final_itab-mblnr = ' ' .
* final_itab-bldat1 = ' ' .
final_itab-bewtp = ITAB-bewtp.
final_itab-ebelp = ITAB-ebelp.
* final_itab-ekgrp = ITAB-ekgrp.
final_itab-werks = ITAB-werks.
* final_itab-lgort = ITAB-lgort.

APPEND FINAL_ITAB.
ENDLOOP.
ENDLOOP.



LOOP AT FINAL_ITAB.
SELECT SINGLE LIFNR INTO LIFNR FROM EKKO WHERE EBELN = FINAL_ITAB-EBELN.
FINAL_ITAB-LIFNR = LIFNR.
MODIFY FINAL_ITAB TRANSPORTING LIFNR.
ENDLOOP.




LOOP AT FINAL_ITAB.
SELECT SINGLE BLDAT INTO INV_DT FROM RBKP WHERE BELNR = FINAL_ITAB-BELNR AND GJAHR = S_GJAHR .
*Added by Anjali on July 14, 2011
SELECT SINGLE XBLNR INTO REF FROM RBKP WHERE BELNR = FINAL_ITAB-BELNR AND GJAHR = S_GJAHR .

SELECT SINGLE DMBTR INTO INV_AMT FROM EKBE WHERE EBELN = FINAL_ITAB-EBELN AND EBELP = FINAL_ITAB-EBELP AND BEWTP = 'Q'.
SELECT SINGLE LFBNR INTO GRN_NO FROM EKBE WHERE EBELN = FINAL_ITAB-EBELN AND EBELP = FINAL_ITAB-EBELP AND BEWTP = 'E'.
SELECT SINGLE NETPR INTO NETPR FROM EKPO WHERE EBELN = FINAL_ITAB-EBELN AND EBELP = FINAL_ITAB-EBELP .
SELECT SINGLE MENGE INTO MENGE FROM EKPO WHERE EBELN = FINAL_ITAB-EBELN AND EBELP = FINAL_ITAB-EBELP .
SELECT SINGLE ADRNR INTO VADRNR FROM LFA1 WHERE LIFNR = FINAL_ITAB-LIFNR .
SELECT SINGLE STCEG INTO TIN FROM LFA1 WHERE LIFNR = FINAL_ITAB-LIFNR .
SELECT SINGLE NAME1 INTO VNAME FROM ADRC WHERE ADDRNUMBER = VADRNR .
SELECT SINGLE REGION INTO VREGION FROM ADRC WHERE ADDRNUMBER = VADRNR .
SELECT SINGLE BEZEI INTO VSTATE FROM T005U WHERE BLAND = VREGION AND LAND1 = 'IN' AND SPRAS = 'E' .
SELECT MWSKZ INTO TAX FROM EKPO WHERE EBELN = FINAL_ITAB-EBELN AND EBELP = FINAL_ITAB-EBELP AND MWSKZ IN S_TAX.




ENDSELECT.



FINAL_ITAB-INV_DT = INV_DT.
FINAL_ITAB-REF = REF.
FINAL_ITAB-INV_AMT = INV_AMT.
FINAL_ITAB-GRN_NO = GRN_NO.
FINAL_ITAB-TIN = TIN.
FINAL_ITAB-VNAME = VNAME.
FINAL_ITAB-VSTATE = VSTATE.
FINAL_ITAB-FT = 'C FORM'.
FINAL_ITAB-TAX = TAX .
FINAL_ITAB-NETPR = NETPR.
FINAL_ITAB-MENGE = MENGE.

MODIFY FINAL_ITAB TRANSPORTING INV_DT REF INV_AMT GRN_NO TIN VNAME VSTATE FT TAX NETPR MENGE.
ENDLOOP.





DELETE FINAL_ITAB WHERE TAX NOT IN S_TAX.
DELETE ADJACENT DUPLICATES FROM FINAL_ITAB COMPARING EBELN MBLNR MATNR .

IF FINAL_ITAB[] IS NOT INITIAL .
SELECT J_1IDOCNUM
J_1ISECREF
J_1IREFYER
J_1IFRMTYP
J_1IFRMNUM
J_1IISSDAT
INTO CORRESPONDING FIELDS OF TABLE I_CFORM
FROM J_1IFRDTPO
WHERE J_1IDOCNUM = ITAB-EBELN.
ENDIF.


LOOP AT FINAL_ITAB.
READ TABLE I_CFORM WITH KEY J_1IDOCNUM = FINAL_ITAB-EBELN.


IF SY-SUBRC = 0.
FINAL_ITAB-C_FORMNO = I_CFORM-J_1IFRMNUM.
FINAL_ITAB-ISSUE_DATE = I_CFORM-J_1IISSDAT.

MODIFY FINAL_ITAB TRANSPORTING C_FORMNO ISSUE_DATE .
ENDIF.
ENDLOOP.


CLEAR : V_EXC1 , V_EXC2, V_EXC3, V_EXC4, V_EXC4, V_EXC5, V_EXC6.
*FOR REFUNDABLE TAX
LOOP AT FINAL_ITAB.
*EITHER OF THE TWO - JVRN / ZVRN
SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH1
WHERE KAPPL = 'TX'
AND ( KSCHL = 'JVRN' )
AND LAND1 = 'IN'
AND MWSKZ = ITAB-TAX
AND DATBI IN S_BUDAT
AND DATAB IN S_BUDAT.


SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH1
WHERE KAPPL = 'TX'
AND ( KSCHL = 'ZVRN' )
AND LAND1 = 'IN'
AND MWSKZ = ITAB-TAX
AND DATBI IN S_BUDAT
AND DATAB IN S_BUDAT.



*EITHER OF THE TWO - JMOP / ZMOP
SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH1
WHERE KAPPL = 'TX'
AND KSCHL = 'JMOP'
AND WERKS = FINAL_ITAB-WERKS
AND MATNR = FINAL_ITAB-MATNR
AND LIFNR = FINAL_ITAB-LIFNR
AND DATBI IN S_BUDAT
AND DATAB IN S_BUDAT.

SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH1
WHERE KAPPL = 'TX'
AND KSCHL = 'ZMOP'
AND WERKS = FINAL_ITAB-WERKS
AND MATNR = FINAL_ITAB-MATNR
AND LIFNR = FINAL_ITAB-LIFNR
AND DATBI IN S_BUDAT
AND DATAB IN S_BUDAT.

SELECT SINGLE KBETR FROM KONP INTO V_EXC1 WHERE KNUMH = V_KNUMH1 AND LOEVM_KO NE 'X'.

V_EXC1 = V_EXC1 / 10 .
V_AMT1 = ( ( FINAL_ITAB-NETPR * ITAB-MENGE ) * V_EXC1 ) / 100 .


SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH3
WHERE KAPPL = 'TX'
AND KSCHL = 'JEC1'
AND WERKS = FINAL_ITAB-WERKS
AND MATNR = FINAL_ITAB-MATNR
AND LIFNR = FINAL_ITAB-LIFNR
AND DATBI IN S_BUDAT
AND DATAB IN S_BUDAT.

SELECT SINGLE KBETR FROM KONP INTO V_EXC3 WHERE KNUMH = V_KNUMH3 AND LOEVM_KO NE 'X'.
V_EXC3 = V_EXC3 / 10 .
V_AMT3 = ( V_AMT1 * V_EXC3 ) / 100.


SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH4
WHERE KAPPL = 'TX'
AND KSCHL = 'JSEP'
AND WERKS = FINAL_ITAB-WERKS
AND MATNR = FINAL_ITAB-MATNR
AND LIFNR = FINAL_ITAB-LIFNR
AND DATBI IN S_BUDAT
AND DATAB IN S_BUDAT.


SELECT SINGLE KBETR FROM KONP INTO V_EXC4 WHERE KNUMH = V_KNUMH4 AND LOEVM_KO NE 'X'.
V_EXC4 = V_EXC4 / 10 .
V_AMT4 = ( V_AMT1 * V_EXC4 ) / 100.


V_EXC2 = V_EXC2 + V_EXC3.
V_EXC3 = V_EXC1 * V_EXC2.
V_EXC3 = V_EXC3 / 100.


CLEAR : V_EXC.

V_EXC = V_EXC1 + V_EXC3.
RTAX = V_AMT1 + V_AMT2 + V_AMT3 + V_AMT4.


FINAL_ITAB-RTAX = RTAX.
MODIFY FINAL_ITAB TRANSPORTING RTAX.
ENDLOOP.




LOOP AT FINAL_ITAB.
SELECT SINGLE KNUMH FROM A950 INTO CST_KNUMH
WHERE KAPPL = 'TX'
AND KSCHL = 'JVRN'
AND LAND1 = 'IN'
AND MWSKZ = FINAL_ITAB-TAX .
* AND DATBI BETWEEN S_BUDAT-LOW AND S_BUDAT-HIGH
* AND DATAB IN S_BUDAT.

SELECT SINGLE KNUMH FROM A950 INTO CST_KNUMH
WHERE KAPPL = 'TX'
AND KSCHL = 'JIPC'
AND LAND1 = 'IN'
AND MWSKZ = FINAL_ITAB-TAX .
* AND DATBI BETWEEN S_BUDAT-LOW AND S_BUDAT-HIGH
* AND DATAB BETWEEN S_BUDAT-LOW AND S_BUDAT-HIGH.






SELECT SINGLE KBETR FROM KONP INTO V_KBETR WHERE KNUMH = CST_KNUMH AND LOEVM_KO NE 'X'.

V_KBETR = V_KBETR / 10 .

V_CST = ( ( FINAL_ITAB-NETPR * FINAL_ITAB-MENGE ) * V_KBETR ) / 100 .

FINAL_ITAB-V_CST = V_CST.

MODIFY FINAL_ITAB TRANSPORTING V_CST.

ENDLOOP.


LOOP AT FINAL_ITAB.
FINAL_ITAB-TOT_VAL = FINAL_ITAB-INV_AMT + FINAL_ITAB-V_CST.
MODIFY FINAL_ITAB TRANSPORTING TOT_VAL.
ENDLOOP.

ENDFORM.

AT LINE-SELECTION.
AT USER-COMMAND.
END-OF-SELECTION.
PERFORM EVENT_BUILD CHANGING I_EVENTS.
PERFORM POPULATE_FIELDCAT USING IT_FIELDCAT.
PERFORM BUILD_LAYOUT.
PERFORM GRID_DISPLAY.
**&----------------------------------------------------------------------*
**& -->P_I_HEADING text
**&----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_HEADING.
ENDFORM. " top_of_page

**----------------------------------------------------------------------*
** <--P_I_EVENTS text
**----------------------------------------------------------------------*
FORM EVENT_BUILD CHANGING P_I_EVENTS TYPE SLIS_T_EVENT.

DATA: W_EVENT TYPE SLIS_ALV_EVENT.
CONSTANTS: GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_I_EVENTS.

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


ENDFORM. " event_build
**----------------------------------------------------------------------*
** FORM grid_display .
**----------------------------------------------------------------------*
FORM GRID_DISPLAY .
W_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_GRID_TITLE = 'CST PURCHASE DETAILS'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
I_SAVE = 'X'
IT_EVENTS = I_EVENTS
TABLES
T_OUTTAB = FINAL_ITAB
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. " grid_display


**&---------------------------------------------------------------------*
**& Form populate_fieldcat
**----------------------------------------------------------------------*
FORM POPULATE_FIELDCAT USING P_I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_L = 'PO NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_L = 'PO DATE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.

*CHANGED BY ANJALI TO CHANGE THE VENDOR INVOICE NO
CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'REF'.
WA_FIELDCAT-SELTEXT_L = 'VENDOR INV NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.



*ADDED BY ANJALI TO DISPLAY VENDOR INVOICE DATE.
CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'INV_DT'.
WA_FIELDCAT-SELTEXT_L = 'INV DATE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.



CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'GRN_NO'.
WA_FIELDCAT-SELTEXT_L = 'GRN NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.


CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'VNAME'.
WA_FIELDCAT-SELTEXT_L = 'SELLER NAME'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.


CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'TIN'.
WA_FIELDCAT-SELTEXT_L = 'SELLER TIN NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.


CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'VSTATE'.
WA_FIELDCAT-SELTEXT_L = 'STATE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'INV_AMT'.
WA_FIELDCAT-SELTEXT_L = 'VALUE OF GOODS'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'RTAX'.
WA_FIELDCAT-SELTEXT_L = 'REFUNDABLE TAX'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'V_CST'.
WA_FIELDCAT-SELTEXT_L = 'TAX'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.



CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'TAX'.
WA_FIELDCAT-SELTEXT_L = 'TAX CODE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.



CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'TOT_VAL'.
WA_FIELDCAT-SELTEXT_L = 'TOTAL'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.



CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'FT'.
WA_FIELDCAT-SELTEXT_L = 'FORM TYPE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.



CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'C_FORMNO'.
WA_FIELDCAT-SELTEXT_L = 'C FORM NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.


CLEAR WA_FIELDCAT.
ADD 1 TO COL_POS.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-FIELDNAME = 'ISSUE_DATE'.
WA_FIELDCAT-SELTEXT_L = 'ISSUE DATE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
ENDFORM.
**&---------------------------------------------------------------------*
**& FORM USER_COMMAND
**&---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'EBELN'.
READ TABLE final_itab INDEX rs_selfield-tabindex.
SET PARAMETER ID 'BES' FIELD final_itab-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
**&---------------------------------------------------------------------*
**& Form build_layout
**&---------------------------------------------------------------------*
FORM BUILD_LAYOUT .
I_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
I_LAYOUT-ZEBRA = 'X'.
ENDFORM. " build_layout