Skip to Content
0
Former Member
Sep 06, 2012 at 10:06 AM

Problem while displaying quotation report more than one at a time

32 Views

I have created a zreport for quotation comparasion using abap classical report.This report is working fine for single ebeln but while i am running this for more than two ebeln it is displaying wrong value for sub total and total.Vendor ac no and name is coming as *.The code is given below:

*&---------------------------------------------------------------------*
*& Report ZMM_QUOTATION_COMPARATIVE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZMM_QUOTATION_COMPARATIVE LINE-SIZE 100.



*----------------------------------------------------------------------------------------------------------------------------------------------*
*/ Tables Used In Program
*/
TABLES: EKKO,
EKPO,
KONP,
A016,
MAKT,
A363,
LFA1,
T001,
T005T,
ADRC,
SPELL,
SSCRFIELDS.


*-----------------------------------------------------------------------------------------------------------------------------------------------

TYPE-POOLS: SLIS. "ALV Declarations

*------------------------------.------------------------------------------------------------------------------------------------------------------*

*Data Declaration
*----------------

DATA : I_LOGO TYPE STRING.

TYPES: BEGIN OF QUOT ,

EBELN LIKE EKPO-EBELN,
MATNR LIKE EKPO-MATNR,
EBELP LIKE EKPO-EBELP,
KTMNG LIKE EKPO-KTMNG,
WERKS LIKE EKPO-WERKS,
BUKRS LIKE EKKO-BUKRS,
LIFNR LIKE EKKO-LIFNR,
BEDAT LIKE EKKO-BEDAT,
MAKTX LIKE MAKT-MAKTX,
VNAME TYPE STRING,
ORT01 TYPE STRING,
ORT02 TYPE STRING,
COST LIKE KONP-KBETR,
RATE LIKE KONP-KBETR,
DISC TYPE STRING,
PKG TYPE STRING,
EXC TYPE STRING,
SALETX TYPE STRING,
OTHER LIKE KONP-KBETR,
TOTAMT LIKE KONP-KBETR,
SRNO TYPE I,
CITY TYPE STRING,
TOTAL TYPE DMBTR,
KUNNR TYPE KNA1-KUNNR,
SUBTOT TYPE DMBTR,
END OF QUOT.

DATA : QUOT1 TYPE STANDARD TABLE OF QUOT WITH HEADER LINE,
WQUOT TYPE QUOT.



DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.
DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '1234510'.

SY-TITLE = 'SPELLING NUMBER'.



DATA : BEGIN OF VENDOR OCCURS 0,
LIFNR LIKE KNA1-LIFNR,
EBELN LIKE EKPO-EBELN,
NAME1 LIKE KNA1-NAME1,
KUNNR LIKE KNA1-KUNNR,
* KUNN2 LIKE KNVP-KUNN2,
END OF VENDOR.


DATA: BEGIN OF ITABF OCCURS 0,
LIFNR LIKE BSIK-LIFNR,
EBELN TYPE EKPO-EBELN,
SRNO TYPE I,
MAKTX LIKE MAKT-MAKTX,
KTMNG LIKE EKPO-KTMNG,
COST LIKE KONP-KBETR,
RATE LIKE KONP-KBETR,
END OF ITABF.




DATA : V_KNUMH LIKE A016-KNUMH.
DATA TITLE TYPE LVC_TITLE.
DATA : V_EBELN LIKE EKPO-EBELN,
V_KBETR LIKE KONP-KBETR,
COST LIKE KONP-KBETR,
DISC_KBETR LIKE KONP-KBETR,
PKG_KBETR LIKE KONP-KBETR,
AMT LIKE KONP-KBETR,
PER LIKE KONP-KBETR,
DISC LIKE KONP-KBETR,
PKG LIKE KONP-KBETR,
PKGAMT LIKE KONP-KBETR,
V_NAME1 TYPE STRING,
V_NAME2 TYPE STRING,
ORT01 TYPE STRING,
ORT02 TYPE STRING,
STR1 TYPE STRING,
STR2 TYPE STRING,
STR3 TYPE STRING,
STR4 TYPE STRING,
TOTAL TYPE DMBTR,
SUBTOT TYPE DMBTR.

**for excise , sales and other taxes

