Skip to Content
author's profile photo Former Member
Former Member

Coding is not running correct in main area of table in smartform

I have created a smart form for service order .The code for vat calculation is running correct in footer of the table while the same code is displaying wrong value while i ma writing in main area of table.Actually i have written this in main area because the vat is different for each line item.It is taking the value of v_vat as 0 which is for first line item and taking for second

**************************** For ST/VAT Charges*****************
DATA: V_MWSKZ LIKE EKPO-MWSKZ,
V_KNUMH TYPE A363-KNUMH.
CLEAR V_KNUMH.



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


DATA : V_NETWR LIKE EKPO-NETWR.
CLEAR : V_NETWR.


SELECT SINGLE NETWR INTO V_NETWR FROM EKPO
WHERE EBELN = L_XEKPO-EBELN
AND EBELP = L_XEKPO-EBELP.


CLEAR V_KNUMH.

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

SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX'
AND ( KSCHL = 'JVRD' )
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ AND
DATBI >= ODT AND DATAB <= ODT .

SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX'
AND ( KSCHL = 'JVRN' )
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ AND
DATBI >= ODT AND DATAB <= ODT .


SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX'
AND ( KSCHL = 'JIPC' )
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ AND
DATBI >= ODT AND DATAB <= ODT .



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

V_VAT = V_VAT / 10.
STR90 = STR90 + V_VAT.
V_VAT = ( V_NETWR ) * V_VAT / 100.

STR10 = STR10 + V_VAT.
****************************************************************************************
IF V_VAT = '0.00'.
CLEAR V_KNUMH.


SELECT SINGLE NETWR INTO V_NETWR FROM EKPO WHERE EBELN = L_XEKPO-EBELN
AND EBELP = L_XEKPO-EBELP.

CLEAR V_KNUMH.
DATA:V_BASE LIKE KONP-KBETR,
V_AMT LIKE EKPO-NETWR.

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

SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX'
AND ( KSCHL = 'ZBSE' )
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ
AND DATBI >= ODT AND DATAB <= ODT .


SELECT SINGLE KBETR FROM KONP INTO V_BASE
WHERE KNUMH = V_KNUMH." AND loevm_ko NE 'X'.

V_BASE = V_BASE / 10 .
V_AMT = ( V_NETWR * V_BASE ) / 100 .



*********FOR ZVRN Condition*********************

CLEAR V_KNUMH.


SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX'
AND ( KSCHL = 'ZVRN' )
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ
AND DATBI >= ODT AND DATAB <= ODT .


SELECT SINGLE KNUMH FROM A950 INTO V_KNUMH
WHERE KAPPL = 'TX'
AND ( KSCHL = 'ZVRD' )
AND LAND1 = 'IN' AND MWSKZ = V_MWSKZ
AND DATBI >= ODT AND DATAB <= ODT .



*CLEAR: V_VAT.


SELECT SINGLE KBETR FROM KONP INTO V_VAT
WHERE KNUMH = V_KNUMH.

V_VAT = V_VAT / 10 .
V_VATA = ( V_AMT * V_VAT ) / 100 .

*CLEAR: str10, STR90.

STR90 = STR90 + V_VAT.
str10 = STR10 + V_VATA.


ENDIF.
***********


IF V_MWSKZ = 'IN'.
str1 = 'Inclusive'.
ELSE.
V_MWSKZ = ' '.
str1 = V_TOT_TAX.

ENDIF.





Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Nov 20, 2012 at 10:32 AM

    Hi ,

    I am not going to solve this code but I am going to suggest an approach
    that simplefy the development.

    This approach is good only in cases when we write every thing meaning that we write
    the print program and also the smart form.

    In this case we pass to the smart form the a full data model to be printed. We minimize the
    calculation in the smart form. any extraction of data from table, calculation and business decision is
    done in the program .

    The benefit:


    It is much easier to debug ABAP program than smart form (According to my experience).
    We get a better separation between business logic and presentation.

    Obviously the number of parameters and the parameter complexity is increased.

    Since I do not want to create too many structure I utilize a class as a place holder for types of structures.

    Those types are decleared in the "public section" of the class and are based for the parameters that are passed
    between the program and the smart form.

    For example:

    The public section :


    The Form Interface:

    Message was edited by: Eitan Rosenberg


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.