DATA : V_NETWR LIKE EKPO-NETWR,
V_EXC LIKE KONP-KBETR,
V_EXC1 LIKE KONP-KBETR,
V_EXC2 LIKE KONP-KBETR,
V_MWSKZ LIKE EKPO-MWSKZ,
V_TOT_EXC LIKE KONP-KBETR,
V_EXCP LIKE KONV-KBETR,
V_EXC1P LIKE KONV-KBETR,
V_EXC2P LIKE KONV-KBETR,
V_VAT LIKE KONP-KBETR,
V_TOT_TAX LIKE KONP-KBETR,
V_OTHERP LIKE KONP-KBETR,
V_OTHAMT LIKE KONP-KBETR,
V_AMT LIKE KONP-KBETR,
V_TEMP1 TYPE STRING,
V_TEMP2 TYPE STRING,
V_TEMP11 TYPE STRING,
V_TEMP12 TYPE STRING,
V_TEMP21 TYPE STRING,
V_TEMP22 TYPE STRING.
* TOTAL TYPE DMBTR.


* ALV data declarations


DATA : EYEAR LIKE BKPF-GJAHR,DEL LIKE SY-SUBRC..
CONSTANTS : C_F VALUE 'F'.
DATA : PAGENO LIKE SY-PAGNO.


*-----------------------------------------------------------------------------------------------------------------------------------------------*

*/ PROGRAM SELECTION
*/
SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_EBELN FOR EKPO-EBELN OBLIGATORY. "Collective Number
PARAMETERS: P_BUKRS LIKE EKPO-BUKRS.

SELECTION-SCREEN END OF BLOCK B3.

*----------------------------------------------------------------------------------------------------

AT SELECTION-SCREEN.

SELECT EBELN FROM EKPO INTO V_EBELN
WHERE EBELN IN S_EBELN.
ENDSELECT.

IF SY-SUBRC NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'Process Discontinued'
TXT1 = 'No Record found'
TXT2 = 'Enter Existing Quotation Number'
EXCEPTIONS
OTHERS = 1.
LEAVE TO SCREEN 1000.
ENDIF.


*----------------------------------------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.




START-OF-SELECTION.

PERFORM DATA_RETERIVAL.
PERFORM SERIALNO.
*

PERFORM SPELL_AMOUNT USING PAMOUNT 'INR'.
*----------------------------------------------------------------------*

*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*

FORM DATA_RETERIVAL.


SELECT EKPO~EBELN
EKPO~MATNR
EKPO~EBELP
EKPO~KTMNG
EKPO~WERKS
EKKO~BUKRS
EKKO~LIFNR
EKKO~BEDAT
MAKT~MAKTX
INTO TABLE
QUOT1 FROM EKPO
INNER JOIN EKKO
ON EKPO~EBELN = EKKO~EBELN
INNER JOIN MAKT
ON EKPO~MATNR = MAKT~MATNR
INNER JOIN LFA1
ON LFA1~LIFNR = EKKO~LIFNR
WHERE EKPO~EBELN IN S_EBELN
AND EKPO~BSTYP = 'A'
ORDER BY EKPO~MATNR.

LOOP AT QUOT1.

**** Vendor Name ***************


SELECT SINGLE NAME1 NAME2 FROM LFA1 INTO (V_NAME1, V_NAME2 )
WHERE LIFNR = QUOT1-LIFNR.

CONCATENATE V_NAME1 V_NAME2 INTO STR1 SEPARATED BY SPACE.
*CONCATENATE ort01 ort02 into str4 SEPARATED BY space.

QUOT1-VNAME = STR1.

MODIFY QUOT1.


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

SELECT SINGLE KNUMH FROM A016 INTO V_KNUMH
WHERE EVRTN = QUOT1-EBELN
AND EVRTP = QUOT1-EBELP.

**** Basic Rate ****************

CLEAR V_KBETR.

SELECT SINGLE KBETR FROM KONP INTO V_KBETR
WHERE KNUMH = V_KNUMH
AND KSCHL IN ('BP00','BPXX').

COST = QUOT1-KTMNG * V_KBETR.

QUOT1-RATE = V_KBETR.
QUOT1-COST = COST.

MODIFY QUOT1.


******* Discount **********

CLEAR: DISC,DISC_KBETR,PER,STR1,STR2,STR3.

SELECT SINGLE KBETR FROM KONP INTO DISC_KBETR
WHERE KNUMH = V_KNUMH
AND KSCHL = 'DC00'.

PER = DISC_KBETR / 10.

DISC = ( COST * PER ) / 100.

STR1 = PER.
STR2 = DISC.

CONCATENATE '('STR1')' STR2 INTO STR3 SEPARATED BY SPACE.

QUOT1-DISC = STR3.

MODIFY QUOT1.

* Package

CLEAR : PKGAMT, AMT, PKG_KBETR, PKG, STR1, STR2, STR3.

SELECT SINGLE KBETR FROM KONP INTO PKG_KBETR
WHERE KNUMH = V_KNUMH
AND KSCHL = 'PCK0'.

PKG = PKG_KBETR / 10.

AMT = COST + DISC.

PKGAMT = ( AMT * PKG ) / 100.

STR1 = PKG.
STR2 = PKGAMT.

CONCATENATE '('STR1')' STR2 INTO STR3 SEPARATED BY SPACE.

QUOT1-PKG = STR3.

MODIFY QUOT1.


******* Excise *************

CLEAR : V_TEMP1,V_TEMP2,V_TEMP11,V_TEMP12,V_TEMP21,V_TEMP22.
CLEAR : V_EXC,V_EXC1 , V_EXC2 , V_TOT_EXC,V_EXCP,V_EXC1P,V_EXC2P.
CLEAR : V_TOT_EXC , V_VAT , V_MWSKZ, V_TOT_TAX, STR1, STR2, STR3.



CLEAR V_KNUMH.

SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH
WHERE KAPPL = 'TX' AND ( KSCHL = 'JMOP' OR KSCHL = 'JMIP' )
AND WERKS = QUOT1-WERKS
AND LIFNR = QUOT1-LIFNR
AND DATBI >= QUOT1-BEDAT
AND DATAB <= QUOT1-BEDAT
AND MATNR = QUOT1-MATNR.


CLEAR : V_NETWR, STR2,STR3.

SELECT SINGLE KBETR FROM KONP INTO V_EXC WHERE KNUMH = V_KNUMH
AND LOEVM_KO NE 'X'.

V_NETWR = COST + DISC + PKGAMT.

V_EXC = V_EXC / 10.

V_EXCP = V_EXC.

V_TEMP1 = V_EXCP.

V_EXC = V_NETWR * V_EXC / 100.

V_TOT_EXC = V_TOT_EXC + V_EXC.

CLEAR V_KNUMH.

SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH
WHERE KAPPL = 'TX' AND ( KSCHL = 'JEC1' OR KSCHL = 'JEC2' )
AND WERKS = QUOT1-WERKS
AND LIFNR = QUOT1-LIFNR
AND DATBI >= QUOT1-BEDAT
AND DATAB <= QUOT1-BEDAT
AND MATNR = QUOT1-MATNR.



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


V_EXC1 = V_EXC1 / 10.

V_EXC1P = V_EXC1.

V_EXC1 = V_EXC1 * V_EXC / 100.

V_TOT_EXC = V_TOT_EXC + V_EXC1.


CLEAR : V_KNUMH.

SELECT SINGLE KNUMH FROM A363 INTO V_KNUMH
WHERE KAPPL = 'TX' AND ( KSCHL = 'JSEP' OR KSCHL = 'JSEI' )
AND WERKS = QUOT1-WERKS
AND LIFNR = QUOT1-LIFNR
AND DATBI >= QUOT1-BEDAT
AND DATAB <= QUOT1-BEDAT
AND MATNR = QUOT1-MATNR.


SELECT SINGLE KBETR FROM KONP INTO V_EXC2 WHERE KNUMH = V_KNUMH
AND LOEVM_KO NE 'X'.

V_EXC2 = V_EXC2 / 10.

V_EXC2P = V_EXC2.

V_EXC2 = V_EXC * V_EXC2 / 100.

V_TOT_EXC = V_TOT_EXC + V_EXC2.

V_EXC2P = V_EXC2P + V_EXC1P.

V_TEMP2 = V_EXC2P.

CLEAR : STR1.

SPLIT V_TEMP1 AT '.' INTO V_TEMP11 V_TEMP12.
SPLIT V_TEMP2 AT '.' INTO V_TEMP21 V_TEMP22.

CONCATENATE V_TEMP11 '.' V_TEMP21 INTO STR1.


STR2 = V_TOT_EXC.

CONCATENATE '('STR1')' STR2 INTO STR3 SEPARATED BY SPACE.


QUOT1-EXC = STR3.

MODIFY QUOT1.

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

******* sale tax **********

CLEAR : V_KNUMH,STR1,STR2,STR3.

SELECT SINGLE MWSKZ INTO V_MWSKZ FROM EKPO
WHERE EBELN = QUOT1-EBELN
AND EBELP = QUOT1-EBELP.

SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX' AND ( KSCHL = 'JVRD' OR KSCHL = 'JVRN' OR KSCHL = 'JIPC')
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ
AND DATBI >= QUOT1-BEDAT
AND DATAB <= QUOT1-BEDAT.


SELECT SINGLE KBETR FROM KONP INTO V_VAT
WHERE KNUMH = V_KNUMH
AND LOEVM_KO NE 'X'.


V_VAT = V_VAT / 10.

V_TOT_TAX = ( V_NETWR + V_TOT_EXC ) * V_VAT / 100.

STR1 = V_VAT.
STR2 = V_TOT_TAX.

CONCATENATE '('STR1')' STR2 INTO STR3 SEPARATED BY SPACE.


QUOT1-SALETX = STR3.

MODIFY QUOT1.

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

******* Other tax **********

CLEAR: V_KNUMH, V_OTHAMT.

SELECT SINGLE KNUMH INTO V_KNUMH FROM A016
WHERE EVRTN = QUOT1-EBELN
AND EVRTP = QUOT1-EBELP.

SELECT SINGLE KBETR FROM KONP INTO V_OTHAMT
WHERE KNUMH = V_KNUMH
AND KSCHL = 'MISC'.

QUOT1-OTHER = V_OTHAMT.

MODIFY QUOT1.


*****************SUBTOTAL*************
*TOTAL = KTMNG * RATE.





SUBTOT = SUBTOT + COST.

*v_amt = cost + disc + pkgamt + v_tot_exc + v_tot_tax + v_othamt.
V_AMT = V_AMT + SUBTOT + DISC .


MODIFY QUOT1.

******************************
ENDLOOP.

ENDFORM.


*&---------------------------------------------------------------------*
*& Form SERIALNO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SERIALNO .



ENDFORM. " SERIALNO
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*FORM DISPLAY .



TOP-OF-PAGE.

SELECT SINGLE * FROM LFA1 INTO LFA1 WHERE LIFNR = VENDOR-LIFNR.

** Company Name
SELECT SINGLE * FROM T001 INTO T001
WHERE BUKRS = P_BUKRS.
FORMAT COLOR 1 ON.
WRITE : /20 'QUOTATION COMPARATIVE REPORT AS ON DATE:-', SY-DATUM ,'(Time-',SY-UZEIT,')' .
ULINE.
FORMAT COLOR OFF.

*endat.
*endloop.
END-OF-PAGE.
WRITE :/50 ' QUOTATION COMPARISION REPORT'.
ULINE.


END-OF-SELECTION.

SORT QUOT1 BY EBELN.

DATA V_COUNT TYPE I.

V_COUNT = 1.
*
LOOP AT QUOT1.

QUOT1-SRNO = V_COUNT.
*
MODIFY QUOT1.


V_COUNT = V_COUNT + 1.

AT NEW EBELN.


WRITE :/002 'QUOTATION NO :', QUOT1-EBELN .


WRITE :/002 'VENDOR A/C NO :', QUOT1-LIFNR .


WRITE :/002 'NAME :', QUOT1-VNAME .
ULINE.



WRITE : /1 SY-VLINE ,2 'ITEM NO',
13 SY-VLINE, 16 'ITEM DESCRIPTION' ,
45 SY-VLINE ,46 'QUANTITY' ,
62 SY-VLINE ,63 ' UNIT PRICE' CENTERED,
81 SY-VLINE, 82 'TOTAL',
100 SY-VLINE.
ULINE.


ENDAT.

WRITE :/1 SY-VLINE, 2 QUOT1-SRNO,

13 SY-VLINE,16 QUOT1-MAKTX,
45 SY-VLINE, 46 QUOT1-KTMNG,
62 SY-VLINE, 63 QUOT1-RATE,
81 SY-VLINE,82 QUOT1-COST,
100 SY-VLINE.
ULINE.
AT END OF EBELN.
CLEAR: V_COUNT.
V_COUNT = 1.

WRITE :/ SY-VLINE,033 'SUB-TOTAL ' , SY-VLINE,63 SUBTOT,100 SY-VLINE.
*ULINE.

WRITE :/ SY-VLINE,033 'DISCOUNT ' , SY-VLINE,63 DISC,100 SY-VLINE.
*ULINE.


WRITE :/ SY-VLINE,033 ' TAX ' , SY-VLINE,63 V_OTHERP,100 SY-VLINE.
ULINE.

WRITE :/ SY-VLINE,033 'GRAND TOTAL' , SY-VLINE,63 V_AMT,100 SY-VLINE.
FORMAT COLOR 6 ON.
ULINE.
WRITE:/ SY-VLINE, 'AMOUNT IN WORDS:',33 T_SPELL-WORD,60'RS ONLY', 100 SY-VLINE.
ULINE.
FORMAT COLOR OFF.
*WRITE:/ SY-VLINE,028 'AMOUNT IN WORDS:',SY-VLINE,'RS ',50 T_SPELL-WORD,'ONLY', 100 SY-VLINE.
*ULINE.

WRITE :/'CUSTOMER :', T001-BUTXT INTENSIFIED ON HOTSPOT.
WRITE :/ 'DATE AS ON :' , SY-DATUM.

SKIP.
SKIP.
SKIP.
SKIP.
ENDAT.


ENDLOOP.





FORM SPELL_AMOUNT USING PWRBTR PWAERS.
PAMOUNT = V_AMT.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = V_AMT
CURRENCY = PWAERS
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.
ENDFORM.

Attachments

op1.gif (229.2 kB)